Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
G4PathFinder.hh
이 파일의 문서화 페이지로 가기
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 // $Id: G4PathFinder.hh 109355 2018-04-12 08:08:58Z gcosmo $
27 //
28 // class G4PathFinder
29 //
30 // Class description:
31 //
32 // This class directs the lock-stepped propagation of a track in the
33 // 'mass' and other parallel geometries. It ensures that tracking
34 // in a magnetic field sees these parallel geometries at each trial step,
35 // and that the earliest boundary limits the step.
36 //
37 // For the movement in field, it relies on the class G4PropagatorInField
38 //
39 // History:
40 // -------
41 // 7.10.05 John Apostolakis, Draft design
42 // 26.04.06 John Apostolakis, Revised design and first implementation
43 // ---------------------------------------------------------------------------
44 #ifndef G4PATHFINDER_HH
45 #define G4PATHFINDER_HH 1
46 
47 #include <vector>
48 #include "G4Types.hh"
49 
50 #include "G4FieldTrack.hh"
51 
53 class G4Navigator;
54 
55 #include "G4TouchableHandle.hh"
56 #include "G4FieldTrack.hh"
57 #include "G4MultiNavigator.hh"
58 
60 
62 {
63 
64  public: // with description
65 
66  static G4PathFinder* GetInstance();
67  //
68  // Retrieve singleton instance and create it if not existing.
69 
71  //
72  // Retrieve singleton instance pointer.
73 
74  G4double ComputeStep( const G4FieldTrack &pFieldTrack,
75  G4double pCurrentProposedStepLength,
76  G4int navigatorId, // Identifies the geometry
77  G4int stepNo, // See next step/check
78  G4double &pNewSafety, // Only for this geometry
79  ELimited &limitedStep,
80  G4FieldTrack &EndState,
81  G4VPhysicalVolume* currentVolume );
82  //
83  // Compute the next geometric Step -- Curved or linear
84  // If it is called with a larger 'stepNo' it will execute a new step;
85  // if 'stepNo' is same as last call, then the results for
86  // the geometry with Id. number 'navigatorId' will be returned.
87 
88  void Locate( const G4ThreeVector& position,
89  const G4ThreeVector& direction,
90  G4bool relativeSearch=true);
91  //
92  // Make primary relocation of global point in all navigators,
93  // and update them.
94 
95  void ReLocate( const G4ThreeVector& position );
96  //
97  // Make secondary relocation of global point (within safety only)
98  // in all navigators, and update them.
99 
100  void PrepareNewTrack( const G4ThreeVector& position,
101  const G4ThreeVector& direction,
102  G4VPhysicalVolume* massStartVol=0);
103  //
104  // Check and cache set of active navigators.
105 
106  void EndTrack();
107  // Signal end of tracking of current track.
108  // Reset internal state
109  // Inform TransportationManager to use 'ordinary' Navigator
110 
112  inline G4VPhysicalVolume* GetLocatedVolume( G4int navId ) const;
113 
115  const G4ThreeVector &pGlobalPoint,
116  const G4ThreeVector &pDirection,
117  const G4double pCurrentProposedStepLength,
118  G4double *prDistance,
119  G4double *prNewSafety= 0)const;
120  // Trial method for checking potential displacement for MS
121 
122  // -----------------------------------------------------------------
123 
124  inline G4bool IsParticleLooping() const;
125 
126  inline G4double GetCurrentSafety() const;
127  // Minimum value of safety after last ComputeStep
128  inline G4double GetMinimumStep() const;
129  // Get the minimum step size from the last ComputeStep call
130  // - in case full step is taken, this is kInfinity
131  inline unsigned int GetNumberGeometriesLimitingStep() const;
132 
133  G4double ComputeSafety( const G4ThreeVector& globalPoint);
134  // Recompute safety for the relevant point the endpoint of the last step!!
135  // Maintain vector of individual safety values (for next method)
136 
137  G4double ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint );
138  // Obtain safety for navigator/geometry navId for last point 'computed'
139  // --> last point for which ComputeSafety was called
140  // Returns the point (center) for which this safety is valid
141 
142  void EnableParallelNavigation( G4bool enableChoice=true );
143  //
144  // Must call it to ensure that PathFinder is prepared,
145  // especially for curved tracks. If true it switches PropagatorInField
146  // to use MultiNavigator. Must call it with false to undo (=PiF use
147  // Navigator for tracking!)
148 
149  inline G4int SetVerboseLevel(G4int lev=-1);
150 
151  public: // with description
152 
153  inline G4int GetMaxLoopCount() const;
154  inline void SetMaxLoopCount( G4int new_max );
155  //
156  // A maximum for the number of steps that a (looping) particle can take.
157 
158  public: // without description
159 
160  inline void MovePoint();
161  //
162  // Signal that location will be moved -- internal use primarily
163 
164  // To provide best compatibility between Coupled and Old Transportation
165  // the next two methods are provided:
166  G4double LastPreSafety( G4int navId, G4ThreeVector& globalCenterPoint, G4double& minSafety );
167  // Obtain last safety needed in ComputeStep (for geometry navId)
168  // --> last point at which ComputeStep recalculated safety
169  // Returns the point (center) for which this safety is valid
170  // and also the minimum safety over all navigators (ie full)
171 
173  // Tell PathFinder to copy PostStep Safety to PreSafety (for use at next step)
174 
176  // Convert ELimited to string
177 
178  ~G4PathFinder();
179  // Destructor
180 
181  protected: // without description
182 
183  G4double DoNextLinearStep( const G4FieldTrack &FieldTrack,
184  G4double proposedStepLength);
185 
186  G4double DoNextCurvedStep( const G4FieldTrack &FieldTrack,
187  G4double proposedStepLength,
188  G4VPhysicalVolume* pCurrentPhysVolume);
189 
190  void WhichLimited();
191  void PrintLimited();
192  //
193  // Print key details out - for debugging
194 
195  // void ClearState();
196  //
197  // Clear all the State of this class and its current associates
198 
200  //
201  // Whether use safety to discard unneccesary calls to navigator
202 
203  void ReportMove( const G4ThreeVector& OldV, const G4ThreeVector& NewV, const G4String& Quantity ) const;
204  // Helper method to report movement (likely of initial point)
205 
206  protected:
207 
208  G4PathFinder(); // Singleton
209 
210  inline G4Navigator* GetNavigator(G4int n) const;
211 
212  private:
213 
214  // ----------------------------------------------------------------------
215  // DATA Members
216  // ----------------------------------------------------------------------
217 
219  //
220  // Object that enables G4PropagatorInField to see many geometries
221 
223  G4bool fNewTrack; // Flag a new track (ensure first step)
224 
225  static const G4int fMaxNav = 16; // rename to kMaxNoNav ??
226 
227  // Global state (retained during stepping for one track)
228 
230 
231  // State changed in a step computation
232 
236  G4int fNoGeometriesLimiting; // How many processes contribute to limit
237 
238  G4ThreeVector fPreSafetyLocation; // last initial position for which safety evaluated
239  G4double fPreSafetyMinValue; // /\ corresponding value of full safety
240  G4double fPreSafetyValues[ fMaxNav ]; // Safeties for the above point
241  // This part of the state can be retained for several calls --> CARE
242 
243  G4ThreeVector fPreStepLocation; // point where last ComputeStep called
244  G4double fMinSafety_PreStepPt; // /\ corresponding value of full safety
245  G4double fCurrentPreStepSafety[ fMaxNav ]; // Safeties for the above point
246  // This changes at each step,
247  // so it can differ when steps inside min-safety are made
248 
249  G4bool fPreStepCenterRenewed; // Whether PreSafety coincides with PreStep point
250 
251  G4double fMinStep; // As reported by Navigators -- can be kInfinity
252  G4double fTrueMinStep; // Corrected in case >= proposed
253 
254  // State after calling 'locate'
255 
258 
259  // State after calling 'ComputeStep' (others member variables will be affected)
260  G4FieldTrack fEndState; // Point, velocity, ... at proposed step end
261  G4bool fFieldExertedForce; // In current proposed step
262 
263  G4bool fRelocatedPoint; // Signals that point was or is being moved
264  // from the position of the last location
265  // or the endpoint resulting from ComputeStep
266  // -- invalidates fEndState
267 
268  // State for 'ComputeSafety' and related methods
269  G4ThreeVector fSafetyLocation; // point where ComputeSafety is called
270  G4double fMinSafety_atSafLocation; // /\ corresponding value of safety
271  G4double fNewSafetyComputed[ fMaxNav ]; // Safeties for last ComputeSafety
272 
273  // State for Step numbers
275 
276  G4int fVerboseLevel; // For debuging purposes
277 
278  G4TransportationManager* fpTransportManager; // Cache for frequent use
280 
282 
284 };
285 
286 // ********************************************************************
287 // Inline methods.
288 // ********************************************************************
289 
291 {
292  G4VPhysicalVolume* vol=0;
293  if( (navId < fMaxNav) && (navId >=0) ) { vol= fLocatedVolume[navId]; }
294  return vol;
295 }
296 
298 {
299  G4int old= fVerboseLevel; fVerboseLevel= newLevel; return old;
300 }
301 
303 {
304  return fMinStep;
305 }
306 
308 {
309  unsigned int noGeometries=fNoGeometriesLimiting;
310  return noGeometries;
311 }
312 
314 {
315  return fMinSafety_PreStepPt;
316 }
317 
319 {
320  fRelocatedPoint= true;
321 }
322 
324 {
325  if( (n>fNoActiveNavigators)||(n<0)) { n=0; }
326  return fpNavigator[n];
327 }
328 
329 inline G4double G4PathFinder::ObtainSafety( G4int navId, G4ThreeVector& globalCenterPoint )
330 {
331  globalCenterPoint= fSafetyLocation;
332  // navId = std::min( navId, fMaxNav-1 );
333  return fNewSafetyComputed[ navId ];
334 }
335 
337  G4ThreeVector& globalCenterPoint,
338  G4double& minSafety )
339 {
340  globalCenterPoint= fPreSafetyLocation;
341  minSafety= fPreSafetyMinValue;
342  // navId = std::min( navId, fMaxNav-1 );
343  return fPreSafetyValues[ navId ];
344 }
345 #endif
G4VPhysicalVolume * fLocatedVolume[fMaxNav]
G4bool fLimitTruth[fMaxNav]
G4double LastPreSafety(G4int navId, G4ThreeVector &globalCenterPoint, G4double &minSafety)
static G4PathFinder * GetInstanceIfExist()
Definition: G4PathFinder.cc:71
G4double ObtainSafety(G4int navId, G4ThreeVector &globalCenterPoint)
G4bool fPreStepCenterRenewed
G4double fMinStep
G4VPhysicalVolume * GetLocatedVolume(G4int navId) const
G4int fNoActiveNavigators
static const G4int fMaxNav
G4double GetCurrentSafety() const
static G4ThreadLocal G4PathFinder * fpPathFinder
G4Navigator * fpNavigator[fMaxNav]
G4ThreeVector fSafetyLocation
G4int fCurrentStepNo
G4bool RecheckDistanceToCurrentBoundary(const G4ThreeVector &pGlobalPoint, const G4ThreeVector &pDirection, const G4double pCurrentProposedStepLength, G4double *prDistance, G4double *prNewSafety=0) const
void WhichLimited()
void ReLocate(const G4ThreeVector &position)
void SetMaxLoopCount(G4int new_max)
G4double DoNextLinearStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength)
#define G4ThreadLocal
Definition: tls.hh:69
G4PropagatorInField * fpFieldPropagator
G4double kCarTolerance
G4bool UseSafetyForOptimization(G4bool)
G4bool IsParticleLooping() const
void EnableParallelNavigation(G4bool enableChoice=true)
G4ThreeVector fPreStepLocation
G4FieldTrack fEndState
G4bool fRelocatedPoint
G4double ComputeStep(const G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4int navigatorId, G4int stepNo, G4double &pNewSafety, ELimited &limitedStep, G4FieldTrack &EndState, G4VPhysicalVolume *currentVolume)
G4Navigator * GetNavigator(G4int n) const
G4String & LimitedString(ELimited lim)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
G4double DoNextCurvedStep(const G4FieldTrack &FieldTrack, G4double proposedStepLength, G4VPhysicalVolume *pCurrentPhysVolume)
void MovePoint()
G4double fPreSafetyValues[fMaxNav]
void PushPostSafetyToPreSafety()
G4double fCurrentPreStepSafety[fMaxNav]
G4TouchableHandle CreateTouchableHandle(G4int navId) const
G4ThreeVector fPreSafetyLocation
ELimited fLimitedStep[fMaxNav]
unsigned int GetNumberGeometriesLimitingStep() const
G4int GetMaxLoopCount() const
G4ThreeVector fLastLocatedPosition
G4bool fFieldExertedForce
G4double fCurrentStepSize[fMaxNav]
void Locate(const G4ThreeVector &position, const G4ThreeVector &direction, G4bool relativeSearch=true)
G4double fNewSafetyComputed[fMaxNav]
G4double fMinSafety_atSafLocation
ELimited
void PrintLimited()
int G4int
Definition: G4Types.hh:78
G4bool fNewTrack
void ReportMove(const G4ThreeVector &OldV, const G4ThreeVector &NewV, const G4String &Quantity) const
G4int fNoGeometriesLimiting
G4int SetVerboseLevel(G4int lev=-1)
G4MultiNavigator * fpMultiNavigator
void PrepareNewTrack(const G4ThreeVector &position, const G4ThreeVector &direction, G4VPhysicalVolume *massStartVol=0)
G4TransportationManager * fpTransportManager
G4int fVerboseLevel
Char_t n[5]
G4double GetMinimumStep() const
G4double fTrueMinStep
static G4PathFinder * GetInstance()
Definition: G4PathFinder.cc:57
G4double fPreSafetyMinValue
G4double ComputeSafety(const G4ThreeVector &globalPoint)
G4double fMinSafety_PreStepPt