Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:28:45

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 "PhysicsListMessenger.hh"
0032 #include "StepMax.hh"
0033 
0034 #include "G4Decay.hh"
0035 #include "G4EmBuilder.hh"
0036 #include "G4EmLivermorePhysics.hh"
0037 #include "G4EmLowEPPhysics.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 "G4ParticleDefinition.hh"
0049 #include "G4ProcessManager.hh"
0050 #include "G4SystemOfUnits.hh"
0051 #include "G4UnitsTable.hh"
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0054 
0055 PhysicsList::PhysicsList() : G4VModularPhysicsList()
0056 {
0057   fMessenger = new PhysicsListMessenger(this);
0058 
0059   // EM physics
0060   fEmName = G4String("emstandard_opt4");
0061   fEmPhysicsList = new G4EmStandardPhysics_option4(1);
0062   if (verboseLevel > -1) {
0063     G4cout << "PhysicsList::Constructor with default list: <" << fEmName << ">" << G4endl;
0064   }
0065 
0066   G4LossTableManager::Instance();
0067   SetVerboseLevel(1);
0068 }
0069 
0070 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0071 
0072 PhysicsList::~PhysicsList()
0073 {
0074   delete fEmPhysicsList;
0075   delete fMessenger;
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 void PhysicsList::ConstructParticle()
0081 {
0082   // minimal set of particles for EM physics
0083   G4EmBuilder::ConstructMinimalEmSet();
0084 }
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0087 
0088 void PhysicsList::ConstructProcess()
0089 {
0090   AddTransportation();
0091   fEmPhysicsList->ConstructProcess();
0092   AddDecay();
0093   AddStepMax();
0094 }
0095 
0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0097 
0098 void PhysicsList::AddDecay()
0099 {
0100   // Add Decay Process
0101 
0102   G4Decay* fDecayProcess = new G4Decay();
0103 
0104   auto particleIterator = GetParticleIterator();
0105   particleIterator->reset();
0106   while ((*particleIterator)()) {
0107     G4ParticleDefinition* particle = particleIterator->value();
0108     G4ProcessManager* pmanager = particle->GetProcessManager();
0109 
0110     if (fDecayProcess->IsApplicable(*particle) && !particle->IsShortLived()) {
0111       pmanager->AddProcess(fDecayProcess);
0112 
0113       // set ordering for PostStepDoIt and AtRestDoIt
0114       pmanager->SetProcessOrdering(fDecayProcess, idxPostStep);
0115       pmanager->SetProcessOrdering(fDecayProcess, idxAtRest);
0116     }
0117   }
0118 }
0119 
0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0121 
0122 void PhysicsList::AddStepMax()
0123 {
0124   // Step limitation seen as a process
0125   StepMax* stepMaxProcess = new StepMax();
0126 
0127   auto particleIterator = GetParticleIterator();
0128   particleIterator->reset();
0129   while ((*particleIterator)()) {
0130     G4ParticleDefinition* particle = particleIterator->value();
0131     G4ProcessManager* pmanager = particle->GetProcessManager();
0132 
0133     if (stepMaxProcess->IsApplicable(*particle)) {
0134       pmanager->AddDiscreteProcess(stepMaxProcess);
0135     }
0136   }
0137 }
0138 
0139 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0140 
0141 void PhysicsList::AddPhysicsList(const G4String& name)
0142 {
0143   if (verboseLevel > -1) {
0144     G4cout << "PhysicsList::AddPhysicsList: <" << name << ">" << G4endl;
0145   }
0146 
0147   if (name == fEmName) return;
0148 
0149   if (name == "emstandard_opt0") {
0150     fEmName = name;
0151     delete fEmPhysicsList;
0152     fEmPhysicsList = new G4EmStandardPhysics(1);
0153   }
0154   else if (name == "emstandard_opt1") {
0155     fEmName = name;
0156     delete fEmPhysicsList;
0157     fEmPhysicsList = new G4EmStandardPhysics_option1(1);
0158   }
0159   else if (name == "emstandard_opt2") {
0160     fEmName = name;
0161     delete fEmPhysicsList;
0162     fEmPhysicsList = new G4EmStandardPhysics_option2(1);
0163   }
0164   else if (name == "emstandard_opt3") {
0165     fEmName = name;
0166     delete fEmPhysicsList;
0167     fEmPhysicsList = new G4EmStandardPhysics_option3(1);
0168   }
0169   else if (name == "emstandard_opt4") {
0170     fEmName = name;
0171     delete fEmPhysicsList;
0172     fEmPhysicsList = new G4EmStandardPhysics_option4(1);
0173   }
0174   else if (name == "emlowenergy") {
0175     fEmName = name;
0176     delete fEmPhysicsList;
0177     fEmPhysicsList = new G4EmLowEPPhysics(1);
0178   }
0179   else if (name == "emstandardSS") {
0180     fEmName = name;
0181     delete fEmPhysicsList;
0182     fEmPhysicsList = new G4EmStandardPhysicsSS(1);
0183   }
0184   else if (name == "emstandardWVI") {
0185     fEmName = name;
0186     delete fEmPhysicsList;
0187     fEmPhysicsList = new G4EmStandardPhysicsWVI(1);
0188   }
0189   else if (name == "emstandardGS") {
0190     fEmName = name;
0191     delete fEmPhysicsList;
0192     fEmPhysicsList = new G4EmStandardPhysicsGS(1);
0193   }
0194   else if (name == "emlivermore") {
0195     fEmName = name;
0196     delete fEmPhysicsList;
0197     fEmPhysicsList = new G4EmLivermorePhysics(1);
0198   }
0199   else if (name == "empenelope") {
0200     fEmName = name;
0201     delete fEmPhysicsList;
0202     fEmPhysicsList = new G4EmPenelopePhysics(1);
0203   }
0204   else {
0205     G4ExceptionDescription description;
0206     description << "      "
0207                 << "PhysicsList::AddPhysicsList: <" << name << "> is not defined";
0208     G4Exception("PhysicsList::AddPhysicsList", "electronScattering2_F001", FatalException,
0209                 description);
0210   }
0211 }
0212 
0213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......