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 // $Id: G4VITProcess.hh 64057 2012-10-30 15:04:49Z gcosmo $ 00027 // 00028 // Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr) 00029 // 00030 // WARNING : This class is released as a prototype. 00031 // It might strongly evolve or even disapear in the next releases. 00032 // 00033 // History: 00034 // ----------- 00035 // 10 Oct 2011 M.Karamitros created 00036 // 00037 // ------------------------------------------------------------------- 00038 00039 #ifndef G4VITProcess_H 00040 #define G4VITProcess_H 00041 00042 #include <G4VProcess.hh> 00043 #include "AddClone_def.hh" 00044 #include "G4ReferenceCast.hh" 00045 00046 class G4IT ; 00047 class G4TrackingInformation ; 00048 00049 struct G4ProcessState_Lock{ 00050 inline virtual ~G4ProcessState_Lock(){;} 00051 }; 00052 00053 #define InitProcessState(destination,source) \ 00054 destination(reference_cast(destination,source)) 00055 00063 class G4VITProcess : public G4VProcess 00064 { 00065 public: 00066 //__________________________________ 00067 // Constructors & destructors 00068 G4VITProcess(const G4String& name, G4ProcessType type = fNotDefined); 00069 00070 virtual ~G4VITProcess(); 00071 G4VITProcess(const G4VITProcess& other); 00072 G4VITProcess& operator=(const G4VITProcess& other); 00073 00074 // equal opperators 00075 G4int operator==(const G4VITProcess &right) const; 00076 G4int operator!=(const G4VITProcess &right) const; 00077 00078 G4IT_TO_BE_CLONED(G4VITProcess) 00079 00080 size_t GetProcessID() const 00081 { 00082 return fProcessID; 00083 } 00084 00085 G4ProcessState_Lock* GetProcessState() 00086 { 00087 return fpState; 00088 } 00089 00090 void SetProcessState(G4ProcessState_Lock* aProcInfo) 00091 { 00092 fpState = (G4ProcessState*) aProcInfo; 00093 } 00094 00095 //__________________________________ 00096 // Initialize and Save process info 00097 00098 virtual void StartTracking(G4Track*); 00099 00100 virtual void BuildPhysicsTable(const G4ParticleDefinition&){} 00101 00102 inline G4double GetInteractionTimeLeft(); 00103 00107 virtual void ResetNumberOfInteractionLengthLeft(); 00108 00109 inline G4bool ProposesTimeStep() const; 00110 00111 inline static const size_t& GetMaxProcessIndex(); 00112 00113 protected: // with description 00114 00115 void RetrieveProcessInfo(); 00116 void CreateInfo(); 00117 00118 //__________________________________ 00119 // Process info 00120 // friend class G4TrackingInformation ; 00121 00122 struct G4ProcessState : public G4ProcessState_Lock 00123 { 00124 public: 00125 G4ProcessState(); 00126 virtual ~G4ProcessState(); 00127 00128 G4double theNumberOfInteractionLengthLeft; 00129 // The flight length left for the current tracking particle 00130 // in unit of "Interaction length". 00131 00132 G4double theInteractionTimeLeft; 00133 // Time left before the interaction : for at rest processes 00134 00135 G4double currentInteractionLength; 00136 // The InteractionLength in the current material 00137 }; 00138 00139 G4ProcessState* fpState ; 00140 00141 inline virtual void ClearInteractionTimeLeft(); 00142 00143 //_________________________________________________ 00144 // Redefine needed members and method of G4VProcess 00145 virtual void SubtractNumberOfInteractionLengthLeft( 00146 G4double previousStepSize 00147 ); 00148 // subtract NumberOfInteractionLengthLeft by the value corresponding to 00149 // previousStepSize 00150 00151 inline virtual void ClearNumberOfInteractionLengthLeft(); 00152 // clear NumberOfInteractionLengthLeft 00153 // !!! This method should be at the end of PostStepDoIt() 00154 // !!! and AtRestDoIt 00155 //_________________________________________________ 00156 00157 00158 void SetInstantiateProcessState(G4bool flag) 00159 { fInstantiateProcessState = flag; } 00160 00161 G4bool InstantiateProcessState() { return fInstantiateProcessState; } 00162 00163 G4bool fProposesTimeStep; 00164 00165 private : 00166 const size_t fProcessID; // During all the simulation will identify a 00167 // process, so if two identical process are created using a copy constructor 00168 // they will have the same fProcessID 00169 static size_t fNbProcess ; 00170 00171 G4bool fInstantiateProcessState; 00172 //_________________________________________________ 00173 // Redefine needed members and method of G4VProcess 00174 G4double* theNumberOfInteractionLengthLeft; 00175 G4double* currentInteractionLength; 00176 G4double* theInteractionTimeLeft; 00177 }; 00178 00179 inline void G4VITProcess::ClearInteractionTimeLeft() 00180 { 00181 fpState->theInteractionTimeLeft = -1.0; 00182 } 00183 00184 inline void G4VITProcess::ClearNumberOfInteractionLengthLeft() 00185 { 00186 fpState->theNumberOfInteractionLengthLeft = -1.0; 00187 } 00188 00189 inline void G4VITProcess::ResetNumberOfInteractionLengthLeft() 00190 { 00191 fpState->theNumberOfInteractionLengthLeft = -std::log( G4UniformRand() ); 00192 } 00193 00194 inline G4double G4VITProcess::GetInteractionTimeLeft() 00195 { 00196 if(fpState) 00197 return fpState->theInteractionTimeLeft ; 00198 00199 return -1 ; 00200 } 00201 00202 inline G4bool G4VITProcess::ProposesTimeStep() const 00203 { 00204 return fProposesTimeStep; 00205 } 00206 00207 inline const size_t& G4VITProcess::GetMaxProcessIndex() 00208 { 00209 return fNbProcess ; 00210 } 00211 #endif // G4VITProcess_H