13#include "G4ChordFinder.hh"
14#include "G4FieldManager.hh"
15#include "G4LogicalVolumeStore.hh"
16#include "G4PhysicalVolumeStore.hh"
17#include "G4MagIntegratorStepper.hh"
18#include "G4MagneticField.hh"
19#include "G4Version.hh"
20#include "G4VIntegrationDriver.hh"
26 const std::string& name,
27 const IInterface* parent)
45 G4MagneticField* field =
m_fieldSvc->getField();
51 field_manager->SetDetectorField(field);
52 field_manager->CreateChordFinder(field);
56 field_manager->CreateChordFinder(field);
58#if G4VERSION_NUMBER < 1040
61 G4MagInt_Driver* magDriver = field_manager->GetChordFinder()->GetIntegrationDriver();
62 magDriver->RenewStepperAndAdjust(stepper);
66 G4ChordFinder* chordFinder = field_manager->GetChordFinder();
67 chordFinder->SetIntegrationDriver(driver);
72 auto logVolStore = G4LogicalVolumeStore::GetInstance();
74 G4LogicalVolume* logicalVolume = logVolStore->GetVolume(volume);
75 if (logicalVolume !=
nullptr) logicalVolume->SetFieldManager(field_manager,
true);
77 ATH_MSG_WARNING(
"No volume called " << volume <<
" was found in the G4LogicalVolumeStore! Skipping this volume.");
81 auto physVolStore = G4PhysicalVolumeStore::GetInstance();
83 G4VPhysicalVolume* physicalVolume = physVolStore->GetVolume(volume);
84 if (physicalVolume !=
nullptr) physicalVolume->GetLogicalVolume()->SetFieldManager(field_manager,
true);
86 ATH_MSG_WARNING(
"No volume called " << volume <<
" was found in the G4PhysicalVolumeStore! Skipping this volume.");
90 ATH_MSG_WARNING(
"No volumes are provided. Field manager is NOT assigned.");
93 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
G4FieldManager that sets tight stepping for muons; disables magnetic field for other particles.