EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Setup_EICDetector.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Setup_EICDetector.C
1 #ifndef MACRO_G4SETUPEICDETECTOR_C
2 #define MACRO_G4SETUPEICDETECTOR_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_Aerogel.C>
7 #include <G4_Barrel_EIC.C>
8 #include <G4_BlackHole.C>
9 #include <G4_CEmc_EIC.C>
10 #include <G4_DIRC.C>
11 #include <G4_EEMC.C>
12 #include <G4_FEMC_EIC.C>
13 #include <G4_FHCAL.C>
14 #include <G4_FST_EIC.C>
15 #include <G4_GEM_EIC.C>
16 #include <G4_HcalIn_ref.C>
17 #include <G4_HcalOut_ref.C>
18 #include <G4_Input.C>
19 #include <G4_Magnet.C>
20 #include <G4_Mvtx_EIC.C>
21 #include <G4_Pipe_EIC.C>
22 #include <G4_PlugDoor_EIC.C>
23 #include <G4_RICH.C>
24 #include <G4_TPC_EIC.C>
25 #include <G4_Tracking_EIC.C>
26 #include <G4_User.C>
27 #include <G4_World.C>
28 
30 
32 
33 #include <g4main/PHG4Reco.h>
35 
36 #include <phfield/PHFieldConfig.h>
37 
38 #include <g4decayer/EDecayType.hh>
39 
41 #include <fun4all/Fun4AllServer.h>
42 
43 R__LOAD_LIBRARY(libg4decayer.so)
44 R__LOAD_LIBRARY(libg4detectors.so)
45 
46 void G4Init()
47 {
48  // First some check for subsystems which do not go together
49 
50  if (Enable::TPC && Enable::FST)
51  {
52  cout << "TPC and FST cannot be enabled together" << endl;
53  gSystem->Exit(1);
54  }
55  else if ((Enable::TPC || Enable::MVTX) && Enable::BARREL)
56  {
57  cout << "TPC/MVTX and BARREL cannot be enabled together" << endl;
58  gSystem->Exit(1);
59  }
60 
61  // load detector/material macros and execute Init() function
62  if (Enable::PIPE) PipeInit();
63 
65 
66  if (Enable::EGEM) EGEM_Init();
67 
68  if (Enable::FGEM) FGEM_Init();
69 
70  if (Enable::FST) FST_Init();
71 
73  if (Enable::MVTX) MvtxInit();
74 
75  if (Enable::TPC) TPCInit();
76 
78 
79  if (Enable::CEMC) CEmcInit(72);
80 
82 
84  MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
86 
87  if (Enable::FEMC) FEMCInit();
88 
89  if (Enable::FHCAL) FHCALInit();
90 
91  if (Enable::EEMC) EEMCInit();
92 
93  if (Enable::DIRC) DIRCInit();
94 
95  if (Enable::RICH) RICHInit();
96 
98  if (Enable::USER) UserInit();
99 
101 }
102 
103 int G4Setup()
104 {
105  //---------------
106  // Fun4All server
107  //---------------
108 
110 
111  PHG4Reco *g4Reco = new PHG4Reco();
112 
113  WorldInit(g4Reco);
114 
115  g4Reco->set_rapidity_coverage(1.1); // according to drawings
116  // uncomment to set QGSP_BERT_HP physics list for productions
117  // (default is QGSP_BERT for speed)
118  // g4Reco->SetPhysicsList("QGSP_BERT_HP");
119 
121  {
123  }
124 
125  double fieldstrength;
126  istringstream stringline(G4MAGNET::magfield);
127  stringline >> fieldstrength;
128  if (stringline.fail())
129  { // conversion to double fails -> we have a string
130 
131  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos)
132  {
134  }
135  else
136  {
138  }
139  }
140  else
141  {
142  g4Reco->set_field(fieldstrength); // use const soleniodal field
143  }
145 
146  double radius = 0.;
147 
148  //----------------------------------------
149  // PIPE
150  if (Enable::PIPE)
151  {
152  radius = Pipe(g4Reco, radius);
153  }
154  //----------------------------------------
155 
156  if (Enable::EGEM)
157  {
158  EGEMSetup(g4Reco);
159  }
160 
161  if (Enable::FGEM)
162  {
163  FGEMSetup(g4Reco);
164  }
165  if (Enable::FST)
166  {
167  FSTSetup(g4Reco);
168  }
169  if (Enable::BARREL)
170  {
171  Barrel(g4Reco, radius);
172  }
173  if (Enable::MVTX)
174  {
175  radius = Mvtx(g4Reco, radius);
176  }
177  if (Enable::TPC)
178  {
179  radius = TPC(g4Reco, radius);
180  }
181 
182  //----------------------------------------
183  // CEMC
184  //
185  if (Enable::CEMC)
186  {
187  radius = CEmc(g4Reco, radius);
188  }
189 
190  //----------------------------------------
191  // HCALIN
192 
193  if (Enable::HCALIN)
194  {
195  radius = HCalInner(g4Reco, radius, 4);
196  }
197  //----------------------------------------
198  // MAGNET
199 
200  if (Enable::MAGNET)
201  {
202  radius = Magnet(g4Reco, radius);
203  }
204  //----------------------------------------
205  // HCALOUT
206 
207  if (Enable::HCALOUT)
208  {
209  radius = HCalOuter(g4Reco, radius, 4);
210  }
211  //----------------------------------------
212  // FEMC
213 
214  if (Enable::FEMC)
215  {
216  FEMCSetup(g4Reco);
217  }
218 
219  //----------------------------------------
220  // FHCAL
221 
222  if (Enable::FHCAL)
223  {
224  FHCALSetup(g4Reco);
225  }
226  //----------------------------------------
227  // EEMC
228 
229  if (Enable::EEMC)
230  {
231  EEMCSetup(g4Reco);
232  }
233 
234  //----------------------------------------
235  // PID
236 
237  if (Enable::DIRC)
238  {
239  DIRCSetup(g4Reco);
240  }
241 
242  if (Enable::RICH)
243  {
244  RICHSetup(g4Reco);
245  }
246 
247  if (Enable::AEROGEL)
248  {
249  AerogelSetup(g4Reco);
250  }
251  //----------------------------------------
252  // sPHENIX forward flux return door
253  if (Enable::PLUGDOOR)
254  {
255  PlugDoor(g4Reco);
256  }
257  if (Enable::USER)
258  {
259  UserDetector(g4Reco);
260  }
261  //----------------------------------------
262  // BLACKHOLE if enabled, needs info from all previous sub detectors for dimensions
263  if (Enable::BLACKHOLE)
264  {
265  BlackHole(g4Reco, radius);
266  }
267 
268  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
269  g4Reco->registerSubsystem(truth);
270  // finally adjust the world size in case the default is too small
271  WorldSize(g4Reco, radius);
272 
273  se->registerSubsystem(g4Reco);
274  return 0;
275 }
276 
278 {
280 
281  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
282  compress->AddHitContainer("G4HIT_PIPE");
283  compress->AddHitContainer("G4HIT_FIELDCAGE");
284  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
285  compress->AddHitContainer("G4HIT_CEMC");
286  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
287  compress->AddHitContainer("G4HIT_CEMC_SPT");
288  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
289  compress->AddHitContainer("G4HIT_HCALIN");
290  compress->AddHitContainer("G4HIT_HCALIN_SPT");
291  compress->AddHitContainer("G4HIT_MAGNET");
292  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
293  compress->AddHitContainer("G4HIT_HCALOUT");
294  compress->AddHitContainer("G4HIT_BH_1");
295  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
296  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
297  compress->AddCellContainer("G4CELL_CEMC");
298  compress->AddCellContainer("G4CELL_HCALIN");
299  compress->AddCellContainer("G4CELL_HCALOUT");
300  compress->AddTowerContainer("TOWER_SIM_CEMC");
301  compress->AddTowerContainer("TOWER_RAW_CEMC");
302  compress->AddTowerContainer("TOWER_CALIB_CEMC");
303  compress->AddTowerContainer("TOWER_SIM_HCALIN");
304  compress->AddTowerContainer("TOWER_RAW_HCALIN");
305  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
306  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
307  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
308  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
309 
310  compress->AddHitContainer("G4HIT_FEMC");
311  compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
312  compress->AddHitContainer("G4HIT_FHCAL");
313  compress->AddHitContainer("G4HIT_ABSORBER_FHCAL");
314  compress->AddCellContainer("G4CELL_FEMC");
315  compress->AddCellContainer("G4CELL_FHCAL");
316  compress->AddTowerContainer("TOWER_SIM_FEMC");
317  compress->AddTowerContainer("TOWER_RAW_FEMC");
318  compress->AddTowerContainer("TOWER_CALIB_FEMC");
319  compress->AddTowerContainer("TOWER_SIM_FHCAL");
320  compress->AddTowerContainer("TOWER_RAW_FHCAL");
321  compress->AddTowerContainer("TOWER_CALIB_FHCAL");
322 
323  compress->AddHitContainer("G4HIT_EEMC");
324  compress->AddHitContainer("G4HIT_ABSORBER_EEMC");
325  compress->AddCellContainer("G4CELL_EEMC");
326  compress->AddTowerContainer("TOWER_SIM_EEMC");
327  compress->AddTowerContainer("TOWER_RAW_EEMC");
328  compress->AddTowerContainer("TOWER_CALIB_EEMC");
329 
330  se->registerSubsystem(compress);
331 
332  return;
333 }
334 
336 {
337  if (out)
338  {
339  out->StripNode("G4HIT_PIPE");
340  out->StripNode("G4HIT_SVTXSUPPORT");
341  out->StripNode("G4HIT_CEMC_ELECTRONICS");
342  out->StripNode("G4HIT_CEMC");
343  out->StripNode("G4HIT_ABSORBER_CEMC");
344  out->StripNode("G4HIT_CEMC_SPT");
345  out->StripNode("G4HIT_ABSORBER_HCALIN");
346  out->StripNode("G4HIT_HCALIN");
347  out->StripNode("G4HIT_HCALIN_SPT");
348  out->StripNode("G4HIT_MAGNET");
349  out->StripNode("G4HIT_ABSORBER_HCALOUT");
350  out->StripNode("G4HIT_HCALOUT");
351  out->StripNode("G4HIT_BH_1");
352  out->StripNode("G4HIT_BH_FORWARD_PLUS");
353  out->StripNode("G4HIT_BH_FORWARD_NEG");
354  out->StripNode("G4CELL_CEMC");
355  out->StripNode("G4CELL_HCALIN");
356  out->StripNode("G4CELL_HCALOUT");
357 
358  out->StripNode("G4HIT_FEMC");
359  out->StripNode("G4HIT_ABSORBER_FEMC");
360  out->StripNode("G4HIT_FHCAL");
361  out->StripNode("G4HIT_ABSORBER_FHCAL");
362  out->StripNode("G4CELL_FEMC");
363  out->StripNode("G4CELL_FHCAL");
364 
365  out->StripNode("G4HIT_EEMC");
366  out->StripNode("G4HIT_ABSORBER_EEMC");
367  out->StripNode("G4CELL_EEMC");
368  }
369 }
370 #endif