Analysis Software
Documentation for sPHENIX simulation 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_Mbd.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_HcalIn_ref.C>
12 #include <G4_HcalOut_ref.C>
13 #include <G4_BeamLine.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 #include <G4_ZDC.C>
25 
27 
29 
30 #include <g4main/PHG4Reco.h>
32 
33 #include <phfield/PHFieldConfig.h>
34 
35 #include <g4decayer/EDecayType.hh>
36 
38 #include <fun4all/Fun4AllServer.h>
39 
40 R__LOAD_LIBRARY(libg4decayer.so)
41 R__LOAD_LIBRARY(libg4detectors.so)
42 
43 void G4Init()
44 {
45  // Check on invalid combinations
47  {
48  cout << "Enable::CEMCALBEDO and Enable::CEMC cannot be set simultanously" << endl;
49  gSystem->Exit(1);
50  }
51  // load detector/material macros and execute Init() function
52 
53  if (Enable::PIPE) PipeInit();
54  if (Enable::MVTX) MvtxInit();
55  if (Enable::INTT) InttInit();
56  if (Enable::TPC) TPCInit();
58  if (Enable::MBD) MbdInit();
60  if (Enable::CEMC) CEmcInit();
63  MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
66  if (Enable::EPD) EPDInit();
67  if (Enable::BEAMLINE)
68  {
69  BeamLineInit();
70  if (Enable::ZDC)
71  {
72  ZDCInit();
73  }
74  }
75  if (Enable::USER) UserInit();
77 }
78 
79 int G4Setup()
80 {
81  //---------------
82  // Fun4All server
83  //---------------
84 
86 
87  PHG4Reco *g4Reco = new PHG4Reco();
88  g4Reco->set_rapidity_coverage(1.1); // according to drawings
89  WorldInit(g4Reco);
91  {
93  }
94 
95  double fieldstrength;
96  istringstream stringline(G4MAGNET::magfield);
97  stringline >> fieldstrength;
98  if (stringline.fail())
99  { // conversion to double fails -> we have a string
100 
101  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos ||
102  G4MAGNET::magfield == "CDB")
103  {
105  }
106  else
107  {
109  }
110  }
111  else
112  {
113  g4Reco->set_field(fieldstrength); // use const soleniodal field
114  }
116 
117 // the radius is an older protection against overlaps, it is not
118 // clear how well this works nowadays but it doesn't hurt either
119  double radius = 0.;
120 
121  if (Enable::PIPE) radius = Pipe(g4Reco, radius);
122  if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
123  if (Enable::INTT) radius = Intt(g4Reco, radius);
124  if (Enable::TPC) radius = TPC(g4Reco, radius);
125  if (Enable::MICROMEGAS) Micromegas(g4Reco);
126  if (Enable::MBD) Mbd(g4Reco);
127  if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
128  if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
129  if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
130  if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
131  if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
132  if (Enable::PLUGDOOR) PlugDoor(g4Reco);
133  if (Enable::EPD) EPD(g4Reco);
134  if (Enable::BEAMLINE)
135  {
136  BeamLineDefineMagnets(g4Reco);
137  BeamLineDefineBeamPipe(g4Reco);
138  if (Enable::ZDC)
139  {
140  ZDCSetup(g4Reco);
141  }
142  }
143  if (Enable::USER) UserDetector(g4Reco);
144 
145 
146  //----------------------------------------
147  // BLACKHOLE
148 
149  if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
150 
151  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
152  g4Reco->registerSubsystem(truth);
153 
154  // finally adjust the world size in case the default is too small
155  WorldSize(g4Reco, radius);
156 
157  se->registerSubsystem(g4Reco);
158  return 0;
159 }
160 
162 {
164 
165  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
166  compress->AddHitContainer("G4HIT_PIPE");
167  compress->AddHitContainer("G4HIT_SVTXSUPPORT");
168  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
169  compress->AddHitContainer("G4HIT_CEMC");
170  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
171  compress->AddHitContainer("G4HIT_CEMC_SPT");
172  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
173  compress->AddHitContainer("G4HIT_HCALIN");
174  compress->AddHitContainer("G4HIT_HCALIN_SPT");
175  compress->AddHitContainer("G4HIT_MAGNET");
176  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
177  compress->AddHitContainer("G4HIT_HCALOUT");
178  compress->AddHitContainer("G4HIT_BH_1");
179  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
180  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
181  compress->AddHitContainer("G4HIT_MBD");
182  compress->AddCellContainer("G4CELL_CEMC");
183  compress->AddCellContainer("G4CELL_HCALIN");
184  compress->AddCellContainer("G4CELL_HCALOUT");
185  compress->AddTowerContainer("TOWER_SIM_CEMC");
186  compress->AddTowerContainer("TOWER_RAW_CEMC");
187  compress->AddTowerContainer("TOWER_CALIB_CEMC");
188  compress->AddTowerContainer("TOWER_SIM_HCALIN");
189  compress->AddTowerContainer("TOWER_RAW_HCALIN");
190  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
191  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
192  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
193  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
194  se->registerSubsystem(compress);
195 
196  return;
197 }
198 
200 {
201  if (out)
202  {
203  out->StripNode("G4HIT_PIPE");
204  out->StripNode("G4HIT_SVTXSUPPORT");
205  out->StripNode("G4HIT_CEMC_ELECTRONICS");
206  out->StripNode("G4HIT_CEMC");
207  out->StripNode("G4HIT_ABSORBER_CEMC");
208  out->StripNode("G4HIT_CEMC_SPT");
209  out->StripNode("G4HIT_ABSORBER_HCALIN");
210  out->StripNode("G4HIT_HCALIN");
211  out->StripNode("G4HIT_HCALIN_SPT");
212  out->StripNode("G4HIT_MAGNET");
213  out->StripNode("G4HIT_ABSORBER_HCALOUT");
214  out->StripNode("G4HIT_HCALOUT");
215  out->StripNode("G4HIT_BH_1");
216  out->StripNode("G4HIT_BH_FORWARD_PLUS");
217  out->StripNode("G4HIT_BH_FORWARD_NEG");
218  out->StripNode("G4HIT_MBD");
219  out->StripNode("G4CELL_CEMC");
220  out->StripNode("G4CELL_HCALIN");
221  out->StripNode("G4CELL_HCALOUT");
222  }
223 }
224 #endif