Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4SafetyHelper.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: G4SafetyHelper.hh 81060 2014-05-20 09:12:39Z gcosmo $
28 //
29 //
30 // class G4SafetyHelper
31 //
32 // Class description:
33 //
34 // This class is a helper for physics processes which require
35 // knowledge of the safety, and the step size for the 'mass' geometry
36 
37 // First version: J. Apostolakis, July 5th, 2006
38 // Modified:
39 // 10.04.07 V.Ivanchenko Use unique G4SafetyHelper
40 // --------------------------------------------------------------------
41 
42 #ifndef G4SAFETYHELPER_HH
43 #define G4SAFETYHELPER_HH 1
44 
45 #include <vector>
46 
47 #include "G4Types.hh"
48 #include "G4ThreeVector.hh"
49 #include "G4Navigator.hh"
50 
51 class G4PathFinder;
52 
54 {
55 public: // with description
56 
57  G4SafetyHelper();
59  //
60  // Constructor and destructor
61 
63  const G4ThreeVector& direction,
64  const G4double currentMaxStep,
65  G4double& newSafety );
66  //
67  // Return linear step for mass geometry
68 
69  G4double ComputeSafety( const G4ThreeVector& pGlobalPoint,
70  G4double maxRadius=DBL_MAX ); // Radius of interest
71  //
72  // Return safety for all geometries.
73  //
74  // The 2nd argument is the radius of your interest (e.g. maximum displacement )
75  // Giving this you can reduce the average computational cost.
76  // If the second argument is not given, this is the real isotropic safety
77 
78  void Locate(const G4ThreeVector& pGlobalPoint,
79  const G4ThreeVector& direction);
80  //
81  // Locate the point for all geometries
82 
83  void ReLocateWithinVolume(const G4ThreeVector& pGlobalPoint );
84  //
85  // Relocate the point in the volume of interest
86 
87 
89  const G4ThreeVector &pGlobalPoint,
90  const G4ThreeVector &pDirection,
91  const G4double pCurrentProposedStepLength,
92  G4double *prDistance,
93  G4double *prNewSafety= 0)const;
94  // Trial method for checking potential displacement for MS
95  // Check new Globalpoint, to see whether it is in current volume
96  // (mother) and not in potential entering daughter.
97  // If in mother, check distance to boundary along pDirection.
98  // If in entering daughter, check distance back to boundary.
99  // NOTE:
100  // Can be called only after ComputeStep is called - before ReLocation
101  // Deals only with current volume (and potentially entered)
102 
103  inline void EnableParallelNavigation(G4bool parallel);
104  //
105  // To have parallel worlds considered, must be true.
106  // Alternative is to use single (mass) Navigator directly
107 
108  void InitialiseNavigator();
109  //
110  // Check for new navigator for tracking, and reinitialise pointer
111 
112  G4int SetVerboseLevel( G4int lev ) { G4int oldlv= fVerbose; fVerbose= lev; return oldlv; }
113 
115  inline void SetCurrentSafety(G4double val, const G4ThreeVector& pos);
116 
117 public: // without description
118 
119  void InitialiseHelper();
120 
121 private:
122 
123  G4PathFinder* fpPathFinder;
124  G4Navigator* fpMassNavigator;
125  G4int fMassNavigatorId;
126 
127  G4bool fUseParallelGeometries;
128  // Flag whether to use PathFinder or single (mass) Navigator directly
129  G4bool fFirstCall;
130  // Flag of first call
131  G4int fVerbose;
132  // Whether to print warning in case of move outside safety
133 
134  // State used during tracking -- for optimisation
135  G4ThreeVector fLastSafetyPosition;
136  G4double fLastSafety;
137  // const G4double fRecomputeFactor;
138  // parameter for further optimisation:
139  // if ( move < fact*safety ) do fast recomputation of safety
140  // End State (tracking)
141 };
142 
143 // Inline definitions
144 
145 inline
147 {
148  fUseParallelGeometries = parallel;
149 }
150 
151 inline
153 {
154  return fpMassNavigator->GetWorldVolume();
155 }
156 
157 inline
159 {
160  fLastSafety = val;
161  fLastSafetyPosition = pos;
162 }
163 
164 #endif
void ReLocateWithinVolume(const G4ThreeVector &pGlobalPoint)
void InitialiseHelper()
G4int SetVerboseLevel(G4int lev)
int G4int
Definition: G4Types.hh:78
void Locate(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &direction)
bool G4bool
Definition: G4Types.hh:79
void EnableParallelNavigation(G4bool parallel)
G4VPhysicalVolume * GetWorldVolume()
G4double ComputeSafety(const G4ThreeVector &pGlobalPoint, G4double maxRadius=DBL_MAX)
G4double CheckNextStep(const G4ThreeVector &position, const G4ThreeVector &direction, const G4double currentMaxStep, G4double &newSafety)
void SetCurrentSafety(G4double val, const G4ThreeVector &pos)
double G4double
Definition: G4Types.hh:76
G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
void InitialiseNavigator()
#define DBL_MAX
Definition: templates.hh:83
G4VPhysicalVolume * GetWorldVolume() const
static const G4double pos