Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Setup_EICIR.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Setup_EICIR.C
1 
2 double no_overlapp = 0.0001; // added to radii to avoid overlapping volumes
3 bool overlapcheck = false; // set to true if you want to check for overlaps
4 
5 void G4Init(bool do_magnet = true,
6  bool do_pipe = true,
7  bool do_ExtendedIR = true
8  ) {
9 
10  // load detector/material macros and execute Init() function
11  if (do_pipe)
12  {
13  gROOT->LoadMacro("G4_Pipe.C");
14  PipeInit();
15  }
16 
17  if (do_magnet)
18  {
19  gROOT->LoadMacro("G4_Magnet.C");
20  MagnetInit();
21  }
22 
23  if (do_ExtendedIR)
24  {
25  gROOT->LoadMacro("G4_IR_EIC.C");
26  IRInit();
27  }
28 
29 }
30 
31 
32 int G4Setup(const int absorberactive = 0,
33  const string &field ="1.5",
35  const bool do_magnet = true,
36  const bool do_pipe = true,
37  const bool do_ExtendedIR = true,
38  const float magfield_rescale = 1.0) {
39 
40  //---------------
41  // Load libraries
42  //---------------
43 
44  gSystem->Load("libg4detectors.so");
45  gSystem->Load("libg4testbench.so");
46 
47  //---------------
48  // Fun4All server
49  //---------------
50 
52 
53  PHG4Reco* g4Reco = new PHG4Reco();
54  g4Reco->set_rapidity_coverage(1.1); // according to drawings
55 
56  /* Set World Volume material to G4Galactic for beam line studies
57  * (beam would be inside vacuum tubes) */
58  g4Reco->SetWorldMaterial("G4_Galactic");
59 
61  g4Reco->set_force_decay(decayType);
62  }
63 
64  double fieldstrength;
65  istringstream stringline(field);
66  stringline >> fieldstrength;
67  if (stringline.fail()) { // conversion to double fails -> we have a string
68 
69  if (field.find("sPHENIX.root") != string::npos) {
70  g4Reco->set_field_map(field, 1);
71  } else {
72  g4Reco->set_field_map(field, 2);
73  }
74  } else {
75  g4Reco->set_field(fieldstrength); // use const soleniodal field
76  }
78 
79  double radius = 0.;
80 
81  //----------------------------------------
82  // PIPE
83  if (do_pipe) radius = Pipe(g4Reco, radius, absorberactive);
84 
85  //----------------------------------------
86  // MAGNET
87 
88  if (do_magnet) radius = Magnet(g4Reco, radius, 0, absorberactive);
89 
90  //----------------------------------------
91  // Extended IR
92  if ( do_ExtendedIR )
93  IRSetup(g4Reco);
94 
95 
96  // discs to track very forward protons
97  PHG4CylinderSubsystem *fwd_disc;
98  for ( unsigned i = 0; i < 900; i++ )
99  {
100  fwd_disc = new PHG4CylinderSubsystem("FWDDISC", i);
101  fwd_disc->set_int_param("lengthviarapidity",0);
102  fwd_disc->set_double_param("length",1);
103  fwd_disc->set_double_param("radius",0);
104  fwd_disc->set_double_param("thickness",200.0);
105  fwd_disc->set_double_param("place_z",450+i*10.0); // cm
106  fwd_disc->set_string_param("material","G4_Galactic");
107  fwd_disc->SetActive(true);
108  fwd_disc->SuperDetector("FWDDISC");
109  fwd_disc->OverlapCheck(overlapcheck);
110  g4Reco->registerSubsystem(fwd_disc);
111  }
112 
113  /* Add truth system */
114  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
115  g4Reco->registerSubsystem(truth);
116 
117  /* add reco to server */
118  se->registerSubsystem( g4Reco );
119 }