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_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_HcalIn_ref.C>
12 #include <G4_HcalOut_ref.C>
13 #include <G4_BeamLine.C>
14 
15 //#include <G4_TPC.C>
16 //#include <G4_Intt.C>
17 //#include <G4_TPC.C>
18 //#include <G4_Micromegas.C>
19 
20 #include <G4_Magnet.C>
21 #include <G4_PSTOF.C>
22 #include <G4_Pipe.C>
23 #include <G4_PlugDoor.C>
24 
25 #include <G4_User.C>
26 #include <G4_World.C>
27 #include <G4_ZDC.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  // Check on invalid combinations
50  {
51  cout << "Enable::CEMCALBEDO and Enable::CEMC cannot be set simultanously" << endl;
52  gSystem->Exit(1);
53  }
54  // load detector/material macros and execute Init() function
55 
56  if (Enable::PIPE) PipeInit();
57 // if (Enable::MVTX) MvtxInit();
58 // if (Enable::INTT) InttInit();
59 // if (Enable::TPC) TPCInit();
60 // if (Enable::MICROMEGAS) MicromegasInit();
61 
62  if (Enable::BBC) BbcInit();
64  if (Enable::CEMC) CEmcInit();
67  MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
70  if (Enable::EPD) EPDInit();
71  if (Enable::BEAMLINE)
72  {
73  BeamLineInit();
74  if (Enable::ZDC)
75  {
76  ZDCInit();
77  }
78  }
79  if (Enable::USER) UserInit();
81 }
82 
83 int G4Setup()
84 {
85  //---------------
86  // Fun4All server
87  //---------------
88 
90 
91  PHG4Reco *g4Reco = new PHG4Reco();
92  g4Reco->set_rapidity_coverage(1.1); // according to drawings
93  WorldInit(g4Reco);
95  {
97  }
98 
99  double fieldstrength;
100  istringstream stringline(G4MAGNET::magfield);
101  stringline >> fieldstrength;
102  if (stringline.fail())
103  { // conversion to double fails -> we have a string
104 
105  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos ||
106  G4MAGNET::magfield == "CDB")
107  {
109  }
110  else
111  {
113  }
114  }
115  else
116  {
117  g4Reco->set_field(fieldstrength); // use const soleniodal field
118  }
120 
121 // the radius is an older protection against overlaps, it is not
122 // clear how well this works nowadays but it doesn't hurt either
123  double radius = 0.;
124 
125  if (Enable::PIPE) radius = Pipe(g4Reco, radius);
126 // if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
127 // if (Enable::INTT) radius = Intt(g4Reco, radius);
128 // if (Enable::TPC) radius = TPC(g4Reco, radius);
129 // if (Enable::MICROMEGAS) Micromegas(g4Reco);
130 
131  if (Enable::BBC) Bbc(g4Reco);
132  if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
133  if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
134  if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
135  if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
136  if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
137  if (Enable::PLUGDOOR) PlugDoor(g4Reco);
138  if (Enable::EPD) EPD(g4Reco);
139  if (Enable::BEAMLINE)
140  {
141  BeamLineDefineMagnets(g4Reco);
142  BeamLineDefineBeamPipe(g4Reco);
143  if (Enable::ZDC)
144  {
145  ZDCSetup(g4Reco);
146  }
147  }
148  if (Enable::USER) UserDetector(g4Reco);
149 
150 
151  //----------------------------------------
152  // BLACKHOLE
153 
154  if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
155 
156  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
157  g4Reco->registerSubsystem(truth);
158 
159  // finally adjust the world size in case the default is too small
160  WorldSize(g4Reco, radius);
161 
162  se->registerSubsystem(g4Reco);
163  return 0;
164 }
165 
167 {
169 
170  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
171  compress->AddHitContainer("G4HIT_PIPE");
172  compress->AddHitContainer("G4HIT_SVTXSUPPORT");
173  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
174  compress->AddHitContainer("G4HIT_CEMC");
175  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
176  compress->AddHitContainer("G4HIT_CEMC_SPT");
177  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
178  compress->AddHitContainer("G4HIT_HCALIN");
179  compress->AddHitContainer("G4HIT_HCALIN_SPT");
180  compress->AddHitContainer("G4HIT_MAGNET");
181  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
182  compress->AddHitContainer("G4HIT_HCALOUT");
183  compress->AddHitContainer("G4HIT_BH_1");
184  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
185  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
186  compress->AddHitContainer("G4HIT_BBC");
187  compress->AddCellContainer("G4CELL_CEMC");
188  compress->AddCellContainer("G4CELL_HCALIN");
189  compress->AddCellContainer("G4CELL_HCALOUT");
190  compress->AddTowerContainer("TOWER_SIM_CEMC");
191  compress->AddTowerContainer("TOWER_RAW_CEMC");
192  compress->AddTowerContainer("TOWER_CALIB_CEMC");
193  compress->AddTowerContainer("TOWER_SIM_HCALIN");
194  compress->AddTowerContainer("TOWER_RAW_HCALIN");
195  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
196  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
197  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
198  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
199  se->registerSubsystem(compress);
200 
201  return;
202 }
203 
205 {
206  if (out)
207  {
208  out->StripNode("G4HIT_PIPE");
209  out->StripNode("G4HIT_SVTXSUPPORT");
210  out->StripNode("G4HIT_CEMC_ELECTRONICS");
211  out->StripNode("G4HIT_CEMC");
212  out->StripNode("G4HIT_ABSORBER_CEMC");
213  out->StripNode("G4HIT_CEMC_SPT");
214  out->StripNode("G4HIT_ABSORBER_HCALIN");
215  out->StripNode("G4HIT_HCALIN");
216  out->StripNode("G4HIT_HCALIN_SPT");
217  out->StripNode("G4HIT_MAGNET");
218  out->StripNode("G4HIT_ABSORBER_HCALOUT");
219  out->StripNode("G4HIT_HCALOUT");
220  out->StripNode("G4HIT_BH_1");
221  out->StripNode("G4HIT_BH_FORWARD_PLUS");
222  out->StripNode("G4HIT_BH_FORWARD_NEG");
223  out->StripNode("G4HIT_BBC");
224  out->StripNode("G4CELL_CEMC");
225  out->StripNode("G4CELL_HCALIN");
226  out->StripNode("G4CELL_HCALOUT");
227  }
228 }
229 #endif