EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Magnet_Cleo.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Magnet_Cleo.C
1 #ifndef MACRO_G4MAGNETJLEIC_C
2 #define MACRO_G4MAGNETJLEIC_C
3 
4 #include <GlobalVariables.C>
5 
7 
8 #include <g4main/PHG4Reco.h>
9 
10 R__LOAD_LIBRARY(libg4detectors.so)
11 
12 namespace Enable
13 {
14  bool MAGNET = false;
15  bool MAGNET_ABSORBER = false;
16  bool MAGNET_OVERLAPCHECK = false;
18 } // namespace Enable
19 
20 namespace G4MAGNET
21 {
22  double magnet_inner_radius = 130.;
23  double magnet_outer_radius = 143.;
24  double magnet_length = 400.;
25 } // namespace G4MAGNET
26 
28 {
29  if (!isfinite(G4MAGNET::magfield_rescale))
30  {
32  }
33  if (G4MAGNET::magfield.empty())
34  {
35  G4MAGNET::magfield = string(getenv("CALIBRATIONROOT")) + string("/Field/Map/SolenoidMag3D.TABLE");
36  }
37 }
38 
39 void MagnetInit()
40 {
45 }
46 
47 double Magnet(PHG4Reco* g4Reco,
48  double radius)
49 {
50  bool AbsorberActive = Enable::ABSORBER || Enable::MAGNET_ABSORBER;
53 
54  if (radius > G4MAGNET::magnet_inner_radius)
55  {
56  cout << "inconsistency: radius: " << radius
57  << " larger than Magnet inner radius: " << G4MAGNET::magnet_inner_radius << endl;
58  gSystem->Exit(-1);
59  }
60 
61  // right now Cleo is a massive Al cylinder which is likely not correct
62  // need to know the radiation length and adjust the material for that
63  // or get an idea about the actual cleo magnet design
65  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("MAGNET", 0);
69  cyl->set_string_param("material", "Al5083");
70  cyl->SuperDetector("MAGNET");
71  if (AbsorberActive) cyl->SetActive();
72  g4Reco->registerSubsystem(cyl);
73 
74  radius = G4MAGNET::magnet_outer_radius; // outside of magnet
75 
76  if (verbosity > 0)
77  {
78  cout << "========================= G4_Magnet.C::Magnet() ===========================" << endl;
79  cout << " MAGNET Material Description:" << endl;
80  cout << " inner radius = " << G4MAGNET::magnet_inner_radius << " cm" << endl;
81  cout << " outer radius = " << G4MAGNET::magnet_outer_radius << " cm" << endl;
82  cout << " length = " << G4MAGNET::magnet_length << " cm" << endl;
83  cout << "===========================================================================" << endl;
84  }
85 
86  radius += no_overlapp;
87 
88  return radius;
89 }
90 
91 #endif // MACRO_G4MAGNETJLEIC_C