38G4double G4FieldManager::fDefault_Delta_One_Step_Value= 0.01 * millimeter;
39G4double G4FieldManager::fDefault_Delta_Intersection_Val= 0.001 * millimeter;
43 G4bool fieldChangesEnergy )
44 : fDetectorField(detectorField),
45 fChordFinder(pChordFinder),
46 fDelta_One_Step_Value( fDefault_Delta_One_Step_Value ),
47 fDelta_Intersection_Val( fDefault_Delta_Intersection_Val ),
48 fEpsilonMin( fEpsilonMinDefault ),
49 fEpsilonMax( fEpsilonMaxDefault)
51 if ( detectorField !=
nullptr )
57 fFieldChangesEnergy = fieldChangesEnergy;
66 : fDetectorField(detectorField), fAllocatedChordFinder(true),
67 fDelta_One_Step_Value( fDefault_Delta_One_Step_Value ),
68 fDelta_Intersection_Val( fDefault_Delta_Intersection_Val ),
69 fEpsilonMin( fEpsilonMinDefault ),
70 fEpsilonMax( fEpsilonMaxDefault )
85 if ( fDetectorField !=
nullptr )
87 aField = fDetectorField->
Clone();
93 aFM =
new G4FieldManager( aField ,
nullptr , fFieldChangesEnergy );
98 if ( fAllocatedChordFinder )
109 aFM->fChordFinder = aCF;
114 aFM->fEpsilonMax = fEpsilonMax;
115 aFM->fEpsilonMin = fEpsilonMin;
116 aFM->fDelta_Intersection_Val = fDelta_Intersection_Val;
117 aFM->fDelta_One_Step_Value = fDelta_One_Step_Value;
141 if( fAllocatedChordFinder )
151 if ( fAllocatedChordFinder )
155 fAllocatedChordFinder =
false;
157 if( detectorMagField !=
nullptr )
160 fAllocatedChordFinder =
true;
164 fChordFinder =
nullptr;
168void G4FieldManager::InitialiseFieldChangesEnergy()
170 if ( fDetectorField !=
nullptr )
176 fFieldChangesEnergy =
false;
188 fDetectorField = pDetectorField;
189 InitialiseFieldChangesEnergy();
193 if( fChordFinder !=
nullptr )
195 failMode= std::max( failMode, 1) ;
199 if( driver !=
nullptr )
206 if( equation !=
nullptr )
214 if( !ableToSet && (failMode > 0) )
219 msg <<
"Unable to set the field in the dependent objects of G4FieldManager"
221 msg <<
"All the dependent classes must be fully initialised,"
222 <<
"before it is possible to call this method." <<
G4endl;
223 msg <<
"The problem encountered was the following: " <<
G4endl;
224 if( fChordFinder ==
nullptr ) { msg <<
" No ChordFinder. " ; }
225 else if( driver ==
nullptr ) { msg <<
" No Integration Driver set. ";}
226 else if( equation ==
nullptr ) { msg <<
" No Equation found. " ; }
228 else { msg <<
" Can NOT find reason for failure. ";}
232 G4Exception(
"G4FieldManager::SetDetectorField",
"Geometry001",
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4VIntegrationDriver * GetIntegrationDriver()
void SetFieldObj(G4Field *pField)
static void DeRegister(G4FieldManager *pVolume)
static void Register(G4FieldManager *pVolume)
virtual G4FieldManager * Clone() const
virtual ~G4FieldManager()
G4bool SetDetectorField(G4Field *detectorField, G4int failMode=0)
void CreateChordFinder(G4MagneticField *detectorMagField)
virtual void ConfigureForTrack(const G4Track *)
G4FieldManager(G4Field *detectorField=nullptr, G4ChordFinder *pChordFinder=nullptr, G4bool b=true)
virtual G4bool DoesFieldChangeEnergy() const =0
virtual G4Field * Clone() const
virtual G4EquationOfMotion * GetEquationOfMotion()=0