Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ProcessManager.hh
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// G4ProcessManager
27//
28// Class Description:
29//
30// G4ProcessManager collects all physics a particle can undertake as
31// vectors. These vectors are:
32// - one vector for all processes (called as "process List")
33// - two vectors for processes with AtRestGetPhysicalInteractionLength()
34// and AtRestDoIt()
35// - two vectors for processes with AlongStepGetPhysicalInteractionLength()
36// and AlongStepDoIt()
37// - two vectors for processes with PostStepGetPhysicalInteractionLength()
38// and PostStepDoIt()
39// The tracking will message three types of GetPhysicalInteractionLength()
40// in order to limit the Step and select the occurrence of processes.
41// It will message the corresponding DoIt() to apply the selected
42// processes. In addition, the Tracking will limit the Step
43// and select the occurrence of the processes according to
44// the shortest physical interaction length computed (except for
45// processes at rest, for which the Tracking will select the
46// occurrence of the process which returns the shortest mean
47// life-time from the GetPhysicalInteractionLength()).
48
49// Authors:
50// - 02.12.1995, G.Cosmo - First implementation, based on object model
51// - 06.05.1996, G.Cosmo - Revised; added vector of processes at rest
52// - 08.01.1997, H.Kurashige - New Physics scheme
53// --------------------------------------------------------------------
54#ifndef G4ProcessManager_hh
55#define G4ProcessManager_hh 1
56
57#include <vector>
58
59#include "globals.hh"
60#include "G4ios.hh"
61
62#include "G4VProcess.hh"
63#include "G4ProcessVector.hh"
65
68
69// Indexes for ProcessVector
70//
72{
73 typeGPIL = 0, // for GetPhysicalInteractionLength
74 typeDoIt =1 // for DoIt
75};
77{
78 idxAll = -1, // for all DoIt/GPIL
79 idxAtRest = 0, // for AtRestDoIt/GPIL
80 idxAlongStep = 1, // for AlongStepDoIt/GPIL
81 idxPostStep =2, // for AlongSTepDoIt/GPIL
82 NDoit =3
83};
84
85// Enumeration for Ordering Parameter
86//
88{
89 ordInActive = -1, // ordering parameter to indicate InActive DoIt
90 ordDefault = 1000, // default ordering parameter
91 ordLast = 9999 // ordering parameter to indicate the last DoIt
92};
93
95{
96 using G4ProcessAttrVector = std::vector<G4ProcessAttribute*>;
97
98 public:
99
100 G4ProcessManager(const G4ParticleDefinition* aParticleType);
101 // Constructor
102
104 // copy constructor
105
108 // Default constructor and assignment operator not allowed
109
111 // Destructor
112
113 G4bool operator==(const G4ProcessManager &right) const;
114 G4bool operator!=(const G4ProcessManager &right) const;
115
117 // Returns the address of the vector of all processes
118
120 // Returns the number of process in the ProcessVector
121
123 // Returns the index of the process in the process List
124
128 ) const;
129 // Returns the address of the vector of processes
130
133 ) const;
134 // Returns the address of the vector of processes for
135 // AtRestGetPhysicalInteractionLength idx =0
136 // AtRestGetPhysicalDoIt idx =1
137
140 ) const;
141 // Returns the address of the vector of processes for
142 // AlongStepGetPhysicalInteractionLength idx =0
143 // AlongStepGetPhysicalDoIt idx =1
144
147 ) const;
148 // Returns the address of the vector of processes for
149 // PostStepGetPhysicalInteractionLength idx =0
150 // PostStepGetPhysicalDoIt idx =1
151
153 G4VProcess* aProcess,
156 ) const;
158 G4VProcess* aProcess,
160 ) const;
162 G4VProcess* aProcess,
164 ) const;
166 G4VProcess* aProcess,
168 ) const;
169 // Returns the index for GPIL/DoIt process vector of the process
170
171 G4int AddProcess( G4VProcess* aProcess,
172 G4int ordAtRestDoIt = ordInActive,
173 G4int ordAlongSteptDoIt = ordInActive,
174 G4int ordPostStepDoIt = ordInActive );
175 // Adds a process to the process List
176 // Return values is the index to the List. Negative return value
177 // indicates that the process has not been added due to some errors
178 // The first argument is a pointer to the process.
179 // Successive arguments are ordering parameters of the process in
180 // process vectors. If value is negative, the process is
181 // not added to the corresponding process vector
182
183 ///////////////////////////////////////////////
184 // The following methods are provided for simple processes
185 // AtRestProcess has only AtRestDoIt
186 // ContinuousProcess has only AlongStepDoIt
187 // DiscreteProcess has only PostStepDoIt
188 // If the ordering parameter is not specified, the process is
189 // added at the end of List of process vectors
190 // If a process with same ordering parameter exists,
191 // this new process will be added just after processes
192 // with same ordering parameter (except for processes assigned to LAST
193 // explicitly) for both DoIt() and GetPhysicalInteractionLength()
194 ///////////////////////////////////////////////
195
199
200 ///////////////////////////////////////////////
201 // Alternative methods for setting ordering parameters
202 // Note: AddProcess() method should precede calls to these methods
203 ///////////////////////////////////////////////
204
206 G4VProcess* aProcess,
208 );
209
211 G4VProcess* aProcess,
213 G4int ordDoIt = ordDefault
214 );
215 // Set ordering parameter for DoIt() specified by typeDoIt.
216 // If a process with same ordering parameter exists,
217 // this new process will be added just after processes
218 // with same ordering parameter
219 // Note: Ordering parameter will bet set to non-zero
220 // even if you set ordDoIt = 0
221
223 G4VProcess* aProcess,
225 );
226 // Set ordering parameter to the first of all processes
227 // for DoIt() specified by idDoIt.
228 // Note: If you use this method for two processes,
229 // a process called later will be first
230
232 G4VProcess* aProcess,
234 );
235 // Set ordering parameter to 1 for DoIt() specified by idDoIt
236 // and the process will be added just after
237 // the processes with ordering parameter equal to zero
238 // Note: If you use this method for two processes,
239 // a process called later will be first
240
242 G4VProcess* aProcess,
244 );
245 // Set ordering parameter to the last of all processes
246 // for DoIt() specified by idDoIt.
247 // Note: If you use this method for two processes,
248 // a process called later will precede.
249
250 ///////////////////////////////////////////////
251
254 // Removes a process from the process List.
255 // Returns pointer to the removed process.
256 // (nullptr value will be returned in case of errors)
257
260 // Set activation flag.
261 // Returns pointer to the applied process.
262 // (nullptr value will be returned in case of errors)
263
264 G4bool GetProcessActivation(G4VProcess* aProcess) const;
265 G4bool GetProcessActivation(G4int index) const;
266 // Get activation flag.
267
269 // Get the particle type
271 // Set the particle type
272
273 G4VProcess* GetProcess (const G4String&) const;
274 // Get process by process name
275
276 void StartTracking(G4Track* aTrack = nullptr);
277 void EndTracking();
278 // These two methods are used by G4TrackingManager
279 // in order to inform Start/End of tracking for each track
280 // to the process manager and all physics processes
281
282 void DumpInfo();
283
284 inline void SetVerboseLevel(G4int value);
285 inline G4int GetVerboseLevel() const;
286 // Control flag for output message
287 // 0: Silent
288 // 1: Warning message
289 // 2: More
290
292
293 private:
294
295 G4int InsertAt(G4int position, G4VProcess* process, G4int ivec);
296 // Insert process at position in theProcVector[ivec]
297
298 G4int RemoveAt(G4int position, G4VProcess* process, G4int ivec);
299 // Remove process at position in theProcVector[ivec]
300
301 G4int FindInsertPosition(G4int ord, G4int ivec);
302 // Find insert position according to ordering parameter
303 // in theProcVector[ivec]
304
305 inline G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx,
307
308 void CheckOrderingParameters(G4VProcess*) const;
309 // Check consistencies between ordering parameters and
310 // validity of DoIt() of the Process
311
312 G4ProcessAttribute* GetAttribute(G4int index) const;
313 G4ProcessAttribute* GetAttribute(G4VProcess* aProcess) const;
314 // Get Pointer to ProcessAttribute
315
316 void CreateGPILvectors();
317 void SetIndexToProcessVector(G4int ivec);
318
319 G4VProcess* ActivateProcess(G4int index);
320 G4VProcess* InActivateProcess(G4int index);
321 // Activate/InActivate process
322
323 private:
324
326 // Vector for processes with GetPhysicalInteractionLength()/DoIt()
327
328 G4ProcessAttrVector* theAttrVector = nullptr;
329 // Vector for process attribute
330
331 const G4ParticleDefinition* theParticleType = nullptr;
332 // Particle which has this process manager object
333
334 G4int numberOfProcesses = 0;
335 G4ProcessVector* theProcessList = nullptr;
336 // Vector for all processes (called as "process List")
337
338 G4bool duringTracking = false;
339
340 G4bool isSetOrderingFirstInvoked[NDoit];
341 G4bool isSetOrderingLastInvoked[NDoit];
342
343 G4int verboseLevel = 1;
344
345 static G4ThreadLocal G4ProcessManagerMessenger* fProcessManagerMessenger;
346 static G4ThreadLocal G4int counterOfObjects;
347};
348
349#include "G4ProcessManager.icc"
350
351#endif
G4ProcessVectorTypeIndex
@ typeGPIL
@ typeDoIt
G4ProcessVectorOrdering
@ ordInActive
@ ordDefault
@ ordLast
G4ProcessVectorDoItIndex
@ idxPostStep
@ idxAtRest
@ NDoit
@ idxAll
@ idxAlongStep
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void SetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt, G4int ordDoIt=ordDefault)
G4VProcess * GetProcess(const G4String &) const
G4ProcessVector * GetProcessVector(G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4int AddRestProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4VProcess * SetProcessActivation(G4VProcess *aProcess, G4bool fActive)
G4ProcessManager()=delete
G4ParticleDefinition * GetParticleType() const
void SetParticleType(const G4ParticleDefinition *)
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4int GetAlongStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVector * GetAlongStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4int AddContinuousProcess(G4VProcess *aProcess, G4int ord=ordDefault)
G4int GetProcessListLength() const
G4int GetAtRestIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
void SetVerboseLevel(G4int value)
G4int GetProcessVectorIndex(G4VProcess *aProcess, G4ProcessVectorDoItIndex idx, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4int GetProcessOrdering(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void SetProcessOrderingToSecond(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4bool GetProcessActivation(G4VProcess *aProcess) const
G4int GetPostStepIndex(G4VProcess *aProcess, G4ProcessVectorTypeIndex typ=typeGPIL) const
G4ProcessVector * GetProcessList() const
G4ProcessManager & operator=(const G4ProcessManager &)=delete
G4int GetProcessIndex(G4VProcess *) const
G4ProcessVector * GetPostStepProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4bool operator==(const G4ProcessManager &right) const
G4VProcess * RemoveProcess(G4VProcess *aProcess)
G4int AddProcess(G4VProcess *aProcess, G4int ordAtRestDoIt=ordInActive, G4int ordAlongSteptDoIt=ordInActive, G4int ordPostStepDoIt=ordInActive)
void SetProcessOrderingToLast(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
G4int GetVerboseLevel() const
G4bool operator!=(const G4ProcessManager &right) const
void SetProcessOrderingToFirst(G4VProcess *aProcess, G4ProcessVectorDoItIndex idDoIt)
void StartTracking(G4Track *aTrack=nullptr)
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
#define G4ThreadLocal
Definition: tls.hh:77