]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4ModularPhysicsList.cxx
Updated class description: added class title, author;
[u/mrichter/AliRoot.git] / TGeant4 / TG4ModularPhysicsList.cxx
CommitLineData
f04eb3a5 1// $Id$
2// Category: physics
3//
e5967ab3 4// Author: I. Hrivnacova
5//
6// Class TG4ModularPhysicsList
7// ---------------------------
f04eb3a5 8// See the class description in the header file.
9
10#include "TG4ModularPhysicsList.h"
e5967ab3 11#include "TG4GeometryServices.h"
f04eb3a5 12#include "TG4G3PhysicsManager.h"
13#include "TG4G3ControlVector.h"
e5967ab3 14#include "TG4ProcessControlMap.h"
8496e315 15#include "TG4ExtDecayer.h"
16#include "AliDecayer.h"
17#include "AliMC.h"
f04eb3a5 18
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>
28#include <G4Decay.hh>
29
e5967ab3 30const G4bool TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
f04eb3a5 31
72095f7c 32//_____________________________________________________________________________
f04eb3a5 33TG4ModularPhysicsList::TG4ModularPhysicsList()
8496e315 34 : G4VModularPhysicsList(),
35 fExtDecayer(0)
f04eb3a5 36{
8496e315 37//
e5967ab3 38 defaultCutValue = fgkDefaultCutValue;
f04eb3a5 39
40 SetVerboseLevel(1);
41}
42
72095f7c 43//_____________________________________________________________________________
8496e315 44TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
45{
46//
47 TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
48}
49
72095f7c 50//_____________________________________________________________________________
f04eb3a5 51TG4ModularPhysicsList::~TG4ModularPhysicsList() {
52//
8496e315 53 //delete fExtDecayer;
54 // fExtDecayer is deleted in G4Decay destructor
55}
56
57// operators
58
72095f7c 59//_____________________________________________________________________________
8496e315 60TG4ModularPhysicsList&
61TG4ModularPhysicsList::operator=(const TG4ModularPhysicsList &right)
62{
63 // check assignement to self
64 if (this == &right) return *this;
65
66 TG4Globals::Exception("TG4ModularPhysicsList is protected from assigning.");
67
68 return *this;
f04eb3a5 69}
70
e5967ab3 71// private methods
72
73//_____________________________________________________________________________
74void TG4ModularPhysicsList::SetProcessActivation(
75 G4ProcessManager* processManager,
76 G4int processId, G4bool activation)
77{
78// Sets process activation for the given process.
79// ---
80
81 G4String strActivation = "activation";
82 if (!activation) strActivation = "inactivation";
83
84 if (verboseLevel>1) {
85 G4cout << "Set process " << strActivation << " for "
86 << (*processManager->GetProcessList())[processId]->GetProcessName()
87 << G4endl;
88 }
89
90 processManager->SetProcessActivation(processId, activation);
91}
92
f04eb3a5 93// protected methods
94
72095f7c 95//_____________________________________________________________________________
f04eb3a5 96void TG4ModularPhysicsList::ConstructParticle()
97{
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.
102// ---
103
f04eb3a5 104 // lock physics manager
105 TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
106 g3PhysicsManager->Lock();
107
108 // create all particles
109 ConstructAllBosons();
110 ConstructAllLeptons();
111 ConstructAllMesons();
112 ConstructAllBaryons();
113 ConstructAllIons();
114 ConstructAllShortLiveds();
115
116 // create particles for registered physics
117 G4VModularPhysicsList::ConstructParticle();
118}
119
72095f7c 120//_____________________________________________________________________________
f04eb3a5 121void TG4ModularPhysicsList::ConstructProcess()
122{
123// Constructs all processes.
124// ---
125
f04eb3a5 126 // create processes for registered physics
127 G4VModularPhysicsList::ConstructProcess();
128
129 ConstructGeneral();
130
131 // verbose
132 if (verboseLevel>1) PrintAllProcesses();
133}
134
72095f7c 135//_____________________________________________________________________________
f04eb3a5 136void TG4ModularPhysicsList::ConstructAllBosons()
137{
138// Construct all bosons
139// ---
140
141 G4BosonConstructor pConstructor;
142 pConstructor.ConstructParticle();
143}
144
72095f7c 145//_____________________________________________________________________________
f04eb3a5 146void TG4ModularPhysicsList::ConstructAllLeptons()
147{
148// Construct all leptons
149// ---
150
151 G4LeptonConstructor pConstructor;
152 pConstructor.ConstructParticle();
153}
154
72095f7c 155//_____________________________________________________________________________
f04eb3a5 156void TG4ModularPhysicsList::ConstructAllMesons()
157{
158// Construct all mesons
159// ---
160
161 G4MesonConstructor pConstructor;
162 pConstructor.ConstructParticle();
163}
164
72095f7c 165//_____________________________________________________________________________
f04eb3a5 166void TG4ModularPhysicsList::ConstructAllBaryons()
167{
168// Construct all barions
169// ---
170
171 G4BaryonConstructor pConstructor;
172 pConstructor.ConstructParticle();
173}
174
72095f7c 175//_____________________________________________________________________________
f04eb3a5 176void TG4ModularPhysicsList::ConstructAllIons()
177{
178// Construct light ions
179// ---
180
181 G4IonConstructor pConstructor;
182 pConstructor.ConstructParticle();
183}
184
72095f7c 185//_____________________________________________________________________________
f04eb3a5 186void TG4ModularPhysicsList::ConstructAllShortLiveds()
187{
188// Construct resonaces and quarks
189// ---
190
191 G4ShortLivedConstructor pConstructor;
192 pConstructor.ConstructParticle();
193}
194
72095f7c 195//_____________________________________________________________________________
f04eb3a5 196void TG4ModularPhysicsList::ConstructGeneral()
197{
198// Constructs general processes.
199// ---
200
201 // Add Decay Process
202 G4Decay* theDecayProcess = new G4Decay();
8496e315 203
204 // Set external decayer
205 AliDecayer* aliDecayer = gMC->Decayer();
206 if (aliDecayer) {
207 TG4ExtDecayer* tg4Decayer = new TG4ExtDecayer(aliDecayer);
208 // the tg4Decayer is deleted in G4Decay destructor
209 tg4Decayer->SetVerboseLevel(1);
210 theDecayProcess->SetExtDecayer(tg4Decayer);
211
212 if (verboseLevel>0) G4cout << "### External decayer is set" << G4endl;
213 }
214
f04eb3a5 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);
224 }
225 }
e5967ab3 226
227 // map to G3 controls
228 TG4ProcessControlMap* processMap = TG4ProcessControlMap::Instance();
229 processMap->Add(theDecayProcess, kDCAY);
f04eb3a5 230}
231
232// public methods
233
72095f7c 234//_____________________________________________________________________________
f04eb3a5 235void TG4ModularPhysicsList::SetCuts()
236{
237// Sets the default cut value for all particle types
238// other then e-/e+.
239// The cut value for e-/e+ is high in oredr to supress
240// tracking of delta electrons.
241// ---
242
243 // SetCutsWithDefault();
244 // "G4VUserPhysicsList::SetCutsWithDefault" method sets
245 // the default cut value for all particle types.
246
247 // default cut value
248 G4double cut = defaultCutValue;
8496e315 249 //G4double ecut = 10.*m;
250 G4double ecut = cut;
f04eb3a5 251
252#ifdef G4VERBOSE
253 if (verboseLevel >1){
254 G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
255 G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
256 }
257#endif
258
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+");
264
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");
269
270 SetCutValueForOthers(cut);
271
272 if (verboseLevel>1) {
273 DumpCutValuesTable();
274 }
275}
276
72095f7c 277//_____________________________________________________________________________
f04eb3a5 278void TG4ModularPhysicsList::SetProcessActivation()
279{
280// (In)Activates built processes according
281// to the setup in TG4G3PhysicsManager::fControlVector.
282// ---
283
e5967ab3 284 TG4G3ControlVector* controlVector
285 = TG4G3PhysicsManager::Instance()->GetControlVector();
286
287 G4bool specialControls
288 = TG4GeometryServices::Instance()->IsSpecialControls();
289
290 if (!specialControls)
291 G4cout << G4endl
292 << "### No special controls in user limits are set." << G4endl;
293
294 if (!controlVector) {
f04eb3a5 295 G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
296 text = text + " Vector of processes controls is not set.";
297 TG4Globals::Warning(text);
e5967ab3 298 return;
f04eb3a5 299 }
e5967ab3 300
301 theParticleIterator->reset();
302 while ((*theParticleIterator)())
303 {
304 G4ProcessManager* processManager
305 = theParticleIterator->value()->GetProcessManager();
306
307 G4ProcessVector* processVector = processManager->GetProcessList();
308
309 // set processes controls
310 for (G4int i=0; i<processVector->length(); i++) {
311
312 TG4G3ControlValue control
313 = controlVector->GetControlValue((*processVector)[i]);
314 G4bool activation = processManager->GetProcessActivation(i);
315
316 if (control != kUnset) {
317 if (!TG4Globals::Compare(activation, control)) {
318
319 // set new process activation
320 G4bool activate;
321 if (control == kInActivate) activate = false;
322 else activate = true;
323
324 SetProcessActivation(processManager, i, activate);
325 }
326 }
327 else {
328 // control == kUnset
329 if ((*processVector)[i]->GetProcessName().find("specialControl")
330 != G4String::npos) {
331
332 SetProcessActivation(processManager, i, specialControls);
333 }
334 }
335 }
336 }
f04eb3a5 337}
338
72095f7c 339//_____________________________________________________________________________
f04eb3a5 340void TG4ModularPhysicsList::PrintAllProcesses() const
341{
342// Prints all processes.
343// ---
344
345 G4cout << "TG4ModularPhysicsList processes: " << G4endl;
346 G4cout << "========================= " << G4endl;
347
348 G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
349 G4ProcessTable::G4ProcNameVector* processNameList
350 = processTable->GetNameList();
351
352 for (G4int i=0; i <processNameList->size(); i++){
353 G4cout << " " << (*processNameList)[i] << G4endl;
354 }
355}
356