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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

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