Geant4  10.01.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 89287 2015-03-31 08:26:25Z 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 G4int GetMaxLoopCount() const;
103  inline void SetMaxLoopCount( G4int new_max );
104  // A maximum for the number of steps that a (looping) particle can take.
105 
106  void printStatus( const G4FieldTrack& startFT,
107  const G4FieldTrack& currentFT,
108  G4double requestStep,
109  G4double safety,
110  G4int step,
111  G4VPhysicalVolume* startVolume);
112  // Print Method - useful mostly for debugging.
113 
114  inline G4FieldTrack GetEndState() const;
115 
116  inline G4double GetMinimumEpsilonStep() const; // Min for relative accuracy
117  inline void SetMinimumEpsilonStep( G4double newEpsMin ); // of any step
118  inline G4double GetMaximumEpsilonStep() const;
119  inline void SetMaximumEpsilonStep( G4double newEpsMax );
120  // The 4 above methods are now obsolescent but *for now* will work
121  // They are being replaced by same-name methods in G4FieldManager,
122  // allowing the specialisation in different volumes.
123  // Their new behaviour is to change the values for the global field
124  // manager
125 
126  inline void SetLargestAcceptableStep( G4double newBigDist );
128 
130  // Set the filter that examines & stores 'intermediate'
131  // curved trajectory points. Currently only position is stored.
132 
133  std::vector<G4ThreeVector>* GimmeTrajectoryVectorAndForgetIt() const;
134  // Access the points which have passed by the filter.
135  // Responsibility for deleting the points lies with the client.
136  // This method MUST BE called exactly ONCE per step.
137 
138  void ClearPropagatorState();
139  // Clear all the State of this class and its current associates
140  // --> the current field manager & chord finder will also be called
141 
142  inline void SetDetectorFieldManager( G4FieldManager* newGlobalFieldManager );
143  // Update this (dangerous) state -- for the time being
144 
145  inline void SetUseSafetyForOptimization( G4bool );
147  // Toggle & view parameter for using safety to discard
148  // unneccesary calls to navigator (thus 'optimising' performance)
149  inline G4bool IntersectChord( const G4ThreeVector& StartPointA,
150  const G4ThreeVector& EndPointB,
151  G4double &NewSafety,
152  G4double &LinearStepLength,
153  G4ThreeVector &IntersectionPoint);
154  // Intersect the chord from StartPointA to EndPointB
155  // and return whether an intersection occurred
156  // NOTE : SAFETY IS CHANGED
157 
159  inline void SetIntersectionLocator(G4VIntersectionLocator *pLocator );
160  // Change or get the object which calculates the exact
161  // intersection point with the next boundary
162 
163  public: // without description
164 
165  inline G4double GetDeltaIntersection() const;
166  inline G4double GetDeltaOneStep() const;
167 
170  // Auxiliary methods - their results can/will change during propagation
171 
172  inline void SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator );
174 
175  inline void SetThresholdNoZeroStep( G4int noAct,
176  G4int noHarsh,
177  G4int noAbandon );
178  inline G4int GetThresholdNoZeroSteps( G4int i );
179 
180  inline G4double GetZeroStepThreshold();
181  inline void SetZeroStepThreshold( G4double newLength );
182 
184  // Update the Locator with parameters from this class
185  // and from current field manager
186 
187  protected: // with description
188 
189  void PrintStepLengthDiagnostic( G4double currentProposedStepLength,
190  G4double decreaseFactor,
191  G4double stepTrial,
192  const G4FieldTrack& aFieldTrack);
193  private:
194  // ----------------------------------------------------------------------
195  // DATA Members
196  // ----------------------------------------------------------------------
197 
198  // ==================================================================
199  // INVARIANTS - Must not change during tracking
200 
201  // ** PARAMETERS -----------
203  // Limit for the number of sub-steps taken in one call to ComputeStep
205 
206  // Thresholds for identifying "abnormal" cases - which cause looping
207  G4int fActionThreshold_NoZeroSteps; // Threshold # - above it act
208  G4int fSevereActionThreshold_NoZeroSteps; // Threshold # to act harshly
209  G4int fAbandonThreshold_NoZeroSteps; // Threshold # to abandon
211  // Threshold *length* for counting of tiny or 'zero' steps
212 
214  // Maximum size of a step - for optimization (and to avoid problems)
215  // ** End of PARAMETERS -----
216 
218  // Geometrical tolerance defining surface thickness
219 
220  G4bool fAllocatedLocator; // Book-keeping
221 
222  // --------------------------------------------------------
223  // ** Dependent Objects - to which work is delegated
224 
226  // The Field Manager of the whole Detector. (default)
227 
229  // Refines candidate intersection
230 
232  // The filter encapsulates the algorithm which selects which
233  // intermediate points should be stored in a trajectory.
234  // When it is NULL, no intermediate points will be stored.
235  // Else PIF::ComputeStep must submit (all) intermediate
236  // points it calculates, to this filter. (jacek 04/11/2002)
237 
239  // Set externally - only by tracking / run manager
240  //
241  // ** End of Dependent Objects ----------------------------
242 
243  // End of INVARIANTS
244  // ==================================================================
245 
246  // STATE information
247  // -----------------
249  // The Field Manager of the current volume (may be the global)
250  G4bool fSetFieldMgr; // Has it been set for the current step
251 
252  // Parameters of current step
253  G4double fEpsilonStep; // Relative accuracy of current Step
254  G4FieldTrack End_PointAndTangent; // End point storage
256  G4int fNoZeroStep; // Count of zero Steps
257 
258  // State used for Optimisation
261  // Previous step information -- for use in adjust step size
264  // Last safety origin & value: for optimisation
265 
267  // For debuging purposes
268 
269  private:
270 };
271 
272 // Inline methods.
273 // *******************************
274 
275 #include "G4PropagatorInField.icc"
276 
277 #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
G4double GetMaximumEpsilonStep() const
G4int SetVerboseLevel(G4int verbose)
G4FieldTrack GetEndState() const
G4EquationOfMotion * GetCurrentEquationOfMotion()
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
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)