diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp index ff31cdf11c5cf4167272597d227ea9c58a0f997e..decac3e9dccc7772fded76ab5e7bec32e2942ca2 100644 --- a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp +++ b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp @@ -19,6 +19,11 @@ #include "G4PhysicalVolumeStore.hh" #include "G4OpticalSurface.hh" +// Field +#include "G4UniformMagField.hh" +#include "G4FieldManager.hh" +#include "G4TransportationManager.hh" + #include "DD4hep/Detector.h" #include "DD4hep/Plugins.h" #include "DDG4/Geant4Converter.h" @@ -143,6 +148,26 @@ AnExampleDetElemTool::ConstructSDandField() { } } + // ======================================================================= + // Construct Field + // ======================================================================= + // TODO: integrate the field between DD4hep and Geant4 + // Note: + // DD4hep provides the parameters of fields + // Geant4 will setup the field based on the DD4hep fields + + // Related Examples: + // - G4: G4GlobalMagFieldMessenger.cc + + G4FieldManager* fieldManager + = G4TransportationManager::GetTransportationManager()->GetFieldManager(); + + G4ThreeVector value(0,0,3.*tesla); + G4UniformMagField* aMagField = new G4UniformMagField(value); + + fieldManager->SetDetectorField(aMagField); + fieldManager->CreateChordFinder(aMagField); + }