EDepSimPhysicsList.cc
Go to the documentation of this file.
1 #include "EDepSimPhysicsList.hh"
3 #include "EDepSimException.hh"
4 #include "EDepSimExtraPhysics.hh"
5 
6 #include <EDepSimLog.hh>
7 
8 #include <G4OpticalPhysics.hh>
9 
10 #include <G4LossTableManager.hh>
11 
12 #include <G4ProcessManager.hh>
13 #include <G4ParticleTypes.hh>
14 #include <G4ParticleTable.hh>
15 
16 #include <G4PhysListFactory.hh>
17 
18 #include <G4Gamma.hh>
19 #include <G4Electron.hh>
20 #include <G4Positron.hh>
21 
22 #include <G4ProcessTable.hh>
23 
24 #include <G4SystemOfUnits.hh>
25 
26 #include <unistd.h>
27 
29  : G4VModularPhysicsList() {
30  G4LossTableManager::Instance();
31  defaultCutValue = 1.*mm;
32  fCutForGamma = defaultCutValue;
33  fCutForElectron = defaultCutValue;
34  fCutForPositron = defaultCutValue;
35 
37 
38  SetVerboseLevel(1);
39 
40  G4PhysListFactory factory;
41  G4VModularPhysicsList* phys = NULL;
42 
43  // Check to see if the physics list has been over ridden from the
44  // environment variable PHYSLIST
45  char* list = getenv("PHYSLIST");
46  if (list) {
47  phys = factory.ReferencePhysList();
48  }
49 
50  // Check if a list name was provided on the command line. It usually is
51  // not provided.
52  if (!phys && physName.size() > 1
53  && factory.IsReferencePhysList(physName)) {
54  EDepSimLog("Set the default physics list");
55  phys =factory.GetReferencePhysList(physName);
56  }
57 
58  // Use the default physics list.
59  if (!phys) {
60  phys =factory.GetReferencePhysList("QGSP_BERT");
61  }
62 
63  if (!phys) {
64  EDepSimThrow("No physics list was created.");
65  }
66 
67  // Transfer the physics list from the factory to this one.
68  for (G4int i = 0; ; ++i) {
69  G4VPhysicsConstructor* elem =
70  const_cast<G4VPhysicsConstructor*> (phys->GetPhysics(i));
71  if (elem == NULL) break;
72  G4cout << "RegisterPhysics: " << elem->GetPhysicsName() << G4endl;
73  RegisterPhysics(elem);
74  }
75 
76  // Add our specific lists.
78  RegisterPhysics(fExtra);
79  RegisterPhysics(new G4OpticalPhysics());
80 
81 }
82 
84  delete fMessenger;
85 }
86 
88  if (verboseLevel >0) {
89  G4cout << "EDepSim::PhysicsList::SetCuts:";
90  G4cout << "CutLength : " << G4BestUnit(defaultCutValue,"Length")
91  << G4endl;
92  }
93 
94  // set cut values for gamma at first and for e- second and next for e+,
95  // because some processes for e+/e- need cut values for gamma
96  SetCutValue(fCutForGamma, "gamma");
97  SetCutValue(fCutForElectron, "e-");
98  SetCutValue(fCutForPositron, "e+");
99 
100  if (verboseLevel>0) DumpCutValuesTable();
101 }
102 
104  fCutForGamma = cut;
105  SetParticleCuts(fCutForGamma, G4Gamma::Gamma());
106 }
107 
109  fCutForElectron = cut;
110  SetParticleCuts(fCutForElectron, G4Electron::Electron());
111 }
112 
114  fCutForPositron = cut;
115  SetParticleCuts(fCutForPositron, G4Positron::Positron());
116 }
117 
120 }
121 
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
EDepSim::PhysicsListMessenger * fMessenger
The messenger to control this class.
void SetCutForGamma(G4double)
Set the range cut for photons.
#define EDepSimThrow(message)
Print an error message, and then throw an exception.
void SetCutForPositron(G4double)
Set the range cut for positrons.
std::string getenv(std::string const &name)
Definition: getenv.cc:15
void SetCutForElectron(G4double)
Set the range cut for electrons.
G4double fCutForPositron
The positron range cut.
virtual void SetCuts()
Used by GEANT4 to set the cuts defined below.
EDepSim::ExtraPhysics * fExtra
The extra physics list.
PhysicsList(G4String physName)
G4double fCutForGamma
The gamma-ray range cut.
static constexpr double mm
Definition: Units.h:65
static bool * b
Definition: config.cpp:1043
G4double fCutForElectron
The electron range cut.