ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GlobalFieldManagerTool Class Reference

Tool for setting up a detector-global magnetic field manager. More...

#include "G4AtlasTools/GlobalFieldManagerTool.h"

Inheritance diagram for GlobalFieldManagerTool:
Collaboration diagram for GlobalFieldManagerTool:

Public Member Functions

 GlobalFieldManagerTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard constructor. More...
 
 ~GlobalFieldManagerTool ()
 Empty destructor. More...
 
StatusCode initializeField () override final
 Initialize a field manager. More...
 
virtual StatusCode initialize () override
 Initialize method. More...
 

Protected Member Functions

G4MagIntegratorStepper * getStepper (const std::string &stepperType, G4MagneticField *field) const
 Common method to construct a stepper of requested type. More...
 
StatusCode setFieldParameters (G4FieldManager *fieldMgr) const
 Common method to apply configuredfield parameters. More...
 

Protected Attributes

Gaudi::Property< bool > m_useTightMuonStepping
 Tight muon stepping parameters via the field manager's configure for track. More...
 
thread_utils::ThreadLocalOwner< G4FieldManager > m_fieldMgrHolder
 My field manager – populated only in the case that we use tight muon stepping. More...
 
ServiceHandle< IG4FieldSvcm_fieldSvc {this, "FieldSvc", "G4FieldSvc", "Service providing a G4MagneticField"}
 Handle to the G4 field service. More...
 
Gaudi::Property< bool > m_fieldOn {this, "FieldOn", true, "Toggles field on/off"}
 
Gaudi::Property< std::string > m_integratorStepper {this, "IntegratorStepper", "AtlasRK4", "Integrator stepper name"}
 The type of stepper to use. More...
 
ToolHandle< IEquationOfMotionToolm_equationOfMotion {this, "EquationOfMotion", "", ""}
 The type of equation of motion to use. More...
 
Field parameters
Gaudi::Property< double > m_minEps {this, "MinimumEpsilonStep", -1.0, "Minimum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_maxEps {this, "MaximumEpsilonStep", -1.0, "Maximum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_deltaChord {this, "DeltaChord", -1.0, "Missing distance for the chord finder"}
 
Gaudi::Property< double > m_deltaOneStep {this, "DeltaOneStep", -1.0, "Delta(one-step)"}
 
Gaudi::Property< double > m_deltaIntersection {this, "DeltaIntersection", -1.0, "Accuracy for boundary intersection"}
 
Gaudi::Property< double > m_maxStep {this, "MaximumStep", -1.0, "Maximum step length in field (see G4 documentation)"}
 
Gaudi::Property< double > m_minStep {this, "MinimumStep",1e-2, "Minimum step length in field (see G4 documentation)"}
 
Field parameters
Gaudi::Property< double > m_minEps {this, "MinimumEpsilonStep", -1.0, "Minimum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_maxEps {this, "MaximumEpsilonStep", -1.0, "Maximum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_deltaChord {this, "DeltaChord", -1.0, "Missing distance for the chord finder"}
 
Gaudi::Property< double > m_deltaOneStep {this, "DeltaOneStep", -1.0, "Delta(one-step)"}
 
Gaudi::Property< double > m_deltaIntersection {this, "DeltaIntersection", -1.0, "Accuracy for boundary intersection"}
 
Gaudi::Property< double > m_maxStep {this, "MaximumStep", -1.0, "Maximum step length in field (see G4 documentation)"}
 
Gaudi::Property< double > m_minStep {this, "MinimumStep",1e-2, "Minimum step length in field (see G4 documentation)"}
 
Field parameters
Gaudi::Property< double > m_minEps {this, "MinimumEpsilonStep", -1.0, "Minimum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_maxEps {this, "MaximumEpsilonStep", -1.0, "Maximum epsilon (see G4 documentation)"}
 
Gaudi::Property< double > m_deltaChord {this, "DeltaChord", -1.0, "Missing distance for the chord finder"}
 
Gaudi::Property< double > m_deltaOneStep {this, "DeltaOneStep", -1.0, "Delta(one-step)"}
 
Gaudi::Property< double > m_deltaIntersection {this, "DeltaIntersection", -1.0, "Accuracy for boundary intersection"}
 
Gaudi::Property< double > m_maxStep {this, "MaximumStep", -1.0, "Maximum step length in field (see G4 documentation)"}
 
Gaudi::Property< double > m_minStep {this, "MinimumStep",1e-2, "Minimum step length in field (see G4 documentation)"}
 

Detailed Description

Tool for setting up a detector-global magnetic field manager.

Author
Andrea Dell'Acqua
Date
2016-03-25

Definition at line 20 of file GlobalFieldManagerTool.h.

Constructor & Destructor Documentation

◆ GlobalFieldManagerTool()

GlobalFieldManagerTool::GlobalFieldManagerTool ( const std::string &  type,
const std::string &  name,
const IInterface *  parent 
)

Standard constructor.

Definition at line 24 of file GlobalFieldManagerTool.cxx.

28 {
29 }

◆ ~GlobalFieldManagerTool()

GlobalFieldManagerTool::~GlobalFieldManagerTool ( )
inline

Empty destructor.

Definition at line 30 of file GlobalFieldManagerTool.h.

30 {};

Member Function Documentation

◆ getStepper()

G4MagIntegratorStepper * G4FieldManagerToolBase::getStepper ( const std::string &  stepperType,
G4MagneticField *  field 
) const
protectedinherited

Common method to construct a stepper of requested type.

Definition at line 190 of file G4FieldManagerToolBase.cxx.

191 {
192  ATH_MSG_DEBUG("getStepper");
193  G4Mag_EqRhs* eqRhs(nullptr);
194  if (!m_equationOfMotion.empty())
195  {
196  eqRhs = m_equationOfMotion->makeEquationOfMotion(field);
197  ATH_MSG_INFO("Configuring alternative equation of motion using " <<
198  m_equationOfMotion.name() );
199  }
200  else
201  {
202  ATH_MSG_VERBOSE("Using G4Mag_UsualEqRhs as the equation of motion.");
203  eqRhs = new G4Mag_UsualEqRhs(field);
204  }
205  // @TODO Add some way of confirming that the choices of Equation of
206  // motion and stepper are compatible.
207  // @TODO consider moving the stepper choice into a tool as well?
208  // Only worthwhile if we envisage adding more stepper choices in the
209  // future.
210  if (name=="HelixImplicitEuler") return new G4HelixImplicitEuler(eqRhs);
211  else if (name=="HelixSimpleRunge") return new G4HelixSimpleRunge(eqRhs);
212  else if (name=="HelixExplicitEuler") return new G4HelixExplicitEuler(eqRhs);
213  else if (name=="NystromRK4") return new G4NystromRK4(eqRhs);
214  else if (name=="ClassicalRK4") return new G4ClassicalRK4(eqRhs);
215  else if (name=="AtlasRK4") return new G4AtlasRK4(eqRhs);
216  else if (name=="BogackiShampine23") return new G4BogackiShampine23(eqRhs);
217  else if (name=="BogackiShampine45") return new G4BogackiShampine45(eqRhs);
218  else if (name=="CashKarpRKF45") return new G4CashKarpRKF45(eqRhs);
219  else if (name=="DoLoMcPriRK34") return new G4DoLoMcPriRK34(eqRhs);
220  else if (name=="DormandPrince745") return new G4DormandPrince745(eqRhs);
221  else if (name=="DormandPrinceRK56") return new G4DormandPrinceRK56(eqRhs);
222  else if (name=="DormandPrinceRK78") return new G4DormandPrinceRK78(eqRhs);
223  else if (name=="RK547FEq1") return new G4RK547FEq1(eqRhs);
224  else if (name=="RK547FEq2") return new G4RK547FEq2(eqRhs);
225  else if (name=="RK547FEq3") return new G4RK547FEq3(eqRhs);
226  else if (name=="RKG3_Stepper") return new G4RKG3_Stepper(eqRhs);
227  else if (name=="TsitourasRK45") return new G4TsitourasRK45(eqRhs);
228  else {
229  ATH_MSG_ERROR("Stepper " << name << " not available! returning NystromRK4!");
230  return new G4NystromRK4(eqRhs);
231  }
232 }

◆ initialize()

StatusCode G4FieldManagerToolBase::initialize ( )
overridevirtualinherited

Initialize method.

Definition at line 62 of file G4FieldManagerToolBase.cxx.

63 {
64  ATH_MSG_DEBUG("G4FieldManagerToolBase::initialize()");
65 
66  // Skip field svc retrieval if field disabled.
67  if(m_fieldOn) {
68  ATH_CHECK( m_fieldSvc.retrieve() );
69  }
70  else {
71  ATH_MSG_DEBUG("Field disabled. Not retrieving G4 field svc.");
72  }
73  if (!m_equationOfMotion.empty())
74  {
75  ATH_CHECK(m_equationOfMotion.retrieve());
76  }
77  return StatusCode::SUCCESS;
78 }

◆ initializeField()

StatusCode GlobalFieldManagerTool::initializeField ( )
finaloverride

Initialize a field manager.

Definition at line 34 of file GlobalFieldManagerTool.cxx.

35 {
36  ATH_MSG_DEBUG("initializeField");
37 
38  if (m_fieldOn) {
39 
40  // Retrieve the G4MagneticField
41  G4MagneticField* field = m_fieldSvc->getField();
42 
43  // Retrieve the global field manager
44  auto transpManager = G4TransportationManager::GetTransportationManager();
45  G4FieldManager* fieldMgr(nullptr);
47  // In the case of tight stepping we need to make our own global field manager
48  // If field manager already exists for current thread, error.
49  // There is no foreseen use-case for this situation.
50  if(m_fieldMgrHolder.get()) {
51  ATH_MSG_ERROR("GlobalFieldManagerTool::initializeField() - " <<
52  "Field manager already exists!");
53  return StatusCode::FAILURE;
54  }
55  // Create a new field manager
56  fieldMgr = new TightMuonSteppingFieldManager();
57 
58  // Save it in the TL holder
59  m_fieldMgrHolder.set(fieldMgr);
60 
61  // Assign it to the global field manager
62  transpManager->SetFieldManager(fieldMgr);
63  } else {
64  // Otherwise get the default from the transportation manager
65  fieldMgr = transpManager->GetFieldManager();
66  }
67 
68  // Configure the field manager
69  fieldMgr->SetDetectorField(field);
70  ATH_CHECK( setFieldParameters(fieldMgr) );
71 
72  // Create and configure the ChordFinder
73  fieldMgr->CreateChordFinder(field);
74 
75 #if G4VERSION_NUMBER < 1040
76  ATH_MSG_DEBUG("Old style stepper setting");
77  G4MagIntegratorStepper* stepper = getStepper(m_integratorStepper, field);
78  G4MagInt_Driver* magDriver = fieldMgr->GetChordFinder()->GetIntegrationDriver();
79  magDriver->RenewStepperAndAdjust(stepper);
80 #else
81  ATH_MSG_DEBUG("New style stepper setting");
82  G4VIntegrationDriver* driver = createDriverAndStepper(m_integratorStepper, field);
83  G4ChordFinder* chordFinder = fieldMgr->GetChordFinder();
84  chordFinder->SetIntegrationDriver(driver);
85 #endif
86 
87  // Configure the propagator
88  G4PropagatorInField* propagator = transpManager->GetPropagatorInField();
89  if (m_maxStep>0) propagator->SetLargestAcceptableStep(m_maxStep);
90 
91  }
92 
93  return StatusCode::SUCCESS;
94 }

◆ setFieldParameters()

StatusCode G4FieldManagerToolBase::setFieldParameters ( G4FieldManager *  fieldMgr) const
protectedinherited

Common method to apply configuredfield parameters.

Definition at line 238 of file G4FieldManagerToolBase.cxx.

240 {
241  ATH_MSG_DEBUG("setFieldParameters");
242  if (fieldMgr) {
243  if (m_deltaChord>0) fieldMgr->GetChordFinder()->SetDeltaChord(m_deltaChord);
244  if (m_deltaOneStep>0) fieldMgr->SetDeltaOneStep(m_deltaOneStep);
245  if (m_deltaIntersection>0) fieldMgr->SetDeltaIntersection(m_deltaIntersection);
246 
247  auto minEps_actual = m_minEps > 0 ? m_minEps.value() : fieldMgr->GetMinimumEpsilonStep();
248  auto maxEps_actual = m_maxEps > 0 ? m_maxEps.value() : fieldMgr->GetMaximumEpsilonStep();
249  G4FieldManagerHelper::SetMinAndMaxEpsilonStep(fieldMgr, minEps_actual, maxEps_actual);
250  }
251  else {
252  ATH_MSG_ERROR("setFieldParameters received NULL field mgr!");
253  return StatusCode::FAILURE;
254  }
255  return StatusCode::SUCCESS;
256 }

Member Data Documentation

◆ m_deltaChord

Gaudi::Property<double> G4FieldManagerToolBase::m_deltaChord {this, "DeltaChord", -1.0, "Missing distance for the chord finder"}
protectedinherited

Definition at line 81 of file G4FieldManagerToolBase.h.

◆ m_deltaIntersection

Gaudi::Property<double> G4FieldManagerToolBase::m_deltaIntersection {this, "DeltaIntersection", -1.0, "Accuracy for boundary intersection"}
protectedinherited

Definition at line 83 of file G4FieldManagerToolBase.h.

◆ m_deltaOneStep

Gaudi::Property<double> G4FieldManagerToolBase::m_deltaOneStep {this, "DeltaOneStep", -1.0, "Delta(one-step)"}
protectedinherited

Definition at line 82 of file G4FieldManagerToolBase.h.

◆ m_equationOfMotion

ToolHandle<IEquationOfMotionTool> G4FieldManagerToolBase::m_equationOfMotion {this, "EquationOfMotion", "", ""}
protectedinherited

The type of equation of motion to use.

Definition at line 74 of file G4FieldManagerToolBase.h.

◆ m_fieldMgrHolder

thread_utils::ThreadLocalOwner<G4FieldManager> GlobalFieldManagerTool::m_fieldMgrHolder
protected

My field manager – populated only in the case that we use tight muon stepping.

Definition at line 42 of file GlobalFieldManagerTool.h.

◆ m_fieldOn

Gaudi::Property<bool> G4FieldManagerToolBase::m_fieldOn {this, "FieldOn", true, "Toggles field on/off"}
protectedinherited
Todo:
TODO why is this duplicated in the g4 field svc?

Definition at line 68 of file G4FieldManagerToolBase.h.

◆ m_fieldSvc

ServiceHandle<IG4FieldSvc> G4FieldManagerToolBase::m_fieldSvc {this, "FieldSvc", "G4FieldSvc", "Service providing a G4MagneticField"}
protectedinherited

Handle to the G4 field service.

Definition at line 65 of file G4FieldManagerToolBase.h.

◆ m_integratorStepper

Gaudi::Property<std::string> G4FieldManagerToolBase::m_integratorStepper {this, "IntegratorStepper", "AtlasRK4", "Integrator stepper name"}
protectedinherited

The type of stepper to use.

Definition at line 71 of file G4FieldManagerToolBase.h.

◆ m_maxEps

Gaudi::Property<double> G4FieldManagerToolBase::m_maxEps {this, "MaximumEpsilonStep", -1.0, "Maximum epsilon (see G4 documentation)"}
protectedinherited

Definition at line 80 of file G4FieldManagerToolBase.h.

◆ m_maxStep

Gaudi::Property<double> G4FieldManagerToolBase::m_maxStep {this, "MaximumStep", -1.0, "Maximum step length in field (see G4 documentation)"}
protectedinherited

Definition at line 84 of file G4FieldManagerToolBase.h.

◆ m_minEps

Gaudi::Property<double> G4FieldManagerToolBase::m_minEps {this, "MinimumEpsilonStep", -1.0, "Minimum epsilon (see G4 documentation)"}
protectedinherited

Definition at line 79 of file G4FieldManagerToolBase.h.

◆ m_minStep

Gaudi::Property<double> G4FieldManagerToolBase::m_minStep {this, "MinimumStep",1e-2, "Minimum step length in field (see G4 documentation)"}
protectedinherited

Definition at line 85 of file G4FieldManagerToolBase.h.

◆ m_useTightMuonStepping

Gaudi::Property<bool> GlobalFieldManagerTool::m_useTightMuonStepping
protected
Initial value:
{this, "UseTightMuonStepping", false,
"Use tight muon stepping parameters by default"}

Tight muon stepping parameters via the field manager's configure for track.

Definition at line 38 of file GlobalFieldManagerTool.h.


The documentation for this class was generated from the following files:
G4FieldManagerToolBase::setFieldParameters
StatusCode setFieldParameters(G4FieldManager *fieldMgr) const
Common method to apply configuredfield parameters.
Definition: G4FieldManagerToolBase.cxx:239
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
G4FieldManagerToolBase::m_equationOfMotion
ToolHandle< IEquationOfMotionTool > m_equationOfMotion
The type of equation of motion to use.
Definition: G4FieldManagerToolBase.h:74
G4FieldManagerToolBase::m_integratorStepper
Gaudi::Property< std::string > m_integratorStepper
The type of stepper to use.
Definition: G4FieldManagerToolBase.h:71
G4FieldManagerToolBase::m_maxStep
Gaudi::Property< double > m_maxStep
Definition: G4FieldManagerToolBase.h:84
G4FieldManagerToolBase::G4FieldManagerToolBase
G4FieldManagerToolBase(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
Definition: G4FieldManagerToolBase.cxx:52
G4FieldManagerToolBase::m_minEps
Gaudi::Property< double > m_minEps
Definition: G4FieldManagerToolBase.h:79
G4FieldManagerToolBase::m_fieldOn
Gaudi::Property< bool > m_fieldOn
Definition: G4FieldManagerToolBase.h:68
G4FieldManagerToolBase::m_fieldSvc
ServiceHandle< IG4FieldSvc > m_fieldSvc
Handle to the G4 field service.
Definition: G4FieldManagerToolBase.h:65
ReadOfcFromCool.field
field
Definition: ReadOfcFromCool.py:48
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
G4FieldManagerToolBase::m_deltaOneStep
Gaudi::Property< double > m_deltaOneStep
Definition: G4FieldManagerToolBase.h:82
FullCPAlgorithmsTest_eljob.driver
driver
Definition: FullCPAlgorithmsTest_eljob.py:175
G4FieldManagerToolBase::m_deltaChord
Gaudi::Property< double > m_deltaChord
Definition: G4FieldManagerToolBase.h:81
thread_utils::ThreadLocalHolder::set
void set(T *obj)
Assign the object of the current thread.
Definition: ThreadLocalHolder.h:67
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
thread_utils::ThreadLocalHolder::get
T * get()
Get the object of the current thread.
Definition: ThreadLocalHolder.h:60
G4FieldManagerToolBase::m_deltaIntersection
Gaudi::Property< double > m_deltaIntersection
Definition: G4FieldManagerToolBase.h:83
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
GlobalFieldManagerTool::m_useTightMuonStepping
Gaudi::Property< bool > m_useTightMuonStepping
Tight muon stepping parameters via the field manager's configure for track.
Definition: GlobalFieldManagerTool.h:38
G4FieldManagerHelper::SetMinAndMaxEpsilonStep
G4bool SetMinAndMaxEpsilonStep(G4FieldManager *fieldMgr, double eps_min, double eps_max)
Set epsilon step range for a G4FieldManager instance accounting for Geant4 sanity checks.
Definition: G4FieldManagerHelper.h:23
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
GlobalFieldManagerTool::m_fieldMgrHolder
thread_utils::ThreadLocalOwner< G4FieldManager > m_fieldMgrHolder
My field manager – populated only in the case that we use tight muon stepping.
Definition: GlobalFieldManagerTool.h:42
TightMuonSteppingFieldManager
G4FieldManager that sets tight stepping for muons; caches global values for other particles.
Definition: TightMuonSteppingFieldManager.h:24
G4FieldManagerToolBase::m_maxEps
Gaudi::Property< double > m_maxEps
Definition: G4FieldManagerToolBase.h:80
G4FieldManagerToolBase::getStepper
G4MagIntegratorStepper * getStepper(const std::string &stepperType, G4MagneticField *field) const
Common method to construct a stepper of requested type.
Definition: G4FieldManagerToolBase.cxx:190