Geant4  10.03
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: G4ProcessPlacer.cc 97276 2016-05-31 14:21:35Z gcosmo $
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;
60 
61  G4cout << " The initial PostStep Vectors: " << G4endl;
64 
65  GetProcessManager()->RemoveProcess(process);
66 
67  G4cout << " The final AlongStep Vectors: " << G4endl;
70 
71  G4cout << " The final PostStep Vectors: " << G4endl;
74 
75  G4cout << "================================================" << G4endl;
76 
77 }
78 
80 {
81  G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
82 
83  G4cout << " The initial AlongStep Vectors: " << G4endl;
86 
87  G4cout << "The initial PostStep Vectors: " << G4endl;
90 
91  if (sol == eLast)
92  {
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);
117  idxAlongStep);
119  idxPostStep);
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;
135 
136  G4cout << "The final PostStep Vectors: " << G4endl;
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 
158 {
159  // get particle iterator to add processes ---------------------
160  G4ParticleTable* theParticleTable = 0;
162  theParticleTable = G4ParticleTable::GetParticleTable();
163  theParticleIterator = theParticleTable->GetIterator();
164  // -------------------------------------------------------
165  G4ProcessManager *processmanager = 0;
166  // find process manager ---------------------------
167  theParticleIterator->reset();
168  while( (*theParticleIterator)() ) /* while checked for unending loop, 30.05.2016, Marc Verderi */
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 
187 {
188  G4cout << "GPIL Vector: " << G4endl;
189  G4ProcessVector* processGPILVec =
191  PrintProcVec(processGPILVec);
192 }
193 
195 {
196  G4cout << "DoIt Vector: " << G4endl;
197  G4ProcessVector* processDoItVec =
199  PrintProcVec(processDoItVec);
200 }
201 
202 
204 {
205  G4cout << "GPIL Vector: " << G4endl;
206  G4ProcessVector* processGPILVec =
208  PrintProcVec(processGPILVec);
209 }
210 
212 {
213  G4cout << "DoIt Vector: " << G4endl;
214  G4ProcessVector* processDoItVec =
216  PrintProcVec(processDoItVec);
217 }
218 
219 
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 }
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
virtual void AddProcessAsSecondDoIt(G4VProcess *process)
void PrintAlongStepGPILVec()
const G4String & GetParticleName() const
void AddProcessAs(G4VProcess *process, SecondOrLast)
virtual void AddProcessAsLastDoIt(G4VProcess *process)
virtual void RemoveProcess(G4VProcess *process)
G4GLOB_DLL std::ostream G4cout
void reset(G4bool ifSkipIon=true)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
#define theParticleIterator
G4int length() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
virtual ~G4ProcessPlacer()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4ProcessPlacer(const G4String &particlename)
static G4ParticleTable * GetParticleTable()
G4ProcessManager * GetProcessManager() const
G4String fParticleName
G4ProcessManager * GetProcessManager()
void PrintAlongStepDoItVec()
#define G4endl
Definition: G4ios.hh:61
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4PTblDicIterator * GetIterator() const
G4ProcessVector * GetProcessList() const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
void PrintProcVec(G4ProcessVector *processVec)