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: G4SteppingManager.hh 67009 2013-01-29 16:00:21Z gcosmo $ 00028 // 00029 //--------------------------------------------------------------- 00030 // 00031 // G4SteppingManager.hh 00032 // 00033 // class description: 00034 // This is the class which plays an essential role in tracking 00035 // the particle. It takes cares all message passing between 00036 // objects in the different categories (for example, 00037 // geometry(including transportation), interactions in 00038 // matter, etc). It's public method 'stepping' steers to step 00039 // the particle. 00040 // Geant4 kernel use only 00041 // 00042 // Contact: 00043 // Questions and comments to this code should be sent to 00044 // Katsuya Amako (e-mail: Katsuya.Amako@kek.jp) 00045 // Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp) 00046 // 00047 //--------------------------------------------------------------- 00048 // modified for new ParticleChange 12 Mar. 1998 H.Kurashige 00049 00050 00051 class G4SteppingManager; 00052 00053 #ifndef G4SteppingManager_h 00054 #define G4SteppingManager_h 1 00055 00056 class G4VSensitiveDetector; 00057 00058 #include "G4ios.hh" // Include from 'system' 00059 #include <iomanip> // Include from 'system' 00060 #include <vector> // Include from 'system' 00061 #include "globals.hh" // Include from 'global' 00062 #include "Randomize.hh" // Include from 'global' 00063 00064 #include "G4Navigator.hh" // Include from 'geometry' 00065 #include "G4LogicalVolume.hh" // Include from 'geometry' 00066 #include "G4VPhysicalVolume.hh" // Include from 'geometry' 00067 #include "G4ProcessManager.hh" // Include from 'piim' 00068 00069 #include "G4Track.hh" // Include from 'tracking' 00070 #include "G4TrackVector.hh" // Include from 'tracking' 00071 #include "G4TrackStatus.hh" // Include from 'tracking' 00072 #include "G4StepStatus.hh" // Include from 'tracking' 00073 #include "G4UserSteppingAction.hh" // Include from 'tracking' 00074 #include "G4Step.hh" // Include from 'tracking' 00075 #include "G4StepPoint.hh" // Include from 'tracking' 00076 #include "G4VSteppingVerbose.hh" // Include from 'tracking' 00077 #include "G4TouchableHandle.hh" // Include from 'geometry' 00078 #include "G4TouchableHistoryHandle.hh" // Include from 'geometry' 00079 00080 // 00081 typedef std::vector<G4int> 00082 G4SelectedAtRestDoItVector; 00083 typedef std::vector<G4int> 00084 G4SelectedAlongStepDoItVector; 00085 typedef std::vector<G4int> 00086 G4SelectedPostStepDoItVector; 00087 00088 static const size_t SizeOfSelectedDoItVector=100; 00089 // In global scope for porting on WIN-VC compiler... 00090 00092 class G4SteppingManager 00094 { 00095 00096 //-------- 00097 public: //without description 00098 //-------- 00099 00100 // Constructor/Destructor 00101 00102 G4SteppingManager(); 00103 // SteppingManger should be dynamically persistent, therefore 00104 // you need to invoke new() when you call this constructor. 00105 // "Secodary track vector" will be dynamically created by this 00106 // cosntructor. "G4UserSteppingAction" will be also constructed 00107 // in this constructor, and "this" pointer will be passed to 00108 // "G4UserSteppingAction". 00109 00110 ~G4SteppingManager(); 00111 00112 // Get/Set functions 00113 00114 const G4TrackVector* GetSecondary() const; 00115 void SetUserAction(G4UserSteppingAction* apAction); 00116 G4Track* GetTrack() const; 00117 void SetVerboseLevel(G4int vLevel); 00118 void SetVerbose(G4VSteppingVerbose*); 00119 G4Step* GetStep() const; 00120 void SetNavigator(G4Navigator* value); 00121 00122 00123 // Other member functions 00124 00125 G4StepStatus Stepping(); 00126 // Steers to move the give particle from the TrackingManger 00127 // by one Step. 00128 00129 void SetInitialStep(G4Track* valueTrack); 00130 // Sets up initial track information (enegry, position, etc) to 00131 // the PreStepPoint of the G4Step. This funciton has to be called 00132 // just once before the stepping loop in the "TrackingManager". 00133 00134 void GetProcessNumber(); 00135 00136 // Get methods 00137 G4double GetPhysicalStep(); 00138 G4double GetGeometricalStep(); 00139 G4double GetCorrectedStep(); 00140 G4bool GetPreStepPointIsGeom(); 00141 G4bool GetFirstStep(); 00142 G4StepStatus GetfStepStatus(); 00143 G4double GetTempInitVelocity(); 00144 G4double GetTempVelocity(); 00145 G4double GetMass(); 00146 G4double GetsumEnergyChange(); 00147 G4VParticleChange* GetfParticleChange(); 00148 G4Track* GetfTrack(); 00149 G4TrackVector* GetfSecondary(); 00150 G4Step* GetfStep(); 00151 G4StepPoint* GetfPreStepPoint(); 00152 G4StepPoint* GetfPostStepPoint(); 00153 G4VPhysicalVolume* GetfCurrentVolume(); 00154 G4VSensitiveDetector* GetfSensitive(); 00155 G4VProcess* GetfCurrentProcess(); 00156 G4ProcessVector* GetfAtRestDoItVector(); 00157 G4ProcessVector* GetfAlongStepDoItVector(); 00158 G4ProcessVector* GetfPostStepDoItVector(); 00159 G4ProcessVector* GetfAlongStepGetPhysIntVector(); 00160 G4ProcessVector* GetfPostStepGetPhysIntVector(); 00161 G4ProcessVector* GetfAtRestGetPhysIntVector(); 00162 G4double GetcurrentMinimumStep(); 00163 G4double GetnumberOfInteractionLengthLeft(); 00164 size_t GetfAtRestDoItProcTriggered(); 00165 size_t GetfAlongStepDoItProcTriggered(); 00166 size_t GetfPostStepDoItProcTriggered(); 00167 G4int GetfN2ndariesAtRestDoIt(); 00168 G4int GetfN2ndariesAlongStepDoIt(); 00169 G4int GetfN2ndariesPostStepDoIt(); 00170 G4Navigator* GetfNavigator(); 00171 G4int GetverboseLevel(); 00172 size_t GetMAXofAtRestLoops(); 00173 size_t GetMAXofAlongStepLoops(); 00174 size_t GetMAXofPostStepLoops(); 00175 G4SelectedAtRestDoItVector* GetfSelectedAtRestDoItVector(); 00176 G4SelectedAlongStepDoItVector* GetfSelectedAlongStepDoItVector(); 00177 G4SelectedPostStepDoItVector* GetfSelectedPostStepDoItVector(); 00178 G4double GetfPreviousStepSize(); 00179 const G4TouchableHandle& GetTouchableHandle(); 00180 G4SteppingControl GetStepControlFlag(); 00181 G4UserSteppingAction* GetUserAction(); 00182 G4double GetphysIntLength(); 00183 G4ForceCondition GetfCondition(); 00184 G4GPILSelection GetfGPILSelection(); 00185 // 00186 G4bool KillVerbose; 00187 //--------- 00188 private: 00189 //--------- 00190 00191 // Member functions 00192 00193 void DefinePhysicalStepLength(); 00194 // Calculate corresponding physical length from the mean free path 00195 // left for each discrete phyiscs process. The minimum allowable 00196 // Step for each continious process will be also calculated. 00197 void InvokeAtRestDoItProcs(); 00198 void InvokeAlongStepDoItProcs(); 00199 void InvokePostStepDoItProcs(); 00200 void InvokePSDIP(size_t); // 00201 G4double CalculateSafety(); 00202 // Return the estimated safety value at the PostStepPoint 00203 void ApplyProductionCut(G4Track*); 00204 00205 // Member data 00206 00207 G4UserSteppingAction* fUserSteppingAction; 00208 00209 G4VSteppingVerbose* fVerbose; 00210 00211 G4double PhysicalStep; 00212 G4double GeometricalStep; 00213 G4double CorrectedStep; 00214 G4bool PreStepPointIsGeom; 00215 G4bool FirstStep; 00216 G4StepStatus fStepStatus; 00217 00218 G4double TempInitVelocity; 00219 G4double TempVelocity; 00220 G4double Mass; 00221 00222 G4double sumEnergyChange; 00223 00224 G4VParticleChange* fParticleChange; 00225 G4Track* fTrack; 00226 G4TrackVector* fSecondary; 00227 G4Step* fStep; 00228 G4StepPoint* fPreStepPoint; 00229 G4StepPoint* fPostStepPoint; 00230 00231 G4VPhysicalVolume* fCurrentVolume; 00232 G4VSensitiveDetector* fSensitive; 00233 G4VProcess* fCurrentProcess; 00234 // The pointer to the process of which DoIt or 00235 // GetPhysicalInteractionLength has been just executed. 00236 00237 00238 G4ProcessVector* fAtRestDoItVector; 00239 G4ProcessVector* fAlongStepDoItVector; 00240 G4ProcessVector* fPostStepDoItVector; 00241 00242 G4ProcessVector* fAtRestGetPhysIntVector; 00243 G4ProcessVector* fAlongStepGetPhysIntVector; 00244 G4ProcessVector* fPostStepGetPhysIntVector; 00245 00246 size_t MAXofAtRestLoops; 00247 size_t MAXofAlongStepLoops; 00248 size_t MAXofPostStepLoops; 00249 00250 size_t fAtRestDoItProcTriggered; 00251 size_t fAlongStepDoItProcTriggered; 00252 size_t fPostStepDoItProcTriggered; 00253 00254 G4int fN2ndariesAtRestDoIt; 00255 G4int fN2ndariesAlongStepDoIt; 00256 G4int fN2ndariesPostStepDoIt; 00257 // These are the numbers of secondaries generated by the process 00258 // just executed. 00259 00260 G4Navigator *fNavigator; 00261 00262 G4int verboseLevel; 00263 00264 G4SelectedAtRestDoItVector* fSelectedAtRestDoItVector; 00265 G4SelectedAlongStepDoItVector* fSelectedAlongStepDoItVector; 00266 G4SelectedPostStepDoItVector* fSelectedPostStepDoItVector; 00267 00268 G4double fPreviousStepSize; 00269 00270 G4TouchableHandle fTouchableHandle; 00271 00272 G4SteppingControl StepControlFlag; 00273 00274 G4double kCarTolerance; 00275 // Cached geometrical tolerance on surface 00276 G4double proposedSafety; 00277 // This keeps the minimum safety value proposed by AlongStepGPILs. 00278 G4ThreeVector endpointSafOrigin; 00279 G4double endpointSafety; 00280 // To get the true safety value at the PostStepPoint, you have 00281 // to subtract the distance to 'endpointSafOrigin' from this value. 00282 G4double physIntLength; 00283 G4ForceCondition fCondition; 00284 G4GPILSelection fGPILSelection; 00285 // Above three variables are for the method 00286 // DefinePhysicalStepLength(). To pass these information to 00287 // the method Verbose, they are kept at here. Need a more 00288 // elegant mechanism. 00289 00290 }; 00291 00292 00293 //******************************************************************* 00294 // 00295 // Inline function 00296 // 00297 //******************************************************************* 00298 00299 inline G4double G4SteppingManager::GetPhysicalStep(){ 00300 return PhysicalStep; 00301 } 00302 00303 inline G4double G4SteppingManager::GetGeometricalStep(){ 00304 return GeometricalStep; 00305 } 00306 00307 inline G4double G4SteppingManager::GetCorrectedStep(){ 00308 return CorrectedStep; 00309 } 00310 00311 inline G4bool G4SteppingManager::GetPreStepPointIsGeom(){ 00312 return PreStepPointIsGeom; 00313 } 00314 00315 inline G4bool G4SteppingManager::GetFirstStep(){ 00316 return FirstStep; 00317 } 00318 00319 inline G4StepStatus G4SteppingManager::GetfStepStatus(){ 00320 return fStepStatus; 00321 } 00322 00323 inline G4double G4SteppingManager::GetTempInitVelocity(){ 00324 return TempInitVelocity; 00325 } 00326 inline G4double G4SteppingManager::GetTempVelocity(){ 00327 return TempVelocity; 00328 } 00329 inline G4double G4SteppingManager::GetMass(){ 00330 return Mass; 00331 } 00332 00333 inline G4double G4SteppingManager::GetsumEnergyChange(){ 00334 return sumEnergyChange; 00335 } 00336 00337 inline G4VParticleChange* G4SteppingManager::GetfParticleChange(){ 00338 return fParticleChange; 00339 } 00340 00341 inline G4Track* G4SteppingManager::GetfTrack(){ 00342 return fTrack; 00343 } 00344 00345 inline G4TrackVector* G4SteppingManager::GetfSecondary(){ 00346 return fStep->GetfSecondary(); 00347 } 00348 inline G4Step* G4SteppingManager::GetfStep(){ 00349 return fStep; 00350 } 00351 inline G4StepPoint* G4SteppingManager::GetfPreStepPoint(){ 00352 return fPreStepPoint; 00353 } 00354 inline G4StepPoint* G4SteppingManager::GetfPostStepPoint(){ 00355 return fPostStepPoint; 00356 } 00357 00358 inline G4VPhysicalVolume* G4SteppingManager::GetfCurrentVolume(){ 00359 return fCurrentVolume; 00360 } 00361 inline G4VSensitiveDetector* G4SteppingManager::GetfSensitive(){ 00362 return fSensitive; 00363 } 00364 inline G4VProcess* G4SteppingManager::GetfCurrentProcess(){ 00365 return fCurrentProcess; 00366 } 00367 00368 inline G4ProcessVector* G4SteppingManager::GetfAtRestDoItVector(){ 00369 return fAtRestDoItVector; 00370 } 00371 inline G4ProcessVector* G4SteppingManager::GetfAlongStepDoItVector(){ 00372 return fAlongStepDoItVector; 00373 } 00374 inline G4ProcessVector* G4SteppingManager::GetfPostStepDoItVector(){ 00375 return fPostStepDoItVector; 00376 } 00377 00378 inline G4ProcessVector* G4SteppingManager::GetfAtRestGetPhysIntVector(){ 00379 return fAtRestGetPhysIntVector; 00380 } 00381 00382 inline G4ProcessVector* G4SteppingManager::GetfAlongStepGetPhysIntVector(){ 00383 return fAlongStepGetPhysIntVector; 00384 } 00385 00386 inline G4ProcessVector* G4SteppingManager::GetfPostStepGetPhysIntVector(){ 00387 return fPostStepGetPhysIntVector; 00388 } 00389 00390 inline size_t G4SteppingManager::GetMAXofAtRestLoops(){ 00391 return MAXofAtRestLoops; 00392 } 00393 inline size_t G4SteppingManager::GetMAXofAlongStepLoops(){ 00394 return MAXofAlongStepLoops; 00395 } 00396 inline size_t G4SteppingManager::GetMAXofPostStepLoops(){ 00397 return MAXofPostStepLoops; 00398 } 00399 00400 inline size_t G4SteppingManager::GetfAtRestDoItProcTriggered(){ 00401 return fAtRestDoItProcTriggered; 00402 } 00403 inline size_t G4SteppingManager::GetfAlongStepDoItProcTriggered(){ 00404 return fAtRestDoItProcTriggered; 00405 } 00406 inline size_t G4SteppingManager::GetfPostStepDoItProcTriggered(){ 00407 return fPostStepDoItProcTriggered; 00408 } 00409 inline G4int G4SteppingManager::GetfN2ndariesAtRestDoIt(){ 00410 return fN2ndariesAtRestDoIt; 00411 } 00412 inline G4int G4SteppingManager::GetfN2ndariesAlongStepDoIt(){ 00413 return fN2ndariesAlongStepDoIt; 00414 } 00415 inline G4int G4SteppingManager::GetfN2ndariesPostStepDoIt(){ 00416 return fN2ndariesPostStepDoIt; 00417 } 00418 00419 inline G4Navigator* G4SteppingManager::GetfNavigator(){ 00420 return fNavigator; 00421 } 00422 inline G4int G4SteppingManager::GetverboseLevel(){ 00423 return verboseLevel; 00424 } 00425 00426 inline G4SelectedAtRestDoItVector* G4SteppingManager::GetfSelectedAtRestDoItVector(){ 00427 return fSelectedAtRestDoItVector; 00428 } 00429 00430 inline G4SelectedAlongStepDoItVector* G4SteppingManager::GetfSelectedAlongStepDoItVector(){ 00431 return fSelectedAlongStepDoItVector; 00432 } 00433 00434 inline G4SelectedPostStepDoItVector* G4SteppingManager::GetfSelectedPostStepDoItVector(){ 00435 return fSelectedPostStepDoItVector; 00436 } 00437 00438 inline G4double G4SteppingManager::GetfPreviousStepSize(){ 00439 return fPreviousStepSize; 00440 } 00441 00442 inline const G4TouchableHandle& G4SteppingManager::GetTouchableHandle() { 00443 return fTouchableHandle; 00444 } 00445 00446 inline G4SteppingControl G4SteppingManager::GetStepControlFlag(){ 00447 return StepControlFlag; 00448 } 00449 inline G4double G4SteppingManager::GetphysIntLength(){ 00450 return physIntLength; 00451 } 00452 inline G4ForceCondition G4SteppingManager::GetfCondition(){ 00453 return fCondition; 00454 } 00455 inline G4GPILSelection G4SteppingManager::GetfGPILSelection(){ 00456 return fGPILSelection; 00457 } 00458 00459 inline const G4TrackVector* G4SteppingManager::GetSecondary() const { 00460 return fStep->GetSecondary(); 00461 } 00462 00463 inline void G4SteppingManager::SetNavigator(G4Navigator* value){ 00464 fNavigator = value; 00465 } 00466 00467 inline void G4SteppingManager::SetUserAction(G4UserSteppingAction* apAction){ 00468 fUserSteppingAction = apAction; 00469 } 00470 inline G4UserSteppingAction* G4SteppingManager::GetUserAction(){ 00471 return fUserSteppingAction; 00472 } 00473 00474 inline G4Track* G4SteppingManager::GetTrack() const { 00475 return fTrack; 00476 } 00477 00478 inline void G4SteppingManager::SetVerboseLevel(G4int vLevel){ 00479 verboseLevel = vLevel; 00480 } 00481 00482 inline void G4SteppingManager::SetVerbose(G4VSteppingVerbose* yourVerbose){ 00483 fVerbose = yourVerbose; 00484 } 00485 00486 inline G4Step* G4SteppingManager::GetStep() const { 00487 return fStep; 00488 } 00489 00490 inline G4double G4SteppingManager::CalculateSafety(){ 00491 return std::max( endpointSafety - 00492 (endpointSafOrigin - fPostStepPoint->GetPosition()).mag(), 00493 kCarTolerance ); 00494 } 00495 00496 00497 #endif