Back to home page

EIC code displayed by LXR

 
 

    


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

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 ChemPhysicsList.cc
0028 /// \brief Implementation of the ChemPhysicsList class
0029 
0030 #include "ChemPhysicsList.hh"
0031 #include "G4EmDNAChemistry_option3_Extended.hh"
0032 
0033 #include "G4SystemOfUnits.hh"
0034 #include "G4EmDNAPhysics.hh"
0035 #include "G4EmDNAPhysics_option1.hh"
0036 #include "G4EmDNAPhysics_option2.hh"
0037 #include "G4EmDNAPhysics_option3.hh"
0038 #include "G4EmDNAPhysics_option4.hh"
0039 #include "G4EmDNAPhysics_option5.hh"
0040 #include "G4EmDNAPhysics_option6.hh"
0041 #include "G4EmDNAPhysics_option7.hh"
0042 #include "G4EmDNAPhysics_option8.hh"
0043 #include "G4EmDNAChemistry.hh"
0044 #include "G4EmDNAChemistry_option1.hh"
0045 #include "G4EmDNAChemistry_option2.hh"
0046 #include "G4EmDNAChemistry_option3.hh"
0047 #include "G4DNAMolecularReactionTable.hh"
0048 #include "G4PhysicsConstructorRegistry.hh"
0049 #include "G4LeptonConstructor.hh"
0050 #include "G4BosonConstructor.hh"
0051 #include "G4MesonConstructor.hh"
0052 #include "G4BaryonConstructor.hh"
0053 #include "G4ShortLivedConstructor.hh"
0054 #include "G4EmParameters.hh"
0055 #include "G4ChemicalMoleculeFinder.hh"
0056 #include "G4Filesystem.hh"
0057 #include "G4EmParameters.hh"
0058 
0059 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0060 
0061 ChemPhysicsList::ChemPhysicsList(G4String chemListName)
0062     : G4VModularPhysicsList()
0063 {
0064     fmsg = new ChemPhysicsMessenger(this);
0065     SetDefaultCutValue(1.0*nanometer);
0066     SetVerboseLevel(1);
0067     RegisterPhysListConstructor(ExtractPhysDNAName());
0068     RegisterChemListConstructor(chemListName);
0069     G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(100*eV, 1*GeV);
0070 }
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 void ChemPhysicsList::ConstructParticle()
0075 {
0076     if(fDNAPhysicsList != nullptr)    
0077     {
0078         fDNAPhysicsList->ConstructParticle(); 
0079     }
0080     
0081     if(fChemistryList_option2 != nullptr)
0082     {
0083         fChemistryList_option2->ConstructParticle();
0084     }
0085     if(fChemistryList_option3_mod != nullptr)
0086     {
0087         fChemistryList_option3_mod->ConstructParticle();
0088     }
0089     
0090     // construct following particles to get rid of warning
0091     G4LeptonConstructor lConstructor;
0092     lConstructor.ConstructParticle();
0093     G4BosonConstructor  pBosonConstructor;
0094     pBosonConstructor.ConstructParticle();
0095     G4MesonConstructor pMesonConstructor;
0096     pMesonConstructor.ConstructParticle();
0097     G4BaryonConstructor pBaryonConstructor;
0098     pBaryonConstructor.ConstructParticle();
0099     G4ShortLivedConstructor pShortLivedConstructor;
0100     pShortLivedConstructor.ConstructParticle();
0101 }
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 
0105 void ChemPhysicsList::ConstructProcess()
0106 {  
0107     AddTransportation();
0108 
0109     if(fDNAPhysicsList != nullptr)    
0110     {
0111         fDNAPhysicsList->ConstructProcess(); 
0112     }
0113     
0114     if(fChemistryList_option2 != nullptr)
0115     {
0116         fChemistryList_option2->ConstructProcess();
0117     }
0118     
0119     if(fChemistryList_option3_mod != nullptr)
0120     {
0121         fChemistryList_option3_mod->ConstructProcess();
0122     }
0123     
0124 }
0125 
0126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0127 
0128 void ChemPhysicsList::RegisterPhysListConstructor(const G4String& name)
0129 {
0130     if(name == fPhysDNAName ) 
0131     {
0132         return; 
0133     }
0134     
0135     if(verboseLevel > 0) 
0136     {
0137         if (fPhysDNAName == "") G4cout << "===== Register constructor ==== " << name << G4endl; 
0138         else G4cout << "===== Change Physics constructor from "<<fPhysDNAName<<" to "<<name<<" ==== " << G4endl; 
0139     }
0140     
0141     if(name == "G4EmDNAPhysics") 
0142     {
0143         fDNAPhysicsList.reset(new G4EmDNAPhysics(verboseLevel));
0144         fPhysDNAName = name;
0145     } 
0146     else if(name == "G4EmDNAPhysics_option1") 
0147     {
0148         fDNAPhysicsList.reset(new G4EmDNAPhysics_option1(verboseLevel));
0149         fPhysDNAName = name;
0150     } 
0151     else if(name == "G4EmDNAPhysics_option2") 
0152     {
0153         fDNAPhysicsList.reset(new G4EmDNAPhysics_option2(verboseLevel));
0154         fPhysDNAName = name;
0155     } 
0156     else if(name == "G4EmDNAPhysics_option3") 
0157     {
0158         fDNAPhysicsList.reset(new G4EmDNAPhysics_option3(verboseLevel));
0159         fPhysDNAName = name;
0160     } 
0161     else if(name == "G4EmDNAPhysics_option4") 
0162     {
0163         fDNAPhysicsList.reset(new G4EmDNAPhysics_option4(verboseLevel));
0164         fPhysDNAName = name;
0165     } 
0166     else if(name == "G4EmDNAPhysics_option5") 
0167     {
0168         fDNAPhysicsList.reset(new G4EmDNAPhysics_option5(verboseLevel));
0169         fPhysDNAName = name;
0170     } 
0171     else if(name == "G4EmDNAPhysics_option6") 
0172     {
0173         fDNAPhysicsList.reset(new G4EmDNAPhysics_option6(verboseLevel));
0174         fPhysDNAName = name;
0175     } 
0176     else if(name == "G4EmDNAPhysics_option7") 
0177     {
0178         fDNAPhysicsList.reset(new G4EmDNAPhysics_option7(verboseLevel));
0179         fPhysDNAName = name;
0180     } 
0181     else if(name == "G4EmDNAPhysics_option8") 
0182     {
0183         fDNAPhysicsList.reset(new G4EmDNAPhysics_option8(verboseLevel));
0184         fPhysDNAName = name;
0185     } 
0186     else 
0187     {
0188         G4cout << "PhysicsList::RegisterPhysListConstructor: <" << name << ">"
0189                << " fails - name is not defined"
0190                << G4endl;    
0191     }
0192 }
0193 
0194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0195 
0196 void ChemPhysicsList::RegisterChemListConstructor(const G4String& name)
0197 {
0198     if(name == fChemListName ) 
0199     {
0200         return; 
0201     }
0202     
0203     if(verboseLevel > 0) 
0204     {
0205         G4cout << "===== Register constructor for Chemitry ==== " << name << G4endl; 
0206     }
0207   
0208     if(name == "G4EmDNAChemistry_option2")
0209     {
0210         if ( fChemistryList_option2 != nullptr) return;
0211         fChemistryList_option2.reset(new G4EmDNAChemistry_option2());
0212         fChemistryList_option2->SetVerboseLevel(verboseLevel);
0213         fTimeStepModel = G4ChemTimeStepModel::SBS;
0214         fChemListName = name;
0215     }
0216     else if(name == "G4EmDNAChemistry_option3") 
0217     {
0218         if ( fChemistryList_option3_mod != nullptr) return;
0219         fChemistryList_option3_mod.reset(new G4EmDNAChemistry_option3_Extended());
0220         fChemistryList_option3_mod->SetVerboseLevel(verboseLevel);
0221         fTimeStepModel = G4ChemTimeStepModel::IRT_syn;
0222         G4EmParameters::Instance()->SetTimeStepModel(fTimeStepModel);
0223         std::cout<<"G4EmParameters::Instance()->SetTimeStepModel(fTimeStepModel);"<<G4endl;
0224         fChemListName = name;
0225     }
0226     else 
0227     {
0228         G4ExceptionDescription msg;
0229         msg <<"ChemPhysicsList::RegisterChemListConstructor: <" << name << ">"
0230             <<" fails - name is not defined";
0231         G4Exception("ChemPhysicsList::RegisterChemListConstructor", "Phys_WrongName", 
0232         JustWarning, msg); 
0233     }
0234 }
0235 
0236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0237 
0238 G4String ChemPhysicsList::ExtractPhysDNAName()
0239 {
0240     G4String out ="G4EmDNAPhysics_option2";
0241     G4fs::path thisP = G4fs::current_path();
0242     for (const auto &entry : G4fs::directory_iterator(thisP)){
0243         if (entry.path().filename() == "imp.info") {
0244             std::ifstream file(entry.path().c_str());
0245             if(!file.good() ){
0246                 G4ExceptionDescription msg;
0247                 msg<<"**** Fatal Error *****\n";
0248                 msg<<"ChemPhysicsList::ExtractPhysDNAName(): File corupted: "
0249                 <<entry.path()<<"\n";
0250                 msg<<"*************** *****";
0251                 G4Exception("ChemPhysicsList::ExtractPhysDNAName", "Phys_WrongParse", 
0252                 FatalException, msg);
0253             }
0254 
0255             G4String line;
0256             while(std::getline(file, line) ){
0257                 std::istringstream iss(line);
0258                 G4String flag;
0259                 iss >> flag;
0260                 if ( flag == "_physList") {
0261                     iss >> out;
0262                 }
0263             }
0264             file.close();
0265         }
0266     }
0267     return out;
0268 }
0269 
0270 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......