00001 // 00002 // ******************************************************************** 00003 // * License and Disclaimer * 00004 // * * 00005 // * The Geant4 software is copyright of the Copyright Holders of * 00006 // * the Geant4 Collaboration. It is provided under the terms and * 00007 // * conditions of the Geant4 Software License, included in the file * 00008 // * LICENSE and available at http://cern.ch/geant4/license . These * 00009 // * include a list of copyright holders. * 00010 // * * 00011 // * Neither the authors of this software system, nor their employing * 00012 // * institutes,nor the agencies providing financial support for this * 00013 // * work make any representation or warranty, express or implied, * 00014 // * regarding this software system or assume any liability for its * 00015 // * use. Please see the license in the file LICENSE and URL above * 00016 // * for the full disclaimer and the limitation of liability. * 00017 // * * 00018 // * This code implementation is the result of the scientific and * 00019 // * technical work of the GEANT4 collaboration. * 00020 // * By using, copying, modifying or distributing the software (or * 00021 // * any work based on the software) you agree to acknowledge its * 00022 // * use in resulting scientific publications, and indicate your * 00023 // * acceptance of all terms of the Geant4 Software license. * 00024 // ******************************************************************** 00025 // 00026 // 00027 // $Id$ 00028 // 00029 // 00030 // ------------------------------------------------------------ 00031 // GEANT 4 class header file 00032 // 00033 // History: first implementation, based on object model of 00034 // 2nd December 1995, G.Cosmo 00035 // ---------------- G4ProcessManager ----------------- 00036 // Class Description 00037 // It collects all physics a particle can undertake as seven vectors. 00038 // These vectors are 00039 // one vector for all processes (called as "process List") 00040 // two vectors for processes with AtRestGetPhysicalInteractionLength 00041 // and AtRestDoIt 00042 // two vectors for processes with AlongStepGetPhysicalInteractionLength 00043 // and AlongStepDoIt 00044 // two vectors for processes with PostStepGetPhysicalInteractionLength 00045 // and PostStepDoIt 00046 // The tracking will message three types of GetPhysicalInteractionLength 00047 // in order to limit the Step and select the occurence of processes. 00048 // It will message the corresponding DoIt() to apply the selected 00049 // processes. In addition, the Tracking will limit the Step 00050 // and select the occurence of the processes according to 00051 // the shortest physical interaction length computed (except for 00052 // processes at rest, for which the Tracking will select the 00053 // occurence of the process which returns the shortest mean 00054 // life-time from the GetPhysicalInteractionLength()). 00055 // 00056 // History: 00057 // revised by G.Cosmo, 06 May 1996 00058 // Added vector of processes at rest, 06 May 1996 00059 // ------------------------------------------------------------ 00060 // New Physics scheme 8 Jan. 1997 H.Kurahige 00061 // Add SetProcessOrdering methods 27 Mar 1998 H.Kurahige 00062 // Add copy constructor (deep copy) 28 June 1998 H.Kurashige 00063 // Add GetProcessActivation 3 May. 1999 H.Kurashige 00064 // Use STL vector instead of RW vector 1. Mar 00 H.Kurashige 00065 // Modify G4ProcessVectorOrdering to fix FindInsedrtPosition 15 Feb. 2005 00066 // Add 00067 // ------------------------------------------------------------ 00068 00069 #ifndef G4ProcessManager_h 00070 #define G4ProcessManager_h 1 00071 00072 #include "globals.hh" 00073 #include "G4ios.hh" 00074 #include <vector> 00075 00076 #include "G4VProcess.hh" 00077 #include "G4ProcessVector.hh" 00078 #include "G4ParticleDefinition.hh" 00079 00080 class G4ProcessManagerMessenger; 00081 class G4ProcessAttribute; 00082 00083 // Indexes for ProcessVector 00084 enum G4ProcessVectorTypeIndex 00085 { 00086 typeGPIL = 0, // for GetPhysicalInteractionLength 00087 typeDoIt =1 // for DoIt 00088 }; 00089 enum G4ProcessVectorDoItIndex 00090 { 00091 idxAll = -1, // for all DoIt/GPIL 00092 idxAtRest = 0, // for AtRestDoIt/GPIL 00093 idxAlongStep = 1, // for AlongStepDoIt/GPIL 00094 idxPostStep =2, // for AlongSTepDoIt/GPIL 00095 NDoit =3 00096 }; 00097 00098 // enumeration for Ordering Parameter 00099 enum G4ProcessVectorOrdering 00100 { 00101 ordInActive = -1, // ordering parameter to indicate InActive DoIt 00102 ordDefault = 1000, // default ordering parameter 00103 ordLast = 9999 // ordering parameter to indicate the last DoIt 00104 }; 00105 00106 class G4ProcessManager 00107 { 00108 00109 public: 00110 // copy constructor 00111 G4ProcessManager(G4ProcessManager &right); 00112 00113 private: 00114 // hide default constructor and assignment operator 00115 G4ProcessManager & operator=(const G4ProcessManager &right); 00116 G4ProcessManager(); 00117 00118 public: 00119 00120 G4ProcessManager(const G4ParticleDefinition* aParticleType); 00121 // Constructor 00122 00123 ~G4ProcessManager(); 00124 // Destructor 00125 00126 G4int operator==(const G4ProcessManager &right) const; 00127 G4int operator!=(const G4ProcessManager &right) const; 00128 00129 public: // with description 00130 G4ProcessVector* GetProcessList() const; 00131 // Returns the address of the vector of all processes 00132 00133 G4int GetProcessListLength() const; 00134 // Returns the number of process in the ProcessVector 00135 00136 G4int GetProcessIndex(G4VProcess *) const; 00137 // Returns the index of the process in the process List 00138 00139 // -------------------------------------- 00140 00141 G4ProcessVector* GetProcessVector( 00142 G4ProcessVectorDoItIndex idx, 00143 G4ProcessVectorTypeIndex typ = typeGPIL 00144 ) const; 00145 // Returns the address of the vector of processes 00146 00147 G4ProcessVector* GetAtRestProcessVector( 00148 G4ProcessVectorTypeIndex typ = typeGPIL 00149 ) const; 00150 // Returns the address of the vector of processes for 00151 // AtRestGetPhysicalInteractionLength idx =0 00152 // AtRestGetPhysicalDoIt idx =1 00153 G4ProcessVector* GetAlongStepProcessVector( 00154 G4ProcessVectorTypeIndex typ = typeGPIL 00155 ) const; 00156 // Returns the address of the vector of processes for 00157 // AlongStepGetPhysicalInteractionLength idx =0 00158 // AlongStepGetPhysicalDoIt idx =1 00159 00160 G4ProcessVector* GetPostStepProcessVector( 00161 G4ProcessVectorTypeIndex typ = typeGPIL 00162 ) const; 00163 // Returns the address of the vector of processes for 00164 // PostStepGetPhysicalInteractionLength idx =0 00165 // PostStepGetPhysicalDoIt idx =1 00166 00167 G4int GetProcessVectorIndex( 00168 G4VProcess* aProcess, 00169 G4ProcessVectorDoItIndex idx, 00170 G4ProcessVectorTypeIndex typ = typeGPIL 00171 ) const; 00172 G4int GetAtRestIndex( 00173 G4VProcess* aProcess, 00174 G4ProcessVectorTypeIndex typ = typeGPIL 00175 ) const; 00176 G4int GetAlongStepIndex( 00177 G4VProcess* aProcess, 00178 G4ProcessVectorTypeIndex typ = typeGPIL 00179 ) const; 00180 G4int GetPostStepIndex( 00181 G4VProcess* aProcess, 00182 G4ProcessVectorTypeIndex typ = typeGPIL 00183 ) const; 00184 // Returns the index for GPIL/DoIt process vector of the process 00185 00186 G4int AddProcess( 00187 G4VProcess *aProcess, 00188 G4int ordAtRestDoIt = ordInActive, 00189 G4int ordAlongSteptDoIt = ordInActive, 00190 G4int ordPostStepDoIt = ordInActive 00191 ); 00192 // Add a process to the process List 00193 // return values are index to the List. Negative return value 00194 // indicates that the process has not be added due to some errors 00195 // The first argument is a pointer to process. 00196 // Following arguments are ordering parameters of the process in 00197 // process vectors. If value is negative, the process is 00198 // not added to the corresponding process vector. 00199 00200 // following methods are provided for simple processes 00201 // AtRestProcess has only AtRestDoIt 00202 // ContinuousProcess has only AlongStepDoIt 00203 // DiscreteProcess has only PostStepDoIt 00204 // If the ording parameter is not specified, the process is 00205 // added at the end of List of process vectors 00206 // If a process with same ordering parameter exists, 00207 // this new process will be added just after processes 00208 // with same ordering parameter 00209 // (except for processes assigned to LAST explicitly ) 00210 // for both DoIt and GetPhysicalInteractionLength 00211 // 00212 00213 G4int AddRestProcess(G4VProcess *aProcess, G4int ord = ordDefault); 00214 G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord = ordDefault); 00215 G4int AddContinuousProcess(G4VProcess *aProcess, G4int ord = ordDefault); 00216 00217 00219 // Methods for setting ordering parameters 00220 // Altanative methods for setting ordering parameters 00221 // Note: AddProcess method should precede these methods 00222 00223 G4int GetProcessOrdering( 00224 G4VProcess *aProcess, 00225 G4ProcessVectorDoItIndex idDoIt 00226 ); 00227 00228 void SetProcessOrdering( 00229 G4VProcess *aProcess, 00230 G4ProcessVectorDoItIndex idDoIt, 00231 G4int ordDoIt = ordDefault 00232 ); 00233 // Set ordering parameter for DoIt specified by typeDoIt. 00234 // If a process with same ordering parameter exists, 00235 // this new process will be added just after processes 00236 // with same ordering parameter 00237 // Note: Ordering parameter will bet set to non-zero 00238 // even if you set ordDoIt = 0 00239 00240 void SetProcessOrderingToFirst( 00241 G4VProcess *aProcess, 00242 G4ProcessVectorDoItIndex idDoIt 00243 ); 00244 // Set ordering parameter to the first of all processes 00245 // for DoIt specified by idDoIt. 00246 // Note: If you use this method for two processes, 00247 // a process called later will be first. 00248 00249 void SetProcessOrderingToSecond( 00250 G4VProcess *aProcess, 00251 G4ProcessVectorDoItIndex idDoIt 00252 ); 00253 // Set ordering parameter to 1 for DoIt specified by idDoIt 00254 // and the rpocess will be added just after 00255 // the processes with ordering parameter equal to zero 00256 // Note: If you use this method for two processes, 00257 // a process called later will be . 00258 00259 void SetProcessOrderingToLast( 00260 G4VProcess *aProcess, 00261 G4ProcessVectorDoItIndex idDoIt 00262 ); 00263 // Set ordering parameter to the last of all processes 00264 // for DoIt specified by idDoIt. 00265 // Note: If you use this method for two processes, 00266 // a process called later will precede. 00267 00268 G4VProcess* RemoveProcess(G4VProcess *aProcess); 00269 G4VProcess* RemoveProcess(G4int index); 00270 // Removes a process from the process List. 00271 // return value is pointer to the removed process. 00272 // (0 value will be returned in case of errors) 00273 00274 G4VProcess* SetProcessActivation(G4VProcess *aProcess, G4bool fActive); 00275 G4VProcess* SetProcessActivation(G4int index, G4bool fActive); 00276 // Set activation flag. 00277 // return value is pointer to the applied process. 00278 // (0 value will be returned in case of errors) 00279 00280 G4bool GetProcessActivation(G4VProcess *aProcess) const; 00281 G4bool GetProcessActivation(G4int index) const; 00282 // Get activation flag. 00283 00284 G4ParticleDefinition* GetParticleType() const; 00285 // get the particle type 00286 void SetParticleType(const G4ParticleDefinition*); 00287 // set the particle type 00288 00289 void StartTracking(G4Track* aTrack=0); 00290 void EndTracking(); 00291 // these two methods are used by G4TrackingManager 00292 // in order to inform Start/End of tracking for each track 00293 // to the process manager and all physics processes 00294 00295 00296 public: 00297 enum {SizeOfProcVectorArray = 6}; 00298 private: 00299 G4ProcessVector* theProcVector[SizeOfProcVectorArray]; 00300 // vector for processes with GetPhysicalInteractionLength/DoIt 00301 00302 typedef std::vector<G4ProcessAttribute*> G4ProcessAttrVector; 00303 G4ProcessAttrVector* theAttrVector; 00304 // vector for process attribute 00305 00306 protected: // with description 00307 G4int InsertAt(G4int position, G4VProcess* process, G4int ivec); 00308 // insert process at position in theProcVector[ivec] 00309 00310 G4int RemoveAt(G4int position, G4VProcess* process, G4int ivec); 00311 // remove process at position in theProcVector[ivec] 00312 00313 G4int FindInsertPosition(G4int ord, G4int ivec); 00314 // find insert position according to ordering parameter 00315 // in theProcVector[ivec] 00316 00317 G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx, 00318 G4ProcessVectorTypeIndex typ = typeGPIL) const; 00319 00320 void CheckOrderingParameters(G4VProcess*) const; 00321 // check consistencies between ordering parameters and 00322 // validity of DoIt of the Process 00323 00324 private: 00325 G4ProcessAttribute* GetAttribute(G4int index) const; 00326 G4ProcessAttribute* GetAttribute(G4VProcess *aProcess) const; 00327 // get Pointer to ProcessAttribute 00328 00329 G4VProcess* ActivateProcess(G4int index); 00330 G4VProcess* InActivateProcess(G4int index); 00331 // Activate/InActivateProcess Process 00332 00333 private: 00334 const G4ParticleDefinition* theParticleType; 00335 // particle which has this process manager object 00336 00337 G4int numberOfProcesses; 00338 G4ProcessVector* theProcessList; 00339 // vector for all processes (called as "process List") 00340 00341 private: 00342 G4bool duringTracking; 00343 void CreateGPILvectors(); 00344 void SetIndexToProcessVector(G4int ivec); 00345 00346 G4bool isSetOrderingFirstInvoked[NDoit]; 00347 G4bool isSetOrderingLastInvoked[NDoit]; 00348 00349 public: // with description 00350 void DumpInfo(); 00351 00352 void SetVerboseLevel(G4int value); 00353 G4int GetVerboseLevel() const; 00354 // controle flag for output message 00355 // 0: Silent 00356 // 1: Warning message 00357 // 2: More 00358 00359 protected: 00360 G4int verboseLevel; 00361 00362 private: 00363 static G4ProcessManagerMessenger* fProcessManagerMessenger; 00364 static G4int counterOfObjects; 00365 }; 00366 #include "G4ProcessManager.icc" 00367 00368 #endif 00369