| 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: G4ProcessManager.hh,v 1.16 2007/10/02 08:23:20 kurasige Exp $
|
|---|
| 28 | // GEANT4 tag $Name: $
|
|---|
| 29 | //
|
|---|
| 30 | //
|
|---|
| 31 | // ------------------------------------------------------------
|
|---|
| 32 | // GEANT 4 class header file
|
|---|
| 33 | //
|
|---|
| 34 | // History: first implementation, based on object model of
|
|---|
| 35 | // 2nd December 1995, G.Cosmo
|
|---|
| 36 | // ---------------- G4ProcessManager -----------------
|
|---|
| 37 | // Class Description
|
|---|
| 38 | // It collects all physics a particle can undertake as seven vectors.
|
|---|
| 39 | // These vectors are
|
|---|
| 40 | // one vector for all processes (called as "process List")
|
|---|
| 41 | // two vectors for processes with AtRestGetPhysicalInteractionLength
|
|---|
| 42 | // and AtRestDoIt
|
|---|
| 43 | // two vectors for processes with AlongStepGetPhysicalInteractionLength
|
|---|
| 44 | // and AlongStepDoIt
|
|---|
| 45 | // two vectors for processes with PostStepGetPhysicalInteractionLength
|
|---|
| 46 | // and PostStepDoIt
|
|---|
| 47 | // The tracking will message three types of GetPhysicalInteractionLength
|
|---|
| 48 | // in order to limit the Step and select the occurence of processes.
|
|---|
| 49 | // It will message the corresponding DoIt() to apply the selected
|
|---|
| 50 | // processes. In addition, the Tracking will limit the Step
|
|---|
| 51 | // and select the occurence of the processes according to
|
|---|
| 52 | // the shortest physical interaction length computed (except for
|
|---|
| 53 | // processes at rest, for which the Tracking will select the
|
|---|
| 54 | // occurence of the process which returns the shortest mean
|
|---|
| 55 | // life-time from the GetPhysicalInteractionLength()).
|
|---|
| 56 | //
|
|---|
| 57 | // History:
|
|---|
| 58 | // revised by G.Cosmo, 06 May 1996
|
|---|
| 59 | // Added vector of processes at rest, 06 May 1996
|
|---|
| 60 | // ------------------------------------------------------------
|
|---|
| 61 | // New Physics scheme 8 Jan. 1997 H.Kurahige
|
|---|
| 62 | // Add SetProcessOrdering methods 27 Mar 1998 H.Kurahige
|
|---|
| 63 | // Add copy constructor (deep copy) 28 June 1998 H.Kurashige
|
|---|
| 64 | // Add GetProcessActivation 3 May. 1999 H.Kurashige
|
|---|
| 65 | // Use STL vector instead of RW vector 1. Mar 00 H.Kurashige
|
|---|
| 66 | // Modify G4ProcessVectorOrdering to fix FindInsedrtPosition 15 Feb. 2005
|
|---|
| 67 | // Add
|
|---|
| 68 | // ------------------------------------------------------------
|
|---|
| 69 |
|
|---|
| 70 | #ifndef G4ProcessManager_h
|
|---|
| 71 | #define G4ProcessManager_h 1
|
|---|
| 72 |
|
|---|
| 73 | #include "globals.hh"
|
|---|
| 74 | #include "G4ios.hh"
|
|---|
| 75 | #include <vector>
|
|---|
| 76 |
|
|---|
| 77 | #include "G4VProcess.hh"
|
|---|
| 78 | #include "G4ProcessVector.hh"
|
|---|
| 79 | #include "G4ParticleDefinition.hh"
|
|---|
| 80 |
|
|---|
| 81 | class G4ProcessManagerMessenger;
|
|---|
| 82 | class G4ProcessAttribute;
|
|---|
| 83 |
|
|---|
| 84 | // Indexes for ProcessVector
|
|---|
| 85 | enum G4ProcessVectorTypeIndex
|
|---|
| 86 | {
|
|---|
| 87 | typeGPIL = 0, // for GetPhysicalInteractionLength
|
|---|
| 88 | typeDoIt =1 // for DoIt
|
|---|
| 89 | };
|
|---|
| 90 | enum G4ProcessVectorDoItIndex
|
|---|
| 91 | {
|
|---|
| 92 | idxAll = -1, // for all DoIt/GPIL
|
|---|
| 93 | idxAtRest = 0, // for AtRestDoIt/GPIL
|
|---|
| 94 | idxAlongStep = 1, // for AlongStepDoIt/GPIL
|
|---|
| 95 | idxPostStep =2 // for AlongSTepDoIt/GPIL
|
|---|
| 96 | };
|
|---|
| 97 |
|
|---|
| 98 | // enumeration for Ordering Parameter
|
|---|
| 99 | enum G4ProcessVectorOrdering
|
|---|
| 100 | {
|
|---|
| 101 | ordInActive = -1, // ordering parameter to indicate InActive DoIt
|
|---|
| 102 | ordDefault = 1000, // default ordering parameter
|
|---|
| 103 | ordLast = 99999 // ordering parameter to indicate the last DoIt
|
|---|
| 104 | };
|
|---|
| 105 |
|
|---|
| 106 | class G4ProcessManager
|
|---|
| 107 | {
|
|---|
| 108 |
|
|---|
| 109 | public:
|
|---|
| 110 | // copy constructor
|
|---|
| 111 | G4ProcessManager(G4ProcessManager &right);
|
|---|
| 112 |
|
|---|
| 113 | private:
|
|---|
| 114 | // hide default constructor and assignment operator
|
|---|
| 115 | G4ProcessManager & operator=(G4ProcessManager &right);
|
|---|
| 116 | G4ProcessManager();
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 | public:
|
|---|
| 120 |
|
|---|
| 121 | G4ProcessManager(const G4ParticleDefinition* aParticleType);
|
|---|
| 122 | // Constructor
|
|---|
| 123 |
|
|---|
| 124 | ~G4ProcessManager();
|
|---|
| 125 | // Destructor
|
|---|
| 126 |
|
|---|
| 127 | G4int operator==(const G4ProcessManager &right) const;
|
|---|
| 128 | G4int operator!=(const G4ProcessManager &right) const;
|
|---|
| 129 |
|
|---|
| 130 | public: // with description
|
|---|
| 131 | G4ProcessVector* GetProcessList() const;
|
|---|
| 132 | // Returns the address of the vector of all processes
|
|---|
| 133 |
|
|---|
| 134 | G4int GetProcessListLength() const;
|
|---|
| 135 | // Returns the number of process in the ProcessVector
|
|---|
| 136 |
|
|---|
| 137 | G4int GetProcessIndex(G4VProcess *) const;
|
|---|
| 138 | // Returns the index of the process in the process List
|
|---|
| 139 |
|
|---|
| 140 | // --------------------------------------
|
|---|
| 141 |
|
|---|
| 142 | G4ProcessVector* GetProcessVector(
|
|---|
| 143 | G4ProcessVectorDoItIndex idx,
|
|---|
| 144 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 145 | ) const;
|
|---|
| 146 | // Returns the address of the vector of processes
|
|---|
| 147 |
|
|---|
| 148 | G4ProcessVector* GetAtRestProcessVector(
|
|---|
| 149 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 150 | ) const;
|
|---|
| 151 | // Returns the address of the vector of processes for
|
|---|
| 152 | // AtRestGetPhysicalInteractionLength idx =0
|
|---|
| 153 | // AtRestGetPhysicalDoIt idx =1
|
|---|
| 154 | G4ProcessVector* GetAlongStepProcessVector(
|
|---|
| 155 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 156 | ) const;
|
|---|
| 157 | // Returns the address of the vector of processes for
|
|---|
| 158 | // AlongStepGetPhysicalInteractionLength idx =0
|
|---|
| 159 | // AlongStepGetPhysicalDoIt idx =1
|
|---|
| 160 |
|
|---|
| 161 | G4ProcessVector* GetPostStepProcessVector(
|
|---|
| 162 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 163 | ) const;
|
|---|
| 164 | // Returns the address of the vector of processes for
|
|---|
| 165 | // PostStepGetPhysicalInteractionLength idx =0
|
|---|
| 166 | // PostStepGetPhysicalDoIt idx =1
|
|---|
| 167 |
|
|---|
| 168 | G4int GetProcessVectorIndex(
|
|---|
| 169 | G4VProcess* aProcess,
|
|---|
| 170 | G4ProcessVectorDoItIndex idx,
|
|---|
| 171 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 172 | ) const;
|
|---|
| 173 | G4int GetAtRestIndex(
|
|---|
| 174 | G4VProcess* aProcess,
|
|---|
| 175 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 176 | ) const;
|
|---|
| 177 | G4int GetAlongStepIndex(
|
|---|
| 178 | G4VProcess* aProcess,
|
|---|
| 179 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 180 | ) const;
|
|---|
| 181 | G4int GetPostStepIndex(
|
|---|
| 182 | G4VProcess* aProcess,
|
|---|
| 183 | G4ProcessVectorTypeIndex typ = typeGPIL
|
|---|
| 184 | ) const;
|
|---|
| 185 | // Returns the index for GPIL/DoIt process vector of the process
|
|---|
| 186 |
|
|---|
| 187 | G4int AddProcess(
|
|---|
| 188 | G4VProcess *aProcess,
|
|---|
| 189 | G4int ordAtRestDoIt = ordInActive,
|
|---|
| 190 | G4int ordAlongSteptDoIt = ordInActive,
|
|---|
| 191 | G4int ordPostStepDoIt = ordInActive
|
|---|
| 192 | );
|
|---|
| 193 | // Add a process to the process List
|
|---|
| 194 | // return values are index to the List. Negative return value
|
|---|
| 195 | // indicates that the process has not be added due to some errors
|
|---|
| 196 | // The first argument is a pointer to process.
|
|---|
| 197 | // Following arguments are ordering parameters of the process in
|
|---|
| 198 | // process vectors. If value is negative, the process is
|
|---|
| 199 | // not added to the corresponding process vector.
|
|---|
| 200 |
|
|---|
| 201 | // following methods are provided for simple processes
|
|---|
| 202 | // AtRestProcess has only AtRestDoIt
|
|---|
| 203 | // ContinuousProcess has only AlongStepDoIt
|
|---|
| 204 | // DiscreteProcess has only PostStepDoIt
|
|---|
| 205 | // If the ording parameter is not specified, the process is
|
|---|
| 206 | // added at the end of List of process vectors
|
|---|
| 207 | // If a process with same ordering parameter exists,
|
|---|
| 208 | // this new process will be added just after processes
|
|---|
| 209 | // with same ordering parameter
|
|---|
| 210 | // (except for processes assigned to LAST explicitly )
|
|---|
| 211 | // for both DoIt and GetPhysicalInteractionLength
|
|---|
| 212 | //
|
|---|
| 213 |
|
|---|
| 214 | G4int AddRestProcess(G4VProcess *aProcess, G4int ord = ordDefault);
|
|---|
| 215 | G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord = ordDefault);
|
|---|
| 216 | G4int AddContinuousProcess(G4VProcess *aProcess, G4int ord = ordDefault);
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 | ///////////////////////////////////////////////
|
|---|
| 220 | // Methods for setting ordering parameters
|
|---|
| 221 | // Altanative methods for setting ordering parameters
|
|---|
| 222 | // Note: AddProcess method should precede these methods
|
|---|
| 223 |
|
|---|
| 224 | G4int GetProcessOrdering(
|
|---|
| 225 | G4VProcess *aProcess,
|
|---|
| 226 | G4ProcessVectorDoItIndex idDoIt
|
|---|
| 227 | );
|
|---|
| 228 |
|
|---|
| 229 | void SetProcessOrdering(
|
|---|
| 230 | G4VProcess *aProcess,
|
|---|
| 231 | G4ProcessVectorDoItIndex idDoIt,
|
|---|
| 232 | G4int ordDoIt = ordDefault
|
|---|
| 233 | );
|
|---|
| 234 | // Set ordering parameter for DoIt specified by typeDoIt.
|
|---|
| 235 | // If a process with same ordering parameter exists,
|
|---|
| 236 | // this new process will be added just after processes
|
|---|
| 237 | // with same ordering parameter
|
|---|
| 238 | // Note: Ordering parameter will bet set to non-zero
|
|---|
| 239 | // even if you set ordDoIt = 0
|
|---|
| 240 |
|
|---|
| 241 | void SetProcessOrderingToFirst(
|
|---|
| 242 | G4VProcess *aProcess,
|
|---|
| 243 | G4ProcessVectorDoItIndex idDoIt
|
|---|
| 244 | );
|
|---|
| 245 | // Set ordering parameter to the first 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 be first.
|
|---|
| 249 |
|
|---|
| 250 | void SetProcessOrderingToSecond(
|
|---|
| 251 | G4VProcess *aProcess,
|
|---|
| 252 | G4ProcessVectorDoItIndex idDoIt
|
|---|
| 253 | );
|
|---|
| 254 | // Set ordering parameter to 1 for DoIt specified by idDoIt
|
|---|
| 255 | // and the rpocess will be added just after
|
|---|
| 256 | // the processes with ordering parameter equal to zero
|
|---|
| 257 | // Note: If you use this method for two processes,
|
|---|
| 258 | // a process called later will be .
|
|---|
| 259 |
|
|---|
| 260 | void SetProcessOrderingToLast(
|
|---|
| 261 | G4VProcess *aProcess,
|
|---|
| 262 | G4ProcessVectorDoItIndex idDoIt
|
|---|
| 263 | );
|
|---|
| 264 | // Set ordering parameter to the last of all processes
|
|---|
| 265 | // for DoIt specified by idDoIt.
|
|---|
| 266 | // Note: If you use this method for two processes,
|
|---|
| 267 | // a process called later will precede.
|
|---|
| 268 |
|
|---|
| 269 | G4VProcess* RemoveProcess(G4VProcess *aProcess);
|
|---|
| 270 | G4VProcess* RemoveProcess(G4int index);
|
|---|
| 271 | // Removes a process from the process List.
|
|---|
| 272 | // return value is pointer to the removed process.
|
|---|
| 273 | // (0 value will be returned in case of errors)
|
|---|
| 274 |
|
|---|
| 275 | G4VProcess* SetProcessActivation(G4VProcess *aProcess, G4bool fActive);
|
|---|
| 276 | G4VProcess* SetProcessActivation(G4int index, G4bool fActive);
|
|---|
| 277 | // Set activation flag.
|
|---|
| 278 | // return value is pointer to the applied process.
|
|---|
| 279 | // (0 value will be returned in case of errors)
|
|---|
| 280 |
|
|---|
| 281 | G4bool GetProcessActivation(G4VProcess *aProcess) const;
|
|---|
| 282 | G4bool GetProcessActivation(G4int index) const;
|
|---|
| 283 | // Get activation flag.
|
|---|
| 284 |
|
|---|
| 285 | G4ParticleDefinition* GetParticleType() const;
|
|---|
| 286 | // get the particle type
|
|---|
| 287 | void SetParticleType(const G4ParticleDefinition*);
|
|---|
| 288 | // set the particle type
|
|---|
| 289 |
|
|---|
| 290 | void StartTracking(G4Track* aTrack=0);
|
|---|
| 291 | void EndTracking();
|
|---|
| 292 | // these two methods are used by G4TrackingManager
|
|---|
| 293 | // in order to inform Start/End of tracking for each track
|
|---|
| 294 | // to the process manager and all physics processes
|
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 | public:
|
|---|
| 298 | enum {SizeOfProcVectorArray = 6};
|
|---|
| 299 | private:
|
|---|
| 300 | G4ProcessVector* theProcVector[SizeOfProcVectorArray];
|
|---|
| 301 | // vector for processes with GetPhysicalInteractionLength/DoIt
|
|---|
| 302 |
|
|---|
| 303 | typedef std::vector<G4ProcessAttribute*> G4ProcessAttrVector;
|
|---|
| 304 | G4ProcessAttrVector* theAttrVector;
|
|---|
| 305 | // vector for process attribute
|
|---|
| 306 |
|
|---|
| 307 | protected: // with description
|
|---|
| 308 | G4int InsertAt(G4int position, G4VProcess* process, G4int ivec);
|
|---|
| 309 | // insert process at position in theProcVector[ivec]
|
|---|
| 310 |
|
|---|
| 311 | G4int RemoveAt(G4int position, G4VProcess* process, G4int ivec);
|
|---|
| 312 | // remove process at position in theProcVector[ivec]
|
|---|
| 313 |
|
|---|
| 314 | G4int FindInsertPosition(G4int ord, G4int ivec);
|
|---|
| 315 | // find insert position according to ordering parameter
|
|---|
| 316 | // in theProcVector[ivec]
|
|---|
| 317 |
|
|---|
| 318 | G4int GetProcessVectorId(G4ProcessVectorDoItIndex idx,
|
|---|
| 319 | G4ProcessVectorTypeIndex typ = typeGPIL) const;
|
|---|
| 320 |
|
|---|
| 321 | void CheckOrderingParameters(G4VProcess*) const;
|
|---|
| 322 | // check consistencies between ordering parameters and
|
|---|
| 323 | // validity of DoIt of the Process
|
|---|
| 324 |
|
|---|
| 325 | private:
|
|---|
| 326 | G4ProcessAttribute* GetAttribute(G4int index) const;
|
|---|
| 327 | G4ProcessAttribute* GetAttribute(G4VProcess *aProcess) const;
|
|---|
| 328 | // get Pointer to ProcessAttribute
|
|---|
| 329 |
|
|---|
| 330 | G4VProcess* ActivateProcess(G4int index);
|
|---|
| 331 | G4VProcess* InActivateProcess(G4int index);
|
|---|
| 332 | // Activate/InActivateProcess Process
|
|---|
| 333 |
|
|---|
| 334 | private:
|
|---|
| 335 | const G4ParticleDefinition* theParticleType;
|
|---|
| 336 | // particle which has this process manager object
|
|---|
| 337 |
|
|---|
| 338 | G4int numberOfProcesses;
|
|---|
| 339 | G4ProcessVector* theProcessList;
|
|---|
| 340 | // vector for all processes (called as "process List")
|
|---|
| 341 |
|
|---|
| 342 | private:
|
|---|
| 343 | G4bool duringTracking;
|
|---|
| 344 | void CreateGPILvectors();
|
|---|
| 345 | void SetIndexToProcessVector(G4int ivec);
|
|---|
| 346 |
|
|---|
| 347 | public: // with description
|
|---|
| 348 | void DumpInfo();
|
|---|
| 349 |
|
|---|
| 350 | void SetVerboseLevel(G4int value);
|
|---|
| 351 | G4int GetVerboseLevel() const;
|
|---|
| 352 | // controle flag for output message
|
|---|
| 353 | // 0: Silent
|
|---|
| 354 | // 1: Warning message
|
|---|
| 355 | // 2: More
|
|---|
| 356 |
|
|---|
| 357 | protected:
|
|---|
| 358 | G4int verboseLevel;
|
|---|
| 359 |
|
|---|
| 360 | private:
|
|---|
| 361 | static G4ProcessManagerMessenger* fProcessManagerMessenger;
|
|---|
| 362 | static G4int counterOfObjects;
|
|---|
| 363 | };
|
|---|
| 364 | #include "G4ProcessManager.icc"
|
|---|
| 365 |
|
|---|
| 366 | #endif
|
|---|
| 367 |
|
|---|