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,
44 ATH_MSG_ERROR(
"DetectorFieldManagerTool::initializeField() - " <<
45 "Field manager already exists!");
46 return StatusCode::FAILURE;
53 G4FieldManager * fieldMgr =
nullptr;
58 fieldMgr =
new G4FieldManager();
65 fieldMgr->SetDetectorField(
field);
66 fieldMgr->CreateChordFinder(
field);
70 fieldMgr->CreateChordFinder(
field);
72 #if G4VERSION_NUMBER < 1040
75 G4MagInt_Driver* magDriver = fieldMgr->GetChordFinder()->GetIntegrationDriver();
76 magDriver->RenewStepperAndAdjust(stepper);
80 G4ChordFinder* chordFinder = fieldMgr->GetChordFinder();
81 chordFinder->SetIntegrationDriver(
driver);
86 auto logVolStore = G4LogicalVolumeStore::GetInstance();
88 G4LogicalVolume* logicalVolume = logVolStore->GetVolume(volume);
89 if (logicalVolume !=
nullptr) logicalVolume->SetFieldManager(fieldMgr,
true);
91 ATH_MSG_WARNING(
"No volume called " << volume <<
" was found in the G4LogicalVolumeStore! Skipping this volume.");
95 auto physVolStore = G4PhysicalVolumeStore::GetInstance();
97 G4VPhysicalVolume* physicalVolume = physVolStore->GetVolume(volume);
98 if (physicalVolume !=
nullptr) physicalVolume->GetLogicalVolume()->SetFieldManager(fieldMgr,
true);
100 ATH_MSG_WARNING(
"No volume called " << volume <<
" was found in the G4PhysicalVolumeStore! Skipping this volume.");
104 ATH_MSG_WARNING(
"No volumes are provided. Field manager is NOT assigned.");
108 return StatusCode::SUCCESS;