ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Setup_ECCEModular.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Setup_ECCEModular.C
1 #ifndef MACRO_G4SETUPECCEMODULAR_C
2 #define MACRO_G4SETUPECCEMODULAR_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_BlackHole.C>
7 
8 //#include <G4_AllSilicon.C>
9 //#include <G4_Mvtx_EIC.C>
10 #include <G4_BECAL.C>
11 #include <G4_Barrel_EIC.C>
12 #include <G4_CEmc_EIC.C>
13 #include <G4_DIRC.C>
14 #include <G4_DRCALO.C>
15 #include <G4_EEMC.C>
16 #include <G4_EEMC_hybrid.C>
17 #include <G4_EHCAL.C>
18 #include <G4_FEMC_EIC.C>
19 #include <G4_FHCAL.C>
20 #include <G4_B0ECAL.C> //for B0 ECAL
21 #include <G4_FST_EIC.C>
22 #include <G4_GEM_EIC.C>
23 #include <G4_HcalIn_ref.C>
24 #include <G4_HcalOut_ref.C>
25 #include <G4_Input.C>
26 #include <G4_LFHCAL.C>
27 #include <G4_Magnet.C>
28 #include <G4_Pipe_EIC.C>
29 #include <G4_PlugDoor_EIC.C>
30 #include <G4_TTL_EIC.C>
31 #include <G4_TrackingSupport.C>
32 #include <G4_Tracking_EIC.C>
33 //#include <G4_B0Tracking_EIC.C> for B0 Tracking
34 #include <G4_dRICH.C>
35 #include <G4_mRICH.C>
36 #include <G4_mRwell_EIC.C>
37 #include <G4_BToF.C>
38 #include <G4_HToF.C>
39 #include <G4_EToF.C>
40 
41 // these two has to be ordered this way for now.
42 #include <G4_hFarFwdBeamLine_EIC.C>
43 #include <G4_hFarBwdBeamLine_EIC.C>
44 
45 #include <G4_User.C>
46 #include <G4_World.C>
47 
49 #include <eicg4b0/EICG4B0Subsystem.h>
50 #include <eicg4b0ecal/EICG4B0ECALSubsystem.h>
51 
53 
54 #include <g4main/PHG4Reco.h>
56 
57 #include <phfield/PHFieldConfig.h>
58 
59 #include <g4decayer/EDecayType.hh>
60 
62 #include <fun4all/Fun4AllServer.h>
63 
64 R__LOAD_LIBRARY(libg4decayer.so)
65 R__LOAD_LIBRARY(libg4detectors.so)
66 
67 void G4Init()
68 {
69  // First some check for subsystems which do not go together
70 
71  if (Enable::IP6 and Enable::IP8)
72  {
73  cout << "Can not enable Enable::IP6 and Enable::IP8 at the same time!" << endl;
74  gSystem->Exit(1);
75  }
76  if (Enable::IP6 == false and Enable::IP8 == false)
77  {
78  cout << "None of the possible EIC IPs were selected: Enable::IP6 and Enable::IP8 !" << endl;
79  gSystem->Exit(1);
80  }
81 
83  {
84  cout << "Can not enable EEMC and EEMCH at the same time!" << endl;
85  gSystem->Exit(1);
86  }
88  {
89  cout << "Can not enable CEMC and BECAL at the same time!" << endl;
90  gSystem->Exit(1);
91  }
92  if (Enable::BTOF and Enable::CTTL)
93  {
94  cout << "Can not enable BTOF and CTTL at the same time!" << endl;
95  gSystem->Exit(1);
96  }
97  if (Enable::ETOF and Enable::ETTL)
98  {
99  cout << "Can not enable ETOF and ETTL at the same time!" << endl;
100  gSystem->Exit(1);
101  }
102  if (Enable::HTOF and Enable::FTTL)
103  {
104  cout << "Can not enable HTOF and FTTL at the same time!" << endl;
105  gSystem->Exit(1);
106  }
107  if (Enable::BMMG and Enable::DIRC)
108  {
109  cout << "Can not enable BMMG and DIRC at the same time!" << endl;
110  gSystem->Exit(1);
111  }
113  {
114  cout << "Can not enable TRD* and RICH at the same time!" << endl;
115  gSystem->Exit(1);
116  }
117 
118  // load detector/material macros and execute Init() function
119  if (Enable::PIPE) PipeInit();
122 // if (Enable::B0TRACKING) B0TrackingInit();
123 
124  //Farforward/backward
125  if (Enable::HFARFWD_MAGNETS) hFarBwdBeamLineInit(); //Shouldnt this be far backward enables
127 
128  //Barrel
130  if (Enable::BARREL) BarrelInit();
131  if (Enable::RWELL) RWellInit();
132  if (Enable::CEMC) CEmcInit(72); // make it 2*2*2*3*3 so we can try other combinations
133  if (Enable::BECAL) BECALInit();
135  if (Enable::MAGNET) MagnetInit();
136  MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
138  if (Enable::DIRC) DIRCInit();
139  if (Enable::BTOF) BToFInit();
140  if (Enable::BMMG) BMMGInit();
141 
142  //Forward
143  if (Enable::FGEM) FGEM_Init();
144  if (Enable::FEMC) FEMCInit();
145  if (Enable::DRCALO) DRCALOInit();
146  if (Enable::FHCAL) FHCALInit();
147  if (Enable::LFHCAL) LFHCALInit();
148  if (Enable::RICH) RICHInit();
149  if (Enable::TRD) TRDInit();
150  if (Enable::HTOF) HTOFInit();
151  if (Enable::B0ECAL) B0ECALInit();
152 
153  //Backward
154  if (Enable::EGEM) EGEM_Init();
155  if (Enable::EEMC) EEMCInit();
156  if (Enable::EEMCH) EEMCHInit();
157  if (Enable::EHCAL) EHCALInit();
158  if (Enable::mRICH) mRICHInit();
159  if (Enable::ETOF) ETOFInit();
160 
161  //Combined
162  if (Enable::FST) FST_Init();
163  if (Enable::FTTL || Enable::ETTL || Enable::CTTL) TTL_Init();
164 
165  if (Enable::USER) UserInit();
167 }
168 
169 int G4Setup()
170 {
171  //---------------
172  // Fun4All server
173  //---------------
174 
176 
177  PHG4Reco *g4Reco = new PHG4Reco();
178 
179  WorldInit(g4Reco);
180 
181  g4Reco->set_rapidity_coverage(1.1); // according to drawings
182  // uncomment to set QGSP_BERT_HP physics list for productions
183  // (default is QGSP_BERT for speed)
184  // g4Reco->SetPhysicsList("QGSP_BERT_HP");
185 
187  {
189  }
190 
191  double fieldstrength;
192  istringstream stringline(G4MAGNET::magfield);
193  stringline >> fieldstrength;
194  if (stringline.fail())
195  { // conversion to double fails -> we have a string
196 
197  if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos)
198  {
200  }
201  else
202  {
204  }
205  }
206  else
207  {
208  g4Reco->set_field(fieldstrength); // use const soleniodal field
209  }
211 
212  // the radius is an older protection against overlaps, it is not
213  // clear how well this works nowadays but it doesn't hurt either
214  double radius = 0.;
215 
216  if (Enable::PIPE) radius = Pipe(g4Reco, radius);
217 
218  // Far Forward Region
222 
223  // Far Backward Region
227 
228  //Barrel
229  if (Enable::TrackingService) TrackingService(g4Reco, radius);
230 
231  if (Enable::RWELL) RWellSetup(g4Reco);
232  if (Enable::FST) FSTSetup(g4Reco);
233  if (Enable::CTTL) CTTLSetup(g4Reco);
234  if (Enable::BARREL) Barrel(g4Reco);
235  if (Enable::CEMC) radius = CEmc(g4Reco, radius);
236  if (Enable::BECAL) BECALSetup(g4Reco);
237  if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
238  if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
239  if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
240  if (Enable::DIRC) DIRCSetup(g4Reco);
241  if (Enable::BTOF) BToFSetup(g4Reco);
242  if (Enable::BMMG) BMMGSetup(g4Reco);
243 
244  //Forward
245  if (Enable::FGEM) FGEMSetup(g4Reco);
246  if (Enable::FTTL) FTTLSetup(g4Reco);
247  if (Enable::FEMC) FEMCSetup(g4Reco);
248  if (Enable::DRCALO) DRCALOSetup(g4Reco);
249  if (Enable::FHCAL) FHCALSetup(g4Reco);
250  if (Enable::LFHCAL) LFHCALSetup(g4Reco);
251  if (Enable::RICH) RICHSetup(g4Reco);
252  if (Enable::TRD) TRDSetup(g4Reco);
253  if (Enable::HTOF) HTOFSetup(g4Reco);
254 
255  //Backward
256  if (Enable::ETTL) ETTLSetup(g4Reco);
257  if (Enable::EGEM) EGEMSetup(g4Reco);
258  if (Enable::EEMC) EEMCSetup(g4Reco);
259  if (Enable::EEMCH) EEMCHSetup(g4Reco);
260  if (Enable::EHCAL) EHCALSetup(g4Reco);
261  if (Enable::mRICH) mRICHSetup(g4Reco);
262  if (Enable::ETOF) ETOFSetup(g4Reco);
263 
264  //----------------------------------------
265  // sPHENIX forward flux return door
266  if (Enable::PLUGDOOR) PlugDoor(g4Reco);
267 
268  if (Enable::USER) UserDetector(g4Reco);
269 
270  //----------------------------------------
271  // BLACKHOLE if enabled, needs info from all previous sub detectors for dimensions
272  if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
273 
274  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
275  g4Reco->registerSubsystem(truth);
276  // finally adjust the world size in case the default is too small
277  WorldSize(g4Reco, radius);
278 
279  se->registerSubsystem(g4Reco);
280  return 0;
281 }
282 
284 {
286 
287  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
288  compress->AddHitContainer("G4HIT_PIPE");
289 
293  //
294  // compress->AddHitContainer("G4HIT_ZDC");
295  // compress->AddHitContainer("G4HIT_RomanPots");
296  // compress->AddHitContainer("G4HIT_B0detector");
297  compress->AddHitContainer("G4HIT_b0Truth");
298  compress->AddHitContainer("G4HIT_FIELDCAGE");
299 
300  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
301  compress->AddHitContainer("G4HIT_CEMC");
302  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
303  compress->AddHitContainer("G4HIT_CEMC_SPT");
304  compress->AddCellContainer("G4CELL_CEMC");
305  compress->AddTowerContainer("TOWER_SIM_CEMC");
306  compress->AddTowerContainer("TOWER_RAW_CEMC");
307  compress->AddTowerContainer("TOWER_CALIB_CEMC");
308 
309  compress->AddHitContainer("G4HIT_BECAL");
310  compress->AddHitContainer("G4HIT_ABSORBER_BECAL");
311  compress->AddCellContainer("G4CELL_BECAL");
312  compress->AddTowerContainer("TOWER_SIM_BECAL");
313  compress->AddTowerContainer("TOWER_RAW_BECAL");
314  compress->AddTowerContainer("TOWER_CALIB_BECAL");
315 
316  compress->AddHitContainer("G4HIT_HCALIN");
317  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
318  compress->AddHitContainer("G4HIT_HCALIN_SPT");
319  compress->AddCellContainer("G4CELL_HCALIN");
320  compress->AddTowerContainer("TOWER_SIM_HCALIN");
321  compress->AddTowerContainer("TOWER_RAW_HCALIN");
322  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
323 
324  compress->AddHitContainer("G4HIT_MAGNET");
325 
326  compress->AddHitContainer("G4HIT_HCALOUT");
327  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
328  compress->AddCellContainer("G4CELL_HCALOUT");
329  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
330  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
331  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
332 
333  compress->AddHitContainer("G4HIT_BH_1");
334  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
335  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
336 
337  compress->AddHitContainer("G4HIT_FEMC");
338  compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
339  compress->AddCellContainer("G4CELL_FEMC");
340  compress->AddTowerContainer("TOWER_SIM_FEMC");
341  compress->AddTowerContainer("TOWER_RAW_FEMC");
342  compress->AddTowerContainer("TOWER_CALIB_FEMC");
343 
344  compress->AddHitContainer("G4HIT_DRCALO");
345  compress->AddHitContainer("G4HIT_ABSORBER_DRCALO");
346  compress->AddCellContainer("G4CELL_DRCALO");
347  compress->AddTowerContainer("TOWER_SIM_DRCALO");
348  compress->AddTowerContainer("TOWER_RAW_DRCALO");
349  compress->AddTowerContainer("TOWER_CALIB_DRCALO");
350 
351  compress->AddHitContainer("G4HIT_FHCAL");
352  compress->AddHitContainer("G4HIT_ABSORBER_FHCAL");
353  compress->AddCellContainer("G4CELL_FHCAL");
354  compress->AddTowerContainer("TOWER_SIM_FHCAL");
355  compress->AddTowerContainer("TOWER_RAW_FHCAL");
356  compress->AddTowerContainer("TOWER_CALIB_FHCAL");
357 
358  compress->AddHitContainer("G4HIT_LFHCAL");
359  compress->AddHitContainer("G4HIT_ABSORBER_LFHCAL");
360  compress->AddCellContainer("G4CELL_LFHCAL");
361  compress->AddTowerContainer("TOWER_SIM_LFHCAL");
362  compress->AddTowerContainer("TOWER_RAW_LFHCAL");
363  compress->AddTowerContainer("TOWER_CALIB_LFHCAL");
364 
365  compress->AddHitContainer("G4HIT_EEMC");
366  compress->AddHitContainer("G4HIT_EEMC_glass");
367  compress->AddHitContainer("G4HIT_ABSORBER_EEMC");
368  compress->AddCellContainer("G4CELL_EEMC");
369  compress->AddTowerContainer("TOWER_SIM_EEMC");
370  compress->AddTowerContainer("TOWER_RAW_EEMC");
371  compress->AddTowerContainer("TOWER_CALIB_EEMC");
372 
373  compress->AddHitContainer("G4HIT_EHCAL");
374  compress->AddHitContainer("G4HIT_ABSORBER_EHCAL");
375  compress->AddTowerContainer("TOWER_SIM_EHCAL");
376  compress->AddTowerContainer("TOWER_RAW_EHCAL");
377  compress->AddTowerContainer("TOWER_CALIB_EHCAL");
378 
379  compress->AddHitContainer("G4HIT_B0ECAL");
380  compress->AddHitContainer("G4HIT_ABSORBER_B0ECAL");
381  compress->AddCellContainer("G4CELL_B0ECAL");
382  compress->AddTowerContainer("TOWER_SIM_B0ECAL");
383  compress->AddTowerContainer("TOWER_RAW_B0ECAL");
384  compress->AddTowerContainer("TOWER_CALIB_B0ECAL");
385 
386  se->registerSubsystem(compress);
387 
388  return;
389 }
390 
392 {
393  if (out)
394  {
395  out->StripNode("G4HIT_PIPE");
396 
400  //
401  // out->StripNode("G4HIT_ZDC");
402  // out->StripNode("G4HIT_RomanPots");
403  // out->StripNode("G4HIT_B0detectors");
404  out->StripNode("G4HIT_b0Truth");
405  out->StripNode("G4HIT_SVTXSUPPORT");
406  out->StripNode("G4HIT_CEMC_ELECTRONICS");
407  out->StripNode("G4HIT_CEMC");
408  out->StripNode("G4HIT_ABSORBER_CEMC");
409  out->StripNode("G4HIT_CEMC_SPT");
410  out->StripNode("G4CELL_CEMC");
411  out->StripNode("G4HIT_BECAL");
412  out->StripNode("G4CELL_BECAL");
413  out->StripNode("G4HIT_ABSORBER_BECAL");
414  out->StripNode("G4HIT_ABSORBER_HCALIN");
415  out->StripNode("G4HIT_HCALIN");
416  out->StripNode("G4HIT_HCALIN_SPT");
417  out->StripNode("G4CELL_HCALIN");
418  out->StripNode("G4HIT_MAGNET");
419  out->StripNode("G4HIT_HCALOUT");
420  out->StripNode("G4HIT_ABSORBER_HCALOUT");
421  out->StripNode("G4CELL_HCALOUT");
422  out->StripNode("G4HIT_BH_1");
423  out->StripNode("G4HIT_BH_FORWARD_PLUS");
424  out->StripNode("G4HIT_BH_FORWARD_NEG");
425 
426  out->StripNode("G4HIT_FEMC");
427  out->StripNode("G4HIT_ABSORBER_FEMC");
428  out->StripNode("G4HIT_FHCAL");
429  out->StripNode("G4HIT_ABSORBER_FHCAL");
430  out->StripNode("G4CELL_FEMC");
431  out->StripNode("G4HIT_DRCALO");
432  out->StripNode("G4HIT_ABSORBER_DRCALO");
433  out->StripNode("G4CELL_DRCALO");
434  out->StripNode("G4CELL_FHCAL");
435  out->StripNode("G4HIT_LFHCAL");
436  out->StripNode("G4HIT_ABSORBER_LFHCAL");
437  out->StripNode("G4CELL_LFHCAL");
438  out->StripNode("G4HIT_EEMC");
439  out->StripNode("G4HIT_EEMC_glass");
440  out->StripNode("G4HIT_ABSORBER_EEMC");
441  out->StripNode("G4CELL_EEMC");
442  out->StripNode("G4HIT_EHCAL");
443  out->StripNode("G4HIT_ABSORBER_EHCAL");
444  out->StripNode("G4CELL_EHCAL");
445  out->StripNode("G4CELL_B0ECAL");
446  }
447 }
448 #endif