4 #include <phparameter/PHParameters.h>
13 #include <Geant4/G4ChordFinder.hh>
14 #include <Geant4/G4ClassicalRK4.hh>
15 #include <Geant4/G4FieldManager.hh>
16 #include <Geant4/G4LogicalVolume.hh>
17 #include <Geant4/G4Mag_UsualEqRhs.hh>
18 #include <Geant4/G4MagneticField.hh>
19 #include <Geant4/G4Material.hh>
20 #include <Geant4/G4PVPlacement.hh>
21 #include <Geant4/G4PhysicalConstants.hh>
22 #include <Geant4/G4QuadrupoleMagField.hh>
23 #include <Geant4/G4RotationMatrix.hh>
24 #include <Geant4/G4String.hh>
25 #include <Geant4/G4SystemOfUnits.hh>
26 #include <Geant4/G4ThreeVector.hh>
27 #include <Geant4/G4Transform3D.hh>
28 #include <Geant4/G4Tubs.hh>
29 #include <Geant4/G4Types.hh>
30 #include <Geant4/G4UniformMagField.hh>
31 #include <Geant4/G4VisAttributes.hh>
33 #include <CLHEP/Units/SystemOfUnits.h>
48 , magnet_physi(nullptr)
49 , magnet_iron_physi(nullptr)
78 G4RotationMatrix *rotm =
new G4RotationMatrix();
84 G4MagneticField *magField =
nullptr;
87 if (magnettype ==
"DIPOLE")
94 magField =
new G4UniformMagField(field);
97 cout <<
"Creating DIPOLE with field x: " << field.x() / tesla
98 <<
", y: " << field.y() / tesla
99 <<
", z: " << field.z() / tesla
100 <<
" and name " <<
GetName() << endl;
103 else if (magnettype ==
"QUADRUPOLE")
110 magField =
new G4QuadrupoleMagField(fieldGradient,
origin, rotm);
114 cout <<
"Creating QUADRUPOLE with gradient " << fieldGradient <<
" and name " <<
GetName() << endl;
115 cout <<
"at x, y, z = " <<
origin.x() <<
" , " <<
origin.y() <<
" , " <<
origin.z() << endl;
116 cout <<
"with rotation around x, y, z axis by: " << rotm->phiX() <<
", " << rotm->phiY() <<
", " << rotm->phiZ() << endl;
122 cout <<
PHWHERE <<
" No magnetic field specified for " <<
GetName()
123 <<
" of type " << magnettype << endl;
127 G4VSolid *magnet_iron_solid =
new G4Tubs(G4String(
GetName().append(
"_Solid").c_str()),
131 G4LogicalVolume *magnet_iron_logic =
new G4LogicalVolume(magnet_iron_solid,
132 G4Material::GetMaterial(
"G4_Fe"),
138 G4String(
GetName().append(
"_Solid").c_str()),
141 G4VSolid *magnet_solid =
new G4Tubs(G4String(
GetName().c_str()),
146 G4LogicalVolume *magnet_logic =
new G4LogicalVolume(magnet_solid,
147 G4Material::GetMaterial(
"G4_Galactic"),
155 G4Mag_UsualEqRhs *localEquation =
new G4Mag_UsualEqRhs(magField);
156 G4ClassicalRK4 *localStepper =
new G4ClassicalRK4(localEquation);
157 G4double minStep = 0.25 *
mm;
158 G4ChordFinder *localChordFinder =
new G4ChordFinder(magField, minStep, localStepper);
160 G4FieldManager *fieldMgr =
new G4FieldManager();
161 fieldMgr->SetDetectorField(magField);
162 fieldMgr->SetChordFinder(localChordFinder);
163 magnet_logic->SetFieldManager(fieldMgr,
true);
169 magnet_physi =
new G4PVPlacement(
nullptr, G4ThreeVector(0, 0, 0),