Skip to content
Snippets Groups Projects
Unverified Commit 47a940da authored by lintao@ihep.ac.cn's avatar lintao@ihep.ac.cn Committed by GitHub
Browse files

Merge pull request #7 from mirguest/field

Setup B-Field in Simulation
parents 82fa4a08 327aea13
No related branches found
No related tags found
No related merge requests found
......@@ -74,4 +74,13 @@
<!--include ref="Field_Solenoid_Map_s_4.0T.xml"/>
<include ref="Field_AntiDID_Map_s.xml"/>
<include ref="Field_FwdMagnets_Ideal_1000GeV.xml"/-->
<fields>
<field name="MagnetFields_Constant" type="ConstantField" field="magnetic">
<strength x="0" y="0" z="3.0*tesla"/>
</field>
</fields>
</lccdd>
......@@ -19,11 +19,16 @@
#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"
#include "DDG4/Geant4Mapping.h"
#include "DDG4/Geant4Field.h"
DECLARE_COMPONENT(AnExampleDetElemTool)
......@@ -143,6 +148,31 @@ 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();
// // Below is a uniform B-field
// G4ThreeVector value(0,0,3.*tesla);
// G4UniformMagField* mag_field = new G4UniformMagField(value);
// DDG4 based B-field
dd4hep::OverlayedField fld = lcdd->field();
G4MagneticField* mag_field = new dd4hep::sim::Geant4Field(fld);
fieldManager->SetDetectorField(mag_field);
fieldManager->CreateChordFinder(mag_field);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment