4 // See the class description in the header file.
6 #include "TG4ModularPhysicsList.h"
7 #include "TG4G3PhysicsManager.h"
8 #include "TG4G3ControlVector.h"
10 #include <G4ParticleDefinition.hh>
11 #include <G4ProcessManager.hh>
12 #include <G4BosonConstructor.hh>
13 #include <G4LeptonConstructor.hh>
14 #include <G4MesonConstructor.hh>
15 #include <G4BaryonConstructor.hh>
16 #include <G4IonConstructor.hh>
17 #include <G4ShortLivedConstructor.hh>
18 #include <G4ProcessTable.hh>
22 TG4ModularPhysicsList::TG4ModularPhysicsList()
23 : G4VModularPhysicsList()
25 G4cout << "TG4ModularPhysicsList::TG4ModularPhysicsList" << G4endl;
27 defaultCutValue = 1.0*mm;
32 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
38 void TG4ModularPhysicsList::ConstructParticle()
40 // In this method, static member functions should be called
41 // for all particles which you want to use.
42 // This ensures that objects of these particle types will be
43 // created in the program.
46 G4cout << "Construct particles" << G4endl;
48 // lock physics manager
49 TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
50 g3PhysicsManager->Lock();
52 // create all particles
54 ConstructAllLeptons();
56 ConstructAllBaryons();
58 ConstructAllShortLiveds();
60 // create particles for registered physics
61 G4VModularPhysicsList::ConstructParticle();
64 void TG4ModularPhysicsList::ConstructProcess()
66 // Constructs all processes.
69 G4cout << "Construct process" << G4endl;
71 // create processes for registered physics
72 G4VModularPhysicsList::ConstructProcess();
77 if (verboseLevel>1) PrintAllProcesses();
81 void TG4ModularPhysicsList::ConstructAllBosons()
83 // Construct all bosons
86 G4BosonConstructor pConstructor;
87 pConstructor.ConstructParticle();
90 void TG4ModularPhysicsList::ConstructAllLeptons()
92 // Construct all leptons
95 G4LeptonConstructor pConstructor;
96 pConstructor.ConstructParticle();
99 void TG4ModularPhysicsList::ConstructAllMesons()
101 // Construct all mesons
104 G4MesonConstructor pConstructor;
105 pConstructor.ConstructParticle();
108 void TG4ModularPhysicsList::ConstructAllBaryons()
110 // Construct all barions
113 G4BaryonConstructor pConstructor;
114 pConstructor.ConstructParticle();
117 void TG4ModularPhysicsList::ConstructAllIons()
119 // Construct light ions
122 G4IonConstructor pConstructor;
123 pConstructor.ConstructParticle();
126 void TG4ModularPhysicsList::ConstructAllShortLiveds()
128 // Construct resonaces and quarks
131 G4ShortLivedConstructor pConstructor;
132 pConstructor.ConstructParticle();
135 void TG4ModularPhysicsList::ConstructGeneral()
137 // Constructs general processes.
141 G4Decay* theDecayProcess = new G4Decay();
142 theParticleIterator->reset();
143 while( (*theParticleIterator)() ){
144 G4ParticleDefinition* particle = theParticleIterator->value();
145 G4ProcessManager* pmanager = particle->GetProcessManager();
146 if (theDecayProcess->IsApplicable(*particle)) {
147 pmanager ->AddProcess(theDecayProcess);
148 // set ordering for PostStepDoIt and AtRestDoIt
149 pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
150 pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
157 void TG4ModularPhysicsList::SetCuts()
159 // Sets the default cut value for all particle types
161 // The cut value for e-/e+ is high in oredr to supress
162 // tracking of delta electrons.
165 // SetCutsWithDefault();
166 // "G4VUserPhysicsList::SetCutsWithDefault" method sets
167 // the default cut value for all particle types.
170 G4double cut = defaultCutValue;
171 G4double ecut = 10.*m;
172 //G4double ecut = cut;
175 if (verboseLevel >1){
176 G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
177 G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
181 // set cut values for gamma at first and for e- second and next for e+,
182 // because some processes for e+/e- need cut values for gamma
183 SetCutValue(cut, "gamma");
184 SetCutValue(ecut, "e-");
185 SetCutValue(ecut, "e+");
187 // set cut values for proton and anti_proton before all other hadrons
188 // because some processes for hadrons need cut values for proton/anti_proton
189 SetCutValue(cut, "proton");
190 SetCutValue(cut, "anti_proton");
192 SetCutValueForOthers(cut);
194 if (verboseLevel>1) {
195 DumpCutValuesTable();
199 void TG4ModularPhysicsList::SetProcessActivation()
201 // (In)Activates built processes according
202 // to the setup in TG4G3PhysicsManager::fControlVector.
205 G4cout << "TG4ModularPhysicsList::SetProcessActivation() start" << G4endl;
207 TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
208 TG4G3ControlVector* controlVector = g3PhysicsManager->GetControlVector();
210 // uncomment following lines to print
211 // the controlVector values
212 //for (G4int i=0; i<kNoG3Controls; i++)
213 //{ cout << i << " control: " << (*controlVector)[i] << G4endl; }
216 theParticleIterator->reset();
217 while ((*theParticleIterator)())
219 G4ParticleDefinition* particle = theParticleIterator->value();
220 G4ProcessManager* processManager = particle->GetProcessManager();
221 G4ProcessVector* processVector = processManager->GetProcessList();
223 // set processes controls
224 for (G4int i=0; i<processManager->GetProcessListLength(); i++) {
225 G4int control = controlVector->GetControl((*processVector)[i]);
226 if ((control == kInActivate) &&
227 (processManager->GetProcessActivation(i))) {
228 if (verboseLevel>1) {
229 G4cout << "Set process inactivation for "
230 << (*processVector)[i]->GetProcessName() << G4endl;
232 processManager->SetProcessActivation(i,false);
234 else if (((control == kActivate) || (control == kActivate2)) &&
235 (!processManager->GetProcessActivation(i))) {
236 if (verboseLevel>1) {
237 G4cout << "Set process activation for "
238 << (*processVector)[i]->GetProcessName() << G4endl;
240 processManager->SetProcessActivation(i,true);
246 G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
247 text = text + " Vector of processes controls is not set.";
248 TG4Globals::Warning(text);
250 G4cout << "TG4ModularPhysicsList::SetProcessActivation() end" << G4endl;
253 void TG4ModularPhysicsList::PrintAllProcesses() const
255 // Prints all processes.
258 G4cout << "TG4ModularPhysicsList processes: " << G4endl;
259 G4cout << "========================= " << G4endl;
261 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
262 G4ProcessTable::G4ProcNameVector* processNameList
263 = processTable->GetNameList();
265 for (G4int i=0; i <processNameList->size(); i++){
266 G4cout << " " << (*processNameList)[i] << G4endl;