Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:08

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4SteppingManager
0027 //
0028 // Class description:
0029 //
0030 // This is the class which plays an essential role in tracking particles.
0031 // It takes cares of all message passing between objects in the different
0032 // categories (for example, geometry - including transportation, interactions
0033 // in matter, etc). Its public method 'stepping' steers to step the particle.
0034 // Only used within the Geant4 kernel.
0035 
0036 // Contact:
0037 //   Questions and comments to this code should be sent to
0038 //     Katsuya Amako  (e-mail: Katsuya.Amako@kek.jp)
0039 //     Takashi Sasaki (e-mail: Takashi.Sasaki@kek.jp)
0040 //
0041 // History:
0042 //   12.03.1998, H.Kurashige - modified for use of G4ParticleChange
0043 // --------------------------------------------------------------------
0044 #ifndef G4SteppingManager_hh
0045 #define G4SteppingManager_hh 1
0046 
0047 #include "G4LogicalVolume.hh"  // Include from 'geometry'
0048 #include "G4Navigator.hh"  // Include from 'geometry'
0049 #include "G4NoProcess.hh"  // Include from 'processes'
0050 #include "G4ProcessManager.hh"  // Include from 'processes'
0051 #include "G4Step.hh"  // Include from 'tracking'
0052 #include "G4StepPoint.hh"  // Include from 'tracking'
0053 #include "G4StepStatus.hh"  // Include from 'tracking'
0054 #include "G4TouchableHandle.hh"  // Include from 'geometry'
0055 #include "G4Track.hh"  // Include from 'tracking'
0056 #include "G4TrackStatus.hh"  // Include from 'tracking'
0057 #include "G4TrackVector.hh"  // Include from 'tracking'
0058 #include "G4UserSteppingAction.hh"  // Include from 'tracking'
0059 #include "G4VPhysicalVolume.hh"  // Include from 'geometry'
0060 #include "G4VSteppingVerbose.hh"  // Include from 'tracking'
0061 #include "Randomize.hh"  // Include from 'global'
0062 #include "globals.hh"  // Include from 'global'
0063 
0064 #include <iomanip>  // Include from 'system'
0065 #include <vector>  // Include from 'system'
0066 
0067 using G4SelectedAtRestDoItVector = std::vector<G4int>;
0068 using G4SelectedAlongStepDoItVector = std::vector<G4int>;
0069 using G4SelectedPostStepDoItVector = std::vector<G4int>;
0070 
0071 class G4VSensitiveDetector;
0072 
0073 class G4SteppingManager
0074 {
0075  public:
0076   using ProfilerConfig = G4Step::ProfilerConfig;
0077 
0078  public:
0079   // Constructor/Destructor
0080 
0081   // SteppingManger should be dynamically allocated, therefore
0082   // you need to invoke new() when you call this constructor.
0083   // "Secodary track vector" will be dynamically created by this
0084   // constructor. G4UserSteppingAction will be also created
0085   // in this constructor, and "this" pointer will be passed to
0086   // G4UserSteppingAction.
0087   G4SteppingManager();
0088   ~G4SteppingManager();
0089 
0090   // Get/Set functions
0091 
0092   const G4TrackVector* GetSecondary() const;
0093   void SetUserAction(G4UserSteppingAction* apAction);
0094   G4Track* GetTrack() const;
0095   void SetVerboseLevel(G4int vLevel);
0096   void SetVerbose(G4VSteppingVerbose*);
0097   G4Step* GetStep() const;
0098   void SetNavigator(G4Navigator* value);
0099 
0100   // Other member functions
0101 
0102   // Steers to move the give particle from the TrackingManger by one Step.
0103   G4StepStatus Stepping();
0104 
0105   // Sets up initial track information (enegry, position, etc) to
0106   // the PreStepPoint of the G4Step. This funciton has to be called
0107   // just once before the stepping loop in the "TrackingManager".
0108   void SetInitialStep(G4Track* valueTrack);
0109 
0110   // Get methods
0111   void GetProcessNumber();
0112   G4double GetPhysicalStep();
0113   G4double GetGeometricalStep();
0114   G4double GetCorrectedStep();
0115   G4bool GetPreStepPointIsGeom();
0116   G4bool GetFirstStep();
0117   G4StepStatus GetfStepStatus();
0118   G4double GetTempInitVelocity();
0119   G4double GetTempVelocity();
0120   G4double GetMass();
0121   G4double GetsumEnergyChange();
0122   G4VParticleChange* GetfParticleChange();
0123   G4Track* GetfTrack();
0124   G4TrackVector* GetfSecondary();
0125   G4Step* GetfStep();
0126   G4StepPoint* GetfPreStepPoint();
0127   G4StepPoint* GetfPostStepPoint();
0128   G4VPhysicalVolume* GetfCurrentVolume();
0129   G4VSensitiveDetector* GetfSensitive();
0130   G4VProcess* GetfCurrentProcess();
0131   G4ProcessVector* GetfAtRestDoItVector();
0132   G4ProcessVector* GetfAlongStepDoItVector();
0133   G4ProcessVector* GetfPostStepDoItVector();
0134   G4ProcessVector* GetfAlongStepGetPhysIntVector();
0135   G4ProcessVector* GetfPostStepGetPhysIntVector();
0136   G4ProcessVector* GetfAtRestGetPhysIntVector();
0137   G4double GetcurrentMinimumStep();
0138   G4double GetnumberOfInteractionLengthLeft();
0139   std::size_t GetfAtRestDoItProcTriggered();
0140   std::size_t GetfAlongStepDoItProcTriggered();
0141   std::size_t GetfPostStepDoItProcTriggered();
0142   G4int GetfN2ndariesAtRestDoIt();
0143   G4int GetfN2ndariesAlongStepDoIt();
0144   G4int GetfN2ndariesPostStepDoIt();
0145   G4Navigator* GetfNavigator();
0146   G4int GetverboseLevel();
0147   std::size_t GetMAXofAtRestLoops();
0148   std::size_t GetMAXofAlongStepLoops();
0149   std::size_t GetMAXofPostStepLoops();
0150   G4SelectedAtRestDoItVector* GetfSelectedAtRestDoItVector();
0151   G4SelectedAlongStepDoItVector* GetfSelectedAlongStepDoItVector();
0152   G4SelectedPostStepDoItVector* GetfSelectedPostStepDoItVector();
0153   G4double GetfPreviousStepSize();
0154   const G4TouchableHandle& GetTouchableHandle();
0155   G4SteppingControl GetStepControlFlag();
0156   G4UserSteppingAction* GetUserAction();
0157   G4double GetphysIntLength();
0158   G4ForceCondition GetfCondition();
0159   G4GPILSelection GetfGPILSelection();
0160 
0161  private:
0162   // Member functions
0163 
0164   // Calculate corresponding physical length from the mean free path
0165   // left for each discrete physics process. The minimum allowable
0166   // step for each continuous process will be also calculated.
0167   void DefinePhysicalStepLength();
0168 
0169   void InvokeAtRestDoItProcs();
0170   void InvokeAlongStepDoItProcs();
0171   void InvokePostStepDoItProcs();
0172   void InvokePSDIP(size_t);  //
0173   G4int ProcessSecondariesFromParticleChange();
0174 
0175   // Return the estimated safety value at the PostStepPoint
0176   G4double CalculateSafety();
0177 
0178   // Member data
0179 
0180   static const size_t SizeOfSelectedDoItVector = 100;
0181 
0182   G4bool KillVerbose = false;
0183 
0184   G4UserSteppingAction* fUserSteppingAction = nullptr;
0185 
0186   G4VSteppingVerbose* fVerbose = nullptr;
0187 
0188   G4double PhysicalStep = 0.0;
0189   G4double GeometricalStep = 0.0;
0190   G4double CorrectedStep = 0.0;
0191   G4bool PreStepPointIsGeom = false;
0192   G4bool FirstStep = false;
0193   G4StepStatus fStepStatus = fUndefined;
0194 
0195   G4double TempInitVelocity = 0.0;
0196   G4double TempVelocity = 0.0;
0197   G4double Mass = 0.0;
0198 
0199   G4double sumEnergyChange = 0.0;
0200 
0201   G4VParticleChange* fParticleChange = nullptr;
0202   G4Track* fTrack = nullptr;
0203   G4TrackVector* fSecondary = nullptr;
0204   G4Step* fStep = nullptr;
0205   G4StepPoint* fPreStepPoint = nullptr;
0206   G4StepPoint* fPostStepPoint = nullptr;
0207 
0208   G4VPhysicalVolume* fCurrentVolume = nullptr;
0209   G4VSensitiveDetector* fSensitive = nullptr;
0210   G4VProcess* fCurrentProcess = nullptr;  // Pointer to process of which DoIt() or
0211                                           // GetPhysicalInteractionLength() has been just executed.
0212 
0213   G4ProcessVector* fAtRestDoItVector = nullptr;
0214   G4ProcessVector* fAlongStepDoItVector = nullptr;
0215   G4ProcessVector* fPostStepDoItVector = nullptr;
0216 
0217   G4ProcessVector* fAtRestGetPhysIntVector = nullptr;
0218   G4ProcessVector* fAlongStepGetPhysIntVector = nullptr;
0219   G4ProcessVector* fPostStepGetPhysIntVector = nullptr;
0220 
0221   std::size_t MAXofAtRestLoops = 0;
0222   std::size_t MAXofAlongStepLoops = 0;
0223   std::size_t MAXofPostStepLoops = 0;
0224 
0225   std::size_t fAtRestDoItProcTriggered = 0;
0226   std::size_t fAlongStepDoItProcTriggered = 0;
0227   std::size_t fPostStepDoItProcTriggered = 0;
0228 
0229   G4int fN2ndariesAtRestDoIt = 0;
0230   G4int fN2ndariesAlongStepDoIt = 0;
0231   G4int fN2ndariesPostStepDoIt = 0;
0232   // These are the numbers of secondaries generated by the process
0233   // just executed.
0234 
0235   G4Navigator* fNavigator = nullptr;
0236 
0237   G4int verboseLevel = 0;
0238 
0239   G4SelectedAtRestDoItVector* fSelectedAtRestDoItVector = nullptr;
0240   G4SelectedAlongStepDoItVector* fSelectedAlongStepDoItVector = nullptr;
0241   G4SelectedPostStepDoItVector* fSelectedPostStepDoItVector = nullptr;
0242 
0243   G4double fPreviousStepSize = 0.0;
0244 
0245   G4TouchableHandle fTouchableHandle;
0246 
0247   G4SteppingControl StepControlFlag = NormalCondition;
0248 
0249   G4double kCarTolerance = 0.0;  // Cached geometrical tolerance on surface
0250   G4double proposedSafety = 0.0;  // This keeps the minimum safety value proposed by AlongStepGPILs.
0251   G4ThreeVector endpointSafOrigin;
0252   G4double endpointSafety = 0.0;  // To get the true safety value at the PostStepPoint, you have to
0253                                   // subtract the distance to 'endpointSafOrigin' from this value.
0254   G4double physIntLength = 0.0;
0255   G4ForceCondition fCondition = InActivated;
0256   G4GPILSelection fGPILSelection = NotCandidateForSelection;
0257   // Above three variables are for the method
0258   // DefinePhysicalStepLength(). To pass these information to
0259   // the method Verbose, they are kept at here. Need a more
0260   // elegant mechanism.
0261 
0262   G4NoProcess const* fNoProcess = nullptr;  // Used in InvokeAtRestDoItProcs() method to flag the
0263                                             // process of any stable ion at rest.
0264 };
0265 
0266 //*******************************************************************
0267 //
0268 // Inline functions
0269 //
0270 //*******************************************************************
0271 
0272 inline G4double G4SteppingManager::GetPhysicalStep() { return PhysicalStep; }
0273 
0274 inline G4double G4SteppingManager::GetGeometricalStep() { return GeometricalStep; }
0275 
0276 inline G4double G4SteppingManager::GetCorrectedStep() { return CorrectedStep; }
0277 
0278 inline G4bool G4SteppingManager::GetPreStepPointIsGeom() { return PreStepPointIsGeom; }
0279 
0280 inline G4bool G4SteppingManager::GetFirstStep() { return FirstStep; }
0281 
0282 inline G4StepStatus G4SteppingManager::GetfStepStatus() { return fStepStatus; }
0283 
0284 inline G4double G4SteppingManager::GetTempInitVelocity() { return TempInitVelocity; }
0285 
0286 inline G4double G4SteppingManager::GetTempVelocity() { return TempVelocity; }
0287 
0288 inline G4double G4SteppingManager::GetMass() { return Mass; }
0289 
0290 inline G4double G4SteppingManager::GetsumEnergyChange() { return sumEnergyChange; }
0291 
0292 inline G4VParticleChange* G4SteppingManager::GetfParticleChange() { return fParticleChange; }
0293 
0294 inline G4Track* G4SteppingManager::GetfTrack() { return fTrack; }
0295 
0296 inline G4TrackVector* G4SteppingManager::GetfSecondary() { return fStep->GetfSecondary(); }
0297 
0298 inline G4Step* G4SteppingManager::GetfStep() { return fStep; }
0299 
0300 inline G4StepPoint* G4SteppingManager::GetfPreStepPoint() { return fPreStepPoint; }
0301 
0302 inline G4StepPoint* G4SteppingManager::GetfPostStepPoint() { return fPostStepPoint; }
0303 
0304 inline G4VPhysicalVolume* G4SteppingManager::GetfCurrentVolume() { return fCurrentVolume; }
0305 
0306 inline G4VSensitiveDetector* G4SteppingManager::GetfSensitive() { return fSensitive; }
0307 
0308 inline G4VProcess* G4SteppingManager::GetfCurrentProcess() { return fCurrentProcess; }
0309 
0310 inline G4ProcessVector* G4SteppingManager::GetfAtRestDoItVector() { return fAtRestDoItVector; }
0311 
0312 inline G4ProcessVector* G4SteppingManager::GetfAlongStepDoItVector()
0313 {
0314   return fAlongStepDoItVector;
0315 }
0316 
0317 inline G4ProcessVector* G4SteppingManager::GetfPostStepDoItVector() { return fPostStepDoItVector; }
0318 
0319 inline G4ProcessVector* G4SteppingManager::GetfAtRestGetPhysIntVector()
0320 {
0321   return fAtRestGetPhysIntVector;
0322 }
0323 
0324 inline G4ProcessVector* G4SteppingManager::GetfAlongStepGetPhysIntVector()
0325 {
0326   return fAlongStepGetPhysIntVector;
0327 }
0328 
0329 inline G4ProcessVector* G4SteppingManager::GetfPostStepGetPhysIntVector()
0330 {
0331   return fPostStepGetPhysIntVector;
0332 }
0333 
0334 inline size_t G4SteppingManager::GetMAXofAtRestLoops() { return MAXofAtRestLoops; }
0335 
0336 inline size_t G4SteppingManager::GetMAXofAlongStepLoops() { return MAXofAlongStepLoops; }
0337 
0338 inline size_t G4SteppingManager::GetMAXofPostStepLoops() { return MAXofPostStepLoops; }
0339 
0340 inline size_t G4SteppingManager::GetfAtRestDoItProcTriggered() { return fAtRestDoItProcTriggered; }
0341 
0342 inline size_t G4SteppingManager::GetfAlongStepDoItProcTriggered()
0343 {
0344   return fAtRestDoItProcTriggered;
0345 }
0346 
0347 inline size_t G4SteppingManager::GetfPostStepDoItProcTriggered()
0348 {
0349   return fPostStepDoItProcTriggered;
0350 }
0351 
0352 inline G4int G4SteppingManager::GetfN2ndariesAtRestDoIt() { return fN2ndariesAtRestDoIt; }
0353 
0354 inline G4int G4SteppingManager::GetfN2ndariesAlongStepDoIt() { return fN2ndariesAlongStepDoIt; }
0355 
0356 inline G4int G4SteppingManager::GetfN2ndariesPostStepDoIt() { return fN2ndariesPostStepDoIt; }
0357 
0358 inline G4Navigator* G4SteppingManager::GetfNavigator() { return fNavigator; }
0359 
0360 inline G4int G4SteppingManager::GetverboseLevel() { return verboseLevel; }
0361 
0362 inline G4SelectedAtRestDoItVector* G4SteppingManager::GetfSelectedAtRestDoItVector()
0363 {
0364   return fSelectedAtRestDoItVector;
0365 }
0366 
0367 inline G4SelectedAlongStepDoItVector* G4SteppingManager::GetfSelectedAlongStepDoItVector()
0368 {
0369   return fSelectedAlongStepDoItVector;
0370 }
0371 
0372 inline G4SelectedPostStepDoItVector* G4SteppingManager::GetfSelectedPostStepDoItVector()
0373 {
0374   return fSelectedPostStepDoItVector;
0375 }
0376 
0377 inline G4double G4SteppingManager::GetfPreviousStepSize() { return fPreviousStepSize; }
0378 
0379 inline const G4TouchableHandle& G4SteppingManager::GetTouchableHandle() { return fTouchableHandle; }
0380 
0381 inline G4SteppingControl G4SteppingManager::GetStepControlFlag() { return StepControlFlag; }
0382 
0383 inline G4double G4SteppingManager::GetphysIntLength() { return physIntLength; }
0384 
0385 inline G4ForceCondition G4SteppingManager::GetfCondition() { return fCondition; }
0386 
0387 inline G4GPILSelection G4SteppingManager::GetfGPILSelection() { return fGPILSelection; }
0388 
0389 inline const G4TrackVector* G4SteppingManager::GetSecondary() const
0390 {
0391   return fStep->GetSecondary();
0392 }
0393 
0394 inline void G4SteppingManager::SetNavigator(G4Navigator* value) { fNavigator = value; }
0395 
0396 inline void G4SteppingManager::SetUserAction(G4UserSteppingAction* apAction)
0397 {
0398   fUserSteppingAction = apAction;
0399 }
0400 
0401 inline G4UserSteppingAction* G4SteppingManager::GetUserAction() { return fUserSteppingAction; }
0402 
0403 inline G4Track* G4SteppingManager::GetTrack() const { return fTrack; }
0404 
0405 inline void G4SteppingManager::SetVerboseLevel(G4int vLevel) { verboseLevel = vLevel; }
0406 
0407 inline void G4SteppingManager::SetVerbose(G4VSteppingVerbose* yourVerbose)
0408 {
0409   fVerbose = yourVerbose;
0410 }
0411 
0412 inline G4Step* G4SteppingManager::GetStep() const { return fStep; }
0413 
0414 inline G4double G4SteppingManager::CalculateSafety()
0415 {
0416   return std::max(
0417     endpointSafety - (endpointSafOrigin - fPostStepPoint->GetPosition()).mag(), kCarTolerance);
0418 }
0419 
0420 #endif