]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4ModularPhysicsList.cxx
updated to renaming in global category
[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
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>
19 #include <G4Decay.hh>
20
21
22 TG4ModularPhysicsList::TG4ModularPhysicsList()
23   : G4VModularPhysicsList()
24 {
25   G4cout << "TG4ModularPhysicsList::TG4ModularPhysicsList" << G4endl;
26
27   defaultCutValue = 1.0*mm;
28
29   SetVerboseLevel(1);
30 }
31
32 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
33 //
34 }
35
36 // protected methods
37
38 void TG4ModularPhysicsList::ConstructParticle()
39 {
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. 
44 // ---
45
46   G4cout << "Construct particles" << G4endl;
47
48   // lock physics manager
49   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
50   g3PhysicsManager->Lock();  
51  
52   // create all particles
53   ConstructAllBosons();
54   ConstructAllLeptons();
55   ConstructAllMesons();
56   ConstructAllBaryons();
57   ConstructAllIons();
58   ConstructAllShortLiveds();
59   
60   // create particles for registered physics
61   G4VModularPhysicsList::ConstructParticle();
62 }
63
64 void TG4ModularPhysicsList::ConstructProcess()
65 {
66 // Constructs all processes.
67 // ---
68
69   G4cout << "Construct process" << G4endl;
70
71   // create processes for registered physics
72   G4VModularPhysicsList::ConstructProcess();
73
74   ConstructGeneral();
75
76   // verbose
77   if (verboseLevel>1) PrintAllProcesses();
78 }
79
80
81 void TG4ModularPhysicsList::ConstructAllBosons()
82 {
83 // Construct all bosons
84 // ---
85
86   G4BosonConstructor pConstructor;
87   pConstructor.ConstructParticle();
88 }
89
90 void TG4ModularPhysicsList::ConstructAllLeptons()
91 {
92 // Construct all leptons
93 // ---
94
95   G4LeptonConstructor pConstructor;
96   pConstructor.ConstructParticle();
97 }
98
99 void TG4ModularPhysicsList::ConstructAllMesons()
100 {
101 // Construct all mesons
102 // ---
103
104   G4MesonConstructor pConstructor;
105   pConstructor.ConstructParticle();
106 }
107
108 void TG4ModularPhysicsList::ConstructAllBaryons()
109 {
110 // Construct all barions
111 // ---
112
113   G4BaryonConstructor pConstructor;
114   pConstructor.ConstructParticle();
115 }
116
117 void TG4ModularPhysicsList::ConstructAllIons()
118 {
119 // Construct light ions
120 // ---
121
122   G4IonConstructor pConstructor;
123   pConstructor.ConstructParticle();  
124 }
125
126 void TG4ModularPhysicsList::ConstructAllShortLiveds()
127 {
128 // Construct  resonaces and quarks
129 // ---
130
131   G4ShortLivedConstructor pConstructor;
132   pConstructor.ConstructParticle();  
133 }
134
135 void TG4ModularPhysicsList::ConstructGeneral()
136 {
137 // Constructs general processes.
138 // ---
139
140   // Add Decay Process
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);
151     }
152   }
153 }
154
155 // public methods
156
157 void TG4ModularPhysicsList::SetCuts()
158 {
159 // Sets the default cut value for all particle types
160 // other then e-/e+. 
161 // The cut value for e-/e+ is high in oredr to supress
162 // tracking of delta electrons.
163 // ---
164
165   // SetCutsWithDefault();   
166          // "G4VUserPhysicsList::SetCutsWithDefault" method sets 
167          // the default cut value for all particle types.
168
169   // default cut value
170   G4double cut  = defaultCutValue;
171   G4double ecut = 10.*m; 
172   //G4double ecut = cut; 
173
174 #ifdef G4VERBOSE    
175   if (verboseLevel >1){
176     G4cout << "G4VUserPhysicsList::SetCutsWithDefault:";
177     G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
178   }  
179 #endif
180
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+");
186  
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");
191   
192   SetCutValueForOthers(cut);
193
194   if (verboseLevel>1) {
195     DumpCutValuesTable();
196   }
197 }
198
199 void TG4ModularPhysicsList::SetProcessActivation()
200 {
201 // (In)Activates built processes according
202 // to the setup in TG4G3PhysicsManager::fControlVector.
203 // ---
204
205   G4cout << "TG4ModularPhysicsList::SetProcessActivation() start" << G4endl;
206   
207   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
208   TG4G3ControlVector* controlVector = g3PhysicsManager->GetControlVector();
209
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; }
214
215   if (controlVector) {
216     theParticleIterator->reset();
217     while ((*theParticleIterator)())
218     {
219       G4ParticleDefinition* particle = theParticleIterator->value();
220       G4ProcessManager* processManager = particle->GetProcessManager(); 
221       G4ProcessVector* processVector = processManager->GetProcessList();
222     
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;
231           }
232           processManager->SetProcessActivation(i,false);
233         }  
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;
239           }
240           processManager->SetProcessActivation(i,true);
241         } 
242       }
243     }
244   }
245   else {
246     G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
247     text = text + "    Vector of processes controls is not set.";
248     TG4Globals::Warning(text);
249   }    
250   G4cout << "TG4ModularPhysicsList::SetProcessActivation() end" << G4endl;
251 }
252
253 void TG4ModularPhysicsList::PrintAllProcesses() const
254 {
255 // Prints all processes.
256 // ---
257
258   G4cout << "TG4ModularPhysicsList processes: " << G4endl;
259   G4cout << "========================= " << G4endl;
260  
261   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
262   G4ProcessTable::G4ProcNameVector* processNameList 
263     = processTable->GetNameList();
264
265   for (G4int i=0; i <processNameList->size(); i++){
266     G4cout << "   " << (*processNameList)[i] << G4endl;
267   }  
268 }
269