]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4ModularPhysicsList.cxx
Latest version
[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"
f04eb3a5 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>
f04eb3a5 25
696e37fa 26const G4double TG4ModularPhysicsList::fgkDefaultCutValue = 1.0 * mm;
f04eb3a5 27
72095f7c 28//_____________________________________________________________________________
f04eb3a5 29TG4ModularPhysicsList::TG4ModularPhysicsList()
5b6ecd36 30 : G4VModularPhysicsList(),
31 TG4Verbose("physicsList") {
8496e315 32//
e5967ab3 33 defaultCutValue = fgkDefaultCutValue;
f04eb3a5 34
5b6ecd36 35 SetVerboseLevel(VerboseLevel());
f04eb3a5 36}
37
72095f7c 38//_____________________________________________________________________________
8496e315 39TG4ModularPhysicsList::TG4ModularPhysicsList(const TG4ModularPhysicsList& right)
5b6ecd36 40 : TG4Verbose("physicsList") {
8496e315 41//
42 TG4Globals::Exception("TG4ModularPhysicsList is protected from copying.");
43}
44
72095f7c 45//_____________________________________________________________________________
f04eb3a5 46TG4ModularPhysicsList::~TG4ModularPhysicsList() {
47//
8496e315 48 //delete fExtDecayer;
49 // fExtDecayer is deleted in G4Decay destructor
50}
51
52// operators
53
72095f7c 54//_____________________________________________________________________________
8496e315 55TG4ModularPhysicsList&
56TG4ModularPhysicsList::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;
f04eb3a5 64}
65
e5967ab3 66// private methods
67
68//_____________________________________________________________________________
69void 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
5b6ecd36 79 if (VerboseLevel() > 1) {
e5967ab3 80 G4cout << "Set process " << strActivation << " for "
81 << (*processManager->GetProcessList())[processId]->GetProcessName()
82 << G4endl;
83 }
84
85 processManager->SetProcessActivation(processId, activation);
86}
87
f04eb3a5 88// protected methods
89
72095f7c 90//_____________________________________________________________________________
f04eb3a5 91void 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
f04eb3a5 99 // lock physics manager
100 TG4G3PhysicsManager* g3PhysicsManager = TG4G3PhysicsManager::Instance();
101 g3PhysicsManager->Lock();
f04eb3a5 102
103 // create particles for registered physics
104 G4VModularPhysicsList::ConstructParticle();
105}
106
72095f7c 107//_____________________________________________________________________________
f04eb3a5 108void TG4ModularPhysicsList::ConstructProcess()
109{
110// Constructs all processes.
111// ---
112
f04eb3a5 113 // create processes for registered physics
114 G4VModularPhysicsList::ConstructProcess();
115
f04eb3a5 116 // verbose
696e37fa 117 if (verboseLevel>1) DumpAllProcesses();
f04eb3a5 118}
119
f04eb3a5 120
121// public methods
122
72095f7c 123//_____________________________________________________________________________
f04eb3a5 124void 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;
8496e315 138 //G4double ecut = 10.*m;
139 G4double ecut = cut;
f04eb3a5 140
141#ifdef G4VERBOSE
5b6ecd36 142 if (VerboseLevel() > 1) {
696e37fa 143 G4cout << "TG4ModularPhysicsList::SetCutsWithDefault:";
f04eb3a5 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
72095f7c 166//_____________________________________________________________________________
f04eb3a5 167void TG4ModularPhysicsList::SetProcessActivation()
168{
169// (In)Activates built processes according
170// to the setup in TG4G3PhysicsManager::fControlVector.
171// ---
172
e5967ab3 173 TG4G3ControlVector* controlVector
174 = TG4G3PhysicsManager::Instance()->GetControlVector();
175
176 G4bool specialControls
177 = TG4GeometryServices::Instance()->IsSpecialControls();
178
179 if (!specialControls)
5b6ecd36 180 if (VerboseLevel() > 0) {
181 G4cout << G4endl
182 << "### No special controls in user limits are set." << G4endl;
183 }
e5967ab3 184
185 if (!controlVector) {
f04eb3a5 186 G4String text = "TG4ModularPhysicsList::SetProcessActivation: \n";
187 text = text + " Vector of processes controls is not set.";
188 TG4Globals::Warning(text);
e5967ab3 189 return;
f04eb3a5 190 }
e5967ab3 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 }
f04eb3a5 228}
229
72095f7c 230//_____________________________________________________________________________
f04eb3a5 231void TG4ModularPhysicsList::PrintAllProcesses() const
232{
233// Prints all processes.
234// ---
235
236 G4cout << "TG4ModularPhysicsList processes: " << G4endl;
696e37fa 237 G4cout << "================================ " << G4endl;
f04eb3a5 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
696e37fa 248//_____________________________________________________________________________
249void 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}