Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:58

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4ProcessManager
0027 //
0028 // Class Description:
0029 //
0030 // G4ProcessManager collects all physics a particle can undertake as
0031 // vectors. These vectors are:
0032 // - one vector for all processes (called as "process List")
0033 // - two vectors for processes with AtRestGetPhysicalInteractionLength()
0034 //                              and AtRestDoIt()
0035 // - two vectors for processes with AlongStepGetPhysicalInteractionLength()
0036 //                              and AlongStepDoIt()
0037 // - two vectors for processes with PostStepGetPhysicalInteractionLength()
0038 //                              and PostStepDoIt()
0039 // The tracking will message three types of GetPhysicalInteractionLength()
0040 // in order to limit the Step and select the occurrence of processes. 
0041 // It will message the corresponding DoIt() to apply the selected 
0042 // processes. In addition, the Tracking will limit the Step
0043 // and select the occurrence of the processes according to
0044 // the shortest physical interaction length computed (except for
0045 // processes at rest, for which the Tracking will select the
0046 // occurrence of the process which returns the shortest mean
0047 // life-time from the GetPhysicalInteractionLength()).
0048 
0049 // Authors:
0050 // - 02.12.1995, G.Cosmo - First implementation, based on object model
0051 // - 06.05.1996, G.Cosmo - Revised; added vector of processes at rest
0052 // - 08.01.1997, H.Kurashige - New Physics scheme
0053 // --------------------------------------------------------------------
0054 #ifndef G4ProcessManager_hh
0055 #define G4ProcessManager_hh 1
0056 
0057 #include <vector>
0058 
0059 #include "globals.hh"
0060 #include "G4ios.hh"
0061 
0062 #include "G4VProcess.hh"
0063 #include "G4ProcessVector.hh"
0064 #include "G4ParticleDefinition.hh"
0065 
0066 class G4ProcessManagerMessenger;
0067 class G4ProcessAttribute;
0068 
0069 // Indexes for ProcessVector
0070 //
0071 enum G4ProcessVectorTypeIndex
0072 { 
0073   typeGPIL = 0,        // for GetPhysicalInteractionLength 
0074   typeDoIt =1          // for DoIt
0075 };
0076 enum G4ProcessVectorDoItIndex
0077 {
0078   idxAll = -1,         // for all DoIt/GPIL 
0079   idxAtRest = 0,       // for AtRestDoIt/GPIL
0080   idxAlongStep = 1,    // for AlongStepDoIt/GPIL
0081   idxPostStep =2,      // for AlongSTepDoIt/GPIL
0082   NDoit =3
0083 };
0084 
0085 // Enumeration for Ordering Parameter
0086 //
0087 enum G4ProcessVectorOrdering
0088 { 
0089   ordInActive = -1,    // ordering parameter to indicate InActive DoIt
0090   ordDefault = 1000,   // default ordering parameter
0091   ordLast    = 9999    // ordering parameter to indicate the last DoIt
0092 };
0093 
0094 class G4ProcessManager 
0095 {
0096   using G4ProcessAttrVector = std::vector<G4ProcessAttribute*>; 
0097 
0098   public: 
0099 
0100     G4ProcessManager(const G4ParticleDefinition* aParticleType);
0101       //  Constructor
0102 
0103     G4ProcessManager(G4ProcessManager& right);
0104       // copy constructor
0105 
0106     G4ProcessManager() = delete;
0107     G4ProcessManager& operator=(const G4ProcessManager&) = delete;
0108       // Default constructor and assignment operator not allowed
0109 
0110     ~G4ProcessManager();
0111       // Destructor
0112 
0113     G4bool operator==(const G4ProcessManager &right) const;
0114     G4bool operator!=(const G4ProcessManager &right) const;
0115 
0116     inline G4ProcessVector* GetProcessList() const;
0117       // Returns the address of the vector of all processes 
0118 
0119     inline G4int GetProcessListLength() const;
0120       // Returns the number of process in the ProcessVector 
0121 
0122     inline G4int GetProcessIndex(G4VProcess*) const;
0123       // Returns the index of the process in the process List
0124 
0125     inline G4ProcessVector* GetProcessVector( 
0126                                G4ProcessVectorDoItIndex idx,
0127                                G4ProcessVectorTypeIndex typ = typeGPIL
0128                               ) const;
0129       // Returns the address of the vector of processes 
0130 
0131     inline G4ProcessVector* GetAtRestProcessVector(
0132                                G4ProcessVectorTypeIndex typ = typeGPIL
0133                               ) const; 
0134       // Returns the address of the vector of processes for
0135       //    AtRestGetPhysicalInteractionLength      idx =0
0136       //    AtRestGetPhysicalDoIt                   idx =1
0137 
0138     inline G4ProcessVector* GetAlongStepProcessVector(
0139                                G4ProcessVectorTypeIndex typ = typeGPIL
0140                               ) const;
0141       // Returns the address of the vector of processes for
0142       //    AlongStepGetPhysicalInteractionLength      idx =0
0143       //    AlongStepGetPhysicalDoIt                   idx =1
0144 
0145     inline G4ProcessVector* GetPostStepProcessVector(
0146                                G4ProcessVectorTypeIndex typ = typeGPIL
0147                               ) const;
0148       // Returns the address of the vector of processes for
0149       //    PostStepGetPhysicalInteractionLength      idx =0
0150       //    PostStepGetPhysicalDoIt                   idx =1
0151 
0152     G4int GetProcessVectorIndex(
0153                            G4VProcess* aProcess,
0154                            G4ProcessVectorDoItIndex idx,
0155                            G4ProcessVectorTypeIndex typ  = typeGPIL
0156                            ) const;
0157     inline G4int GetAtRestIndex(
0158                            G4VProcess* aProcess,
0159                            G4ProcessVectorTypeIndex typ  = typeGPIL
0160                            ) const;
0161     inline G4int GetAlongStepIndex(
0162                            G4VProcess* aProcess,
0163                            G4ProcessVectorTypeIndex typ  = typeGPIL
0164                            ) const;
0165     inline G4int GetPostStepIndex(
0166                            G4VProcess* aProcess,
0167                            G4ProcessVectorTypeIndex typ = typeGPIL
0168                            ) const;
0169       // Returns the index for GPIL/DoIt process vector of the process  
0170 
0171     G4int AddProcess( G4VProcess* aProcess,
0172                       G4int ordAtRestDoIt = ordInActive,
0173                       G4int ordAlongSteptDoIt = ordInActive,
0174                       G4int ordPostStepDoIt = ordInActive );
0175       // Adds a process to the process List
0176       // Return values is the index to the List. Negative return value 
0177       // indicates that the process has not been added due to some errors
0178       // The first argument is a pointer to the process.
0179       // Successive arguments are ordering parameters of the process in 
0180       // process vectors. If value is negative, the process is
0181       // not added to the corresponding process vector
0182    
0183     /////////////////////////////////////////////// 
0184     // The following methods are provided for simple processes  
0185     //   AtRestProcess has only AtRestDoIt
0186     //   ContinuousProcess has only AlongStepDoIt
0187     //   DiscreteProcess has only PostStepDoIt
0188     // If the ordering parameter is not specified, the process is
0189     // added at the end of List of process vectors 
0190     // If a process with same ordering parameter exists, 
0191     // this new process will be added just after processes 
0192     // with same ordering parameter (except for processes assigned to LAST
0193     // explicitly) for both DoIt() and GetPhysicalInteractionLength()
0194     /////////////////////////////////////////////// 
0195 
0196     inline G4int AddRestProcess(G4VProcess* aProcess, G4int ord=ordDefault);
0197     inline G4int AddDiscreteProcess(G4VProcess* aProcess, G4int ord=ordDefault);
0198     inline G4int AddContinuousProcess(G4VProcess* aProcess, G4int ord=ordDefault);
0199 
0200     /////////////////////////////////////////////// 
0201     // Alternative methods for setting ordering parameters
0202     // Note: AddProcess() method should precede calls to these methods
0203     /////////////////////////////////////////////// 
0204 
0205     G4int GetProcessOrdering(
0206                             G4VProcess* aProcess,
0207                             G4ProcessVectorDoItIndex idDoIt
0208                             );
0209 
0210     void SetProcessOrdering(
0211                             G4VProcess* aProcess,
0212                             G4ProcessVectorDoItIndex idDoIt,
0213                             G4int ordDoIt = ordDefault
0214                            );
0215       // Set ordering parameter for DoIt() specified by typeDoIt.
0216       // If a process with same ordering parameter exists, 
0217       // this new process will be added just after processes 
0218       // with same ordering parameter  
0219       // Note: Ordering parameter will bet set to non-zero 
0220       //       even if you set ordDoIt = 0
0221             
0222     void SetProcessOrderingToFirst(
0223                             G4VProcess* aProcess,
0224                             G4ProcessVectorDoItIndex idDoIt
0225                            );
0226       // Set ordering parameter to the first of all processes 
0227       // for DoIt() specified by idDoIt.
0228       // Note: If you use this method for two processes,
0229       //       a process called later will be first
0230 
0231     void SetProcessOrderingToSecond(
0232                             G4VProcess* aProcess,
0233                             G4ProcessVectorDoItIndex idDoIt
0234                            );
0235       // Set ordering parameter to 1 for DoIt() specified by idDoIt
0236       // and the process will be added just after 
0237       // the processes with ordering parameter equal to zero
0238       // Note: If you use this method for two processes,
0239       //       a process called later will be first
0240 
0241     void SetProcessOrderingToLast(
0242                             G4VProcess* aProcess,
0243                             G4ProcessVectorDoItIndex idDoIt
0244                            );
0245       // Set ordering parameter to the last of all processes 
0246       // for DoIt() specified by idDoIt.
0247       // Note: If you use this method for two processes,
0248       //       a process called later will precede.
0249 
0250     /////////////////////////////////////////////// 
0251 
0252     G4VProcess* RemoveProcess(G4VProcess* aProcess);
0253     G4VProcess* RemoveProcess(G4int index);
0254       // Removes a process from the process List.
0255       // Returns pointer to the removed process.
0256       // (nullptr value will be returned in case of errors)
0257 
0258     G4VProcess* SetProcessActivation(G4VProcess* aProcess, G4bool fActive);
0259     G4VProcess* SetProcessActivation(G4int index, G4bool fActive);
0260       // Set activation flag. 
0261       // Returns pointer to the applied process.
0262       // (nullptr value will be returned in case of errors)
0263 
0264     G4bool GetProcessActivation(G4VProcess* aProcess) const;
0265     G4bool GetProcessActivation(G4int index) const;
0266       // Get activation flag. 
0267 
0268     inline G4ParticleDefinition* GetParticleType() const;
0269       // Get the particle type 
0270     inline void SetParticleType(const G4ParticleDefinition*);
0271       // Set the particle type
0272 
0273     G4VProcess* GetProcess (const G4String&) const;
0274       // Get process by process name
0275 
0276     void StartTracking(G4Track* aTrack = nullptr);
0277     void EndTracking();
0278       // These two methods are used by G4TrackingManager 
0279       // in order to inform Start/End of tracking for each track
0280       // to the process manager and all physics processes
0281 
0282     void DumpInfo();
0283 
0284     inline void SetVerboseLevel(G4int value);
0285     inline G4int GetVerboseLevel() const;
0286       // Control flag for output message
0287       //  0: Silent
0288       //  1: Warning message
0289       //  2: More
0290 
0291     enum {SizeOfProcVectorArray = 6};
0292 
0293   private:
0294 
0295     G4int InsertAt(G4int position, G4VProcess* process, G4int ivec);
0296       // Insert process at position in theProcVector[ivec]
0297 
0298     G4int RemoveAt(G4int position, G4VProcess* process, G4int ivec);
0299       // Remove process at position in theProcVector[ivec]
0300 
0301     G4int FindInsertPosition(G4int ord, G4int ivec);
0302       // Find insert position according to ordering parameter 
0303       // in theProcVector[ivec]
0304 
0305     inline G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx,
0306                              G4ProcessVectorTypeIndex typ = typeGPIL) const;
0307 
0308     void CheckOrderingParameters(G4VProcess*) const;
0309       // Check consistencies between ordering parameters and 
0310       // validity of DoIt() of the Process 
0311 
0312     G4ProcessAttribute* GetAttribute(G4int index) const;
0313     G4ProcessAttribute* GetAttribute(G4VProcess* aProcess) const;
0314       // Get Pointer to ProcessAttribute
0315 
0316     void  CreateGPILvectors();
0317     void  SetIndexToProcessVector(G4int ivec);
0318 
0319     G4VProcess* ActivateProcess(G4int index);
0320     G4VProcess* InActivateProcess(G4int index);
0321       // Activate/InActivate process
0322       
0323   private:
0324 
0325     G4ProcessVector* theProcVector[SizeOfProcVectorArray];
0326       // Vector for processes with GetPhysicalInteractionLength()/DoIt()
0327 
0328     G4ProcessAttrVector* theAttrVector = nullptr;
0329       // Vector for process attribute  
0330 
0331     const G4ParticleDefinition* theParticleType = nullptr;
0332       // Particle which has this process manager object     
0333 
0334     G4int numberOfProcesses = 0;
0335     G4ProcessVector* theProcessList = nullptr;
0336       // Vector for all processes (called as "process List")
0337 
0338     G4bool duringTracking = false;
0339 
0340     G4bool isSetOrderingFirstInvoked[NDoit];
0341     G4bool isSetOrderingLastInvoked[NDoit];
0342 
0343     G4int verboseLevel = 1;
0344   
0345     static G4ThreadLocal G4ProcessManagerMessenger* fProcessManagerMessenger;
0346     static G4ThreadLocal G4int counterOfObjects;
0347 };
0348 
0349 #include "G4ProcessManager.icc"
0350 
0351 #endif