ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ProcessPlacer.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ProcessPlacer.cc
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;
59 
60  G4cout << " The initial PostStep Vectors: " << G4endl;
63 
64  GetProcessManager()->RemoveProcess(process);
65 
66  G4cout << " The final AlongStep Vectors: " << G4endl;
69 
70  G4cout << " The final PostStep Vectors: " << G4endl;
73 
74  G4cout << "================================================" << G4endl;
75 
76 }
77 
79 {
80  G4cout << " Modifying Process Order for ProcessName: " << process->GetProcessName() << G4endl;
81 
82  G4cout << " The initial AlongStep Vectors: " << G4endl;
85 
86  G4cout << "The initial PostStep Vectors: " << G4endl;
89 
90  if (sol == eLast)
91  {
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);
116  idxAlongStep);
118  idxPostStep);
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;
134 
135  G4cout << "The final PostStep Vectors: " << G4endl;
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 
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 
186 {
187  G4cout << "GPIL Vector: " << G4endl;
188  G4ProcessVector* processGPILVec =
190  PrintProcVec(processGPILVec);
191 }
192 
194 {
195  G4cout << "DoIt Vector: " << G4endl;
196  G4ProcessVector* processDoItVec =
198  PrintProcVec(processDoItVec);
199 }
200 
201 
203 {
204  G4cout << "GPIL Vector: " << G4endl;
205  G4ProcessVector* processGPILVec =
207  PrintProcVec(processGPILVec);
208 }
209 
211 {
212  G4cout << "DoIt Vector: " << G4endl;
213  G4ProcessVector* processDoItVec =
215  PrintProcVec(processDoItVec);
216 }
217 
218 
220 {
221  if (!processVec)
222  {
223  G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidArgument",
224  FatalException, "NULL pointer to process-vector !");
225  }
226  size_t len = processVec->length();
227  if (len==0)
228  {
229  G4Exception("G4ProcessPlacer::G4ProcessPlacer()", "InvalidSetup",
230  FatalException, "Length of process-vector is zero !");
231  }
232  for (size_t 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 }