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