Geant4-11
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4FieldManager Class Reference

#include <G4FieldManager.hh>

Public Member Functions

void ChangeDetectorField (G4Field *detectorField)
 
virtual G4FieldManagerClone () const
 
virtual void ConfigureForTrack (const G4Track *)
 
void CreateChordFinder (G4MagneticField *detectorMagField)
 
G4bool DoesFieldChangeEnergy () const
 
G4bool DoesFieldExist () const
 
 G4FieldManager (const G4FieldManager &)=delete
 
 G4FieldManager (G4Field *detectorField=nullptr, G4ChordFinder *pChordFinder=nullptr, G4bool b=true)
 
 G4FieldManager (G4MagneticField *detectorMagneticField)
 
G4ChordFinderGetChordFinder ()
 
const G4ChordFinderGetChordFinder () const
 
G4double GetDeltaIntersection () const
 
G4double GetDeltaOneStep () const
 
const G4FieldGetDetectorField () const
 
G4double GetMaximumEpsilonStep () const
 
G4double GetMinimumEpsilonStep () const
 
G4FieldManageroperator= (const G4FieldManager &)=delete
 
void ProposeDetectorField (G4Field *detectorField)
 
void SetAccuraciesWithDeltaOneStep (G4double valDeltaOneStep)
 
void SetChordFinder (G4ChordFinder *aChordFinder)
 
void SetDeltaIntersection (G4double valueDintersection)
 
void SetDeltaOneStep (G4double valueD1step)
 
G4bool SetDetectorField (G4Field *detectorField, G4int failMode=0)
 
void SetFieldChangesEnergy (G4bool value)
 
void SetMaximumEpsilonStep (G4double newEpsMax)
 
void SetMinimumEpsilonStep (G4double newEpsMin)
 
virtual ~G4FieldManager ()
 

Private Member Functions

void InitialiseFieldChangesEnergy ()
 

Private Attributes

G4bool fAllocatedChordFinder = false
 
G4ChordFinderfChordFinder = nullptr
 
G4double fDelta_Intersection_Val
 
G4double fDelta_One_Step_Value
 
G4FieldfDetectorField = nullptr
 
G4double fEpsilonMax
 
const G4double fEpsilonMaxDefault = 1.0e-3
 
G4double fEpsilonMin
 
const G4double fEpsilonMinDefault = 5.0e-5
 
G4bool fFieldChangesEnergy = false
 

Static Private Attributes

static G4double fDefault_Delta_Intersection_Val = 0.001 * millimeter
 
static G4double fDefault_Delta_One_Step_Value = 0.01 * millimeter
 

Detailed Description

Definition at line 84 of file G4FieldManager.hh.

Constructor & Destructor Documentation

◆ G4FieldManager() [1/3]

G4FieldManager::G4FieldManager ( G4Field detectorField = nullptr,
G4ChordFinder pChordFinder = nullptr,
G4bool  b = true 
)

Definition at line 41 of file G4FieldManager.cc.

44 : fDetectorField(detectorField),
45 fChordFinder(pChordFinder),
50{
51 if ( detectorField != nullptr )
52 {
54 }
55 else
56 {
57 fFieldChangesEnergy = fieldChangesEnergy;
58 }
59
60 // Add to store
61 //
63}
static void Register(G4FieldManager *pVolume)
const G4double fEpsilonMinDefault
static G4double fDefault_Delta_One_Step_Value
static G4double fDefault_Delta_Intersection_Val
G4double fEpsilonMin
G4double fDelta_One_Step_Value
G4double fEpsilonMax
const G4double fEpsilonMaxDefault
G4Field * fDetectorField
G4ChordFinder * fChordFinder
G4bool fFieldChangesEnergy
G4double fDelta_Intersection_Val
virtual G4bool DoesFieldChangeEnergy() const =0

References G4Field::DoesFieldChangeEnergy(), fFieldChangesEnergy, and G4FieldManagerStore::Register().

Referenced by Clone().

◆ G4FieldManager() [2/3]

G4FieldManager::G4FieldManager ( G4MagneticField detectorMagneticField)

◆ ~G4FieldManager()

G4FieldManager::~G4FieldManager ( )
virtual

Definition at line 139 of file G4FieldManager.cc.

140{
142 {
143 delete fChordFinder;
144 }
146}
static void DeRegister(G4FieldManager *pVolume)

References G4FieldManagerStore::DeRegister(), fAllocatedChordFinder, and fChordFinder.

◆ G4FieldManager() [3/3]

G4FieldManager::G4FieldManager ( const G4FieldManager )
delete

Member Function Documentation

◆ ChangeDetectorField()

void G4FieldManager::ChangeDetectorField ( G4Field detectorField)
inline

◆ Clone()

G4FieldManager * G4FieldManager::Clone ( ) const
virtual

Definition at line 79 of file G4FieldManager.cc.

80{
81 G4Field* aField = nullptr;
82 G4FieldManager* aFM = nullptr;
83 G4ChordFinder* aCF = nullptr;
84 try {
85 if ( fDetectorField != nullptr )
86 {
87 aField = fDetectorField->Clone();
88 }
89
90 // Create a new field manager, note that we do not set
91 // any chordfinder now
92 //
93 aFM = new G4FieldManager( aField , nullptr , fFieldChangesEnergy );
94
95 // Check if originally we have the fAllocatedChordFinder variable
96 // set, in case, call chord constructor
97 //
99 {
100 aFM->CreateChordFinder( dynamic_cast<G4MagneticField*>(aField) );
101 }
102 else
103 {
104 // Chord was specified by user, should we clone?
105 // TODO: For the moment copy pointer, to be understood
106 // if cloning of ChordFinder is needed
107 //
108 aCF = fChordFinder; /*->Clone*/
109 aFM->fChordFinder = aCF;
110 }
111
112 // Copy values of other variables
113
118 // TODO: Should we really add to the store the cloned FM?
119 // Who will use this?
120 }
121 catch ( ... )
122 {
123 // Failed creating clone: probably user did not implement Clone method
124 // in derived classes?
125 // Perform clean-up after ourselves...
126 delete aField;
127 delete aFM;
128 delete aCF;
129 throw;
130 }
131 return aFM;
132}
void CreateChordFinder(G4MagneticField *detectorMagField)
G4FieldManager(G4Field *detectorField=nullptr, G4ChordFinder *pChordFinder=nullptr, G4bool b=true)
virtual G4Field * Clone() const
Definition: G4Field.cc:54

References G4Field::Clone(), CreateChordFinder(), fAllocatedChordFinder, fChordFinder, fDelta_Intersection_Val, fDelta_One_Step_Value, fDetectorField, fEpsilonMax, fEpsilonMin, fFieldChangesEnergy, and G4FieldManager().

Referenced by G4VUserDetectorConstruction::CloneF().

◆ ConfigureForTrack()

void G4FieldManager::ConfigureForTrack ( const G4Track )
virtual

◆ CreateChordFinder()

void G4FieldManager::CreateChordFinder ( G4MagneticField detectorMagField)

Definition at line 149 of file G4FieldManager.cc.

150{
152 {
153 delete fChordFinder;
154 }
155 fAllocatedChordFinder = false;
156
157 if( detectorMagField != nullptr )
158 {
159 fChordFinder = new G4ChordFinder( detectorMagField );
161 }
162 else
163 {
164 fChordFinder = nullptr;
165 }
166}

References fAllocatedChordFinder, and fChordFinder.

Referenced by Clone(), export_G4FieldManager(), G4GlobalMagFieldMessenger::SetField(), and ExN03DetectorConstruction::SetMagField().

◆ DoesFieldChangeEnergy()

G4bool G4FieldManager::DoesFieldChangeEnergy ( ) const
inline

◆ DoesFieldExist()

G4bool G4FieldManager::DoesFieldExist ( ) const
inline

◆ GetChordFinder() [1/2]

G4ChordFinder * G4FieldManager::GetChordFinder ( )
inline

◆ GetChordFinder() [2/2]

const G4ChordFinder * G4FieldManager::GetChordFinder ( ) const
inline

◆ GetDeltaIntersection()

G4double G4FieldManager::GetDeltaIntersection ( ) const
inline

◆ GetDeltaOneStep()

G4double G4FieldManager::GetDeltaOneStep ( ) const
inline

◆ GetDetectorField()

const G4Field * G4FieldManager::GetDetectorField ( ) const
inline

◆ GetMaximumEpsilonStep()

G4double G4FieldManager::GetMaximumEpsilonStep ( ) const
inline

◆ GetMinimumEpsilonStep()

G4double G4FieldManager::GetMinimumEpsilonStep ( ) const
inline

◆ InitialiseFieldChangesEnergy()

void G4FieldManager::InitialiseFieldChangesEnergy ( )
private

Definition at line 168 of file G4FieldManager.cc.

169{
170 if ( fDetectorField != nullptr )
171 {
173 }
174 else
175 {
176 fFieldChangesEnergy = false; // No field, no change!
177 }
178}

References G4Field::DoesFieldChangeEnergy(), fDetectorField, and fFieldChangesEnergy.

Referenced by SetDetectorField().

◆ operator=()

G4FieldManager & G4FieldManager::operator= ( const G4FieldManager )
delete

◆ ProposeDetectorField()

void G4FieldManager::ProposeDetectorField ( G4Field detectorField)
inline

◆ SetAccuraciesWithDeltaOneStep()

void G4FieldManager::SetAccuraciesWithDeltaOneStep ( G4double  valDeltaOneStep)
inline

Referenced by export_G4FieldManager().

◆ SetChordFinder()

void G4FieldManager::SetChordFinder ( G4ChordFinder aChordFinder)
inline

◆ SetDeltaIntersection()

void G4FieldManager::SetDeltaIntersection ( G4double  valueDintersection)
inline

Referenced by export_G4FieldManager().

◆ SetDeltaOneStep()

void G4FieldManager::SetDeltaOneStep ( G4double  valueD1step)
inline

Referenced by export_G4FieldManager().

◆ SetDetectorField()

G4bool G4FieldManager::SetDetectorField ( G4Field detectorField,
G4int  failMode = 0 
)

Definition at line 180 of file G4FieldManager.cc.

182{
183 G4VIntegrationDriver* driver = nullptr;
184 G4EquationOfMotion* equation = nullptr;
185 // G4bool compatibleField = false;
186 G4bool ableToSet = false;
187
188 fDetectorField = pDetectorField;
190
191 // Must 'propagate' the field to the dependent classes
192 //
193 if( fChordFinder != nullptr )
194 {
195 failMode= std::max( failMode, 1) ;
196 // If a chord finder exists, warn in case of error!
197
199 if( driver != nullptr )
200 {
201 equation = driver->GetEquationOfMotion();
202
203 // Should check the compatibility between the
204 // field and the equation HERE
205
206 if( equation != nullptr )
207 {
208 equation->SetFieldObj(pDetectorField);
209 ableToSet = true;
210 }
211 }
212 }
213
214 if( !ableToSet && (failMode > 0) )
215 {
216 // If this fails, report the issue !
217
219 msg << "Unable to set the field in the dependent objects of G4FieldManager"
220 << G4endl;
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. " ; }
227 // else if( !compatibleField ) { msg << " Field not compatible. ";}
228 else { msg << " Can NOT find reason for failure. ";}
229 msg << G4endl;
230 G4ExceptionSeverity severity = (failMode != 1)
232 G4Exception("G4FieldManager::SetDetectorField", "Geometry001",
233 severity, msg);
234 }
235 return ableToSet;
236}
G4ExceptionSeverity
@ JustWarning
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
G4VIntegrationDriver * GetIntegrationDriver()
void SetFieldObj(G4Field *pField)
void InitialiseFieldChangesEnergy()
virtual G4EquationOfMotion * GetEquationOfMotion()=0
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References FatalException, fChordFinder, fDetectorField, G4endl, G4Exception(), G4VIntegrationDriver::GetEquationOfMotion(), G4ChordFinder::GetIntegrationDriver(), InitialiseFieldChangesEnergy(), JustWarning, G4INCL::Math::max(), and G4EquationOfMotion::SetFieldObj().

Referenced by export_G4FieldManager(), G4GlobalMagFieldMessenger::SetField(), and ExN03DetectorConstruction::SetMagField().

◆ SetFieldChangesEnergy()

void G4FieldManager::SetFieldChangesEnergy ( G4bool  value)
inline

Referenced by export_G4FieldManager().

◆ SetMaximumEpsilonStep()

void G4FieldManager::SetMaximumEpsilonStep ( G4double  newEpsMax)
inline

Referenced by export_G4FieldManager().

◆ SetMinimumEpsilonStep()

void G4FieldManager::SetMinimumEpsilonStep ( G4double  newEpsMin)
inline

Referenced by export_G4FieldManager().

Field Documentation

◆ fAllocatedChordFinder

G4bool G4FieldManager::fAllocatedChordFinder = false
private

Definition at line 188 of file G4FieldManager.hh.

Referenced by Clone(), CreateChordFinder(), and ~G4FieldManager().

◆ fChordFinder

G4ChordFinder* G4FieldManager::fChordFinder = nullptr
private

◆ fDefault_Delta_Intersection_Val

G4double G4FieldManager::fDefault_Delta_Intersection_Val = 0.001 * millimeter
staticprivate

Definition at line 198 of file G4FieldManager.hh.

◆ fDefault_Delta_One_Step_Value

G4double G4FieldManager::fDefault_Delta_One_Step_Value = 0.01 * millimeter
staticprivate

Definition at line 197 of file G4FieldManager.hh.

◆ fDelta_Intersection_Val

G4double G4FieldManager::fDelta_Intersection_Val
private

Definition at line 208 of file G4FieldManager.hh.

Referenced by Clone().

◆ fDelta_One_Step_Value

G4double G4FieldManager::fDelta_One_Step_Value
private

Definition at line 207 of file G4FieldManager.hh.

Referenced by Clone().

◆ fDetectorField

G4Field* G4FieldManager::fDetectorField = nullptr
private

Definition at line 184 of file G4FieldManager.hh.

Referenced by Clone(), InitialiseFieldChangesEnergy(), and SetDetectorField().

◆ fEpsilonMax

G4double G4FieldManager::fEpsilonMax
private

Definition at line 212 of file G4FieldManager.hh.

Referenced by Clone().

◆ fEpsilonMaxDefault

const G4double G4FieldManager::fEpsilonMaxDefault = 1.0e-3
private

Definition at line 195 of file G4FieldManager.hh.

◆ fEpsilonMin

G4double G4FieldManager::fEpsilonMin
private

Definition at line 211 of file G4FieldManager.hh.

Referenced by Clone().

◆ fEpsilonMinDefault

const G4double G4FieldManager::fEpsilonMinDefault = 5.0e-5
private

Definition at line 194 of file G4FieldManager.hh.

◆ fFieldChangesEnergy

G4bool G4FieldManager::fFieldChangesEnergy = false
private

Definition at line 203 of file G4FieldManager.hh.

Referenced by Clone(), G4FieldManager(), and InitialiseFieldChangesEnergy().


The documentation for this class was generated from the following files: