Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
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// $Id$
28//
29// ----------------------------------------------------------------------
30// GEANT 4 class source file
31//
32// G4ProcessPlacer.cc
33//
34// ----------------------------------------------------------------------
35
36#include "G4ProcessPlacer.hh"
37#include "G4ProcessManager.hh"
38#include "G4VProcess.hh"
39#include "G4ParticleTable.hh"
40
42 : fParticleName(particlename)
43{
44}
45
47{
48}
49
51{
52 G4cout << "=== G4ProcessPlacer::RemoveProcess: for: " << fParticleName
53 << G4endl;
54 G4cout << " ProcessName: " << process->GetProcessName()
55 << ", will be removed!" << G4endl;
56
57 G4cout << " The initial AlongStep Vectors: " << G4endl;
58 PrintAlongStepGPILVec();
59 PrintAlongStepDoItVec();
60
61 G4cout << " The initial PostStep Vectors: " << G4endl;
62 PrintPostStepGPILVec();
63 PrintPostStepDoItVec();
64
65 GetProcessManager()->RemoveProcess(process);
66
67 G4cout << " The final AlongStep Vectors: " << G4endl;
68 PrintAlongStepGPILVec();
69 PrintAlongStepDoItVec();
70
71 G4cout << " The final PostStep Vectors: " << G4endl;
72 PrintPostStepGPILVec();
73 PrintPostStepDoItVec();
74
75 G4cout << "================================================" << G4endl;
76
77}
78
79void G4ProcessPlacer::AddProcessAs(G4VProcess *process, SecondOrLast sol)
80{
81 G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
82
83 G4cout << " The initial AlongStep Vectors: " << G4endl;
84 PrintAlongStepGPILVec();
85 PrintAlongStepDoItVec();
86
87 G4cout << "The initial PostStep Vectors: " << G4endl;
88 PrintPostStepGPILVec();
89 PrintPostStepDoItVec();
90
91 if (sol == eLast)
92 {
93 GetProcessManager()->AddProcess(process, ordInActive, ordInActive, ordLast);
94 }
95 else if (sol == eSecond)
96 {
97 // get transportation process
98 G4VProcess *transportation =
99 (* (GetProcessManager()->GetProcessList()))[0];
100
101 if (!transportation)
102 {
103 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0001",RunMustBeAborted," could not get process id=0");
104 }
105 if (transportation->GetProcessName() != "Transportation" && transportation->GetProcessName() != "Transportation8" && transportation->GetProcessName() != "CoupledTransportation")
106 {
107 // G4cout << " GOT HERE CoupledTransportation" << G4endl;
108 G4cout << transportation->GetProcessName() << G4endl;
109 G4Exception("G4ProcessPlacer::AddProcessAs","Bias0002",RunMustBeAborted," process id=0 is not Transportation");
110 }
111
112 // place the given proces as first for the moment
113 // 31/5/11 previously set to first, then transportation set ahead of it,
114 // which is more conveniently correctly set with placing it second!
115 GetProcessManager()->AddProcess(process);
116 GetProcessManager()->SetProcessOrderingToSecond(process,
118 GetProcessManager()->SetProcessOrderingToSecond(process,
120 // xx test
121 // if(process->GetProcessName() == "ImportanceProcess")
122 //bug31/10/07 GetProcessManager()->SetProcessOrdering(process,
123 //bug31/10/07 idxAlongStep, 1);
124 // place transportation first again
125// GetProcessManager()->SetProcessOrderingToFirst(transportation,
126// idxAlongStep);
127// GetProcessManager()->SetProcessOrderingToFirst(transportation,
128// idxPostStep);
129 }
130
131 // for verification inly
132 G4cout << " The final AlongStep Vectors: " << G4endl;
133 PrintAlongStepGPILVec();
134 PrintAlongStepDoItVec();
135
136 G4cout << "The final PostStep Vectors: " << G4endl;
137 PrintPostStepGPILVec();
138 PrintPostStepDoItVec();
139
140 G4cout << "================================================" << G4endl;
141}
142
144{
145 G4cout << "=== G4ProcessPlacer::AddProcessAsSecondDoIt: for: "
146 << fParticleName << G4endl;
147 AddProcessAs(process, eSecond);
148}
149
151{
152 G4cout << "=== G4ProcessPlacer::AddProcessAsLastDoIt: for: "
153 << fParticleName << G4endl;
154 AddProcessAs(process, eLast);
155}
156
157G4ProcessManager *G4ProcessPlacer::GetProcessManager()
158{
159 // get particle iterator to add processes ---------------------
160 G4ParticleTable* theParticleTable = 0;
161 G4ParticleTable::G4PTblDicIterator* theParticleIterator = 0;
162 theParticleTable = G4ParticleTable::GetParticleTable();
163 theParticleIterator = theParticleTable->GetIterator();
164 // -------------------------------------------------------
165 G4ProcessManager *processmanager = 0;
166 // find process manager ---------------------------
167 theParticleIterator->reset();
168 while( (*theParticleIterator)() )
169 {
170 G4ParticleDefinition* particle = theParticleIterator->value();
171 if (particle->GetParticleName() == fParticleName)
172 {
173 processmanager = particle->GetProcessManager();
174 break;
175 }
176 }
177 // ---------------------------------------------------------
178 if (!processmanager)
179 {
180 G4Exception("G4ProcessPlacer::GetProcessManager()", "InvalidSetup",
181 FatalException, "NULL pointer to Process Manager ! Sampler.Configure() must be after PhysicsList instantiation");
182 }
183 return processmanager;
184}
185
186void G4ProcessPlacer::PrintAlongStepGPILVec()
187{
188 G4cout << "GPIL Vector: " << G4endl;
189 G4ProcessVector* processGPILVec =
190 GetProcessManager()->GetAlongStepProcessVector(typeGPIL);
191 PrintProcVec(processGPILVec);
192}
193
194void G4ProcessPlacer::PrintAlongStepDoItVec()
195{
196 G4cout << "DoIt Vector: " << G4endl;
197 G4ProcessVector* processDoItVec =
198 GetProcessManager()->GetAlongStepProcessVector(typeDoIt);
199 PrintProcVec(processDoItVec);
200}
201
202
203void G4ProcessPlacer::PrintPostStepGPILVec()
204{
205 G4cout << "GPIL Vector: " << G4endl;
206 G4ProcessVector* processGPILVec =
207 GetProcessManager()->GetPostStepProcessVector(typeGPIL);
208 PrintProcVec(processGPILVec);
209}
210
211void G4ProcessPlacer::PrintPostStepDoItVec()
212{
213 G4cout << "DoIt Vector: " << G4endl;
214 G4ProcessVector* processDoItVec =
215 GetProcessManager()->GetPostStepProcessVector(typeDoIt);
216 PrintProcVec(processDoItVec);
217}
218
219
220void G4ProcessPlacer::PrintProcVec(G4ProcessVector* processVec)
221{
222 if (!processVec)
223 {
224 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument",
225 FatalException, "NULL pointer to process-vector !");
226 }
227 size_t len = processVec->length();
228 if (len==0)
229 {
230 G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup",
231 FatalException, "Length of process-vector is zero !");
232 }
233 for (size_t i=0; i<len; i++)
234 {
235 G4VProcess *p = (*processVec)[i];
236 if (p)
237 {
238 G4cout << " " << p->GetProcessName() << G4endl;
239 }
240 else
241 {
242 G4cout << " " << "no process found for position: " << i
243 << ", in vector of length: " << len << G4endl;
244 }
245 }
246}
@ FatalException
@ RunMustBeAborted
@ typeGPIL
@ typeDoIt
@ ordInActive
@ ordLast
@ idxPostStep
@ idxAlongStep
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
G4PTblDicIterator * GetIterator()
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)
G4int length() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:379
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41