Geant4-11
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// class G4PropagatorInField Inline implementation
27//
28// To create an object of this type, must have:
29// - an object that calculates the Curved paths
30// - the navigator to find (linear) intersections
31// - and also must know the value of the maximum displacement allowed
32//
33// 25.10.96 John Apostolakis, design and implementation
34// 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
35// ------------------------------------------------------------------------
36
37// ------------------------------------------------------------------------
38//
39inline
40G4ChordFinder* G4PropagatorInField::GetChordFinder()
41{
42 // The "Chord Finder" of the current Field Mgr is used
43 // -- this could be of the global field manager
44 // or that of another, from the current volume
45 return fCurrentFieldMgr->GetChordFinder();
46}
47
48// ------------------------------------------------------------------------
49// Obtain the final space-point and velocity (normal) at the end of the Step
50//
51inline
52G4ThreeVector G4PropagatorInField::EndPosition() const
53{
54 return End_PointAndTangent.GetPosition();
55}
56
57// ------------------------------------------------------------------------
58//
59inline
60G4ThreeVector G4PropagatorInField::EndMomentumDir() const
61{
62 return End_PointAndTangent.GetMomentumDir();
63}
64
65// ------------------------------------------------------------------------
66//
67inline
68G4double G4PropagatorInField::GetEpsilonStep() const
69{
70 return fEpsilonStep;
71}
72
73// ------------------------------------------------------------------------
74//
75inline
76void G4PropagatorInField::SetEpsilonStep( G4double newEps )
77{
78 fEpsilonStep = newEps;
79}
80
81// ------------------------------------------------------------------------
82//
83inline
84G4bool G4PropagatorInField::IsParticleLooping() const
85{
86 return fParticleIsLooping;
87}
88
89// ------------------------------------------------------------------------
90//
91inline
92G4int G4PropagatorInField::GetMaxLoopCount() const
93{
94 return fMax_loop_count;
95}
96
97// ------------------------------------------------------------------------
98//
99inline
100void G4PropagatorInField::SetMaxLoopCount( G4int new_max )
101{
102 fMax_loop_count = new_max;
103}
104
105// ------------------------------------------------------------------------
106//
107inline
108G4double G4PropagatorInField::GetDeltaIntersection() const
109{
110 return fCurrentFieldMgr->GetDeltaIntersection();
111}
112
113// ------------------------------------------------------------------------
114//
115inline
116G4double G4PropagatorInField::GetDeltaOneStep() const
117{
118 return fCurrentFieldMgr->GetDeltaOneStep();
119}
120
121// ------------------------------------------------------------------------
122//
123inline
124G4int G4PropagatorInField::GetVerboseLevel() const
125{
126 return fVerboseLevel;
127}
128
129// ------------------------------------------------------------------------
130//
131inline
132G4int G4PropagatorInField::Verbose() const // Obsolete
133{
134 return GetVerboseLevel();
135}
136
137// ------------------------------------------------------------------------
138//
139inline
140void G4PropagatorInField::SetVerboseTrace( G4bool enable )
141{
142 fVerbTracePiF = enable;
143}
144
145// ------------------------------------------------------------------------
146//
147inline
148G4bool G4PropagatorInField::GetVerboseTrace()
149{
150 return fVerbTracePiF;
151}
152
153// ------------------------------------------------------------------------
154//
155inline
156void G4PropagatorInField::CheckMode(G4bool mode)
157{
158 fCheck = mode;
159 if (fIntersectionLocator != nullptr)
160 {
161 fIntersectionLocator->SetCheckMode(mode);
162 }
163}
164
165// ------------------------------------------------------------------------
166//
167inline
168G4FieldTrack G4PropagatorInField::GetEndState() const
169{
170 return End_PointAndTangent;
171}
172
173// ------------------------------------------------------------------------
174// Minimum for Relative accuracy of a Step in volumes of global field
175//
176inline
177G4double G4PropagatorInField::GetMinimumEpsilonStep() const
178{
179 return fDetectorFieldMgr->GetMinimumEpsilonStep();
180}
181
182// ------------------------------------------------------------------------
183//
184inline
185void G4PropagatorInField::SetMinimumEpsilonStep( G4double newEpsMin )
186{
187 fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
188}
189
190// ------------------------------------------------------------------------
191// Maximum for Relative accuracy of any Step
192//
193inline
194G4double G4PropagatorInField::GetMaximumEpsilonStep() const
195{
196 return fDetectorFieldMgr->GetMaximumEpsilonStep();
197}
198
199// ------------------------------------------------------------------------
200//
201inline
202void G4PropagatorInField::SetMaximumEpsilonStep( G4double newEpsMax )
203{
204 fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
205}
206
207// ------------------------------------------------------------------------
208//
209inline
210void G4PropagatorInField::SetLargestAcceptableStep( G4double newBigDist )
211{
212 if( fLargestAcceptableStep>0.0 )
213 {
214 fLargestAcceptableStep = newBigDist;
215 }
216}
217
218// ------------------------------------------------------------------------
219//
220inline
221G4double G4PropagatorInField::GetLargestAcceptableStep()
222{
223 return fLargestAcceptableStep;
224}
225
226// ------------------------------------------------------------------------
227//
228inline
229G4FieldManager* G4PropagatorInField::GetCurrentFieldManager()
230{
231 return fCurrentFieldMgr;
232}
233
234// ------------------------------------------------------------------------
235//
236inline
237void G4PropagatorInField::SetThresholdNoZeroStep( G4int noAct,
238 G4int noHarsh,
239 G4int noAbandon )
240{
241 if( noAct>0 )
242 fActionThreshold_NoZeroSteps = noAct;
243
244 if( noHarsh > fActionThreshold_NoZeroSteps )
245 fSevereActionThreshold_NoZeroSteps = noHarsh;
246 else
247 fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
248
249 if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
250 fAbandonThreshold_NoZeroSteps = noAbandon;
251 else
252 fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3);
253}
254
255// ------------------------------------------------------------------------
256//
257inline
258G4int G4PropagatorInField::GetThresholdNoZeroSteps( G4int i )
259{
260 G4int t=0;
261 if( i==0 ) { t = 3; } // No of parameters
262 else if (i==1) { t = fActionThreshold_NoZeroSteps; }
263 else if (i==2) { t = fSevereActionThreshold_NoZeroSteps; }
264 else if (i==3) { t = fAbandonThreshold_NoZeroSteps; }
265
266 return t;
267}
268
269// ------------------------------------------------------------------------
270//
271inline G4double G4PropagatorInField::GetZeroStepThreshold()
272{
273 return fZeroStepThreshold;
274}
275
276// ------------------------------------------------------------------------
277//
278inline void G4PropagatorInField::SetZeroStepThreshold( G4double newLength )
279{
280 fZeroStepThreshold= newLength;
281}
282
283// ------------------------------------------------------------------------
284//
285inline
286void G4PropagatorInField::SetDetectorFieldManager(G4FieldManager* newDFMan)
287{
288 fDetectorFieldMgr = newDFMan;
289}
290
291// ------------------------------------------------------------------------
292//
293inline
294void G4PropagatorInField:: SetUseSafetyForOptimization( G4bool value )
295{
296 fUseSafetyForOptimisation = value;
297}
298
299// ------------------------------------------------------------------------
300//
301inline
302G4bool G4PropagatorInField::GetUseSafetyForOptimization()
303{
304 return fUseSafetyForOptimisation;
305}
306
307// ------------------------------------------------------------------------
308//
309inline
310void G4PropagatorInField::
311SetNavigatorForPropagating( G4Navigator* SimpleOrMultiNavigator )
312{
313 if (SimpleOrMultiNavigator != nullptr)
314 {
315 fNavigator = SimpleOrMultiNavigator;
316 if( fIntersectionLocator )
317 {
318 fIntersectionLocator->SetNavigatorFor( SimpleOrMultiNavigator );
319 }
320 }
321}
322
323// ------------------------------------------------------------------------
324//
325inline
326G4Navigator* G4PropagatorInField::GetNavigatorForPropagating()
327{
328 return fNavigator;
329}
330
331// ------------------------------------------------------------------------
332//
333inline
334void G4PropagatorInField::
335SetIntersectionLocator( G4VIntersectionLocator* pIntLoc )
336{
337 if (pIntLoc != nullptr)
338 {
339 fIntersectionLocator= pIntLoc;
340
341 // Ensure that the Intersection Locator uses the correct Navigator
342 //
343 pIntLoc->SetNavigatorFor( fNavigator );
344 }
345}
346
347// ------------------------------------------------------------------------
348//
349inline
350G4VIntersectionLocator* G4PropagatorInField::GetIntersectionLocator()
351{
352 return fIntersectionLocator;
353}
354
355// ------------------------------------------------------------------------
356//
357inline
358G4bool G4PropagatorInField::IntersectChord( const G4ThreeVector& StartPointA,
359 const G4ThreeVector& EndPointB,
360 G4double& NewSafety,
361 G4double& LinearStepLength,
362 G4ThreeVector& IntersectionPoint )
363{
364 // Calculate the direction and length of the chord AB
365 //
366#ifdef G4DEBUG_PROPAGATION
367 if( fVerbTracePiF )
368 G4cout << "**** G4PropagatorInField::IntersectChord called."
369 << " InPut: StartPointA: " << StartPointA
370 << " EndPointB= " << EndPointB
371 << " StepLength= " << LinearStepLength
372 << " IntersecLen= " << IntersectionPoint
373 << G4endl;
374#endif
375
376 G4bool retVal= fIntersectionLocator
377 ->IntersectChord(StartPointA,EndPointB,NewSafety,
378 fPreviousSafety,fPreviousSftOrigin,
379 LinearStepLength,IntersectionPoint);
380
381#ifdef G4DEBUG_PROPAGATION
382 if( fVerbTracePiF )
383 G4cout << "**** G4PropagatorInField::IntersectChord ended."
384 << " OutPut: Safety= " << NewSafety
385 << " StepLength= " << LinearStepLength
386 << " IntersecPt= " << IntersectionPoint
387 << G4endl;
388#endif
389
390 return retVal;
391}
392
393// ------------------------------------------------------------------------
394//
395inline G4bool G4PropagatorInField::IsFirstStepInVolume()
396{
397 return fFirstStepInVolume;
398}
399
400// ------------------------------------------------------------------------
401//
402inline G4bool G4PropagatorInField::IsLastStepInVolume()
403{
404 return fLastStepInVolume;
405}
406
407// ------------------------------------------------------------------------
408//
409inline void G4PropagatorInField::PrepareNewTrack()
410{
411 fNewTrack = true;
412 fFirstStepInVolume = false;
413 fLastStepInVolume = false;
414}
415
416// ------------------------------------------------------------------------
417//
418inline G4EquationOfMotion* G4PropagatorInField::GetCurrentEquationOfMotion()
419{
420 if (auto pChordFinder = GetChordFinder())
421 {
422 if (auto pIntDriver = pChordFinder->GetIntegrationDriver())
423 {
424 return pIntDriver->GetEquationOfMotion();
425 }
426 }
427 return nullptr;
428}
429
430// ------------------------------------------------------------------------
431//
432G4int G4PropagatorInField::GetIterationsToIncreaseChordDistance() const
433{
434 return fIncreaseChordDistanceThreshold;
435}
436
437// ------------------------------------------------------------------------
438//
439void G4PropagatorInField::SetIterationsToIncreaseChordDistance(G4int numIters)
440{
441 fIncreaseChordDistanceThreshold = numIters;
442 if(numIters <= 0)
443 {
444 // Disables relaxation
445 if( fVerboseLevel ){
446 G4cout << "G4PropagatorInField: Turned OFF the Relaxation of chord "
447 << "finder as iteration threshold = " << numIters
448 << " is not positive." << G4endl;
449 }
450 }
451}