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: G4ITStepProcessor.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 G4ITSTEPPROCESSOR_H 00040 #define G4ITSTEPPROCESSOR_H 00041 00042 #include "G4ios.hh" // Include from 'system' 00043 #include "globals.hh" // Include from 'global' 00044 #include "Randomize.hh" // Include from 'global' 00045 00046 #include "G4LogicalVolume.hh" // Include from 'geometry' 00047 #include "G4VPhysicalVolume.hh" // Include from 'geometry' 00048 #include "G4ProcessManager.hh" // Include from 'piim' 00049 00050 #include "G4Track.hh" // Include from 'track' 00051 #include "G4TrackVector.hh" // Include from 'track' 00052 #include "G4TrackStatus.hh" // Include from 'track' 00053 #include "G4StepStatus.hh" // Include from 'track' 00054 //#include "G4UserSteppingAction.hh" // Include from 'tracking' 00055 //#include "G4UserTrackingAction.hh" // Include from 'tracking' 00056 #include "G4Step.hh" // Include from 'track' 00057 #include "G4StepPoint.hh" // Include from 'track' 00058 #include "G4TouchableHandle.hh" // Include from 'geometry' 00059 #include "G4TouchableHistoryHandle.hh" // Include from 'geometry' 00060 00061 00062 #include "G4TrackingInformation.hh" 00063 00064 //class G4Navigator; 00065 class G4ITNavigator; 00066 class G4ParticleDefinition ; 00067 class G4ITTrackingManager; 00068 class G4IT; 00069 class G4TrackingInformation; 00070 class G4ITTransportation; 00071 class G4VITProcess; 00072 typedef class std::vector<int, std::allocator<int> > G4SelectedAtRestDoItVector; 00073 typedef class std::vector<int, std::allocator<int> > G4SelectedAlongStepDoItVector; 00074 typedef class std::vector<int, std::allocator<int> > G4SelectedPostStepDoItVector; 00075 00076 00083 class G4ITStepProcessor 00084 { 00085 00086 public: 00087 G4ITStepProcessor(); 00088 virtual ~G4ITStepProcessor(); 00089 00090 inline void SetPreviousStepTime(G4double); 00091 00092 inline G4Track* GetTrack() {return fpTrack;} 00093 inline G4Step* GetStep() {return fpStep;} 00094 inline const G4Step* GetStep() const {return fpStep;} 00095 inline void SetStep(G4Step* val) {fpStep = val;} 00096 00097 inline G4TrackVector* GetSecondaries() {return fpSecondary;} 00098 inline void SetTrackingManager(G4ITTrackingManager* trackMan) {fpTrackingManager = trackMan;} 00099 inline G4ITTrackingManager* GetTrackingManager() {return fpTrackingManager;} 00100 00101 virtual void Initialize(); 00102 void ForceReInitialization(); 00103 00104 void DefinePhysicalStepLength(G4Track*); 00105 void Stepping(G4Track*, const double&); 00106 void CalculateStep(G4Track*, const double&); 00107 void CalculateStep(G4Track*); 00108 00109 void DoIt(G4Track*,double); 00110 00111 void FindTransportationStep(); 00112 void UpdateTrack(G4Track*); 00113 00114 inline double GetInteractionTime(); 00115 inline const G4Track* GetTrack() const ; 00116 inline void CleanProcessor(); 00117 00118 protected: 00119 void SetupGeneralProcessInfo(G4ParticleDefinition*,G4ProcessManager*); 00120 void ClearProcessInfo(); 00121 void SetTrack(G4Track*); 00122 00123 void GetProcessInfo(); 00124 00125 void SetupMembers(); 00126 void ResetSecondaries(); 00127 void InitDefineStep(); 00128 00129 void SetInitialStep(); 00130 00131 void GetAtRestIL(); 00132 void DoDefinePhysicalStepLength(); 00133 void DoStepping(); 00134 00135 void CalculateStep(); 00136 void DoCalculateStep(); 00137 00138 void CloneProcesses(); 00139 void ActiveOnlyITProcess(); 00140 void ActiveOnlyITProcess(G4ProcessManager*); 00141 00142 void DealWithSecondaries(G4int&); 00143 void InvokeAtRestDoItProcs(); 00144 void InvokeAlongStepDoItProcs(); 00145 void InvokePostStepDoItProcs(); 00146 void InvokePSDIP(size_t); // 00147 void InvokeTransportationProc(); 00148 void SetNavigator(G4ITNavigator *value); 00149 G4double CalculateSafety(); 00150 00151 // Return the estimated safety value at the PostStepPoint 00152 void ApplyProductionCut(G4Track*); 00153 00154 00155 G4ITStepProcessor(const G4ITStepProcessor& other); 00156 G4ITStepProcessor& operator=(const G4ITStepProcessor& other); 00157 00158 private: 00159 //________________________________________________ 00160 // 00161 // General members 00162 //________________________________________________ 00163 00164 G4bool fInitialized; 00165 00166 G4ITTrackingManager* fpTrackingManager; 00167 // G4UserSteppingAction* fpUserSteppingAction; 00168 00169 G4double kCarTolerance; 00170 // Cached geometrical tolerance on surface 00171 00172 G4ITNavigator* fpNavigator; 00173 // G4Navigator* fpNavigator; 00174 G4int fStoreTrajectory; 00175 G4int verboseLevel; 00176 00177 //________________________________________________ 00178 // 00179 // Members used as temporaries (= not proper to a track) 00180 //________________________________________________ 00181 00182 G4double fTimeStep ; // not proper to a track 00183 G4double fPreviousTimeStep; 00184 G4TrackVector* fpSecondary ; // get from fpStep at every configuration setup 00185 G4VParticleChange* fpParticleChange; 00186 00187 G4VITProcess* fpCurrentProcess; 00188 // The pointer to the process of which DoIt or 00189 // GetPhysicalInteractionLength has been just executed 00190 00191 // * Secondaries 00192 G4int fN2ndariesAtRestDoIt; 00193 G4int fN2ndariesAlongStepDoIt; 00194 G4int fN2ndariesPostStepDoIt; 00195 // These are the numbers of secondaries generated by the process 00196 // just executed. 00197 00198 // * Process selection 00199 size_t fAtRestDoItProcTriggered; 00200 size_t fPostStepDoItProcTriggered; 00201 size_t fPostStepAtTimeDoItProcTriggered; 00202 // Record the selected process 00203 00204 G4ForceCondition fCondition; 00205 G4GPILSelection fGPILSelection; 00206 // Above three variables are for the method 00207 // DefinePhysicalStepLength(). To pass these information to 00208 // the method Verbose, they are kept at here. Need a more 00209 // elegant mechanism. 00210 00211 G4double fPhysIntLength; 00212 // The minimum physical interaction length over all possible processes 00213 00214 // * Sensitive detector 00215 // G4SteppingControl StepControlFlag; 00216 // G4VSensitiveDetector* fpSensitive; 00217 00218 G4VPhysicalVolume* fpCurrentVolume; // Get from fpStep or touchable, keep as member for user interface 00219 00220 //________________________________________________ 00221 // 00222 // Members related to ParticleDefinition and not 00223 // proper to a track 00224 //________________________________________________ 00225 struct ProcessGeneralInfo 00226 { 00227 G4ProcessVector* fpAtRestDoItVector; 00228 G4ProcessVector* fpAlongStepDoItVector; 00229 G4ProcessVector* fpPostStepDoItVector; 00230 00231 G4ProcessVector* fpAtRestGetPhysIntVector; 00232 G4ProcessVector* fpAlongStepGetPhysIntVector; 00233 G4ProcessVector* fpPostStepGetPhysIntVector; 00234 // 00235 // Note: DoItVector has inverse order against GetPhysIntVector 00236 // and SelectedPostStepDoItVector. 00237 // 00238 // * Max Number of Process 00239 size_t MAXofAtRestLoops; 00240 size_t MAXofAlongStepLoops; 00241 size_t MAXofPostStepLoops; 00242 // Maximum number of processes for each type of process 00243 // These depend on the G4ParticleDefinition, so on the track 00244 00245 // * Transportation process 00246 G4ITTransportation* fpTransportation ; 00247 }; 00248 00249 std::map<const G4ParticleDefinition*, ProcessGeneralInfo*> fProcessGeneralInfoMap; 00250 ProcessGeneralInfo* fpProcessInfo; 00251 00252 G4ITTransportation* fpTransportation ; 00253 00254 //________________________________________________ 00255 // 00256 // Members proper to a track 00257 //________________________________________________ 00258 class G4ITStepProcessorState : public G4ITStepProcessorState_Lock 00259 { 00260 public: 00261 G4ITStepProcessorState(); 00262 virtual ~G4ITStepProcessorState(); 00263 00264 // * Max Number of Process 00265 G4SelectedAtRestDoItVector fSelectedAtRestDoItVector; 00266 G4SelectedPostStepDoItVector fSelectedPostStepDoItVector; 00267 00268 G4double fPhysicalStep; 00269 G4double fPreviousStepSize; 00270 G4double fSafety; 00271 00272 G4StepStatus fStepStatus; 00273 00274 // * Safety 00275 G4double proposedSafety; 00276 // This keeps the minimum safety value proposed by AlongStepGPILs. 00277 G4ThreeVector endpointSafOrigin; 00278 G4double endpointSafety; 00279 // To get the true safety value at the PostStepPoint, you have 00280 // to subtract the distance to 'endpointSafOrigin' from this value. 00281 00282 G4TouchableHandle fTouchableHandle; 00283 private : 00284 G4ITStepProcessorState(const G4ITStepProcessorState&); 00285 G4ITStepProcessorState& operator=(const G4ITStepProcessorState&); 00286 }; 00287 00288 //________________________________________________ 00289 // 00290 // Members used for configurating the processor 00291 //________________________________________________ 00292 00293 G4Track* fpTrack; // Set track 00294 G4IT* fpITrack ; // Set track 00295 G4TrackingInformation* fpTrackingInfo ; // Set track 00296 00297 G4ITStepProcessorState* fpState; // SetupMembers or InitDefineStep 00298 G4Step* fpStep; // Set track or InitDefineStep 00299 00300 G4StepPoint* fpPreStepPoint; // SetupMembers 00301 G4StepPoint* fpPostStepPoint; // SetupMembers 00302 }; 00303 00304 inline void G4ITStepProcessor::SetPreviousStepTime(G4double previousTimeStep) 00305 { 00306 fPreviousTimeStep = previousTimeStep; 00307 } 00308 00309 inline const G4Track* G4ITStepProcessor::GetTrack() const 00310 { 00311 return fpTrack; 00312 } 00313 00314 inline G4double G4ITStepProcessor::CalculateSafety() 00315 { 00316 return std::max( fpState->endpointSafety - 00317 (fpState->endpointSafOrigin - fpPostStepPoint->GetPosition()).mag(), 00318 kCarTolerance ); 00319 } 00320 00321 inline void G4ITStepProcessor::SetNavigator(G4ITNavigator *value) 00322 { 00323 fpNavigator = value; 00324 } 00325 00326 inline void G4ITStepProcessor::CleanProcessor() 00327 { 00328 fTimeStep = DBL_MAX ; 00329 fPhysIntLength = DBL_MAX; 00330 00331 fpState = 0; 00332 fpTrack = 0; 00333 fpTrackingInfo = 0 ; 00334 fpITrack = 0; 00335 fpStep = 0; 00336 fpPreStepPoint = 0; 00337 fpPostStepPoint = 0; 00338 00339 fpParticleChange = 0; 00340 00341 fpCurrentVolume = 0; 00342 // fpSensitive = 0; 00343 00344 fpSecondary = 0 ; 00345 00346 fpTransportation = 0; 00347 00348 fpCurrentProcess= 0; 00349 fpProcessInfo = 0; 00350 00351 fAtRestDoItProcTriggered = INT_MAX; 00352 fPostStepDoItProcTriggered = INT_MAX; 00353 fPostStepAtTimeDoItProcTriggered = INT_MAX; 00354 fGPILSelection = NotCandidateForSelection ; 00355 fCondition = NotForced; 00356 } 00357 00358 //______________________________________________________________________________ 00359 inline double G4ITStepProcessor::GetInteractionTime() 00360 { 00361 return fTimeStep ; 00362 } 00363 00364 00365 #endif // G4ITSTEPPROCESSOR_H