EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4Setup_fsPHENIX.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4Setup_fsPHENIX.C
1 #ifndef MACRO_G4SETUPFSPHENIX_C
2 #define MACRO_G4SETUPFSPHENIX_C
3 
4 #include <GlobalVariables.C>
5 
6 #include <G4_Bbc.C>
7 #include <G4_BlackHole.C>
8 #include <G4_CEmc_Spacal.C>
9 #include <G4_FEMC.C>
10 #include <G4_FGEM_fsPHENIX.C>
11 #include <G4_FHCAL.C>
12 #include <G4_HcalIn_ref.C>
13 #include <G4_HcalOut_ref.C>
14 #include <G4_Magnet.C>
15 #include <G4_Mvtx.C>
16 #include <G4_Pipe.C>
17 #include <G4_Piston.C>
18 #include <G4_PlugDoor_fsPHENIX.C>
19 #include <G4_TPC.C>
20 #include <G4_User.C>
21 #include <G4_World.C>
22 
24 
25 #include <g4main/PHG4Reco.h>
27 
28 #include <phfield/PHFieldConfig.h>
29 
31 
32 R__LOAD_LIBRARY(libg4decayer.so)
33 R__LOAD_LIBRARY(libg4detectors.so)
34 
35 void ShowerCompress(int verbosity = 0);
37 
38 void RunLoadTest() {}
39 
40 void G4Init()
41 {
42  // load detector/material macros and execute Init() function
43 
44  if (Enable::PIPE) PipeInit();
45  if (Enable::MVTX) MvtxInit();
46  if (Enable::INTT) InttInit();
47  if (Enable::TPC) TPCInit();
48  if (Enable::BBC) BbcInit();
49  if (Enable::CEMC) CEmcInit();
52 // We want the field - even if the magnet volume is disabled
55  if (Enable::FGEM) FGEM_Init();
56  if (Enable::FEMC) FEMCInit();
57  if (Enable::FHCAL) FHCALInit();
60  if (Enable::USER) UserInit();
62 }
63 
64 int G4Setup()
65 {
66  //---------------
67  // Fun4All server
68  //---------------
69 
71 
72  PHG4Reco *g4Reco = new PHG4Reco();
73  g4Reco->save_DST_geometry(true); //Save geometry from Geant4 to DST
74  WorldInit(g4Reco);
75  g4Reco->set_rapidity_coverage(1.1); // according to drawings
77  {
79  }
80 
81  double fieldstrength;
82  istringstream stringline(G4MAGNET::magfield);
83  stringline >> fieldstrength;
84  if (stringline.fail())
85  { // conversion to double fails -> we have a string
86 
87  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos)
88  {
90  }
91  else
92  {
94  }
95  }
96  else
97  {
98  g4Reco->set_field(fieldstrength); // use const soleniodal field
99  }
101 
102  double radius = 0.;
103 
104  //----------------------------------------
105  // PIPE
106  if (Enable::PIPE)
107  {
108  radius = Pipe(g4Reco, radius);
109  }
110  if (Enable::MVTX)
111  {
112  radius = Mvtx(g4Reco, radius);
113  }
114  if (Enable::INTT)
115  {
116  radius = Intt(g4Reco, radius);
117  }
118  if (Enable::TPC)
119  {
120  radius = TPC(g4Reco, radius);
121  }
122 
123  //----------------------------------------
124  // BBC
125 
126  if (Enable::BBC) Bbc(g4Reco);
127 
128  //----------------------------------------
129  // CEMC
130  //
131  if (Enable::CEMC)
132  {
133  radius = CEmc(g4Reco, radius, 8);
134  }
135 
136  //----------------------------------------
137  // HCALIN
138 
139  if (Enable::HCALIN)
140  {
141  radius = HCalInner(g4Reco, radius, 4);
142  }
143 
144  //----------------------------------------
145  // MAGNET
146 
147  if (Enable::MAGNET)
148  {
149  radius = Magnet(g4Reco, radius);
150  }
151 
152  //----------------------------------------
153  // HCALOUT
154 
155  if (Enable::HCALOUT)
156  {
157  radius = HCalOuter(g4Reco, radius, 4);
158  }
159 
160  //----------------------------------------
161  // Forward tracking
162 
163  if (Enable::FGEM)
164  {
165  FGEMSetup(g4Reco);
166  }
167 
168  //----------------------------------------
169  // FEMC
170 
171  if (Enable::FEMC)
172  {
173  FEMCSetup(g4Reco);
174  }
175  //----------------------------------------
176  // FHCAL
177 
178  if (Enable::FHCAL)
179  {
180  FHCALSetup(g4Reco);
181  }
182  if (Enable::PISTON)
183  {
184  Piston(g4Reco);
185  }
186 
187  if (Enable::PLUGDOOR)
188  {
189  PlugDoor(g4Reco);
190  }
191 
192  if (Enable::USER)
193  {
194  UserDetector(g4Reco);
195  }
196 
197  if (Enable::BLACKHOLE)
198  {
199  BlackHole(g4Reco, radius);
200  }
201 
202  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
203  g4Reco->registerSubsystem(truth);
204 
205  // finally adjust the world size in case the default is too small
206  WorldSize(g4Reco, radius);
207 
208  se->registerSubsystem(g4Reco);
209  return 0;
210 }
211 
212 void ShowerCompress(int verbosity = 0)
213 {
215 
216  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
217  compress->AddHitContainer("G4HIT_PIPE");
218  compress->AddHitContainer("G4HIT_SVTXSUPPORT");
219  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
220  compress->AddHitContainer("G4HIT_CEMC");
221  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
222  compress->AddHitContainer("G4HIT_CEMC_SPT");
223  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
224  compress->AddHitContainer("G4HIT_HCALIN");
225  compress->AddHitContainer("G4HIT_HCALIN_SPT");
226  compress->AddHitContainer("G4HIT_MAGNET");
227  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
228  compress->AddHitContainer("G4HIT_HCALOUT");
229  compress->AddHitContainer("G4HIT_BH_1");
230  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
231  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
232  compress->AddCellContainer("G4CELL_CEMC");
233  compress->AddCellContainer("G4CELL_HCALIN");
234  compress->AddCellContainer("G4CELL_HCALOUT");
235  compress->AddTowerContainer("TOWER_SIM_CEMC");
236  compress->AddTowerContainer("TOWER_RAW_CEMC");
237  compress->AddTowerContainer("TOWER_CALIB_CEMC");
238  compress->AddTowerContainer("TOWER_SIM_HCALIN");
239  compress->AddTowerContainer("TOWER_RAW_HCALIN");
240  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
241  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
242  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
243  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
244 
245  compress->AddHitContainer("G4HIT_FEMC");
246  compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
247  compress->AddHitContainer("G4HIT_FHCAL");
248  compress->AddHitContainer("G4HIT_ABSORBER_FHCAL");
249  compress->AddCellContainer("G4CELL_FEMC");
250  compress->AddCellContainer("G4CELL_FHCAL");
251  compress->AddTowerContainer("TOWER_SIM_FEMC");
252  compress->AddTowerContainer("TOWER_RAW_FEMC");
253  compress->AddTowerContainer("TOWER_CALIB_FEMC");
254  compress->AddTowerContainer("TOWER_SIM_FHCAL");
255  compress->AddTowerContainer("TOWER_RAW_FHCAL");
256  compress->AddTowerContainer("TOWER_CALIB_FHCAL");
257 
258  se->registerSubsystem(compress);
259 
260  return;
261 }
262 
264 {
265  if (out)
266  {
267  out->StripNode("G4HIT_PIPE");
268  out->StripNode("G4HIT_SVTXSUPPORT");
269  out->StripNode("G4HIT_CEMC_ELECTRONICS");
270  out->StripNode("G4HIT_CEMC");
271  out->StripNode("G4HIT_ABSORBER_CEMC");
272  out->StripNode("G4HIT_CEMC_SPT");
273  out->StripNode("G4HIT_ABSORBER_HCALIN");
274  out->StripNode("G4HIT_HCALIN");
275  out->StripNode("G4HIT_HCALIN_SPT");
276  out->StripNode("G4HIT_MAGNET");
277  out->StripNode("G4HIT_ABSORBER_HCALOUT");
278  out->StripNode("G4HIT_HCALOUT");
279  out->StripNode("G4HIT_BH_1");
280  out->StripNode("G4HIT_BH_FORWARD_PLUS");
281  out->StripNode("G4HIT_BH_FORWARD_NEG");
282  out->StripNode("G4CELL_CEMC");
283  out->StripNode("G4CELL_HCALIN");
284  out->StripNode("G4CELL_HCALOUT");
285 
286  out->StripNode("G4HIT_FEMC");
287  out->StripNode("G4HIT_ABSORBER_FEMC");
288  out->StripNode("G4HIT_FHCAL");
289  out->StripNode("G4HIT_ABSORBER_FHCAL");
290  out->StripNode("G4CELL_FEMC");
291  out->StripNode("G4CELL_FHCAL");
292  }
293 }
294 #endif