2 // ********************************************************************
3 // * License and Disclaimer *
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. *
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. *
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 // ********************************************************************
27 // $Id: G4PropagatorInField.icc 90009 2015-05-08 07:42:39Z gcosmo $
30 // ------------------------------------------------------------------------
31 // GEANT 4 inline implementation
33 // ------------------------------------------------------------------------
35 // 25.10.96 John Apostolakis, design and implementation
36 // 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
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 // ------------------------------------------------------------------------
45 G4ChordFinder* G4PropagatorInField::GetChordFinder()
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();
53 // Obtain the final space-point and velocity (normal) at the end of the Step
56 G4ThreeVector G4PropagatorInField::EndPosition() const
58 return End_PointAndTangent.GetPosition();
62 G4ThreeVector G4PropagatorInField::EndMomentumDir() const
64 return End_PointAndTangent.GetMomentumDir();
68 G4double G4PropagatorInField::GetEpsilonStep() const
74 void G4PropagatorInField::SetEpsilonStep( G4double newEps )
80 G4bool G4PropagatorInField::IsParticleLooping() const
82 return fParticleIsLooping;
86 G4int G4PropagatorInField::GetMaxLoopCount() const
88 return fMax_loop_count;
92 void G4PropagatorInField::SetMaxLoopCount( G4int new_max )
94 fMax_loop_count = new_max;
99 G4double G4PropagatorInField::GetDeltaIntersection() const
101 return fCurrentFieldMgr->GetDeltaIntersection();
105 G4double G4PropagatorInField::GetDeltaOneStep() const
107 return fCurrentFieldMgr->GetDeltaOneStep();
112 G4int G4PropagatorInField::GetVerboseLevel() const
114 return fVerboseLevel;
117 G4int G4PropagatorInField::Verbose() const // Obsolete
119 return GetVerboseLevel();
123 G4FieldTrack G4PropagatorInField::GetEndState() const
125 return End_PointAndTangent;
128 // Minimum for Relative accuracy of a Step in volumes of global field
130 G4double G4PropagatorInField::GetMinimumEpsilonStep() const
132 return fDetectorFieldMgr->GetMinimumEpsilonStep();
136 void G4PropagatorInField::SetMinimumEpsilonStep( G4double newEpsMin )
138 fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
141 // Maximum for Relative accuracy of any Step
143 G4double G4PropagatorInField::GetMaximumEpsilonStep() const
145 return fDetectorFieldMgr->GetMaximumEpsilonStep();
149 void G4PropagatorInField::SetMaximumEpsilonStep( G4double newEpsMax )
151 fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
155 void G4PropagatorInField::SetLargestAcceptableStep( G4double newBigDist )
157 if( fLargestAcceptableStep>0.0 )
159 fLargestAcceptableStep = newBigDist;
164 G4double G4PropagatorInField::GetLargestAcceptableStep()
166 return fLargestAcceptableStep;
170 G4FieldManager* G4PropagatorInField::GetCurrentFieldManager()
172 return fCurrentFieldMgr;
176 void G4PropagatorInField::SetThresholdNoZeroStep( G4int noAct,
181 fActionThreshold_NoZeroSteps = noAct;
183 if( noHarsh > fActionThreshold_NoZeroSteps )
184 fSevereActionThreshold_NoZeroSteps = noHarsh;
186 fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
188 if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
189 fAbandonThreshold_NoZeroSteps = noAbandon;
191 fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3);
195 G4int G4PropagatorInField::GetThresholdNoZeroSteps( G4int i )
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; }
206 inline G4double G4PropagatorInField::GetZeroStepThreshold()
208 return fZeroStepThreshold;
211 inline void G4PropagatorInField::SetZeroStepThreshold( G4double newLength )
213 fZeroStepThreshold= newLength;
217 void G4PropagatorInField::SetDetectorFieldManager(G4FieldManager* newDetectorFieldManager)
219 fDetectorFieldMgr = newDetectorFieldManager;
224 void G4PropagatorInField:: SetUseSafetyForOptimization( G4bool value )
226 fUseSafetyForOptimisation= value;
230 G4bool G4PropagatorInField::GetUseSafetyForOptimization()
232 return fUseSafetyForOptimisation;
236 void G4PropagatorInField::
237 SetNavigatorForPropagating( G4Navigator *SimpleOrMultiNavigator )
239 if(SimpleOrMultiNavigator) {
240 fNavigator= SimpleOrMultiNavigator;
241 if( fIntersectionLocator ) {
242 fIntersectionLocator->SetNavigatorFor( SimpleOrMultiNavigator );
248 G4Navigator* G4PropagatorInField::GetNavigatorForPropagating()
254 void G4PropagatorInField::
255 SetIntersectionLocator( G4VIntersectionLocator *pIntLoc )
258 fIntersectionLocator= pIntLoc;
260 // Ensure that the Intersection Locator uses the correct Navigator
261 pIntLoc->SetNavigatorFor( fNavigator );
266 G4VIntersectionLocator* G4PropagatorInField::GetIntersectionLocator()
268 return fIntersectionLocator;
272 G4bool G4PropagatorInField::IntersectChord( const G4ThreeVector& StartPointA,
273 const G4ThreeVector& EndPointB,
275 G4double &LinearStepLength,
276 G4ThreeVector &IntersectionPoint )
278 // Calculate the direction and length of the chord AB
280 #ifdef G4DEBUG_PROPAGATION
282 G4cout << "**** G4PropagatorInField::IntersectChord called."
283 << " InPut: StartPointA: " << StartPointA
284 << " EndPointB= " << EndPointB
285 << " StepLength= " << LinearStepLength
286 << " IntersecLen= " << IntersectionPoint
292 ->IntersectChord(StartPointA,EndPointB,NewSafety,
293 fPreviousSafety,fPreviousSftOrigin,
294 LinearStepLength,IntersectionPoint);
296 #ifdef G4DEBUG_PROPAGATION
298 G4cout << "**** G4PropagatorInField::IntersectChord ended."
299 << " OutPut: Safety= " << NewSafety
300 << " StepLength= " << LinearStepLength
301 << " IntersecPt= " << IntersectionPoint
308 inline G4EquationOfMotion* G4PropagatorInField::GetCurrentEquationOfMotion()
310 G4EquationOfMotion* equationOfMotion = 0;
312 // equationOfMotion =
313 // (fFieldPropagator->GetChordFinder()->GetIntegrationDriver()->GetStepper())
314 // ->GetEquationOfMotion();
316 // Consolidate into auxiliary method G4EquationOfMotion* GetEquationOfMotion()
317 G4MagIntegratorStepper* pStepper= 0;
319 G4ChordFinder* pChordFinder= this->GetChordFinder();
322 G4MagInt_Driver* pIntDriver= 0;
324 pIntDriver= pChordFinder->GetIntegrationDriver();
327 pStepper= pIntDriver->GetStepper();
331 equationOfMotion= pStepper->GetEquationOfMotion();
334 return equationOfMotion;