Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:33

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 //
0027 //
0028 //
0029 // class G4ITSafetyHelper
0030 //
0031 // Class description:
0032 //
0033 // G4ITSafetyHelper is a duplicated version of G4SafetyHelper
0034 // This class is a helper for physics processes which require 
0035 // knowledge of the safety, and the step size for the 'mass' geometry
0036 
0037 // First version:  J. Apostolakis,  July 5th, 2006
0038 // Modified:
0039 //  10.04.07 V.Ivanchenko  Use unique G4ITSafetyHelper
0040 // --------------------------------------------------------------------
0041 
0042 #ifndef G4ITSAFETYHELPER_HH
0043 #define G4ITSAFETYHELPER_HH 1
0044 
0045 #include <vector>
0046 
0047 #include "G4Types.hh"
0048 #include "G4ThreeVector.hh"
0049 #include "G4ITNavigator.hh"
0050 #include "G4TrackState.hh"
0051 
0052 class G4PathFinder;
0053 
0054 class G4ITSafetyHelper : public G4TrackStateDependent<G4ITSafetyHelper>
0055 {
0056 public:
0057   // with description
0058   G4ITSafetyHelper();
0059   ~G4ITSafetyHelper() override;
0060   //
0061   // Constructor and destructor
0062 
0063   G4double CheckNextStep(const G4ThreeVector& position,
0064                          const G4ThreeVector& direction,
0065                          const G4double currentMaxStep,
0066                          G4double& newSafety);
0067   //
0068   // Return linear step for mass geometry
0069 
0070   G4double ComputeSafety(const G4ThreeVector& pGlobalPoint,
0071                          G4double maxRadius = DBL_MAX); // Radius of interest
0072   //
0073   // Return safety for all geometries.
0074   //
0075   //  The 2nd argument is the radius of your interest (e.g. maximum displacement )
0076   //    Giving this you can reduce the average computational cost.
0077   //  If the second argument is not given, this is the real isotropic safety
0078 
0079   void Locate(const G4ThreeVector& pGlobalPoint,
0080               const G4ThreeVector& direction);
0081   //
0082   // Locate the point for all geometries
0083 
0084   void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
0085   //
0086   // Relocate the point in the volume of interest
0087 
0088   inline void EnableParallelNavigation(G4bool parallel);
0089   //
0090   //  To have parallel worlds considered, must be true.
0091   //  Alternative is to use single (mass) Navigator directly
0092 
0093   void InitialiseNavigator();
0094   //
0095   // Check for new navigator for tracking, and reinitialise pointer
0096 
0097   G4int SetVerboseLevel( G4int lev )
0098   { G4int oldlv= fVerbose; fVerbose= lev; return oldlv;}
0099 
0100   inline G4VPhysicalVolume* GetWorldVolume();
0101   inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
0102 
0103 public: // without description
0104 
0105   void InitialiseHelper();
0106 
0107 private:
0108 
0109   G4PathFinder* fpPathFinder;
0110   G4ITNavigator* fpMassNavigator;
0111   G4int fMassNavigatorId;
0112 
0113   G4bool fUseParallelGeometries{false};
0114   // Flag whether to use PathFinder or single (mass) Navigator directly
0115   G4bool fFirstCall{true};
0116   // Flag of first call
0117   G4int fVerbose{0};
0118   // Whether to print warning in case of move outside safety
0119 
0120 public:
0121   // State used during tracking -- for optimisation
0122   class State
0123   {
0124     friend class G4ITSafetyHelper;
0125     G4ThreeVector fLastSafetyPosition;
0126     G4double fLastSafety{0.0};
0127 
0128   public:
0129     State() :
0130     fLastSafetyPosition(0.0,0.0,0.0)
0131     {}
0132 
0133     virtual ~State()
0134     = default;
0135   };
0136 
0137   // const G4double  fRecomputeFactor;
0138   // parameter for further optimisation:
0139   // if ( move < fact*safety )  do fast recomputation of safety
0140   // End State (tracking)
0141 };
0142 
0143 RegisterTrackState(G4ITSafetyHelper, State)
0144 
0145 // Inline definitions
0146 
0147 inline
0148 void G4ITSafetyHelper::EnableParallelNavigation(G4bool parallel)
0149 {
0150   fUseParallelGeometries = parallel;
0151 }
0152 
0153 inline G4VPhysicalVolume* G4ITSafetyHelper::GetWorldVolume()
0154 {
0155   return fpMassNavigator->GetWorldVolume();
0156 }
0157 
0158 inline
0159 void G4ITSafetyHelper::SetCurrentSafety(G4double val, const G4ThreeVector& pos)
0160 {
0161   fpTrackState->fLastSafety = val;
0162   fpTrackState->fLastSafetyPosition = pos;
0163 }
0164 
0165 #endif