Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-19 08:37:07

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 #include "PhysicsList.hh"
0030 
0031 #include "DetectorConstruction.hh"
0032 #include "PhysListEmStandard.hh"
0033 #include "PhysicsListMessenger.hh"
0034 
0035 #include "G4EmLivermorePhysics.hh"
0036 #include "G4EmLowEPPhysics.hh"
0037 #include "G4EmParameters.hh"
0038 #include "G4EmPenelopePhysics.hh"
0039 #include "G4EmStandardPhysics.hh"
0040 #include "G4EmStandardPhysicsGS.hh"
0041 #include "G4EmStandardPhysicsSS.hh"
0042 #include "G4EmStandardPhysicsWVI.hh"
0043 #include "G4EmStandardPhysics_option1.hh"
0044 #include "G4EmStandardPhysics_option2.hh"
0045 #include "G4EmStandardPhysics_option3.hh"
0046 #include "G4EmStandardPhysics_option4.hh"
0047 #include "G4LossTableManager.hh"
0048 #include "G4SystemOfUnits.hh"
0049 #include "G4UnitsTable.hh"
0050 
0051 // particles
0052 
0053 #include "StepMax.hh"
0054 
0055 #include "G4BaryonConstructor.hh"
0056 #include "G4BosonConstructor.hh"
0057 #include "G4Decay.hh"
0058 #include "G4Electron.hh"
0059 #include "G4Gamma.hh"
0060 #include "G4GenericIon.hh"
0061 #include "G4IonConstructor.hh"
0062 #include "G4LeptonConstructor.hh"
0063 #include "G4Material.hh"
0064 #include "G4MesonConstructor.hh"
0065 #include "G4NuclideTable.hh"
0066 #include "G4PhysicsListHelper.hh"
0067 #include "G4ProcessManager.hh"
0068 #include "G4Proton.hh"
0069 #include "G4RadioactiveDecay.hh"
0070 #include "G4ShortLivedConstructor.hh"
0071 
0072 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0073 
0074 PhysicsList::PhysicsList(DetectorConstruction* det) : fDet(det)
0075 {
0076   fMessenger = new PhysicsListMessenger(this);
0077   SetVerboseLevel(1);
0078 
0079   // EM physics
0080   AddPhysicsList("emstandard_opt3");
0081 
0082   // fix lower limit for cut
0083   G4ProductionCutsTable::GetProductionCutsTable()->SetEnergyRange(10 * eV, 1 * GeV);
0084   SetDefaultCutValue(1 * mm);
0085 }
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 
0089 PhysicsList::~PhysicsList()
0090 {
0091   delete fMessenger;
0092 }
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0095 
0096 void PhysicsList::ConstructParticle()
0097 {
0098   G4BosonConstructor pBosonConstructor;
0099   pBosonConstructor.ConstructParticle();
0100 
0101   G4LeptonConstructor pLeptonConstructor;
0102   pLeptonConstructor.ConstructParticle();
0103 
0104   G4MesonConstructor pMesonConstructor;
0105   pMesonConstructor.ConstructParticle();
0106 
0107   G4BaryonConstructor pBaryonConstructor;
0108   pBaryonConstructor.ConstructParticle();
0109 
0110   G4IonConstructor pIonConstructor;
0111   pIonConstructor.ConstructParticle();
0112 
0113   G4ShortLivedConstructor pShortLivedConstructor;
0114   pShortLivedConstructor.ConstructParticle();
0115 }
0116 
0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0118 
0119 void PhysicsList::ConstructProcess()
0120 {
0121   // Transportation
0122   //
0123   AddTransportation();
0124 
0125   // Electromagnetic physics list
0126   //
0127   fEmPhysicsList->ConstructProcess();
0128 
0129   // Decay Process
0130   //
0131   AddDecay();
0132 
0133   // Decay Process
0134   //
0135   AddRadioactiveDecay();
0136 
0137   // step limitation (as a full process)
0138   //
0139   AddStepMax();
0140 
0141   // example of Get process
0142   auto process = GetProcess("RadioactiveDecay");
0143   if (process != nullptr) {
0144     G4cout << "\n  GetProcess : " << process->GetProcessName() << G4endl;
0145   }
0146 }
0147 
0148 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0149 
0150 void PhysicsList::AddPhysicsList(const G4String& name)
0151 {
0152   if (verboseLevel > 0) {
0153     G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
0154   }
0155 
0156   if (name == fEmName) return;
0157 
0158   if (name == "local") {
0159     fEmName = name;
0160     delete fEmPhysicsList;
0161     fEmPhysicsList = new PhysListEmStandard(name);
0162   }
0163   else if (name == "emstandard_opt0") {
0164     fEmName = name;
0165     delete fEmPhysicsList;
0166     fEmPhysicsList = new G4EmStandardPhysics();
0167   }
0168   else if (name == "emstandard_opt1") {
0169     fEmName = name;
0170     delete fEmPhysicsList;
0171     fEmPhysicsList = new G4EmStandardPhysics_option1();
0172   }
0173   else if (name == "emstandard_opt2") {
0174     fEmName = name;
0175     delete fEmPhysicsList;
0176     fEmPhysicsList = new G4EmStandardPhysics_option2();
0177   }
0178   else if (name == "emstandard_opt3") {
0179     fEmName = name;
0180     delete fEmPhysicsList;
0181     fEmPhysicsList = new G4EmStandardPhysics_option3();
0182   }
0183   else if (name == "emstandard_opt4") {
0184     fEmName = name;
0185     delete fEmPhysicsList;
0186     fEmPhysicsList = new G4EmStandardPhysics_option4();
0187   }
0188   else if (name == "emstandardSS") {
0189     fEmName = name;
0190     delete fEmPhysicsList;
0191     fEmPhysicsList = new G4EmStandardPhysicsSS();
0192   }
0193   else if (name == "emstandardGS") {
0194     fEmName = name;
0195     delete fEmPhysicsList;
0196     fEmPhysicsList = new G4EmStandardPhysicsGS();
0197   }
0198   else if (name == "emstandardWVI") {
0199     fEmName = name;
0200     delete fEmPhysicsList;
0201     fEmPhysicsList = new G4EmStandardPhysicsWVI();
0202   }
0203   else if (name == "emlivermore") {
0204     fEmName = name;
0205     delete fEmPhysicsList;
0206     fEmPhysicsList = new G4EmLivermorePhysics();
0207   }
0208   else if (name == "empenelope") {
0209     fEmName = name;
0210     delete fEmPhysicsList;
0211     fEmPhysicsList = new G4EmPenelopePhysics();
0212   }
0213   else if (name == "emlowenergy") {
0214     fEmName = name;
0215     delete fEmPhysicsList;
0216     fEmPhysicsList = new G4EmLowEPPhysics();
0217   }
0218   else {
0219     G4cout << "PhysicsList::AddPhysicsList: <" << name << ">"
0220            << " is not defined" << G4endl;
0221   }
0222 
0223   // Em options
0224   //
0225   G4EmParameters::Instance()->SetBuildCSDARange(true);
0226   G4EmParameters::Instance()->SetGeneralProcessActive(false);
0227 }
0228 
0229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0230 
0231 void PhysicsList::AddDecay()
0232 {
0233   G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
0234 
0235   // Decay Process
0236   //
0237   G4Decay* fDecayProcess = new G4Decay();
0238 
0239   auto particleIterator = GetParticleIterator();
0240   particleIterator->reset();
0241   while ((*particleIterator)()) {
0242     G4ParticleDefinition* particle = particleIterator->value();
0243     if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived())
0244       ph->RegisterProcess(fDecayProcess, particle);
0245   }
0246 }
0247 
0248 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0249 
0250 void PhysicsList::AddRadioactiveDecay()
0251 {
0252   G4RadioactiveDecay* radioactiveDecay = new G4RadioactiveDecay();
0253 
0254   G4bool armFlag = false;
0255   radioactiveDecay->SetARM(armFlag);  // Atomic Rearangement
0256 
0257   // atomic de-excitation module
0258   if (armFlag) {
0259     G4EmParameters::Instance()->SetAuger(true);
0260     G4EmParameters::Instance()->SetDeexcitationIgnoreCut(true);
0261   }
0262 
0263   G4PhysicsListHelper* ph = G4PhysicsListHelper::GetPhysicsListHelper();
0264   ph->RegisterProcess(radioactiveDecay, G4GenericIon::GenericIon());
0265 
0266   // mandatory for G4NuclideTable
0267   //
0268   const G4double meanLife = 1 * picosecond, halfLife = meanLife * std::log(2);
0269   G4NuclideTable::GetInstance()->SetThresholdOfHalfLife(halfLife);
0270 }
0271 
0272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0273 
0274 void PhysicsList::AddStepMax()
0275 {
0276   // Step limitation seen as a process
0277   StepMax* stepMaxProcess = new StepMax();
0278 
0279   auto particleIterator = GetParticleIterator();
0280   particleIterator->reset();
0281   while ((*particleIterator)()) {
0282     G4ParticleDefinition* particle = particleIterator->value();
0283     G4ProcessManager* pmanager = particle->GetProcessManager();
0284 
0285     if (stepMaxProcess->IsApplicable(*particle) && !particle->IsShortLived())
0286       pmanager->AddDiscreteProcess(stepMaxProcess);
0287   }
0288 }
0289 
0290 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0291 
0292 void PhysicsList::GetRange(G4double val)
0293 {
0294   G4LogicalVolume* lBox = fDet->GetWorld()->GetLogicalVolume();
0295   const G4MaterialCutsCouple* couple = lBox->GetMaterialCutsCouple();
0296   const G4Material* currMat = lBox->GetMaterial();
0297 
0298   G4ParticleDefinition* part;
0299   G4double cut;
0300   part = G4Electron::Electron();
0301   cut = G4LossTableManager::Instance()->GetRange(part, val, couple);
0302   G4cout << "material : " << currMat->GetName() << G4endl;
0303   G4cout << "particle : " << part->GetParticleName() << G4endl;
0304   G4cout << "energy   : " << G4BestUnit(val, "Energy") << G4endl;
0305   G4cout << "range    : " << G4BestUnit(cut, "Length") << G4endl;
0306 }
0307 
0308 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0309 
0310 G4VProcess* PhysicsList::GetProcess(const G4String& processName) const
0311 {
0312   G4ParticleDefinition* particle = G4GenericIon::GenericIon();
0313   G4ProcessVector* procList = particle->GetProcessManager()->GetProcessList();
0314   G4int nbProc = particle->GetProcessManager()->GetProcessListLength();
0315   for (G4int k = 0; k < nbProc; k++) {
0316     G4VProcess* process = (*procList)[k];
0317     if (process->GetProcessName() == processName) return process;
0318   }
0319   return nullptr;
0320 }
0321 
0322 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......