ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Setup_sPHENIX.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Setup_sPHENIX.C
1 #ifndef MACRO_G4SETUPSPHENIX_C
2 #define MACRO_G4SETUPSPHENIX_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_Bbc.C>
7 #include <G4_BlackHole.C>
8 #include <G4_CEmc_Albedo.C>
9 #include <G4_CEmc_Spacal.C>
10 //#include <G4_EPD.C>
11 #include <G4_FEMC.C>
12 #include <G4_HcalIn_ref.C>
13 #include <G4_HcalOut_ref.C>
14 #include <G4_Intt.C>
15 #include <G4_Magnet.C>
16 #include <G4_Micromegas.C>
17 #include <G4_Mvtx.C>
18 #include <G4_PSTOF.C>
19 #include <G4_Pipe.C>
20 #include <G4_PlugDoor.C>
21 #include <G4_TPC.C>
22 #include <G4_User.C>
23 #include <G4_World.C>
24 
26 
28 
29 #include <g4main/PHG4Reco.h>
31 
32 #include <phfield/PHFieldConfig.h>
33 
34 #include <g4decayer/EDecayType.hh>
35 
37 #include <fun4all/Fun4AllServer.h>
38 
39 R__LOAD_LIBRARY(libg4decayer.so)
40 R__LOAD_LIBRARY(libg4detectors.so)
41 
42 void G4Init()
43 {
44  // Check on invalid combinations
46  {
47  cout << "Enable::CEMCALBEDO and Enable::CEMC cannot be set simultanously" << endl;
48  gSystem->Exit(1);
49  }
50  // load detector/material macros and execute Init() function
51 
52  if (Enable::PIPE) PipeInit();
53  if (Enable::MVTX) MvtxInit();
54  if (Enable::INTT) InttInit();
55  if (Enable::TPC) TPCInit();
57  if (Enable::BBC) BbcInit();
59  if (Enable::CEMC) CEmcInit();
62  MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
65  if (Enable::FEMC) FEMCInit();
66  //if (Enable::EPD) EPDInit();
67  if (Enable::USER) UserInit();
69 }
70 
71 int G4Setup()
72 {
73  //---------------
74  // Fun4All server
75  //---------------
76 
78 
79  PHG4Reco *g4Reco = new PHG4Reco();
80  g4Reco->set_rapidity_coverage(1.1); // according to drawings
81  WorldInit(g4Reco);
83  {
85  }
86 
87  double fieldstrength;
88  istringstream stringline(G4MAGNET::magfield);
89  stringline >> fieldstrength;
90  if (stringline.fail())
91  { // conversion to double fails -> we have a string
92 
93  if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos)
94  {
96  }
97  else
98  {
100  }
101  }
102  else
103  {
104  g4Reco->set_field(fieldstrength); // use const soleniodal field
105  }
107 
108 // the radius is an older protection against overlaps, it is not
109 // clear how well this works nowadays but it doesn't hurt either
110  double radius = 0.;
111 
112  if (Enable::PIPE) radius = Pipe(g4Reco, radius);
113  if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
114  if (Enable::INTT) radius = Intt(g4Reco, radius);
115  if (Enable::TPC) radius = TPC(g4Reco, radius);
116  if (Enable::MICROMEGAS) Micromegas(g4Reco);
117  if (Enable::BBC) Bbc(g4Reco);
118  if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
119  if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
120  if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
121  if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
122  if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
123  if (Enable::PLUGDOOR) PlugDoor(g4Reco);
124  if (Enable::FEMC) FEMCSetup(g4Reco);
125  //if (Enable::EPD) EPD(g4Reco);
126  if (Enable::USER) UserDetector(g4Reco);
127 
128 
129  //----------------------------------------
130  // BLACKHOLE
131 
132  if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
133 
134  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
135  g4Reco->registerSubsystem(truth);
136 
137  // finally adjust the world size in case the default is too small
138  WorldSize(g4Reco, radius);
139 
140  se->registerSubsystem(g4Reco);
141  return 0;
142 }
143 
144 void ShowerCompress(int verbosity = 0)
145 {
147 
148  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
149  compress->AddHitContainer("G4HIT_PIPE");
150  compress->AddHitContainer("G4HIT_SVTXSUPPORT");
151  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
152  compress->AddHitContainer("G4HIT_CEMC");
153  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
154  compress->AddHitContainer("G4HIT_CEMC_SPT");
155  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
156  compress->AddHitContainer("G4HIT_HCALIN");
157  compress->AddHitContainer("G4HIT_HCALIN_SPT");
158  compress->AddHitContainer("G4HIT_MAGNET");
159  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
160  compress->AddHitContainer("G4HIT_HCALOUT");
161  compress->AddHitContainer("G4HIT_BH_1");
162  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
163  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
164  compress->AddHitContainer("G4HIT_BBC");
165  compress->AddCellContainer("G4CELL_CEMC");
166  compress->AddCellContainer("G4CELL_HCALIN");
167  compress->AddCellContainer("G4CELL_HCALOUT");
168  compress->AddTowerContainer("TOWER_SIM_CEMC");
169  compress->AddTowerContainer("TOWER_RAW_CEMC");
170  compress->AddTowerContainer("TOWER_CALIB_CEMC");
171  compress->AddTowerContainer("TOWER_SIM_HCALIN");
172  compress->AddTowerContainer("TOWER_RAW_HCALIN");
173  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
174  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
175  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
176  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
177  compress->AddHitContainer("G4HIT_FEMC");
178  compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
179  compress->AddCellContainer("G4CELL_FEMC");
180  compress->AddTowerContainer("TOWER_SIM_FEMC");
181  compress->AddTowerContainer("TOWER_RAW_FEMC");
182  compress->AddTowerContainer("TOWER_CALIB_FEMC");
183  se->registerSubsystem(compress);
184 
185  return;
186 }
187 
189 {
190  if (out)
191  {
192  out->StripNode("G4HIT_PIPE");
193  out->StripNode("G4HIT_SVTXSUPPORT");
194  out->StripNode("G4HIT_CEMC_ELECTRONICS");
195  out->StripNode("G4HIT_CEMC");
196  out->StripNode("G4HIT_ABSORBER_CEMC");
197  out->StripNode("G4HIT_CEMC_SPT");
198  out->StripNode("G4HIT_ABSORBER_HCALIN");
199  out->StripNode("G4HIT_HCALIN");
200  out->StripNode("G4HIT_HCALIN_SPT");
201  out->StripNode("G4HIT_MAGNET");
202  out->StripNode("G4HIT_ABSORBER_HCALOUT");
203  out->StripNode("G4HIT_HCALOUT");
204  out->StripNode("G4HIT_BH_1");
205  out->StripNode("G4HIT_BH_FORWARD_PLUS");
206  out->StripNode("G4HIT_BH_FORWARD_NEG");
207  out->StripNode("G4HIT_BBC");
208  out->StripNode("G4CELL_CEMC");
209  out->StripNode("G4CELL_HCALIN");
210  out->StripNode("G4CELL_HCALOUT");
211  out->StripNode("G4HIT_FEMC");
212  out->StripNode("G4HIT_ABSORBER_FEMC");
213  out->StripNode("G4CELL_FEMC");
214  }
215 }
216 #endif