Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:26:25

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   // Constructor/Destructor
0077 
0078   // SteppingManger should be dynamically allocated, therefore
0079   // you need to invoke new() when you call this constructor.
0080   // "Secodary track vector" will be dynamically created by this
0081   // constructor. G4UserSteppingAction will be also created
0082   // in this constructor, and "this" pointer will be passed to
0083   // G4UserSteppingAction.
0084   G4SteppingManager();
0085   ~G4SteppingManager();
0086 
0087   // Get/Set functions
0088 
0089   const G4TrackVector* GetSecondary() const;
0090   void SetUserAction(G4UserSteppingAction* apAction);
0091   G4Track* GetTrack() const;
0092   void SetVerboseLevel(G4int vLevel);
0093   void SetVerbose(G4VSteppingVerbose*);
0094   G4Step* GetStep() const;
0095   void SetNavigator(G4Navigator* value);
0096 
0097   // Other member functions
0098 
0099   // Steers to move the give particle from the TrackingManger by one Step.
0100   G4StepStatus Stepping();
0101 
0102   // Sets up initial track information (enegry, position, etc) to
0103   // the PreStepPoint of the G4Step. This funciton has to be called
0104   // just once before the stepping loop in the "TrackingManager".
0105   void SetInitialStep(G4Track* valueTrack);
0106 
0107   // Get methods
0108   void GetProcessNumber();
0109   G4double GetPhysicalStep();
0110   G4double GetGeometricalStep();
0111   G4double GetCorrectedStep();
0112   G4bool GetPreStepPointIsGeom();
0113   G4bool GetFirstStep();
0114   G4StepStatus GetfStepStatus();
0115   G4double GetTempInitVelocity();
0116   G4double GetTempVelocity();
0117   G4double GetMass();
0118   G4double GetsumEnergyChange();
0119   G4VParticleChange* GetfParticleChange();
0120   G4Track* GetfTrack();
0121   G4TrackVector* GetfSecondary();
0122   G4Step* GetfStep();
0123   G4StepPoint* GetfPreStepPoint();
0124   G4StepPoint* GetfPostStepPoint();
0125   G4VPhysicalVolume* GetfCurrentVolume();
0126   G4VSensitiveDetector* GetfSensitive();
0127   G4VProcess* GetfCurrentProcess();
0128   G4ProcessVector* GetfAtRestDoItVector();
0129   G4ProcessVector* GetfAlongStepDoItVector();
0130   G4ProcessVector* GetfPostStepDoItVector();
0131   G4ProcessVector* GetfAlongStepGetPhysIntVector();
0132   G4ProcessVector* GetfPostStepGetPhysIntVector();
0133   G4ProcessVector* GetfAtRestGetPhysIntVector();
0134   G4double GetcurrentMinimumStep();
0135   G4double GetnumberOfInteractionLengthLeft();
0136   std::size_t GetfAtRestDoItProcTriggered();
0137   std::size_t GetfAlongStepDoItProcTriggered();
0138   std::size_t GetfPostStepDoItProcTriggered();
0139   G4int GetfN2ndariesAtRestDoIt();
0140   G4int GetfN2ndariesAlongStepDoIt();
0141   G4int GetfN2ndariesPostStepDoIt();
0142   G4Navigator* GetfNavigator();
0143   G4int GetverboseLevel();
0144   std::size_t GetMAXofAtRestLoops();
0145   std::size_t GetMAXofAlongStepLoops();
0146   std::size_t GetMAXofPostStepLoops();
0147   G4SelectedAtRestDoItVector* GetfSelectedAtRestDoItVector();
0148   G4SelectedAlongStepDoItVector* GetfSelectedAlongStepDoItVector();
0149   G4SelectedPostStepDoItVector* GetfSelectedPostStepDoItVector();
0150   G4double GetfPreviousStepSize();
0151   const G4TouchableHandle& GetTouchableHandle();
0152   G4SteppingControl GetStepControlFlag();
0153   G4UserSteppingAction* GetUserAction();
0154   G4double GetphysIntLength();
0155   G4ForceCondition GetfCondition();
0156   G4GPILSelection GetfGPILSelection();
0157 
0158  private:
0159   // Member functions
0160 
0161   // Calculate corresponding physical length from the mean free path
0162   // left for each discrete physics process. The minimum allowable
0163   // step for each continuous process will be also calculated.
0164   void DefinePhysicalStepLength();
0165 
0166   void InvokeAtRestDoItProcs();
0167   void InvokeAlongStepDoItProcs();
0168   void InvokePostStepDoItProcs();
0169   void InvokePSDIP(size_t);  //
0170   G4int ProcessSecondariesFromParticleChange();
0171 
0172   // Return the estimated safety value at the PostStepPoint
0173   G4double CalculateSafety();
0174 
0175   // Member data
0176 
0177   static const size_t SizeOfSelectedDoItVector = 100;
0178 
0179   G4bool KillVerbose = false;
0180 
0181   G4UserSteppingAction* fUserSteppingAction = nullptr;
0182 
0183   G4VSteppingVerbose* fVerbose = nullptr;
0184 
0185   G4double PhysicalStep = 0.0;
0186   G4double GeometricalStep = 0.0;
0187   G4double CorrectedStep = 0.0;
0188   G4bool PreStepPointIsGeom = false;
0189   G4bool FirstStep = false;
0190   G4StepStatus fStepStatus = fUndefined;
0191 
0192   G4double TempInitVelocity = 0.0;
0193   G4double TempVelocity = 0.0;
0194   G4double Mass = 0.0;
0195 
0196   G4double sumEnergyChange = 0.0;
0197 
0198   G4VParticleChange* fParticleChange = nullptr;
0199   G4Track* fTrack = nullptr;
0200   G4TrackVector* fSecondary = nullptr;
0201   G4Step* fStep = nullptr;
0202   G4StepPoint* fPreStepPoint = nullptr;
0203   G4StepPoint* fPostStepPoint = nullptr;
0204 
0205   G4VPhysicalVolume* fCurrentVolume = nullptr;
0206   G4VSensitiveDetector* fSensitive = nullptr;
0207   G4VProcess* fCurrentProcess = nullptr;  // Pointer to process of which DoIt() or
0208                                           // GetPhysicalInteractionLength() has been just executed.
0209 
0210   G4ProcessVector* fAtRestDoItVector = nullptr;
0211   G4ProcessVector* fAlongStepDoItVector = nullptr;
0212   G4ProcessVector* fPostStepDoItVector = nullptr;
0213 
0214   G4ProcessVector* fAtRestGetPhysIntVector = nullptr;
0215   G4ProcessVector* fAlongStepGetPhysIntVector = nullptr;
0216   G4ProcessVector* fPostStepGetPhysIntVector = nullptr;
0217 
0218   std::size_t MAXofAtRestLoops = 0;
0219   std::size_t MAXofAlongStepLoops = 0;
0220   std::size_t MAXofPostStepLoops = 0;
0221 
0222   std::size_t fAtRestDoItProcTriggered = 0;
0223   std::size_t fAlongStepDoItProcTriggered = 0;
0224   std::size_t fPostStepDoItProcTriggered = 0;
0225 
0226   G4int fN2ndariesAtRestDoIt = 0;
0227   G4int fN2ndariesAlongStepDoIt = 0;
0228   G4int fN2ndariesPostStepDoIt = 0;
0229   // These are the numbers of secondaries generated by the process
0230   // just executed.
0231 
0232   G4Navigator* fNavigator = nullptr;
0233 
0234   G4int verboseLevel = 0;
0235 
0236   G4SelectedAtRestDoItVector* fSelectedAtRestDoItVector = nullptr;
0237   G4SelectedAlongStepDoItVector* fSelectedAlongStepDoItVector = nullptr;
0238   G4SelectedPostStepDoItVector* fSelectedPostStepDoItVector = nullptr;
0239 
0240   G4double fPreviousStepSize = 0.0;
0241 
0242   G4TouchableHandle fTouchableHandle;
0243 
0244   G4SteppingControl StepControlFlag = NormalCondition;
0245 
0246   G4double kCarTolerance = 0.0;  // Cached geometrical tolerance on surface
0247   G4double proposedSafety = 0.0;  // This keeps the minimum safety value proposed by AlongStepGPILs.
0248   G4ThreeVector endpointSafOrigin;
0249   G4double endpointSafety = 0.0;  // To get the true safety value at the PostStepPoint, you have to
0250                                   // subtract the distance to 'endpointSafOrigin' from this value.
0251   G4double physIntLength = 0.0;
0252   G4ForceCondition fCondition = InActivated;
0253   G4GPILSelection fGPILSelection = NotCandidateForSelection;
0254   // Above three variables are for the method
0255   // DefinePhysicalStepLength(). To pass these information to
0256   // the method Verbose, they are kept at here. Need a more
0257   // elegant mechanism.
0258 
0259   G4NoProcess const* fNoProcess = nullptr;  // Used in InvokeAtRestDoItProcs() method to flag the
0260                                             // process of any stable ion at rest.
0261 };
0262 
0263 //*******************************************************************
0264 //
0265 // Inline functions
0266 //
0267 //*******************************************************************
0268 
0269 inline G4double G4SteppingManager::GetPhysicalStep() { return PhysicalStep; }
0270 
0271 inline G4double G4SteppingManager::GetGeometricalStep() { return GeometricalStep; }
0272 
0273 inline G4double G4SteppingManager::GetCorrectedStep() { return CorrectedStep; }
0274 
0275 inline G4bool G4SteppingManager::GetPreStepPointIsGeom() { return PreStepPointIsGeom; }
0276 
0277 inline G4bool G4SteppingManager::GetFirstStep() { return FirstStep; }
0278 
0279 inline G4StepStatus G4SteppingManager::GetfStepStatus() { return fStepStatus; }
0280 
0281 inline G4double G4SteppingManager::GetTempInitVelocity() { return TempInitVelocity; }
0282 
0283 inline G4double G4SteppingManager::GetTempVelocity() { return TempVelocity; }
0284 
0285 inline G4double G4SteppingManager::GetMass() { return Mass; }
0286 
0287 inline G4double G4SteppingManager::GetsumEnergyChange() { return sumEnergyChange; }
0288 
0289 inline G4VParticleChange* G4SteppingManager::GetfParticleChange() { return fParticleChange; }
0290 
0291 inline G4Track* G4SteppingManager::GetfTrack() { return fTrack; }
0292 
0293 inline G4TrackVector* G4SteppingManager::GetfSecondary() { return fStep->GetfSecondary(); }
0294 
0295 inline G4Step* G4SteppingManager::GetfStep() { return fStep; }
0296 
0297 inline G4StepPoint* G4SteppingManager::GetfPreStepPoint() { return fPreStepPoint; }
0298 
0299 inline G4StepPoint* G4SteppingManager::GetfPostStepPoint() { return fPostStepPoint; }
0300 
0301 inline G4VPhysicalVolume* G4SteppingManager::GetfCurrentVolume() { return fCurrentVolume; }
0302 
0303 inline G4VSensitiveDetector* G4SteppingManager::GetfSensitive() { return fSensitive; }
0304 
0305 inline G4VProcess* G4SteppingManager::GetfCurrentProcess() { return fCurrentProcess; }
0306 
0307 inline G4ProcessVector* G4SteppingManager::GetfAtRestDoItVector() { return fAtRestDoItVector; }
0308 
0309 inline G4ProcessVector* G4SteppingManager::GetfAlongStepDoItVector()
0310 {
0311   return fAlongStepDoItVector;
0312 }
0313 
0314 inline G4ProcessVector* G4SteppingManager::GetfPostStepDoItVector() { return fPostStepDoItVector; }
0315 
0316 inline G4ProcessVector* G4SteppingManager::GetfAtRestGetPhysIntVector()
0317 {
0318   return fAtRestGetPhysIntVector;
0319 }
0320 
0321 inline G4ProcessVector* G4SteppingManager::GetfAlongStepGetPhysIntVector()
0322 {
0323   return fAlongStepGetPhysIntVector;
0324 }
0325 
0326 inline G4ProcessVector* G4SteppingManager::GetfPostStepGetPhysIntVector()
0327 {
0328   return fPostStepGetPhysIntVector;
0329 }
0330 
0331 inline size_t G4SteppingManager::GetMAXofAtRestLoops() { return MAXofAtRestLoops; }
0332 
0333 inline size_t G4SteppingManager::GetMAXofAlongStepLoops() { return MAXofAlongStepLoops; }
0334 
0335 inline size_t G4SteppingManager::GetMAXofPostStepLoops() { return MAXofPostStepLoops; }
0336 
0337 inline size_t G4SteppingManager::GetfAtRestDoItProcTriggered() { return fAtRestDoItProcTriggered; }
0338 
0339 inline size_t G4SteppingManager::GetfAlongStepDoItProcTriggered()
0340 {
0341   return fAtRestDoItProcTriggered;
0342 }
0343 
0344 inline size_t G4SteppingManager::GetfPostStepDoItProcTriggered()
0345 {
0346   return fPostStepDoItProcTriggered;
0347 }
0348 
0349 inline G4int G4SteppingManager::GetfN2ndariesAtRestDoIt() { return fN2ndariesAtRestDoIt; }
0350 
0351 inline G4int G4SteppingManager::GetfN2ndariesAlongStepDoIt() { return fN2ndariesAlongStepDoIt; }
0352 
0353 inline G4int G4SteppingManager::GetfN2ndariesPostStepDoIt() { return fN2ndariesPostStepDoIt; }
0354 
0355 inline G4Navigator* G4SteppingManager::GetfNavigator() { return fNavigator; }
0356 
0357 inline G4int G4SteppingManager::GetverboseLevel() { return verboseLevel; }
0358 
0359 inline G4SelectedAtRestDoItVector* G4SteppingManager::GetfSelectedAtRestDoItVector()
0360 {
0361   return fSelectedAtRestDoItVector;
0362 }
0363 
0364 inline G4SelectedAlongStepDoItVector* G4SteppingManager::GetfSelectedAlongStepDoItVector()
0365 {
0366   return fSelectedAlongStepDoItVector;
0367 }
0368 
0369 inline G4SelectedPostStepDoItVector* G4SteppingManager::GetfSelectedPostStepDoItVector()
0370 {
0371   return fSelectedPostStepDoItVector;
0372 }
0373 
0374 inline G4double G4SteppingManager::GetfPreviousStepSize() { return fPreviousStepSize; }
0375 
0376 inline const G4TouchableHandle& G4SteppingManager::GetTouchableHandle() { return fTouchableHandle; }
0377 
0378 inline G4SteppingControl G4SteppingManager::GetStepControlFlag() { return StepControlFlag; }
0379 
0380 inline G4double G4SteppingManager::GetphysIntLength() { return physIntLength; }
0381 
0382 inline G4ForceCondition G4SteppingManager::GetfCondition() { return fCondition; }
0383 
0384 inline G4GPILSelection G4SteppingManager::GetfGPILSelection() { return fGPILSelection; }
0385 
0386 inline const G4TrackVector* G4SteppingManager::GetSecondary() const
0387 {
0388   return fStep->GetSecondary();
0389 }
0390 
0391 inline void G4SteppingManager::SetNavigator(G4Navigator* value) { fNavigator = value; }
0392 
0393 inline void G4SteppingManager::SetUserAction(G4UserSteppingAction* apAction)
0394 {
0395   fUserSteppingAction = apAction;
0396 }
0397 
0398 inline G4UserSteppingAction* G4SteppingManager::GetUserAction() { return fUserSteppingAction; }
0399 
0400 inline G4Track* G4SteppingManager::GetTrack() const { return fTrack; }
0401 
0402 inline void G4SteppingManager::SetVerboseLevel(G4int vLevel) { verboseLevel = vLevel; }
0403 
0404 inline void G4SteppingManager::SetVerbose(G4VSteppingVerbose* yourVerbose)
0405 {
0406   fVerbose = yourVerbose;
0407 }
0408 
0409 inline G4Step* G4SteppingManager::GetStep() const { return fStep; }
0410 
0411 inline G4double G4SteppingManager::CalculateSafety()
0412 {
0413   return std::max(
0414     endpointSafety - (endpointSafOrigin - fPostStepPoint->GetPosition()).mag(), kCarTolerance);
0415 }
0416 
0417 #endif