4 // Author: I. Hrivnacova
6 // Class TG4ModularPhysicsList
7 // ---------------------------
8 // See the class description in the header file.
10 #include "TG4ModularPhysicsList.h"
11 #include "TG4GeometryServices.h"
12 #include "TG4G3PhysicsManager.h"
13 #include "TG4G3ControlVector.h"
14 #include "TG4ProcessControlMap.h"
15 #include "TG4ExtDecayer.h"
16 #include "AliDecayer.h"
19 #include <G4ParticleDefinition.hh>
20 #include <G4ProcessManager.hh>
21 #include <G4BosonConstructor.hh>
22 #include <G4LeptonConstructor.hh>
23 #include <G4MesonConstructor.hh>
24 #include <G4BaryonConstructor.hh>
25 #include <G4IonConstructor.hh>
26 #include <G4ShortLivedConstructor.hh>
27 #include <G4ProcessTable.hh>
30 const G4bool TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
32 //_____________________________________________________________________________
33 TG4ModularPhysicsList::TG4ModularPhysicsList()
34 : G4VModularPhysicsList(),
38 defaultCutValue = fgkDefaultCutValue;
43 //_____________________________________________________________________________
44 TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
47 TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
50 //_____________________________________________________________________________
51 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
54 // fExtDecayer is deleted in G4Decay destructor
59 //_____________________________________________________________________________
60 TG4ModularPhysicsList&
61 TG4ModularPhysicsList::operator=(const TG4ModularPhysicsList &right)
63 // check assignement to self
64 if (this == &right) return *this;
66 TG4Globals::Exception("TG4ModularPhysicsList is protected from assigning.");
73 //_____________________________________________________________________________
74 void TG4ModularPhysicsList::SetProcessActivation(
75 G4ProcessManager* processManager,
76 G4int processId, G4bool activation)
78 // Sets process activation for the given process.
81 G4String strActivation = "activation";
82 if (!activation) strActivation = "inactivation";
85 G4cout << "Set process " << strActivation << " for "
86 << (*processManager->GetProcessList())[processId]->GetProcessName()
90 processManager->SetProcessActivation(processId, activation);
95 //_____________________________________________________________________________
96 void TG4ModularPhysicsList::ConstructParticle()
98 // In this method, static member functions should be called
99 // for all particles which you want to use.
100 // This ensures that objects of these particle types will be
101 // created in the program.
104 // lock physics manager
105 TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
106 g3PhysicsManager->Lock();
108 // create all particles
109 ConstructAllBosons();
110 ConstructAllLeptons();
111 ConstructAllMesons();
112 ConstructAllBaryons();
114 ConstructAllShortLiveds();
116 // create particles for registered physics
117 G4VModularPhysicsList::ConstructParticle();
120 //_____________________________________________________________________________
121 void TG4ModularPhysicsList::ConstructProcess()
123 // Constructs all processes.
126 // create processes for registered physics
127 G4VModularPhysicsList::ConstructProcess();
132 if (verboseLevel>1) PrintAllProcesses();
135 //_____________________________________________________________________________
136 void TG4ModularPhysicsList::ConstructAllBosons()
138 // Construct all bosons
141 G4BosonConstructor pConstructor;
142 pConstructor.ConstructParticle();
145 //_____________________________________________________________________________
146 void TG4ModularPhysicsList::ConstructAllLeptons()
148 // Construct all leptons
151 G4LeptonConstructor pConstructor;
152 pConstructor.ConstructParticle();
155 //_____________________________________________________________________________
156 void TG4ModularPhysicsList::ConstructAllMesons()
158 // Construct all mesons
161 G4MesonConstructor pConstructor;
162 pConstructor.ConstructParticle();
165 //_____________________________________________________________________________
166 void TG4ModularPhysicsList::ConstructAllBaryons()
168 // Construct all barions
171 G4BaryonConstructor pConstructor;
172 pConstructor.ConstructParticle();
175 //_____________________________________________________________________________
176 void TG4ModularPhysicsList::ConstructAllIons()
178 // Construct light ions
181 G4IonConstructor pConstructor;
182 pConstructor.ConstructParticle();
185 //_____________________________________________________________________________
186 void TG4ModularPhysicsList::ConstructAllShortLiveds()
188 // Construct resonaces and quarks
191 G4ShortLivedConstructor pConstructor;
192 pConstructor.ConstructParticle();
195 //_____________________________________________________________________________
196 void TG4ModularPhysicsList::ConstructGeneral()
198 // Constructs general processes.
202 G4Decay* theDecayProcess = new G4Decay();
204 // Set external decayer
205 AliDecayer* aliDecayer = gMC->Decayer();
207 TG4ExtDecayer* tg4Decayer = new TG4ExtDecayer(aliDecayer);
208 // the tg4Decayer is deleted in G4Decay destructor
209 tg4Decayer->SetVerboseLevel(1);
210 theDecayProcess->SetExtDecayer(tg4Decayer);
212 if (verboseLevel>0) G4cout << "### External decayer is set" << G4endl;
215 theParticleIterator->reset();
216 while( (*theParticleIterator)() ){
217 G4ParticleDefinition* particle = theParticleIterator->value();
218 G4ProcessManager* pmanager = particle->GetProcessManager();
219 if (theDecayProcess->IsApplicable(*particle)) {
220 pmanager ->AddProcess(theDecayProcess);
221 // set ordering for PostStepDoIt and AtRestDoIt
222 pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
223 pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
227 // map to G3 controls
228 TG4ProcessControlMap* processMap = TG4ProcessControlMap::Instance();
229 processMap->Add(theDecayProcess, kDCAY);
234 //_____________________________________________________________________________
235 void TG4ModularPhysicsList::SetCuts()
237 // Sets the default cut value for all particle types
239 // The cut value for e-/e+ is high in oredr to supress
240 // tracking of delta electrons.
243 // SetCutsWithDefault();
244 // "G4VUserPhysicsList::SetCutsWithDefault" method sets
245 // the default cut value for all particle types.
248 G4double cut = defaultCutValue;
249 //G4double ecut = 10.*m;
253 if (verboseLevel >1){
254 G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
255 G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
259 // set cut values for gamma at first and for e- second and next for e+,
260 // because some processes for e+/e- need cut values for gamma
261 SetCutValue(cut, "gamma");
262 SetCutValue(ecut, "e-");
263 SetCutValue(ecut, "e+");
265 // set cut values for proton and anti_proton before all other hadrons
266 // because some processes for hadrons need cut values for proton/anti_proton
267 SetCutValue(cut, "proton");
268 SetCutValue(cut, "anti_proton");
270 SetCutValueForOthers(cut);
272 if (verboseLevel>1) {
273 DumpCutValuesTable();
277 //_____________________________________________________________________________
278 void TG4ModularPhysicsList::SetProcessActivation()
280 // (In)Activates built processes according
281 // to the setup in TG4G3PhysicsManager::fControlVector.
284 TG4G3ControlVector* controlVector
285 = TG4G3PhysicsManager::Instance()->GetControlVector();
287 G4bool specialControls
288 = TG4GeometryServices::Instance()->IsSpecialControls();
290 if (!specialControls)
292 << "### No special controls in user limits are set." << G4endl;
294 if (!controlVector) {
295 G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
296 text = text + " Vector of processes controls is not set.";
297 TG4Globals::Warning(text);
301 theParticleIterator->reset();
302 while ((*theParticleIterator)())
304 G4ProcessManager* processManager
305 = theParticleIterator->value()->GetProcessManager();
307 G4ProcessVector* processVector = processManager->GetProcessList();
309 // set processes controls
310 for (G4int i=0; i<processVector->length(); i++) {
312 TG4G3ControlValue control
313 = controlVector->GetControlValue((*processVector)[i]);
314 G4bool activation = processManager->GetProcessActivation(i);
316 if (control != kUnset) {
317 if (!TG4Globals::Compare(activation, control)) {
319 // set new process activation
321 if (control == kInActivate) activate = false;
322 else activate = true;
324 SetProcessActivation(processManager, i, activate);
329 if ((*processVector)[i]->GetProcessName().find("specialControl")
332 SetProcessActivation(processManager, i, specialControls);
339 //_____________________________________________________________________________
340 void TG4ModularPhysicsList::PrintAllProcesses() const
342 // Prints all processes.
345 G4cout << "TG4ModularPhysicsList processes: " << G4endl;
346 G4cout << "========================= " << G4endl;
348 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
349 G4ProcessTable::G4ProcNameVector* processNameList
350 = processTable->GetNameList();
352 for (G4int i=0; i <processNameList->size(); i++){
353 G4cout << " " << (*processNameList)[i] << G4endl;