Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-10-14 08:06:14

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //
0027 /// \file ParametersParser.cc
0028 /// \brief Implementation of the ParametersParser class
0029 
0030 #include "ParametersParser.hh"
0031 
0032 #include <fstream>
0033 #include <iostream>
0034 #include <sstream>
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0037 
0038 ParametersParser* ParametersParser::fInstance = nullptr;
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0041 
0042 ParametersParser* ParametersParser::Instance()
0043 {
0044     if (fInstance == nullptr) {
0045         static ParametersParser parParser;
0046         fInstance = &parParser;
0047     }
0048     return fInstance;
0049 }
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0052 
0053 ParametersParser::ParametersParser()
0054 {
0055     fSDDfileName = "SDDformat_"+fOutputName;
0056 }
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0059 
0060 void ParametersParser::LoadParameters(const std::string &fileName)
0061 {
0062     std::ifstream file;
0063     file.open(fileName.c_str());
0064     if (!file.is_open()) {
0065         std::cout<<"ParametersParser::LoadParameters Error in openning file!!!\n"
0066         <<"Plese check the input macro file!!!"<<std::endl;
0067         exit(0);
0068     } else {
0069         std::string line;
0070         while(std::getline(file, line))
0071         {
0072             std::istringstream iss(line);
0073             std::string flag;
0074             iss >> flag;
0075             std::string tvalue;
0076             iss >> tvalue;
0077             if (flag == "/ana/thresholdFordirectSBSelection") fThresholdE = (tvalue);
0078             if (flag == "/ana/probForIndirectSBSelection") fProbabilityForIndirectSB = (tvalue);
0079             if (flag == "/ana/BpForDSB") BpForDSB = std::stoi(tvalue);
0080             if (flag == "/ana/TLK/lambda1") TLKLambda1 = (tvalue);
0081             if (flag == "/ana/TLK/lambda2") TLKLambda2 = (tvalue);
0082             if (flag == "/ana/TLK/beta1") TLKBeta1 = (tvalue);
0083             if (flag == "/ana/TLK/beta2") TLKBeta2 = (tvalue);
0084             if (flag == "/ana/TLK/eta") TLKEta = (tvalue);
0085             if (flag == "/ana/TLK/doseMax") TLKdoseMax = (tvalue);
0086             if (flag == "/ana/TLK/deltaDose") TLKdeltaDose = (tvalue);
0087             if (flag == "/ana/LEMIV/loopLength") LEMIVLoopLength = tvalue;
0088             if (flag == "/ana/LEMIV/Ni") LEMIVNi = tvalue;
0089             if (flag == "/ana/LEMIV/Nc") LEMIVNc = tvalue;
0090             if (flag == "/ana/LEMIV/NDSB") LEMIVNDSB = tvalue;
0091             if (flag == "/ana/LEMIV/Funrej") LEMIVFunrej = tvalue;
0092             if (flag == "/ana/LEMIV/Tfast") LEMIVTfast = tvalue;
0093             if (flag == "/ana/LEMIV/Tslow") LEMIVTslow = tvalue;
0094             if (flag == "/ana/LEMIV/timeMax") LEMIVtimeMax = tvalue;
0095             if (flag == "/ana/LEMIV/deltaTime") LEMIVdeltaTime = tvalue;
0096             if (flag == "/ana/BELOV/Nirrep") BELOVNirrep = tvalue;
0097             if (flag == "/ana/BELOV/Dz") BELOVDz = tvalue;
0098 
0099             if (flag == "/ana/TLK/used") useTLK = tvalue;
0100             if (flag == "/ana/LEMIV/used") useLEMIV = tvalue;
0101             if (flag == "/ana/BELOV/used") useBELOV = tvalue;
0102 
0103             if (flag == "/ana/ouputName") fOutputName = tvalue;
0104             if (flag == "/ana/folderForChemOut") fChemOutFolderName = tvalue;
0105             if (flag == "/ana/cellNucleusName") fCellNucleusName = tvalue;
0106             if (flag == "/ana/loadDamagesFromSDD") {
0107                 fSDDfileName = tvalue;
0108                 fLoadDamagesFromSDD = true;
0109             }
0110             if (flag == "/ana/unitOfNormalization") fUnitOfNormalization = std::stoi(tvalue);
0111 
0112             if (flag == "/ana/skipIndirectDamages") fSkipScanningIndirectDamage = true;
0113 
0114             if (flag == "/gps/particle") fParticleName = (tvalue);
0115             if (flag == "/gps/energy") {
0116                 fParticleEnergy = std::stof(tvalue);
0117                 iss >> tvalue;
0118                 fEnergyUnit = tvalue;
0119             }
0120             if (flag == "/run/beamOn") fNumberOfParticles = std::stoi(tvalue);
0121             if (flag == "/scheduler/endTime") {
0122                 fEndTimeForChemReactions = tvalue;
0123                 iss >> tvalue;
0124                 fEndTimeForChemReactions += tvalue;
0125             }
0126         }
0127     }
0128 }
0129 
0130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0131 
0132 bool ParametersParser::UseTLK()
0133 {
0134     bool used = false;
0135     if (useTLK == "true" || useTLK == "TRUE" || useTLK == "True" || useTLK == "1" || 
0136         useTLK == "yes" || useTLK == "YES" || useTLK == "Yes") used = true;
0137     return used;
0138 }
0139 
0140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0141 
0142 bool ParametersParser::UseLEMIV()
0143 {
0144     bool used = false;
0145     if (useLEMIV == "true" || useLEMIV == "TRUE" || useLEMIV== "True" || useLEMIV == "1" || 
0146         useLEMIV == "yes" || useLEMIV == "YES"|| useLEMIV == "Yes") used = true;
0147     return used;
0148 }
0149 
0150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0151 
0152 bool ParametersParser::UseBelov()
0153 {
0154     bool used = false;
0155     if (useBELOV == "true" || useBELOV == "TRUE" || useBELOV == "True" || useBELOV == "1" || 
0156         useBELOV == "yes" || useBELOV == "YES"|| useBELOV == "Yes") used = true;
0157     return used;
0158 }