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_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::BBC) BbcInit();
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);
90  //PYTHIA 6
92  {
94  }
95  //EvtGen
97 
98  double fieldstrength;
99  istringstream stringline(G4MAGNET::magfield);
100  stringline >> fieldstrength;
101  if (stringline.fail())
102  { // conversion to double fails -> we have a string
103 
104  if (G4MAGNET::magfield.find("sphenix3dbigmapxyz") != string::npos ||
105  G4MAGNET::magfield == "CDB")
106  {
108  }
109  else
110  {
112  }
113  }
114  else
115  {
116  g4Reco->set_field(fieldstrength); // use const soleniodal field
117  }
119 
120 // the radius is an older protection against overlaps, it is not
121 // clear how well this works nowadays but it doesn't hurt either
122  double radius = 0.;
123 
124  if (Enable::PIPE) radius = Pipe(g4Reco, radius);
125  if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
126  if (Enable::INTT) radius = Intt(g4Reco, radius);
127  if (Enable::TPC) radius = TPC(g4Reco, radius);
128  if (Enable::MICROMEGAS) Micromegas(g4Reco);
129  if (Enable::BBC) Bbc(g4Reco);
130  if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
131  if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
132  if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
133  if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
134  if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
135  if (Enable::PLUGDOOR) PlugDoor(g4Reco);
136  if (Enable::EPD) EPD(g4Reco);
137  if (Enable::BEAMLINE)
138  {
139  BeamLineDefineMagnets(g4Reco);
140  BeamLineDefineBeamPipe(g4Reco);
141  if (Enable::ZDC)
142  {
143  ZDCSetup(g4Reco);
144  }
145  }
146  if (Enable::USER) UserDetector(g4Reco);
147 
148 
149  //----------------------------------------
150  // BLACKHOLE
151 
152  if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
153 
154  PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
155  g4Reco->registerSubsystem(truth);
156 
157  // finally adjust the world size in case the default is too small
158  WorldSize(g4Reco, radius);
159 
160  se->registerSubsystem(g4Reco);
161  return 0;
162 }
163 
165 {
167 
168  PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
169  compress->AddHitContainer("G4HIT_PIPE");
170  compress->AddHitContainer("G4HIT_SVTXSUPPORT");
171  compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
172  compress->AddHitContainer("G4HIT_CEMC");
173  compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
174  compress->AddHitContainer("G4HIT_CEMC_SPT");
175  compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
176  compress->AddHitContainer("G4HIT_HCALIN");
177  compress->AddHitContainer("G4HIT_HCALIN_SPT");
178  compress->AddHitContainer("G4HIT_MAGNET");
179  compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
180  compress->AddHitContainer("G4HIT_HCALOUT");
181  compress->AddHitContainer("G4HIT_BH_1");
182  compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
183  compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
184  compress->AddHitContainer("G4HIT_BBC");
185  compress->AddCellContainer("G4CELL_CEMC");
186  compress->AddCellContainer("G4CELL_HCALIN");
187  compress->AddCellContainer("G4CELL_HCALOUT");
188  compress->AddTowerContainer("TOWER_SIM_CEMC");
189  compress->AddTowerContainer("TOWER_RAW_CEMC");
190  compress->AddTowerContainer("TOWER_CALIB_CEMC");
191  compress->AddTowerContainer("TOWER_SIM_HCALIN");
192  compress->AddTowerContainer("TOWER_RAW_HCALIN");
193  compress->AddTowerContainer("TOWER_CALIB_HCALIN");
194  compress->AddTowerContainer("TOWER_SIM_HCALOUT");
195  compress->AddTowerContainer("TOWER_RAW_HCALOUT");
196  compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
197  se->registerSubsystem(compress);
198 
199  return;
200 }
201 
203 {
204  if (out)
205  {
206  out->StripNode("G4HIT_PIPE");
207  out->StripNode("G4HIT_SVTXSUPPORT");
208  out->StripNode("G4HIT_CEMC_ELECTRONICS");
209  out->StripNode("G4HIT_CEMC");
210  out->StripNode("G4HIT_ABSORBER_CEMC");
211  out->StripNode("G4HIT_CEMC_SPT");
212  out->StripNode("G4HIT_ABSORBER_HCALIN");
213  out->StripNode("G4HIT_HCALIN");
214  out->StripNode("G4HIT_HCALIN_SPT");
215  out->StripNode("G4HIT_MAGNET");
216  out->StripNode("G4HIT_ABSORBER_HCALOUT");
217  out->StripNode("G4HIT_HCALOUT");
218  out->StripNode("G4HIT_BH_1");
219  out->StripNode("G4HIT_BH_FORWARD_PLUS");
220  out->StripNode("G4HIT_BH_FORWARD_NEG");
221  out->StripNode("G4HIT_BBC");
222  out->StripNode("G4CELL_CEMC");
223  out->StripNode("G4CELL_HCALIN");
224  out->StripNode("G4CELL_HCALOUT");
225  }
226 }
227 #endif