Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file ParametersParser.cc 28 /// \brief Implementation of the ParametersParser class 29 30 #include "ParametersParser.hh" 31 32 #include <fstream> 33 #include <iostream> 34 #include <sstream> 35 36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 37 38 ParametersParser* ParametersParser::fInstance = nullptr; 39 40 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 41 42 ParametersParser* ParametersParser::Instance() 43 { 44 if (fInstance == nullptr) { 45 static ParametersParser parParser; 46 fInstance = &parParser; 47 } 48 return fInstance; 49 } 50 51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 52 53 ParametersParser::ParametersParser() 54 { 55 fSDDfileName = "SDDformat_"+fOutputName; 56 } 57 58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 59 60 void ParametersParser::LoadParameters(const std::string &fileName) 61 { 62 std::ifstream file; 63 file.open(fileName.c_str()); 64 if (!file.is_open()) { 65 std::cout<<"ParametersParser::LoadParameters Error in openning file!!!\n" 66 <<"Plese check the input macro file!!!"<<std::endl; 67 exit(0); 68 } else { 69 std::string line; 70 while(std::getline(file, line)) 71 { 72 std::istringstream iss(line); 73 std::string flag; 74 iss >> flag; 75 std::string tvalue; 76 iss >> tvalue; 77 if (flag == "/ana/thresholdFordirectSBSelection") fThresholdE = (tvalue); 78 if (flag == "/ana/probForIndirectSBSelection") fProbabilityForIndirectSB = (tvalue); 79 if (flag == "/ana/BpForDSB") BpForDSB = std::stoi(tvalue); 80 if (flag == "/ana/TLK/lambda1") TLKLambda1 = (tvalue); 81 if (flag == "/ana/TLK/lambda2") TLKLambda2 = (tvalue); 82 if (flag == "/ana/TLK/beta1") TLKBeta1 = (tvalue); 83 if (flag == "/ana/TLK/beta2") TLKBeta2 = (tvalue); 84 if (flag == "/ana/TLK/eta") TLKEta = (tvalue); 85 if (flag == "/ana/TLK/doseMax") TLKdoseMax = (tvalue); 86 if (flag == "/ana/TLK/deltaDose") TLKdeltaDose = (tvalue); 87 if (flag == "/ana/LEMIV/loopLength") LEMIVLoopLength = tvalue; 88 if (flag == "/ana/LEMIV/Ni") LEMIVNi = tvalue; 89 if (flag == "/ana/LEMIV/Nc") LEMIVNc = tvalue; 90 if (flag == "/ana/LEMIV/NDSB") LEMIVNDSB = tvalue; 91 if (flag == "/ana/LEMIV/Funrej") LEMIVFunrej = tvalue; 92 if (flag == "/ana/LEMIV/Tfast") LEMIVTfast = tvalue; 93 if (flag == "/ana/LEMIV/Tslow") LEMIVTslow = tvalue; 94 if (flag == "/ana/LEMIV/timeMax") LEMIVtimeMax = tvalue; 95 if (flag == "/ana/LEMIV/deltaTime") LEMIVdeltaTime = tvalue; 96 if (flag == "/ana/BELOV/Nirrep") BELOVNirrep = tvalue; 97 if (flag == "/ana/BELOV/Dz") BELOVDz = tvalue; 98 99 if (flag == "/ana/TLK/used") useTLK = tvalue; 100 if (flag == "/ana/LEMIV/used") useLEMIV = tvalue; 101 if (flag == "/ana/BELOV/used") useBELOV = tvalue; 102 103 if (flag == "/ana/ouputName") fOutputName = tvalue; 104 if (flag == "/ana/folderForChemOut") fChemOutFolderName = tvalue; 105 if (flag == "/ana/cellNucleusName") fCellNucleusName = tvalue; 106 if (flag == "/ana/loadDamagesFromSDD") { 107 fSDDfileName = tvalue; 108 fLoadDamagesFromSDD = true; 109 } 110 if (flag == "/ana/unitOfNormalization") fUnitOfNormalization = std::stoi(tvalue); 111 112 if (flag == "/ana/skipIndirectDamages") fSkipScanningIndirectDamage = true; 113 114 if (flag == "/gps/particle") fParticleName = (tvalue); 115 if (flag == "/gps/energy") { 116 fParticleEnergy = std::stof(tvalue); 117 iss >> tvalue; 118 fEnergyUnit = tvalue; 119 } 120 if (flag == "/run/beamOn") fNumberOfParticles = std::stoi(tvalue); 121 if (flag == "/scheduler/endTime") { 122 fEndTimeForChemReactions = tvalue; 123 iss >> tvalue; 124 fEndTimeForChemReactions += tvalue; 125 } 126 } 127 } 128 } 129 130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 131 132 bool ParametersParser::UseTLK() 133 { 134 bool used = false; 135 if (useTLK == "true" || useTLK == "TRUE" || useTLK == "True" || useTLK == "1" || 136 useTLK == "yes" || useTLK == "YES" || useTLK == "Yes") used = true; 137 return used; 138 } 139 140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 141 142 bool ParametersParser::UseLEMIV() 143 { 144 bool used = false; 145 if (useLEMIV == "true" || useLEMIV == "TRUE" || useLEMIV== "True" || useLEMIV == "1" || 146 useLEMIV == "yes" || useLEMIV == "YES"|| useLEMIV == "Yes") used = true; 147 return used; 148 } 149 150 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo..... 151 152 bool ParametersParser::UseBelov() 153 { 154 bool used = false; 155 if (useBELOV == "true" || useBELOV == "TRUE" || useBELOV == "True" || useBELOV == "1" || 156 useBELOV == "yes" || useBELOV == "YES"|| useBELOV == "Yes") used = true; 157 return used; 158 }