Geant4  10.02
G4PropagatorInField.icc
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.icc 90009 2015-05-08 07:42:39Z gcosmo $
28 //
29 //
30 // ------------------------------------------------------------------------
31 // GEANT 4 inline implementation
32 //
33 // ------------------------------------------------------------------------
34 //
35 // 25.10.96 John Apostolakis, design and implementation
36 // 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
37 //
38 // To create an object of this type, must have:
39 // - an object that calculates the Curved paths
40 // - the navigator to find (linear) intersections
41 // - and ?? also must know the value of the maximum displacement allowed
42 // ------------------------------------------------------------------------
43 
44 inline
45 G4ChordFinder* G4PropagatorInField::GetChordFinder()
46 {
47  // The "Chord Finder" of the current Field Mgr is used
48  // -- this could be of the global field manager
49  // or that of another, from the current volume
50  return fCurrentFieldMgr->GetChordFinder();
51 }
52 
53 // Obtain the final space-point and velocity (normal) at the end of the Step
54 //
55 inline
56 G4ThreeVector G4PropagatorInField::EndPosition() const
57 {
58  return End_PointAndTangent.GetPosition();
59 }
60 
61 inline
62 G4ThreeVector G4PropagatorInField::EndMomentumDir() const
63 {
64  return End_PointAndTangent.GetMomentumDir();
65 }
66 
67 inline
68 G4double G4PropagatorInField::GetEpsilonStep() const
69 {
70  return fEpsilonStep;
71 }
72 
73 inline
74 void G4PropagatorInField::SetEpsilonStep( G4double newEps )
75 {
76  fEpsilonStep=newEps;
77 }
78 
79 inline
80 G4bool G4PropagatorInField::IsParticleLooping() const
81 {
82  return fParticleIsLooping;
83 }
84 
85 inline
86 G4int G4PropagatorInField::GetMaxLoopCount() const
87 {
88  return fMax_loop_count;
89 }
90 
91 inline
92 void G4PropagatorInField::SetMaxLoopCount( G4int new_max )
93 {
94  fMax_loop_count = new_max;
95 }
96 
97 // #if 0
98 inline
99 G4double G4PropagatorInField::GetDeltaIntersection() const
100 {
101  return fCurrentFieldMgr->GetDeltaIntersection();
102 }
103 
104 inline
105 G4double G4PropagatorInField::GetDeltaOneStep() const
106 {
107  return fCurrentFieldMgr->GetDeltaOneStep();
108 }
109 // #endif
110 
111 inline
112 G4int G4PropagatorInField::GetVerboseLevel() const
113 {
114  return fVerboseLevel;
115 }
116 inline
117 G4int G4PropagatorInField::Verbose() const // Obsolete
118 {
119  return GetVerboseLevel();
120 }
121 
122 inline
123 G4FieldTrack G4PropagatorInField::GetEndState() const
124 {
125  return End_PointAndTangent;
126 }
127 
128 // Minimum for Relative accuracy of a Step in volumes of global field
129 inline
130 G4double G4PropagatorInField::GetMinimumEpsilonStep() const
131 {
132  return fDetectorFieldMgr->GetMinimumEpsilonStep();
133 }
134 
135 inline
136 void G4PropagatorInField::SetMinimumEpsilonStep( G4double newEpsMin )
137 {
138  fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
139 }
140 
141 // Maximum for Relative accuracy of any Step
142 inline
143 G4double G4PropagatorInField::GetMaximumEpsilonStep() const
144 {
145  return fDetectorFieldMgr->GetMaximumEpsilonStep();
146 }
147 
148 inline
149 void G4PropagatorInField::SetMaximumEpsilonStep( G4double newEpsMax )
150 {
151  fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
152 }
153 
154 inline
155 void G4PropagatorInField::SetLargestAcceptableStep( G4double newBigDist )
156 {
157  if( fLargestAcceptableStep>0.0 )
158  {
159  fLargestAcceptableStep = newBigDist;
160  }
161 }
162 
163 inline
164 G4double G4PropagatorInField::GetLargestAcceptableStep()
165 {
166  return fLargestAcceptableStep;
167 }
168 
169 inline
170 G4FieldManager* G4PropagatorInField::GetCurrentFieldManager()
171 {
172  return fCurrentFieldMgr;
173 }
174 
175 inline
176 void G4PropagatorInField::SetThresholdNoZeroStep( G4int noAct,
177  G4int noHarsh,
178  G4int noAbandon )
179 {
180  if( noAct>0 )
181  fActionThreshold_NoZeroSteps = noAct;
182 
183  if( noHarsh > fActionThreshold_NoZeroSteps )
184  fSevereActionThreshold_NoZeroSteps = noHarsh;
185  else
186  fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
187 
188  if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
189  fAbandonThreshold_NoZeroSteps = noAbandon;
190  else
191  fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3);
192 }
193 
194 inline
195 G4int G4PropagatorInField::GetThresholdNoZeroSteps( G4int i )
196 {
197  G4int t=0;
198  if( i==0 ) { t = 3; } // No of parameters
199  else if (i==1) { t = fActionThreshold_NoZeroSteps; }
200  else if (i==2) { t = fSevereActionThreshold_NoZeroSteps; }
201  else if (i==3) { t = fAbandonThreshold_NoZeroSteps; }
202 
203  return t;
204 }
205 
206 inline G4double G4PropagatorInField::GetZeroStepThreshold()
207 {
208  return fZeroStepThreshold;
209 }
210 
211 inline void G4PropagatorInField::SetZeroStepThreshold( G4double newLength )
212 {
213  fZeroStepThreshold= newLength;
214 }
215 
216 inline
217 void G4PropagatorInField::SetDetectorFieldManager(G4FieldManager* newDetectorFieldManager)
218 {
219  fDetectorFieldMgr = newDetectorFieldManager;
220 }
221 
222 
223 inline
224 void G4PropagatorInField:: SetUseSafetyForOptimization( G4bool value )
225 {
226  fUseSafetyForOptimisation= value;
227 }
228 
229 inline
230 G4bool G4PropagatorInField::GetUseSafetyForOptimization()
231 {
232  return fUseSafetyForOptimisation;
233 }
234 
235 inline
236 void G4PropagatorInField::
237 SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator )
238 {
239  if(SimpleOrMultiNavigator) {
240  fNavigator= SimpleOrMultiNavigator;
241  if( fIntersectionLocator ) {
242  fIntersectionLocator->SetNavigatorFor( SimpleOrMultiNavigator );
243  }
244  }
245 }
246 
247 inline
248 G4Navigator* G4PropagatorInField::GetNavigatorForPropagating()
249 {
250  return fNavigator;
251 }
252 
253 inline
254 void G4PropagatorInField::
255 SetIntersectionLocator( G4VIntersectionLocator *pIntLoc )
256 {
257  if(pIntLoc) {
258  fIntersectionLocator= pIntLoc;
259 
260  // Ensure that the Intersection Locator uses the correct Navigator
261  pIntLoc->SetNavigatorFor( fNavigator );
262  }
263 }
264 
265 inline
266 G4VIntersectionLocator* G4PropagatorInField::GetIntersectionLocator()
267 {
268  return fIntersectionLocator;
269 }
270 
271 inline
272 G4bool G4PropagatorInField::IntersectChord( const G4ThreeVector& StartPointA,
273  const G4ThreeVector& EndPointB,
274  G4double &NewSafety,
275  G4double &LinearStepLength,
276  G4ThreeVector &IntersectionPoint )
277 {
278  // Calculate the direction and length of the chord AB
279  //
280 #ifdef G4DEBUG_PROPAGATION
281  if( fVerbTracePiF )
282  G4cout << "**** G4PropagatorInField::IntersectChord called."
283  << " InPut: StartPointA: " << StartPointA
284  << " EndPointB= " << EndPointB
285  << " StepLength= " << LinearStepLength
286  << " IntersecLen= " << IntersectionPoint
287  << G4endl;
288 #endif
289 
290  G4bool retVal=
291  fIntersectionLocator
292  ->IntersectChord(StartPointA,EndPointB,NewSafety,
293  fPreviousSafety,fPreviousSftOrigin,
294  LinearStepLength,IntersectionPoint);
295 
296 #ifdef G4DEBUG_PROPAGATION
297  if( fVerbTracePiF )
298  G4cout << "**** G4PropagatorInField::IntersectChord ended."
299  << " OutPut: Safety= " << NewSafety
300  << " StepLength= " << LinearStepLength
301  << " IntersecPt= " << IntersectionPoint
302  << G4endl;
303 #endif
304 
305  return retVal;
306 }
307 
308 inline G4EquationOfMotion* G4PropagatorInField::GetCurrentEquationOfMotion()
309 {
310  G4EquationOfMotion* equationOfMotion = 0;
311 
312  // equationOfMotion =
313  // (fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetStepper())
314  // ->GetEquationOfMotion();
315 
316  // Consolidate into auxiliary method G4EquationOfMotion* GetEquationOfMotion()
317  G4MagIntegratorStepper* pStepper= 0;
318 
319  G4ChordFinder* pChordFinder= this->GetChordFinder();
320  if( pChordFinder )
321  {
322  G4MagInt_Driver* pIntDriver= 0;
323 
324  pIntDriver= pChordFinder->GetIntegrationDriver();
325  if( pIntDriver )
326  {
327  pStepper= pIntDriver->GetStepper();
328  }
329  if( pStepper )
330  {
331  equationOfMotion= pStepper->GetEquationOfMotion();
332  }
333  }
334  return equationOfMotion;
335 }