]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TGeant4/TG4ModularPhysicsList.cxx
Format() method added; changed Print() - usage of Format()
[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
16 #include <G4ParticleDefinition.hh>
17 #include <G4ProcessManager.hh>
18 #include <G4BosonConstructor.hh>
19 #include <G4LeptonConstructor.hh>
20 #include <G4MesonConstructor.hh>
21 #include <G4BaryonConstructor.hh>
22 #include <G4IonConstructor.hh>
23 #include <G4ShortLivedConstructor.hh>
24 #include <G4ProcessTable.hh>
25
26 const G4double TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
27
28 //_____________________________________________________________________________
29 TG4ModularPhysicsList::TG4ModularPhysicsList()
30   : G4VModularPhysicsList(),
31     TG4Verbose("physicsList") {
32 //
33   defaultCutValue = fgkDefaultCutValue;
34
35   SetVerboseLevel(VerboseLevel());
36 }
37
38 //_____________________________________________________________________________
39 TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
40   : TG4Verbose("physicsList") {
41 //
42   TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
43 }
44
45 //_____________________________________________________________________________
46 TG4ModularPhysicsList::~TG4ModularPhysicsList() {
47 //
48   //delete fExtDecayer;
49        // fExtDecayer is deleted in G4Decay destructor
50 }
51
52 // operators
53
54 //_____________________________________________________________________________
55 TG4ModularPhysicsList& 
56 TG4ModularPhysicsList::operator=(const TG4ModularPhysicsList &right)
57 {
58   // check assignement to self
59   if (this == &right) return *this;
60   
61   TG4Globals::Exception("TG4ModularPhysicsList is protected from assigning.");
62
63   return *this;
64 }
65
66 // private methods
67
68 //_____________________________________________________________________________
69 void TG4ModularPhysicsList::SetProcessActivation(
70                                       G4ProcessManager* processManager,
71                                       G4int  processId, G4bool activation)
72 {                                     
73 // Sets process activation for the given process.
74 // ---
75
76   G4String strActivation = "activation";
77   if (!activation) strActivation = "inactivation";
78
79   if (VerboseLevel() > 1) {
80     G4cout << "Set process " << strActivation << " for " 
81            << (*processManager->GetProcessList())[processId]->GetProcessName() 
82            << G4endl;
83   }
84   
85   processManager->SetProcessActivation(processId, activation);  
86 }  
87
88 // protected methods
89
90 //_____________________________________________________________________________
91 void TG4ModularPhysicsList::ConstructParticle()
92 {
93 // In this method, static member functions should be called
94 // for all particles which you want to use.
95 // This ensures that objects of these particle types will be
96 // created in the program. 
97 // ---
98
99   // lock physics manager
100   TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
101   g3PhysicsManager->Lock();  
102   
103   // create particles for registered physics
104   G4VModularPhysicsList::ConstructParticle();
105 }
106
107 //_____________________________________________________________________________
108 void TG4ModularPhysicsList::ConstructProcess()
109 {
110 // Constructs all processes.
111 // ---
112
113   // create processes for registered physics
114   G4VModularPhysicsList::ConstructProcess();
115
116   // verbose
117   if (verboseLevel>1) DumpAllProcesses();
118 }
119
120
121 // public methods
122
123 //_____________________________________________________________________________
124 void TG4ModularPhysicsList::SetCuts()
125 {
126 // Sets the default cut value for all particle types
127 // other then e-/e+. 
128 // The cut value for e-/e+ is high in oredr to supress
129 // tracking of delta electrons.
130 // ---
131
132   // SetCutsWithDefault();   
133          // "G4VUserPhysicsList::SetCutsWithDefault" method sets 
134          // the default cut value for all particle types.
135
136   // default cut value
137   G4double cut  = defaultCutValue;
138   //G4double ecut = 10.*m; 
139   G4double ecut = cut; 
140
141 #ifdef G4VERBOSE    
142   if (VerboseLevel() > 1) {
143     G4cout << "TG4ModularPhysicsList::SetCutsWithDefault:";
144     G4cout << "CutLength : " << cut/mm << " (mm)" << G4endl;
145   }  
146 #endif
147
148   // set cut values for gamma at first and for e- second and next for e+,
149   // because some processes for e+/e- need cut values for gamma 
150   SetCutValue(cut, "gamma");
151   SetCutValue(ecut, "e-");
152   SetCutValue(ecut, "e+");
153  
154   // set cut values for proton and anti_proton before all other hadrons
155   // because some processes for hadrons need cut values for proton/anti_proton 
156   SetCutValue(cut, "proton");
157   SetCutValue(cut, "anti_proton");
158   
159   SetCutValueForOthers(cut);
160
161   if (verboseLevel>1) {
162     DumpCutValuesTable();
163   }
164 }
165
166 //_____________________________________________________________________________
167 void TG4ModularPhysicsList::SetProcessActivation()
168 {
169 // (In)Activates built processes according
170 // to the setup in TG4G3PhysicsManager::fControlVector.
171 // ---
172
173   TG4G3ControlVector* controlVector 
174     = TG4G3PhysicsManager::Instance()->GetControlVector();
175
176   G4bool specialControls 
177     = TG4GeometryServices::Instance()->IsSpecialControls();  
178
179   if (!specialControls) 
180     if (VerboseLevel() > 0) {
181       G4cout << G4endl
182              << "### No special controls in user limits are set." << G4endl;
183     }        
184
185   if (!controlVector) {
186     G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
187     text = text + "    Vector of processes controls is not set.";
188     TG4Globals::Warning(text);
189     return;
190   }    
191   
192   theParticleIterator->reset();
193   while ((*theParticleIterator)())
194   {
195     G4ProcessManager* processManager 
196       = theParticleIterator->value()->GetProcessManager(); 
197       
198     G4ProcessVector* processVector = processManager->GetProcessList();
199   
200     // set processes controls
201     for (G4int i=0; i<processVector->length(); i++) {
202
203       TG4G3ControlValue control
204          = controlVector->GetControlValue((*processVector)[i]);
205       G4bool activation = processManager->GetProcessActivation(i);
206
207       if (control != kUnset) {
208         if (!TG4Globals::Compare(activation, control)) {
209
210           // set new process activation
211           G4bool activate;
212           if (control == kInActivate) activate = false; 
213           else                        activate = true;
214           
215           SetProcessActivation(processManager, i, activate);         
216         }
217       } 
218       else  {
219         // control == kUnset
220         if ((*processVector)[i]->GetProcessName().find("specialControl")
221             != G4String::npos) { 
222
223           SetProcessActivation(processManager, i, specialControls);         
224         }  
225       } 
226     }
227   }  
228 }
229
230 //_____________________________________________________________________________
231 void TG4ModularPhysicsList::PrintAllProcesses() const
232 {
233 // Prints all processes.
234 // ---
235
236   G4cout << "TG4ModularPhysicsList processes: " << G4endl;
237   G4cout << "================================ " << G4endl;
238  
239   G4ProcessTable* processTable = G4ProcessTable::GetProcessTable();
240   G4ProcessTable::G4ProcNameVector* processNameList 
241     = processTable->GetNameList();
242
243   for (G4int i=0; i <processNameList->size(); i++){
244     G4cout << "   " << (*processNameList)[i] << G4endl;
245   }  
246 }
247
248 //_____________________________________________________________________________
249 void TG4ModularPhysicsList::DumpAllProcesses() const
250 {
251 // Dumps all particles and their processes.
252 // ---
253
254   G4cout << "TG4ModularPhysicsList particles and processes: " << G4endl;
255   G4cout << "============================================== " << G4endl;
256  
257   theParticleIterator->reset();
258   while ((*theParticleIterator)())
259   {
260     // print particle name
261     G4cout << "Particle: " 
262            << theParticleIterator->value()->GetParticleName()
263            << G4endl;
264
265     // dump particle processes
266     G4ProcessVector* processVector 
267       = theParticleIterator->value()->GetProcessManager()->GetProcessList();
268     for (G4int i=0; i<processVector->length(); i++)
269       (*processVector)[i]->DumpInfo();
270       
271     G4cout << G4endl;  
272   }  
273 }