Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ProcessPlacer.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28// ----------------------------------------------------------------------
29// GEANT 4 class source file
30//
31// G4ProcessPlacer.cc
32//
33// ----------------------------------------------------------------------
34
35#include "G4ProcessPlacer.hh"
36#include "G4ProcessManager.hh"
37#include "G4VProcess.hh"
38#include "G4ParticleTable.hh"
39
41 : fParticleName(particlename)
42{
43}
44
46{
47}
48
50{
51 G4cout << "=== G4ProcessPlacer::RemoveProcess: for: " << fParticleName
52 << G4endl;
53 G4cout << " ProcessName: " << process->GetProcessName()
54 << ", will be removed!" << G4endl;
55
56 G4cout << " The initial AlongStep Vectors: " << G4endl;
57 PrintAlongStepGPILVec();
58 PrintAlongStepDoItVec();
59
60 G4cout << " The initial PostStep Vectors: " << G4endl;
61 PrintPostStepGPILVec();
62 PrintPostStepDoItVec();
63
64 GetProcessManager()->RemoveProcess(process);
65
66 G4cout << " The final AlongStep Vectors: " << G4endl;
67 PrintAlongStepGPILVec();
68 PrintAlongStepDoItVec();
69
70 G4cout << " The final PostStep Vectors: " << G4endl;
71 PrintPostStepGPILVec();
72 PrintPostStepDoItVec();
73
74 G4cout << "================================================" << G4endl;
75
76}
77
78void G4ProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol)
79{
80 G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
81
82 G4cout << " The initial AlongStep Vectors: " << G4endl;
83 PrintAlongStepGPILVec();
84 PrintAlongStepDoItVec();
85
86 G4cout << "The initial PostStep Vectors: " << G4endl;
87 PrintPostStepGPILVec();
88 PrintPostStepDoItVec();
89
90 if (sol == eLast)
91 {
92 GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast);
93 }
94 else if (sol == eSecond)
95 {
96 // get transportation process
97 G4VProcess *transportation =
98 (* (GetProcessManager()->GetProcessList()))[0];
99
100 if (!transportation)
101 {
102 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0001",RunMustBeAborted," could not get process id=0");
103 }
104 if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "Transportation8" && transportation->GetProcessName() != "CoupledTransportation")
105 {
106 // G4cout << " GOT HERE CoupledTransportation" << G4endl;
107 G4cout << transportation->GetProcessName() << G4endl;
108 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0002",RunMustBeAborted," process id=0 is not Transportation");
109 }
110
111 // place the given proces as first for the moment
112 // 31/5/11 previously set to first, then transportation set ahead of it,
113 // which is more conveniently correctly set with placing it second!
114 GetProcessManager()->AddProcess(process);
115 GetProcessManager()->SetProcessOrderingToSecond(process,
117 GetProcessManager()->SetProcessOrderingToSecond(process,
119 // xx test
120 // if(process->GetProcessName() == "ImportanceProcess")
121 //bug31/10/07 GetProcessManager()->SetProcessOrdering(process,
122 //bug31/10/07 idxAlongStep, 1);
123 // place transportation first again
124// GetProcessManager()->SetProcessOrderingToFirst(transportation,
125// idxAlongStep);
126// GetProcessManager()->SetProcessOrderingToFirst(transportation,
127// idxPostStep);
128 }
129
130 // for verification inly
131 G4cout << " The final AlongStep Vectors: " << G4endl;
132 PrintAlongStepGPILVec();
133 PrintAlongStepDoItVec();
134
135 G4cout << "The final PostStep Vectors: " << G4endl;
136 PrintPostStepGPILVec();
137 PrintPostStepDoItVec();
138
139 G4cout << "================================================" << G4endl;
140}
141
143{
144 G4cout << "=== G4ProcessPlacer::AddProcessAsSecondDoIt: for: "
145 << fParticleName << G4endl;
146 AddProcessAs(process, eSecond);
147}
148
150{
151 G4cout << "=== G4ProcessPlacer::AddProcessAsLastDoIt: for: "
152 << fParticleName << G4endl;
153 AddProcessAs(process, eLast);
154}
155
156G4ProcessManager *G4ProcessPlacer::GetProcessManager()
157{
158 // get particle iterator to add processes ---------------------
159 G4ParticleTable* theParticleTable = 0;
161 theParticleTable = G4ParticleTable::GetParticleTable();
162 theParticleIterator = theParticleTable->GetIterator();
163 // -------------------------------------------------------
164 G4ProcessManager *processmanager = 0;
165 // find process manager ---------------------------
166 theParticleIterator->reset();
167 while( (*theParticleIterator)() ) /* while checked for unending loop, 30.05.2016, Marc Verderi */
168 {
169 G4ParticleDefinition* particle = theParticleIterator->value();
170 if (particle->GetParticleName() == fParticleName)
171 {
172 processmanager = particle->GetProcessManager();
173 break;
174 }
175 }
176 // ---------------------------------------------------------
177 if (!processmanager)
178 {
179 G4Exception("G4ProcessPlacer::GetProcessManager()", "InvalidSetup",
180 FatalException, "NULL pointer to Process Manager ! Sampler.Configure() must be after PhysicsList instantiation");
181 }
182 return processmanager;
183}
184
185void G4ProcessPlacer::PrintAlongStepGPILVec()
186{
187 G4cout << "GPIL Vector: " << G4endl;
188 G4ProcessVector* processGPILVec =
189 GetProcessManager()->GetAlongStepProcessVector(typeGPIL);
190 PrintProcVec(processGPILVec);
191}
192
193void G4ProcessPlacer::PrintAlongStepDoItVec()
194{
195 G4cout << "DoIt Vector: " << G4endl;
196 G4ProcessVector* processDoItVec =
197 GetProcessManager()->GetAlongStepProcessVector(typeDoIt);
198 PrintProcVec(processDoItVec);
199}
200
201
202void G4ProcessPlacer::PrintPostStepGPILVec()
203{
204 G4cout << "GPIL Vector: " << G4endl;
205 G4ProcessVector* processGPILVec =
206 GetProcessManager()->GetPostStepProcessVector(typeGPIL);
207 PrintProcVec(processGPILVec);
208}
209
210void G4ProcessPlacer::PrintPostStepDoItVec()
211{
212 G4cout << "DoIt Vector: " << G4endl;
213 G4ProcessVector* processDoItVec =
214 GetProcessManager()->GetPostStepProcessVector(typeDoIt);
215 PrintProcVec(processDoItVec);
216}
217
218
219void G4ProcessPlacer::PrintProcVec(G4ProcessVector* processVec)
220{
221 if (!processVec)
222 {
223 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument",
224 FatalException, "NULL pointer to process-vector !");
225 }
226 G4int len = (G4int)processVec->length();
227 if (len==0)
228 {
229 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup",
230 FatalException, "Length of process-vector is zero !");
231 }
232 for (G4int i=0; i<len; ++i)
233 {
234 G4VProcess *p = (*processVec)[i];
235 if (p)
236 {
237 G4cout << " " << p->GetProcessName() << G4endl;
238 }
239 else
240 {
241 G4cout << " " << "no process found for position: " << i
242 << ", in vector of length: " << len << G4endl;
243 }
244 }
245}
@ FatalException
@ RunMustBeAborted
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:59
@ typeGPIL
@ typeDoIt
@ ordInActive
@ ordLast
@ idxPostStep
@ idxAlongStep
int G4int
Definition: G4Types.hh:85
#define theParticleIterator
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator() const
static G4ParticleTable * GetParticleTable()
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4ProcessVector * GetProcessList() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
virtual ~G4ProcessPlacer()
virtual void AddProcessAsSecondDoIt(G4VProcess *process)
virtual void AddProcessAsLastDoIt(G4VProcess *process)
G4ProcessPlacer(const G4String &particlename)
virtual void RemoveProcess(G4VProcess *process)
std::size_t length() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:386