]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4ModularPhysicsList.cxx
Updated class description: added class title, author;
[u/mrichter/AliRoot.git] / TGeant4 / TG4ModularPhysicsList.cxx
1 // $Id$
2 // Category: physics
3 //
4 // Author: I. Hrivnacova
5 //
6 // Class TG4ModularPhysicsList
7 // ---------------------------
8 // See the class description in the header file.
9
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"
17 #include "AliMC.h"
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
30 const G4bool TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
31
32 //_____________________________________________________________________________
33 TG4ModularPhysicsList::TG4ModularPhysicsList()
34   : G4VModularPhysicsList(),
35     fExtDecayer(0)
36 {
37 //
38   defaultCutValue = fgkDefaultCutValue;
39
40   SetVerboseLevel(1);
41 }
42
43 //_____________________________________________________________________________
44 TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
45 {
46 //
47   TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
48 }
49
50 //_____________________________________________________________________________
51 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
52 //
53   //delete fExtDecayer;
54        // fExtDecayer is deleted in G4Decay destructor
55 }
56
57 // operators
58
59 //_____________________________________________________________________________
60 TG4ModularPhysicsList& 
61 TG4ModularPhysicsList::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;
69 }
70
71 // private methods
72
73 //_____________________________________________________________________________
74 void 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
93 // protected methods
94
95 //_____________________________________________________________________________
96 void 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
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
120 //_____________________________________________________________________________
121 void TG4ModularPhysicsList::ConstructProcess()
122 {
123 // Constructs all processes.
124 // ---
125
126   // create processes for registered physics
127   G4VModularPhysicsList::ConstructProcess();
128
129   ConstructGeneral();
130
131   // verbose
132   if (verboseLevel>1) PrintAllProcesses();
133 }
134
135 //_____________________________________________________________________________
136 void TG4ModularPhysicsList::ConstructAllBosons()
137 {
138 // Construct all bosons
139 // ---
140
141   G4BosonConstructor pConstructor;
142   pConstructor.ConstructParticle();
143 }
144
145 //_____________________________________________________________________________
146 void TG4ModularPhysicsList::ConstructAllLeptons()
147 {
148 // Construct all leptons
149 // ---
150
151   G4LeptonConstructor pConstructor;
152   pConstructor.ConstructParticle();
153 }
154
155 //_____________________________________________________________________________
156 void TG4ModularPhysicsList::ConstructAllMesons()
157 {
158 // Construct all mesons
159 // ---
160
161   G4MesonConstructor pConstructor;
162   pConstructor.ConstructParticle();
163 }
164
165 //_____________________________________________________________________________
166 void TG4ModularPhysicsList::ConstructAllBaryons()
167 {
168 // Construct all barions
169 // ---
170
171   G4BaryonConstructor pConstructor;
172   pConstructor.ConstructParticle();
173 }
174
175 //_____________________________________________________________________________
176 void TG4ModularPhysicsList::ConstructAllIons()
177 {
178 // Construct light ions
179 // ---
180
181   G4IonConstructor pConstructor;
182   pConstructor.ConstructParticle();  
183 }
184
185 //_____________________________________________________________________________
186 void TG4ModularPhysicsList::ConstructAllShortLiveds()
187 {
188 // Construct  resonaces and quarks
189 // ---
190
191   G4ShortLivedConstructor pConstructor;
192   pConstructor.ConstructParticle();  
193 }
194
195 //_____________________________________________________________________________
196 void TG4ModularPhysicsList::ConstructGeneral()
197 {
198 // Constructs general processes.
199 // ---
200
201   // Add Decay Process
202   G4Decay* theDecayProcess = new G4Decay();
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
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   }
226   
227   // map to G3 controls
228   TG4ProcessControlMap* processMap = TG4ProcessControlMap::Instance();
229   processMap->Add(theDecayProcess, kDCAY); 
230 }
231
232 // public methods
233
234 //_____________________________________________________________________________
235 void 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;
249   //G4double ecut = 10.*m; 
250   G4double ecut = cut; 
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
277 //_____________________________________________________________________________
278 void TG4ModularPhysicsList::SetProcessActivation()
279 {
280 // (In)Activates built processes according
281 // to the setup in TG4G3PhysicsManager::fControlVector.
282 // ---
283
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) {
295     G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
296     text = text + "    Vector of processes controls is not set.";
297     TG4Globals::Warning(text);
298     return;
299   }    
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   }  
337 }
338
339 //_____________________________________________________________________________
340 void 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