From 8aa102d8527731c1df278ca5beaf8c5f3c9d32b2 Mon Sep 17 00:00:00 2001 From: lintao <lintao51@gmail.com> Date: Mon, 24 Aug 2020 23:26:15 +0800 Subject: [PATCH] WIP: hardcode a uniform magnetic field. --- .../DetSimGeom/src/AnExampleDetElemTool.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp b/Simulation/DetSimGeom/src/AnExampleDetElemTool.cpp index ff31cdf1..decac3e9 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); + } -- GitLab