Geant4  10.02.p01
G4PropagatorInField.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: G4PropagatorInField.hh 90009 2015-05-08 07:42:39Z gcosmo $
28 //
29 //
30 // Class G4PropagatorInField
31 //
32 // class description:
33 //
34 // This class performs the navigation/propagation of a particle/track
35 // in a magnetic field. The field is in general non-uniform.
36 // For the calculation of the path, it relies on the class G4ChordFinder.
37 //
38 // Key Method: ComputeStep(..)
39 
40 // History:
41 // -------
42 // 25.10.96 John Apostolakis, design and implementation
43 // 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
44 // 8.11.02 John Apostolakis, changes to enable use of safety in intersecting
45 // ---------------------------------------------------------------------------
46 
47 #ifndef G4PropagatorInField_hh
48 #define G4PropagatorInField_hh 1
49 
50 #include "G4Types.hh"
51 
52 #include <vector>
53 
54 #include "G4FieldTrack.hh"
55 #include "G4FieldManager.hh"
57 
58 class G4ChordFinder;
59 
60 class G4Navigator;
61 class G4VPhysicalVolume;
63 
65 {
66 
67  public: // with description
68 
69  G4PropagatorInField( G4Navigator *theNavigator,
70  G4FieldManager *detectorFieldMgr,
71  G4VIntersectionLocator *vLocator=0 );
73 
74  G4double ComputeStep( G4FieldTrack &pFieldTrack,
75  G4double pCurrentProposedStepLength,
76  G4double &pNewSafety,
77  G4VPhysicalVolume *pPhysVol=0 );
78  // Compute the next geometric Step
79 
80  inline G4ThreeVector EndPosition() const;
81  inline G4ThreeVector EndMomentumDir() const;
82  inline G4bool IsParticleLooping() const;
83  // Return the state after the Step
84 
85  inline G4double GetEpsilonStep() const;
86  // Relative accuracy for current Step (Calc.)
87  inline void SetEpsilonStep(G4double newEps);
88  // The ratio DeltaOneStep()/h_current_step
89 
91  // Set (and return) the correct field manager (global or local),
92  // if it exists.
93  // Should be called before ComputeStep is called;
94  // - currently, ComputeStep will call it, if it has not been called.
95 
96  inline G4ChordFinder* GetChordFinder();
97 
98  G4int SetVerboseLevel( G4int verbose );
99  inline G4int GetVerboseLevel() const;
100  inline G4int Verbose() const;
101 
102  inline void SetVerboseTrace( G4bool enable ) { fVerbTracePiF = enable; }
103  inline G4bool GetVerboseTrace() { return fVerbTracePiF; }
104  // Tracing key parts of Compute Step
105 
106  inline G4int GetMaxLoopCount() const;
107  inline void SetMaxLoopCount( G4int new_max );
108  // A maximum for the number of steps that a (looping) particle can take.
109 
110  void printStatus( const G4FieldTrack& startFT,
111  const G4FieldTrack& currentFT,
112  G4double requestStep,
113  G4double safety,
114  G4int step,
115  G4VPhysicalVolume* startVolume);
116  // Print Method - useful mostly for debugging.
117 
118  inline G4FieldTrack GetEndState() const;
119 
120  inline G4double GetMinimumEpsilonStep() const; // Min for relative accuracy
121  inline void SetMinimumEpsilonStep( G4double newEpsMin ); // of any step
122  inline G4double GetMaximumEpsilonStep() const;
123  inline void SetMaximumEpsilonStep( G4double newEpsMax );
124  // The 4 above methods are now obsolescent but *for now* will work
125  // They are being replaced by same-name methods in G4FieldManager,
126  // allowing the specialisation in different volumes.
127  // Their new behaviour is to change the values for the global field
128  // manager
129 
130  inline void SetLargestAcceptableStep( G4double newBigDist );
132 
134  // Set the filter that examines & stores 'intermediate'
135  // curved trajectory points. Currently only position is stored.
136 
137  std::vector<G4ThreeVector>* GimmeTrajectoryVectorAndForgetIt() const;
138  // Access the points which have passed by the filter.
139  // Responsibility for deleting the points lies with the client.
140  // This method MUST BE called exactly ONCE per step.
141 
142  void ClearPropagatorState();
143  // Clear all the State of this class and its current associates
144  // --> the current field manager & chord finder will also be called
145 
146  inline void SetDetectorFieldManager( G4FieldManager* newGlobalFieldManager );
147  // Update this (dangerous) state -- for the time being
148 
149  inline void SetUseSafetyForOptimization( G4bool );
151  // Toggle & view parameter for using safety to discard
152  // unneccesary calls to navigator (thus 'optimising' performance)
153  inline G4bool IntersectChord( const G4ThreeVector& StartPointA,
154  const G4ThreeVector& EndPointB,
155  G4double &NewSafety,
156  G4double &LinearStepLength,
157  G4ThreeVector &IntersectionPoint);
158  // Intersect the chord from StartPointA to EndPointB
159  // and return whether an intersection occurred
160  // NOTE : SAFETY IS CHANGED
161 
165 
167  inline void SetIntersectionLocator(G4VIntersectionLocator *pLocator );
168  // Change or get the object which calculates the exact
169  // intersection point with the next boundary
170 
171  public: // without description
172 
173  inline G4double GetDeltaIntersection() const;
174  inline G4double GetDeltaOneStep() const;
175 
178  // Auxiliary methods - their results can/will change during propagation
179 
180  inline void SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator );
182 
183  inline void SetThresholdNoZeroStep( G4int noAct,
184  G4int noHarsh,
185  G4int noAbandon );
186  inline G4int GetThresholdNoZeroSteps( G4int i );
187 
188  inline G4double GetZeroStepThreshold();
189  inline void SetZeroStepThreshold( G4double newLength );
190 
192  // Update the Locator with parameters from this class
193  // and from current field manager
194 
195  protected: // without description
196 
197  void PrintStepLengthDiagnostic( G4double currentProposedStepLength,
198  G4double decreaseFactor,
199  G4double stepTrial,
200  const G4FieldTrack& aFieldTrack);
201 
202  void ReportLoopingParticle( G4int count, double StepTaken, G4VPhysicalVolume* pPhysVol);
203  void ReportStuckParticle( G4int noZeroSteps, G4double proposedStep, G4double lastTriedStep,
204  G4VPhysicalVolume* physVol );
205  private:
206  // ----------------------------------------------------------------------
207  // DATA Members
208  // ----------------------------------------------------------------------
209 
210  // ==================================================================
211  // INVARIANTS - Must not change during tracking
212 
213  // ** PARAMETERS -----------
215  // Limit for the number of sub-steps taken in one call to ComputeStep
217 
218  // Thresholds for identifying "abnormal" cases - which cause looping
219  G4int fActionThreshold_NoZeroSteps; // Threshold # - above it act
220  G4int fSevereActionThreshold_NoZeroSteps; // Threshold # to act harshly
221  G4int fAbandonThreshold_NoZeroSteps; // Threshold # to abandon
223  // Threshold *length* for counting of tiny or 'zero' steps
224 
226  // Maximum size of a step - for optimization (and to avoid problems)
227  // ** End of PARAMETERS -----
228 
230  // Geometrical tolerance defining surface thickness
231 
232  G4bool fAllocatedLocator; // Book-keeping
233 
234  // --------------------------------------------------------
235  // ** Dependent Objects - to which work is delegated
236 
238  // The Field Manager of the whole Detector. (default)
239 
241  // Refines candidate intersection
242 
244  // The filter encapsulates the algorithm which selects which
245  // intermediate points should be stored in a trajectory.
246  // When it is NULL, no intermediate points will be stored.
247  // Else PIF::ComputeStep must submit (all) intermediate
248  // points it calculates, to this filter. (jacek 04/11/2002)
249 
251  // Set externally - only by tracking / run manager
252  //
253  // ** End of Dependent Objects ----------------------------
254 
255  // End of INVARIANTS
256  // ==================================================================
257 
258  // STATE information
259  // -----------------
261  // The Field Manager of the current volume (may be the global)
262  G4bool fSetFieldMgr; // Has it been set for the current step
263 
264  // Parameters of current step
265  G4double fEpsilonStep; // Relative accuracy of current Step
266  G4FieldTrack End_PointAndTangent; // End point storage
268  G4int fNoZeroStep; // Count of zero Steps
269 
270  // State used for Optimisation
273  // Previous step information -- for use in adjust step size
276  // Last safety origin & value: for optimisation
277 
280  // For debugging purposes
281 
285 };
286 
287 // Inline methods.
288 // *******************************
289 
290 #include "G4PropagatorInField.icc"
291 
292 #endif
G4double GetZeroStepThreshold()
G4FieldManager * fCurrentFieldMgr
void SetEpsilonStep(G4double newEps)
void SetNavigatorForPropagating(G4Navigator *SimpleOrMultiNavigator)
G4int GetMaxLoopCount() const
G4Navigator * GetNavigatorForPropagating()
void SetIntersectionLocator(G4VIntersectionLocator *pLocator)
G4VCurvedTrajectoryFilter * fpTrajectoryFilter
std::vector< G4ThreeVector > * GimmeTrajectoryVectorAndForgetIt() const
CLHEP::Hep3Vector G4ThreeVector
G4int Verbose() const
void SetThresholdNoZeroStep(G4int noAct, G4int noHarsh, G4int noAbandon)
void PrintStepLengthDiagnostic(G4double currentProposedStepLength, G4double decreaseFactor, G4double stepTrial, const G4FieldTrack &aFieldTrack)
G4ThreeVector EndPosition() const
void SetUseSafetyForOptimization(G4bool)
G4double GetDeltaIntersection() const
G4ThreeVector EndMomentumDir() const
G4PropagatorInField(G4Navigator *theNavigator, G4FieldManager *detectorFieldMgr, G4VIntersectionLocator *vLocator=0)
int G4int
Definition: G4Types.hh:78
G4ThreeVector fPreviousSftOrigin
void SetVerboseTrace(G4bool enable)
G4double GetMaximumEpsilonStep() const
G4int SetVerboseLevel(G4int verbose)
G4FieldTrack GetEndState() const
G4EquationOfMotion * GetCurrentEquationOfMotion()
void ReportLoopingParticle(G4int count, double StepTaken, G4VPhysicalVolume *pPhysVol)
bool G4bool
Definition: G4Types.hh:79
G4int GetVerboseLevel() const
G4bool GetUseSafetyForOptimization()
void SetZeroStepThreshold(G4double newLength)
G4double GetDeltaOneStep() const
G4FieldManager * FindAndSetFieldManager(G4VPhysicalVolume *pCurrentPhysVol)
void SetMaxLoopCount(G4int new_max)
G4double ComputeStep(G4FieldTrack &pFieldTrack, G4double pCurrentProposedStepLength, G4double &pNewSafety, G4VPhysicalVolume *pPhysVol=0)
G4int GetThresholdNoZeroSteps(G4int i)
G4bool IsParticleLooping() const
void ReportStuckParticle(G4int noZeroSteps, G4double proposedStep, G4double lastTriedStep, G4VPhysicalVolume *physVol)
G4ChordFinder * GetChordFinder()
G4FieldManager * GetCurrentFieldManager()
void SetMinimumEpsilonStep(G4double newEpsMin)
G4FieldManager * fDetectorFieldMgr
G4bool IntersectChord(const G4ThreeVector &StartPointA, const G4ThreeVector &EndPointB, G4double &NewSafety, G4double &LinearStepLength, G4ThreeVector &IntersectionPoint)
void SetTrajectoryFilter(G4VCurvedTrajectoryFilter *filter)
G4double GetMinimumEpsilonStep() const
G4FieldTrack End_PointAndTangent
void SetLargestAcceptableStep(G4double newBigDist)
double G4double
Definition: G4Types.hh:76
void SetDetectorFieldManager(G4FieldManager *newGlobalFieldManager)
void SetMaximumEpsilonStep(G4double newEpsMax)
G4double GetLargestAcceptableStep()
G4VIntersectionLocator * GetIntersectionLocator()
G4double GetEpsilonStep() const
G4VIntersectionLocator * fIntersectionLocator
void printStatus(const G4FieldTrack &startFT, const G4FieldTrack &currentFT, G4double requestStep, G4double safety, G4int step, G4VPhysicalVolume *startVolume)