]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4ModularPhysicsList.cxx
added comment lines separating methods
[u/mrichter/AliRoot.git] / TGeant4 / TG4ModularPhysicsList.cxx
1 // $Id$
2 // Category: physics
3 //
4 // See the class description in the header file.
5
6 #include "TG4ModularPhysicsList.h"
7 #include "TG4G3PhysicsManager.h"
8 #include "TG4G3ControlVector.h"
9 #include "TG4ExtDecayer.h"
10 #include "AliDecayer.h"
11 #include "AliMC.h"
12
13 #include <G4ParticleDefinition.hh>
14 #include <G4ProcessManager.hh>
15 #include <G4BosonConstructor.hh>
16 #include <G4LeptonConstructor.hh>
17 #include <G4MesonConstructor.hh>
18 #include <G4BaryonConstructor.hh>
19 #include <G4IonConstructor.hh>
20 #include <G4ShortLivedConstructor.hh>
21 #include <G4ProcessTable.hh>
22 #include <G4Decay.hh>
23
24
25 //_____________________________________________________________________________
26 TG4ModularPhysicsList::TG4ModularPhysicsList()
27   : G4VModularPhysicsList(),
28     fExtDecayer(0)
29 {
30 //
31   defaultCutValue = 1.0*mm;
32
33   SetVerboseLevel(1);
34 }
35
36 //_____________________________________________________________________________
37 TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
38 {
39 //
40   TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
41 }
42
43 //_____________________________________________________________________________
44 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
45 //
46   //delete fExtDecayer;
47        // fExtDecayer is deleted in G4Decay destructor
48 }
49
50 // operators
51
52 //_____________________________________________________________________________
53 TG4ModularPhysicsList& 
54 TG4ModularPhysicsList::operator=(const TG4ModularPhysicsList &right)
55 {
56   // check assignement to self
57   if (this == &right) return *this;
58   
59   TG4Globals::Exception("TG4ModularPhysicsList is protected from assigning.");
60
61   return *this;
62 }
63
64 // protected methods
65
66 //_____________________________________________________________________________
67 void TG4ModularPhysicsList::ConstructParticle()
68 {
69 // In this method, static member functions should be called
70 // for all particles which you want to use.
71 // This ensures that objects of these particle types will be
72 // created in the program. 
73 // ---
74
75   // lock physics manager
76   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
77   g3PhysicsManager->Lock();  
78  
79   // create all particles
80   ConstructAllBosons();
81   ConstructAllLeptons();
82   ConstructAllMesons();
83   ConstructAllBaryons();
84   ConstructAllIons();
85   ConstructAllShortLiveds();
86   
87   // create particles for registered physics
88   G4VModularPhysicsList::ConstructParticle();
89 }
90
91 //_____________________________________________________________________________
92 void TG4ModularPhysicsList::ConstructProcess()
93 {
94 // Constructs all processes.
95 // ---
96
97   // create processes for registered physics
98   G4VModularPhysicsList::ConstructProcess();
99
100   ConstructGeneral();
101
102   // verbose
103   if (verboseLevel>1) PrintAllProcesses();
104 }
105
106 //_____________________________________________________________________________
107 void TG4ModularPhysicsList::ConstructAllBosons()
108 {
109 // Construct all bosons
110 // ---
111
112   G4BosonConstructor pConstructor;
113   pConstructor.ConstructParticle();
114 }
115
116 //_____________________________________________________________________________
117 void TG4ModularPhysicsList::ConstructAllLeptons()
118 {
119 // Construct all leptons
120 // ---
121
122   G4LeptonConstructor pConstructor;
123   pConstructor.ConstructParticle();
124 }
125
126 //_____________________________________________________________________________
127 void TG4ModularPhysicsList::ConstructAllMesons()
128 {
129 // Construct all mesons
130 // ---
131
132   G4MesonConstructor pConstructor;
133   pConstructor.ConstructParticle();
134 }
135
136 //_____________________________________________________________________________
137 void TG4ModularPhysicsList::ConstructAllBaryons()
138 {
139 // Construct all barions
140 // ---
141
142   G4BaryonConstructor pConstructor;
143   pConstructor.ConstructParticle();
144 }
145
146 //_____________________________________________________________________________
147 void TG4ModularPhysicsList::ConstructAllIons()
148 {
149 // Construct light ions
150 // ---
151
152   G4IonConstructor pConstructor;
153   pConstructor.ConstructParticle();  
154 }
155
156 //_____________________________________________________________________________
157 void TG4ModularPhysicsList::ConstructAllShortLiveds()
158 {
159 // Construct  resonaces and quarks
160 // ---
161
162   G4ShortLivedConstructor pConstructor;
163   pConstructor.ConstructParticle();  
164 }
165
166 //_____________________________________________________________________________
167 void TG4ModularPhysicsList::ConstructGeneral()
168 {
169 // Constructs general processes.
170 // ---
171
172   // Add Decay Process
173   G4Decay* theDecayProcess = new G4Decay();
174
175   // Set external decayer
176   AliDecayer* aliDecayer = gMC->Decayer(); 
177   if (aliDecayer) {
178     TG4ExtDecayer* tg4Decayer = new TG4ExtDecayer(aliDecayer);
179        // the tg4Decayer is deleted in G4Decay destructor
180     tg4Decayer->SetVerboseLevel(1);   
181     theDecayProcess->SetExtDecayer(tg4Decayer);
182     
183     if (verboseLevel>0) G4cout << "### External decayer is set" << G4endl;
184   } 
185
186   theParticleIterator->reset();
187   while( (*theParticleIterator)() ){
188     G4ParticleDefinition* particle = theParticleIterator->value();
189     G4ProcessManager* pmanager = particle->GetProcessManager();
190     if (theDecayProcess->IsApplicable(*particle)) { 
191       pmanager ->AddProcess(theDecayProcess);
192       // set ordering for PostStepDoIt and AtRestDoIt
193       pmanager ->SetProcessOrdering(theDecayProcess, idxPostStep);
194       pmanager ->SetProcessOrdering(theDecayProcess, idxAtRest);
195     }
196   }
197 }
198
199 // public methods
200
201 //_____________________________________________________________________________
202 void TG4ModularPhysicsList::SetCuts()
203 {
204 // Sets the default cut value for all particle types
205 // other then e-/e+. 
206 // The cut value for e-/e+ is high in oredr to supress
207 // tracking of delta electrons.
208 // ---
209
210   // SetCutsWithDefault();   
211          // "G4VUserPhysicsList::SetCutsWithDefault" method sets 
212          // the default cut value for all particle types.
213
214   // default cut value
215   G4double cut  = defaultCutValue;
216   //G4double ecut = 10.*m; 
217   G4double ecut = cut; 
218
219 #ifdef G4VERBOSE    
220   if (verboseLevel >1){
221     G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
222     G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
223   }  
224 #endif
225
226   // set cut values for gamma at first and for e- second and next for e+,
227   // because some processes for e+/e- need cut values for gamma 
228   SetCutValue(cut, "gamma");
229   SetCutValue(ecut, "e-");
230   SetCutValue(ecut, "e+");
231  
232   // set cut values for proton and anti_proton before all other hadrons
233   // because some processes for hadrons need cut values for proton/anti_proton 
234   SetCutValue(cut, "proton");
235   SetCutValue(cut, "anti_proton");
236   
237   SetCutValueForOthers(cut);
238
239   if (verboseLevel>1) {
240     DumpCutValuesTable();
241   }
242 }
243
244 //_____________________________________________________________________________
245 void TG4ModularPhysicsList::SetProcessActivation()
246 {
247 // (In)Activates built processes according
248 // to the setup in TG4G3PhysicsManager::fControlVector.
249 // ---
250
251   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
252   TG4G3ControlVector* controlVector = g3PhysicsManager->GetControlVector();
253
254   // uncomment following lines to print
255   // the controlVector values
256   //for (G4int i=0; i<kNoG3Controls; i++)
257   //{ cout << i << " control: " << (*controlVector)[i] << G4endl; }
258
259   if (controlVector) {
260     theParticleIterator->reset();
261     while ((*theParticleIterator)())
262     {
263       G4ParticleDefinition* particle = theParticleIterator->value();
264       G4ProcessManager* processManager = particle->GetProcessManager(); 
265       G4ProcessVector* processVector = processManager->GetProcessList();
266     
267       // set processes controls
268       for (G4int i=0; i<processManager->GetProcessListLength(); i++) {
269         G4int control = controlVector->GetControl((*processVector)[i]);
270         if ((control == kInActivate) && 
271             (processManager->GetProcessActivation(i))) {
272           if (verboseLevel>1) {
273              G4cout << "Set process inactivation for " 
274                     << (*processVector)[i]->GetProcessName() << G4endl;
275           }
276           processManager->SetProcessActivation(i,false);
277         }  
278         else if (((control == kActivate) || (control == kActivate2)) &&
279                  (!processManager->GetProcessActivation(i))) {
280           if (verboseLevel>1) {
281              G4cout << "Set process activation for " 
282                     << (*processVector)[i]->GetProcessName() << G4endl;
283           }
284           processManager->SetProcessActivation(i,true);
285         } 
286       }
287     }
288   }
289   else {
290     G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
291     text = text + "    Vector of processes controls is not set.";
292     TG4Globals::Warning(text);
293   }    
294 }
295
296 //_____________________________________________________________________________
297 void TG4ModularPhysicsList::PrintAllProcesses() const
298 {
299 // Prints all processes.
300 // ---
301
302   G4cout << "TG4ModularPhysicsList processes: " << G4endl;
303   G4cout << "========================= " << G4endl;
304  
305   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
306   G4ProcessTable::G4ProcNameVector* processNameList 
307     = processTable->GetNameList();
308
309   for (G4int i=0; i <processNameList->size(); i++){
310     G4cout << "   " << (*processNameList)[i] << G4endl;
311   }  
312 }
313