Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-16 07:41:38

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 /// \file PhysicsList.cc
0027 /// \brief Implementation of the PhysicsList class
0028 
0029 // This example is provided by the Geant4-DNA collaboration
0030 // chem6 example is derived from chem4 and chem5 examples
0031 //
0032 // Any report or published results obtained using the Geant4-DNA software
0033 // shall cite the following Geant4-DNA collaboration publication:
0034 // J. Appl. Phys. 125 (2019) 104301
0035 // Med. Phys. 45 (2018) e722-e739
0036 // J. Comput. Phys. 274 (2014) 841-882
0037 // Med. Phys. 37 (2010) 4692-4708
0038 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157-178
0039 // The Geant4-DNA web site is available at http://geant4-dna.org
0040 //
0041 // Authors: W. G. Shin and S. Incerti (CENBG, France)
0042 //
0043 
0044 #include "PhysicsList.hh"
0045 #include "PhysicsListMessenger.hh"
0046 
0047 #include "G4EmDNAChemistry.hh"
0048 #include "G4EmDNAChemistry_option1.hh"
0049 #include "G4EmDNAChemistry_option2.hh"
0050 #include "G4EmDNAChemistry_option3.hh"
0051 #include "G4EmDNAPhysics.hh"
0052 #include "G4EmDNAPhysics_option1.hh"
0053 #include "G4EmDNAPhysics_option2.hh"
0054 #include "G4EmDNAPhysics_option3.hh"
0055 #include "G4EmDNAPhysics_option4.hh"
0056 #include "G4EmDNAPhysics_option5.hh"
0057 #include "G4EmDNAPhysics_option6.hh"
0058 #include "G4EmDNAPhysics_option7.hh"
0059 #include "G4EmDNAPhysics_option8.hh"
0060 #include "G4EmParameters.hh"
0061 #include "G4SystemOfUnits.hh"
0062 #include "G4ProductionCutsTable.hh"
0063 #include <map>
0064 #include <functional>
0065 #include <string>
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0067 
0068 PhysicsList::PhysicsList() : G4VModularPhysicsList() {
0069   constexpr G4double currentDefaultCut = 0.001 * mm;
0070   G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(100 * eV, 1 * GeV);
0071   SetDefaultCutValue(currentDefaultCut);
0072   SetVerboseLevel(1);
0073 
0074   fMessenger = std::make_unique<PhysicsListMessenger>(this);
0075 
0076   fEmDNAPhysicsList = std::make_unique<G4EmDNAPhysics_option2>();
0077   fEmDNAChemistryList = std::make_unique<G4EmDNAChemistry_option3>();
0078   fChemDNAName = "G4EmDNAChemistry_option3";
0079   fPhysDNAName = "G4EmDNAPhysics_option2";
0080 }
0081 
0082 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0083 
0084 PhysicsList::~PhysicsList() = default;
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0087 
0088 void PhysicsList::ConstructParticle() {
0089   if (fEmDNAPhysicsList != nullptr) {
0090     fEmDNAPhysicsList->ConstructParticle();
0091   }
0092   if (fEmDNAChemistryList != nullptr) {
0093     fEmDNAChemistryList->ConstructParticle();
0094   }
0095 }
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 
0099 void PhysicsList::ConstructProcess() {
0100   AddTransportation();
0101   if (fEmDNAPhysicsList != nullptr) {
0102     fEmDNAPhysicsList->ConstructProcess();
0103   }
0104   if (fEmDNAChemistryList != nullptr) {
0105     fEmDNAChemistryList->ConstructProcess();
0106   }
0107 }
0108 
0109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0110 
0111 void PhysicsList::RegisterConstructor(const G4String &name) {
0112   // Factory maps to reduce long if-else chains and centralize constructor bindings
0113   using PhysFactory = std::function<std::unique_ptr<G4VPhysicsConstructor>(G4int)>;
0114   using ChemFactory = std::function<std::unique_ptr<G4VPhysicsConstructor>()>;
0115 
0116   static const std::map<std::string, PhysFactory> physFactories = {
0117     {"G4EmDNAPhysics", [](G4int v) { return std::make_unique<G4EmDNAPhysics>(v); }},
0118     {"G4EmDNAPhysics_option1", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option1>(v); }},
0119     {"G4EmDNAPhysics_option2", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option2>(v); }},
0120     {"G4EmDNAPhysics_option3", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option3>(v); }},
0121     {"G4EmDNAPhysics_option4", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option4>(v); }},
0122     {"G4EmDNAPhysics_option5", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option5>(v); }},
0123     {"G4EmDNAPhysics_option6", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option6>(v); }},
0124     {"G4EmDNAPhysics_option7", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option7>(v); }},
0125     {"G4EmDNAPhysics_option8", [](G4int v) { return std::make_unique<G4EmDNAPhysics_option8>(v); }}
0126   };
0127 
0128   static const std::map<std::string, ChemFactory> chemFactories = {
0129     {"G4EmDNAChemistry", [] { return std::make_unique<G4EmDNAChemistry>(); }},
0130     {"G4EmDNAChemistry_option1", [] { return std::make_unique<G4EmDNAChemistry_option1>(); }},
0131     {"G4EmDNAChemistry_option2", [] { return std::make_unique<G4EmDNAChemistry_option2>(); }},
0132     {"G4EmDNAChemistry_option3", [] { return std::make_unique<G4EmDNAChemistry_option3>(); }}
0133   };
0134 
0135   // Try EM physics first
0136   if (const auto it = physFactories.find(name); it != physFactories.end()) {
0137     if (name == fPhysDNAName) {
0138       if (verboseLevel > 0) {
0139         G4cout << "PhysicsList: EM constructor '" << name << "' already active, no change" <<
0140             G4endl;
0141       }
0142       return;
0143     }
0144     if (verboseLevel > 0) {
0145       G4cout << "===== Register EM constructor ==== '" << name << "'" << G4endl;
0146     }
0147     fEmDNAPhysicsList = it->second(verboseLevel);
0148     fPhysDNAName = name;
0149     return;
0150   }
0151 
0152   // Then chemistry
0153   if (const auto it = chemFactories.find(name); it != chemFactories.end()) {
0154     if (name == fChemDNAName) {
0155       if (verboseLevel > 0) {
0156         G4cout << "PhysicsList: Chemistry constructor '" << name << "' already active, no change" <<
0157             G4endl;
0158       }
0159       return;
0160     }
0161     if (verboseLevel > 0) {
0162       G4cout << "===== Register Chemistry constructor ==== '" << name << "'" << G4endl;
0163     }
0164     fEmDNAChemistryList = it->second();
0165     if (fEmDNAChemistryList) {
0166       fEmDNAChemistryList->SetVerboseLevel(verboseLevel);
0167     }
0168     fChemDNAName = name;
0169     return;
0170   }
0171 
0172   // Unknown name
0173   G4cout << "PhysicsList::RegisterConstructor: <" << name << "> fails - name is not defined" <<
0174       G4endl;
0175 }
0176 
0177 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......