ECCE @ 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;
18 } // namespace Enable
19 
20 namespace G4MAGNET
21 {
24  double magnet_length = 379.;
25 } // namespace G4MAGNET
26 
28 {
30  {
32  }
33  if (G4MAGNET::magfield.empty())
34  {
35  G4MAGNET::magfield = string(getenv("CALIBRATIONROOT")) + string("/Field/Map/sPHENIX.2d.root");
36 cout << "Using magnetic field map: " << G4MAGNET::magfield << endl;
37  }
38 }
39 
40 void MagnetInit()
41 {
46 }
47 
48 double Magnet(PHG4Reco* g4Reco, double radius)
49 {
50  bool AbsorberActive = Enable::ABSORBER || Enable::MAGNET_ABSORBER;
53 
54  double magnet_inner_cryostat_wall_radius = 142;
55  double magnet_inner_cryostat_wall_thickness = 1;
56  double magnet_coil_radius = 150.8;
57  double magnet_coil_thickness = 9.38;
58  double magnet_length = 379.;
59  double coil_length = 361.5;
60  if (radius > magnet_inner_cryostat_wall_radius)
61  {
62  cout << "inconsistency: radius: " << radius
63  << " larger than Magnet inner radius: " << magnet_inner_cryostat_wall_radius << endl;
64  gSystem->Exit(-1);
65  }
66 
67  radius = magnet_inner_cryostat_wall_radius;
68  PHG4CylinderSubsystem* cyl = new PHG4CylinderSubsystem("MAGNET", 0);
69  cyl->set_double_param("radius", magnet_inner_cryostat_wall_radius);
70  cyl->set_int_param("lengthviarapidity", 0);
72  cyl->set_double_param("thickness", magnet_inner_cryostat_wall_thickness);
73  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
74  cyl->SuperDetector("MAGNET");
75  if (AbsorberActive) cyl->SetActive();
76  cyl->OverlapCheck(OverlapCheck);
77  g4Reco->registerSubsystem(cyl);
78 
79  cyl = new PHG4CylinderSubsystem("MAGNET", 1);
80  cyl->set_double_param("radius", magnet_coil_radius);
81  cyl->set_int_param("lengthviarapidity", 0);
82  cyl->set_double_param("length", coil_length);
83  cyl->set_double_param("thickness", magnet_coil_thickness);
84  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
85  cyl->SuperDetector("MAGNET");
86  if (AbsorberActive) cyl->SetActive();
87  cyl->OverlapCheck(OverlapCheck);
88  g4Reco->registerSubsystem(cyl);
89 
90  cyl = new PHG4CylinderSubsystem("MAGNET", 2);
92  cyl->set_int_param("lengthviarapidity", 0);
95  cyl->set_string_param("material", "Al5083"); // use 1 radiation length Al for magnet thickness
96  cyl->SuperDetector("MAGNET");
97  if (AbsorberActive) cyl->SetActive();
98  cyl->OverlapCheck(OverlapCheck);
99  g4Reco->registerSubsystem(cyl);
100 
102 
103  if (verbosity > 0)
104  {
105  cout << "========================= G4_Magnet.C::Magnet() ===========================" << endl;
106  cout << " MAGNET Material Description:" << endl;
107  cout << " inner radius = " << magnet_inner_cryostat_wall_radius << " cm" << endl;
108  cout << " outer radius = " << G4MAGNET::magnet_outer_cryostat_wall_radius + G4MAGNET::magnet_outer_cryostat_wall_thickness << " cm" << endl;
109  cout << " length = " << G4MAGNET::magnet_length << " cm" << endl;
110  cout << "===========================================================================" << endl;
111  }
112 
113  radius += no_overlapp;
114 
115  return radius;
116 }
117 #endif