EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_Magnet.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_Magnet.C
1 #ifndef MACRO_G4MAGNET_C
2 #define MACRO_G4MAGNET_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;
17  int MAGNET_VERBOSITY = 0;
18 } // namespace Enable
19 
20 namespace G4MAGNET
21 {
24  double magnet_length = 379.;
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/sphenix3dbigmapxyz.root");
36  }
37 }
38 
39 void MagnetInit()
40 {
45 }
46 
47 double Magnet(PHG4Reco* g4Reco, double radius)
48 {
49  bool AbsorberActive = Enable::ABSORBER || Enable::MAGNET_ABSORBER;
52 
53  double magnet_inner_cryostat_wall_radius = 142;
54  double magnet_inner_cryostat_wall_thickness = 1;
55  double magnet_coil_radius = 150.8;
56  double magnet_coil_thickness = 9.38;
57  double magnet_length = 379.;
58  double coil_length = 361.5;
59  if (radius > magnet_inner_cryostat_wall_radius)
60  {
61  cout << "inconsistency: radius: " << radius
62  << " larger than Magnet inner radius: " << magnet_inner_cryostat_wall_radius << endl;
63  gSystem->Exit(-1);
64  }
65 
66  radius = magnet_inner_cryostat_wall_radius;
67  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("MAGNET", 0);
68  cyl->set_double_param("radius", magnet_inner_cryostat_wall_radius);
69  cyl->set_int_param("lengthviarapidity", 0);
71  cyl->set_double_param("thickness", magnet_inner_cryostat_wall_thickness);
72  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
73  cyl->SuperDetector("MAGNET");
74  if (AbsorberActive) cyl->SetActive();
75  cyl->OverlapCheck(OverlapCheck);
76  g4Reco->registerSubsystem(cyl);
77 
78  cyl = new PHG4CylinderSubsystem("MAGNET", 1);
79  cyl->set_double_param("radius", magnet_coil_radius);
80  cyl->set_int_param("lengthviarapidity", 0);
81  cyl->set_double_param("length", coil_length);
82  cyl->set_double_param("thickness", magnet_coil_thickness);
83  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
84  cyl->SuperDetector("MAGNET");
85  if (AbsorberActive) cyl->SetActive();
86  cyl->OverlapCheck(OverlapCheck);
87  g4Reco->registerSubsystem(cyl);
88 
89  cyl = new PHG4CylinderSubsystem("MAGNET", 2);
91  cyl->set_int_param("lengthviarapidity", 0);
94  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
95  cyl->SuperDetector("MAGNET");
96  if (AbsorberActive) cyl->SetActive();
97  cyl->OverlapCheck(OverlapCheck);
98  g4Reco->registerSubsystem(cyl);
99 
101 
102  if (verbosity > 0)
103  {
104  cout << "========================= G4_Magnet.C::Magnet() ===========================" << endl;
105  cout << " MAGNET Material Description:" << endl;
106  cout << " inner radius = " << magnet_inner_cryostat_wall_radius << " cm" << endl;
107  cout << " outer radius = " << G4MAGNET::magnet_outer_cryostat_wall_radius + G4MAGNET::magnet_outer_cryostat_wall_thickness << " cm" << endl;
108  cout << " length = " << G4MAGNET::magnet_length << " cm" << endl;
109  cout << "===========================================================================" << endl;
110  }
111 
112  radius += no_overlapp;
113 
114  return radius;
115 }
116 #endif