15 #include <Geant4/G4Field.hh>
16 #include <Geant4/G4FieldManager.hh>
17 #include <Geant4/G4PhysicalConstants.hh>
18 #include <Geant4/G4SystemOfUnits.hh>
19 #include <Geant4/G4TransportationManager.hh>
20 #include <Geant4/G4Types.hh>
21 #include <Geant4/G4Vector3D.hh>
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wshadow"
25 #include <boost/stacktrace.hpp>
26 #pragma GCC diagnostic pop
34 G4double scintiGap, G4double tiltAngle)
35 : is_in_iron(isInIron)
36 , n_steel_plates(steelPlates)
37 , scinti_gap(scintiGap)
38 , tilt_angle(tiltAngle)
44 G4FieldManager* field_manager =
45 G4TransportationManager::GetTransportationManager()->GetFieldManager();
49 std::cout <<
"PHG4OuterHcalField::GetFieldValue"
50 <<
" - Error! can not find field manager in G4TransportationManager"
56 const G4Field* default_field = field_manager->GetDetectorField();
60 default_field->GetFieldValue(Point, Bfield);
70 const G4Vector3D B0(Bfield[0], Bfield[1], Bfield[2]);
71 const G4Vector3D B0XY(Bfield[0], Bfield[1], 0);
72 const G4Vector3D B0Z(0, 0, Bfield[2]);
74 const double R = sqrt(x * x + y * y);
76 const double layer_width = layer_RdPhi * cos(
tilt_angle);
78 if (gap_width >= layer_width)
80 std::cout <<
"PHG4OuterHcalField::GetFieldValue gap_width " << gap_width
81 <<
" < layer_width: " << layer_width
82 <<
" existing now, here is some debug info" << std::endl;
83 std::cout <<
"coordinates: x: " << Point[0] /
cm
84 <<
", y: " << Point[1] /
cm
85 <<
", z: " << Point[2] /
cm << std::endl;
87 std::cout <<
"Radius: " << R << std::endl;
88 std::cout <<
"layer_RdPhi: " << layer_RdPhi << std::endl;
89 std::cout <<
"layer_width: " << layer_width << std::endl;
90 std::cout <<
"tilt_angle: " <<
tilt_angle << std::endl;
91 std::cout <<
"And this is who called it:" << std::endl;
92 std::cout << boost::stacktrace::stacktrace();
93 std::cout << std::endl;
97 const G4Vector3D absorber_dir(cos(atan2(y, x) -
tilt_angle),
99 const G4Vector3D radial_dir(cos(atan2(y, x)), sin(atan2(y, x)), 0);
101 const double radial_flux_per_layer = layer_RdPhi * (B0XY.dot(radial_dir));
106 const G4Vector3D B_New_XY = B_XY_mag * absorber_dir;
108 const double z_flux_per_layer = layer_width * B0Z.z();
112 const G4Vector3D B_New_Z(0, 0, B_Z_mag);
115 G4Vector3D B_New = B_New_Z + B_New_XY;
116 Bfield[0] = B_New.x();
117 Bfield[1] = B_New.y();
118 Bfield[2] = B_New.z();
122 std::cout <<
"PHG4OuterHcalField::GetFieldValue"
123 <<
" - Error! can not find detecor field in field manager!"