Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHG4OHCalFieldSetup.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHG4OHCalFieldSetup.cc
1 // $Id: $
2 
11 #include "PHG4OHCalFieldSetup.h"
12 
14 
15 #include <phfield/PHFieldConfig.h> // for PHFieldConfig, PHFieldCo...
16 #include <phfield/PHFieldConfigv1.h>
17 #include <phfield/PHFieldUtility.h>
18 
19 #include <Geant4/G4ChordFinder.hh>
20 #include <Geant4/G4ClassicalRK4.hh>
21 #include <Geant4/G4FieldManager.hh>
22 #include <Geant4/G4MagIntegratorDriver.hh>
23 #include <Geant4/G4MagIntegratorStepper.hh>
24 #include <Geant4/G4Mag_UsualEqRhs.hh>
25 #include <Geant4/G4MagneticField.hh>
26 #include <Geant4/G4SystemOfUnits.hh>
27 #include <Geant4/G4Types.hh> // for G4int
28 
29 #include <cassert>
30 
31 PHG4OHCalFieldSetup::PHG4OHCalFieldSetup(const std::string &iron_fieldmap_path, const double scale, const double inner_radius, const double outer_radius, const double size_z)
32  : fMinStep(0.005 * mm)
33 {
34  static const G4int nvar = 8;
35 
36  // the new HCal expect 3D magnetic field
37  PHFieldConfigv1 field_config(PHFieldConfig::Field3DCartesian, iron_fieldmap_path, scale);
38 
39  fEMfieldIron = new PHG4MagneticField(PHFieldUtility::BuildFieldMap(&field_config, inner_radius, outer_radius, size_z));
41 
42  fEquationIron = new G4Mag_UsualEqRhs(fEMfieldIron);
43 
44  fStepperIron = new G4ClassicalRK4(fEquationIron, nvar);
45 
46  fChordFinderIron = new G4ChordFinder(
47  new G4MagInt_Driver(fMinStep, fStepperIron,
48  fStepperIron->GetNumberOfVariables()));
49 
50  fFieldManagerIron = new G4FieldManager();
51  fFieldManagerIron->SetDetectorField(fEMfieldIron);
52  fFieldManagerIron->SetChordFinder(fChordFinderIron);
53 }
54 
56 {
57  delete fEMfieldIron;
58 }