Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:00

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!!!"<<std::endl;
0066     } else {
0067         std::string line;
0068         while(std::getline(file, line))
0069         {
0070             std::istringstream iss(line);
0071             std::string flag;
0072             iss >> flag;
0073             std::string tvalue;
0074             iss >> tvalue;
0075             if (flag == "/ana/thresholdFordirectSBSelection") fThresholdE = (tvalue);
0076             if (flag == "/ana/probForIndirectSBSelection") fProbabilityForIndirectSB = (tvalue);
0077             if (flag == "/ana/BpForDSB") BpForDSB = std::stoi(tvalue);
0078             if (flag == "/ana/TLK/lambda1") TLKLambda1 = (tvalue);
0079             if (flag == "/ana/TLK/lambda2") TLKLambda2 = (tvalue);
0080             if (flag == "/ana/TLK/beta1") TLKBeta1 = (tvalue);
0081             if (flag == "/ana/TLK/beta2") TLKBeta2 = (tvalue);
0082             if (flag == "/ana/TLK/eta") TLKEta = (tvalue);
0083             if (flag == "/ana/TLK/doseMax") TLKdoseMax = (tvalue);
0084             if (flag == "/ana/TLK/deltaDose") TLKdeltaDose = (tvalue);
0085             if (flag == "/ana/LEMIV/loopLength") LEMIVLoopLength = tvalue;
0086             if (flag == "/ana/LEMIV/Ni") LEMIVNi = tvalue;
0087             if (flag == "/ana/LEMIV/Nc") LEMIVNc = tvalue;
0088             if (flag == "/ana/LEMIV/NDSB") LEMIVNDSB = tvalue;
0089             if (flag == "/ana/LEMIV/Funrej") LEMIVFunrej = tvalue;
0090             if (flag == "/ana/LEMIV/Tfast") LEMIVTfast = tvalue;
0091             if (flag == "/ana/LEMIV/Tslow") LEMIVTslow = tvalue;
0092             if (flag == "/ana/LEMIV/timeMax") LEMIVtimeMax = tvalue;
0093             if (flag == "/ana/LEMIV/deltaTime") LEMIVdeltaTime = tvalue;
0094             if (flag == "/ana/BELOV/Nirrep") BELOVNirrep = tvalue;
0095             if (flag == "/ana/BELOV/Dz") BELOVDz = tvalue;
0096 
0097             if (flag == "/ana/TLK/used") useTLK = tvalue;
0098             if (flag == "/ana/LEMIV/used") useLEMIV = tvalue;
0099             if (flag == "/ana/BELOV/used") useBELOV = tvalue;
0100 
0101             if (flag == "/ana/ouputName") fOutputName = tvalue;
0102             if (flag == "/ana/cellNucleusName") fCellNucleusName = tvalue;
0103             if (flag == "/ana/loadDamagesFromSDD") {
0104                 fSDDfileName = tvalue;
0105                 fLoadDamagesFromSDD = true;
0106             }
0107             if (flag == "/ana/unitOfNormalization") fUnitOfNormalization = std::stoi(tvalue);
0108 
0109             if (flag == "/ana/skipIndirectDamages") fSkipScanningIndirectDamage = true;
0110 
0111             if (flag == "/gps/particle") fParticleName = (tvalue);
0112             if (flag == "/gps/energy") {
0113                 fParticleEnergy = std::stof(tvalue);
0114                 iss >> tvalue;
0115                 fEnergyUnit = tvalue;
0116             }
0117             if (flag == "/run/beamOn") fNumberOfParticles = std::stoi(tvalue);
0118             if (flag == "/scheduler/endTime") {
0119                 fEndTimeForChemReactions = tvalue;
0120                 iss >> tvalue;
0121                 fEndTimeForChemReactions += tvalue;
0122             }
0123         }
0124     }
0125 }
0126 
0127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0128 
0129 bool ParametersParser::UseTLK()
0130 {
0131     bool used = false;
0132     if (useTLK == "true" || useTLK == "TRUE" || useTLK == "True" || useTLK == "1" || 
0133         useTLK == "yes" || useTLK == "YES" || useTLK == "Yes") used = true;
0134     return used;
0135 }
0136 
0137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0138 
0139 bool ParametersParser::UseLEMIV()
0140 {
0141     bool used = false;
0142     if (useLEMIV == "true" || useLEMIV == "TRUE" || useLEMIV== "True" || useLEMIV == "1" || 
0143         useLEMIV == "yes" || useLEMIV == "YES"|| useLEMIV == "Yes") used = true;
0144     return used;
0145 }
0146 
0147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
0148 
0149 bool ParametersParser::UseBelov()
0150 {
0151     bool used = false;
0152     if (useBELOV == "true" || useBELOV == "TRUE" || useBELOV == "True" || useBELOV == "1" || 
0153         useBELOV == "yes" || useBELOV == "YES"|| useBELOV == "Yes") used = true;
0154     return used;
0155 }