Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4ITSafetyHelper.hh
Go to the documentation of this file.
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 // $Id: G4ITSafetyHelper.hh 72309 2013-07-15 15:52:17Z gcosmo $
28 //
29 //
30 // class G4ITSafetyHelper
31 //
32 // Class description:
33 //
34 // G4ITSafetyHelper is a duplicated version of G4SafetyHelper
35 // This class is a helper for physics processes which require
36 // knowledge of the safety, and the step size for the 'mass' geometry
37 
38 // First version: J. Apostolakis, July 5th, 2006
39 // Modified:
40 // 10.04.07 V.Ivanchenko Use unique G4ITSafetyHelper
41 // --------------------------------------------------------------------
42 
43 #ifndef G4ITSAFETYHELPER_HH
44 #define G4ITSAFETYHELPER_HH 1
45 
46 #include <vector>
47 
48 #include "G4Types.hh"
49 #include "G4ThreeVector.hh"
50 #include "G4ITNavigator.hh"
51 #include "G4TrackState.hh"
52 
53 class G4PathFinder;
54 
55 class G4ITSafetyHelper : public G4TrackStateDependent<G4ITSafetyHelper>
56 {
57 public:
58  // with description
61  //
62  // Constructor and destructor
63 
65  const G4ThreeVector& direction,
66  const G4double currentMaxStep,
67  G4double& newSafety);
68  //
69  // Return linear step for mass geometry
70 
71  G4double ComputeSafety(const G4ThreeVector& pGlobalPoint,
72  G4double maxRadius = DBL_MAX); // Radius of interest
73  //
74  // Return safety for all geometries.
75  //
76  // The 2nd argument is the radius of your interest (e.g. maximum displacement )
77  // Giving this you can reduce the average computational cost.
78  // If the second argument is not given, this is the real isotropic safety
79 
80  void Locate(const G4ThreeVector& pGlobalPoint,
81  const G4ThreeVector& direction);
82  //
83  // Locate the point for all geometries
84 
85  void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
86  //
87  // Relocate the point in the volume of interest
88 
89  inline void EnableParallelNavigation(G4bool parallel);
90  //
91  // To have parallel worlds considered, must be true.
92  // Alternative is to use single (mass) Navigator directly
93 
94  void InitialiseNavigator();
95  //
96  // Check for new navigator for tracking, and reinitialise pointer
97 
99  { G4int oldlv= fVerbose; fVerbose= lev; return oldlv;}
100 
102  inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
103 
104 public: // without description
105 
106  void InitialiseHelper();
107 
108 private:
109 
110  G4PathFinder* fpPathFinder;
111  G4ITNavigator* fpMassNavigator;
112  G4int fMassNavigatorId;
113 
114  G4bool fUseParallelGeometries;
115  // Flag whether to use PathFinder or single (mass) Navigator directly
116  G4bool fFirstCall;
117  // Flag of first call
118  G4int fVerbose;
119  // Whether to print warning in case of move outside safety
120 
121 public:
122  // State used during tracking -- for optimisation
123  class State
124  {
125  friend class G4ITSafetyHelper;
126  G4ThreeVector fLastSafetyPosition;
127  G4double fLastSafety;
128 
129  public:
130  State() :
131  fLastSafetyPosition(0.0,0.0,0.0),
132  fLastSafety(0.0)
133  {}
134 
135  virtual ~State()
136  {}
137  };
138 
139  // const G4double fRecomputeFactor;
140  // parameter for further optimisation:
141  // if ( move < fact*safety ) do fast recomputation of safety
142  // End State (tracking)
143 };
144 
146 
147 // Inline definitions
148 
149 inline
151 {
152  fUseParallelGeometries = parallel;
153 }
154 
156 {
157  return fpMassNavigator->GetWorldVolume();
158 }
159 
160 inline
162 {
163  fpTrackState->fLastSafety = val;
164  fpTrackState->fLastSafetyPosition = pos;
165 }
166 
167 #endif
#define inline
Definition: internal.h:71
#define RegisterTrackState(CLASS, STATE)
void EnableParallelNavigation(G4bool parallel)
G4double CheckNextStep(const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety)
#define State(X)
void ReLocateWithinVolume(const G4ThreeVector &pGlobalPoint)
int G4int
Definition: G4Types.hh:78
G4int SetVerboseLevel(G4int lev)
bool G4bool
Definition: G4Types.hh:79
G4double ComputeSafety(const G4ThreeVector &pGlobalPoint, G4double maxRadius=DBL_MAX)
void Locate(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction)
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83
static const G4double pos
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
G4VPhysicalVolume * GetWorldVolume()