forked from sPHENIX-Collaboration/tutorials
/
G4Setup_sPHENIX.C
216 lines (188 loc) · 6.65 KB
/
G4Setup_sPHENIX.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#ifndef MACRO_G4SETUPSPHENIX_C
#define MACRO_G4SETUPSPHENIX_C
#include <GlobalVariables.C>
#include <G4_Bbc.C>
#include <G4_BlackHole.C>
#include <G4_CEmc_Albedo.C>
#include <G4_CEmc_Spacal.C>
#include <G4_EPD.C>
#include <G4_FEMC.C>
#include <G4_HcalIn_ref.C>
#include <G4_HcalOut_ref.C>
#include <G4_Intt.C>
#include <G4_Magnet.C>
#include <G4_Micromegas.C>
#include <G4_Mvtx.C>
#include <G4_PSTOF.C>
#include <G4_Pipe.C>
#include <G4_PlugDoor.C>
#include <G4_TPC.C>
#include <G4_User.C>
#include <G4_World.C>
#include <g4detectors/PHG4CylinderSubsystem.h>
#include <g4eval/PHG4DstCompressReco.h>
#include <g4main/PHG4Reco.h>
#include <g4main/PHG4TruthSubsystem.h>
#include <phfield/PHFieldConfig.h>
#include <g4decayer/EDecayType.hh>
#include <fun4all/Fun4AllDstOutputManager.h>
#include <fun4all/Fun4AllServer.h>
R__LOAD_LIBRARY(libg4decayer.so)
R__LOAD_LIBRARY(libg4detectors.so)
void G4Init()
{
// Check on invalid combinations
if (Enable::CEMC && Enable::CEMCALBEDO)
{
cout << "Enable::CEMCALBEDO and Enable::CEMC cannot be set simultanously" << endl;
gSystem->Exit(1);
}
// load detector/material macros and execute Init() function
if (Enable::PIPE) PipeInit();
if (Enable::MVTX) MvtxInit();
if (Enable::INTT) InttInit();
if (Enable::TPC) TPCInit();
if (Enable::MICROMEGAS) MicromegasInit();
if (Enable::BBC) BbcInit();
if (Enable::CEMCALBEDO) CEmcAlbedoInit();
if (Enable::CEMC) CEmcInit();
if (Enable::HCALIN) HCalInnerInit();
if (Enable::MAGNET) MagnetInit();
MagnetFieldInit(); // We want the field - even if the magnet volume is disabled
if (Enable::HCALOUT) HCalOuterInit();
if (Enable::PLUGDOOR) PlugDoorInit();
if (Enable::FEMC) FEMCInit();
if (Enable::EPD) EPDInit();
if (Enable::USER) UserInit();
if (Enable::BLACKHOLE) BlackHoleInit();
}
int G4Setup()
{
//---------------
// Fun4All server
//---------------
Fun4AllServer *se = Fun4AllServer::instance();
PHG4Reco *g4Reco = new PHG4Reco();
g4Reco->set_rapidity_coverage(1.1); // according to drawings
WorldInit(g4Reco);
if (G4P6DECAYER::decayType != EDecayType::kAll)
{
g4Reco->set_force_decay(G4P6DECAYER::decayType);
}
double fieldstrength;
istringstream stringline(G4MAGNET::magfield);
stringline >> fieldstrength;
if (stringline.fail())
{ // conversion to double fails -> we have a string
if (G4MAGNET::magfield.find("sPHENIX.root") != string::npos)
{
g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::Field3DCartesian);
}
else
{
g4Reco->set_field_map(G4MAGNET::magfield, PHFieldConfig::kField2D);
}
}
else
{
g4Reco->set_field(fieldstrength); // use const soleniodal field
}
g4Reco->set_field_rescale(G4MAGNET::magfield_rescale);
// the radius is an older protection against overlaps, it is not
// clear how well this works nowadays but it doesn't hurt either
double radius = 0.;
if (Enable::PIPE) radius = Pipe(g4Reco, radius);
if (Enable::MVTX) radius = Mvtx(g4Reco, radius);
if (Enable::INTT) radius = Intt(g4Reco, radius);
if (Enable::TPC) radius = TPC(g4Reco, radius);
if (Enable::MICROMEGAS) Micromegas(g4Reco);
if (Enable::BBC) Bbc(g4Reco);
if (Enable::CEMCALBEDO) CEmcAlbedo(g4Reco);
if (Enable::CEMC) radius = CEmc(g4Reco, radius, 8);
if (Enable::HCALIN) radius = HCalInner(g4Reco, radius, 4);
if (Enable::MAGNET) radius = Magnet(g4Reco, radius);
if (Enable::HCALOUT) radius = HCalOuter(g4Reco, radius, 4);
if (Enable::PLUGDOOR) PlugDoor(g4Reco);
if (Enable::FEMC) FEMCSetup(g4Reco);
if (Enable::EPD) EPD(g4Reco);
if (Enable::USER) UserDetector(g4Reco);
//----------------------------------------
// BLACKHOLE
if (Enable::BLACKHOLE) BlackHole(g4Reco, radius);
PHG4TruthSubsystem *truth = new PHG4TruthSubsystem();
g4Reco->registerSubsystem(truth);
// finally adjust the world size in case the default is too small
WorldSize(g4Reco, radius);
se->registerSubsystem(g4Reco);
return 0;
}
void ShowerCompress(int verbosity = 0)
{
Fun4AllServer *se = Fun4AllServer::instance();
PHG4DstCompressReco *compress = new PHG4DstCompressReco("PHG4DstCompressReco");
compress->AddHitContainer("G4HIT_PIPE");
compress->AddHitContainer("G4HIT_SVTXSUPPORT");
compress->AddHitContainer("G4HIT_CEMC_ELECTRONICS");
compress->AddHitContainer("G4HIT_CEMC");
compress->AddHitContainer("G4HIT_ABSORBER_CEMC");
compress->AddHitContainer("G4HIT_CEMC_SPT");
compress->AddHitContainer("G4HIT_ABSORBER_HCALIN");
compress->AddHitContainer("G4HIT_HCALIN");
compress->AddHitContainer("G4HIT_HCALIN_SPT");
compress->AddHitContainer("G4HIT_MAGNET");
compress->AddHitContainer("G4HIT_ABSORBER_HCALOUT");
compress->AddHitContainer("G4HIT_HCALOUT");
compress->AddHitContainer("G4HIT_BH_1");
compress->AddHitContainer("G4HIT_BH_FORWARD_PLUS");
compress->AddHitContainer("G4HIT_BH_FORWARD_NEG");
compress->AddHitContainer("G4HIT_BBC");
compress->AddCellContainer("G4CELL_CEMC");
compress->AddCellContainer("G4CELL_HCALIN");
compress->AddCellContainer("G4CELL_HCALOUT");
compress->AddTowerContainer("TOWER_SIM_CEMC");
compress->AddTowerContainer("TOWER_RAW_CEMC");
compress->AddTowerContainer("TOWER_CALIB_CEMC");
compress->AddTowerContainer("TOWER_SIM_HCALIN");
compress->AddTowerContainer("TOWER_RAW_HCALIN");
compress->AddTowerContainer("TOWER_CALIB_HCALIN");
compress->AddTowerContainer("TOWER_SIM_HCALOUT");
compress->AddTowerContainer("TOWER_RAW_HCALOUT");
compress->AddTowerContainer("TOWER_CALIB_HCALOUT");
compress->AddHitContainer("G4HIT_FEMC");
compress->AddHitContainer("G4HIT_ABSORBER_FEMC");
compress->AddCellContainer("G4CELL_FEMC");
compress->AddTowerContainer("TOWER_SIM_FEMC");
compress->AddTowerContainer("TOWER_RAW_FEMC");
compress->AddTowerContainer("TOWER_CALIB_FEMC");
se->registerSubsystem(compress);
return;
}
void DstCompress(Fun4AllDstOutputManager *out)
{
if (out)
{
out->StripNode("G4HIT_PIPE");
out->StripNode("G4HIT_SVTXSUPPORT");
out->StripNode("G4HIT_CEMC_ELECTRONICS");
out->StripNode("G4HIT_CEMC");
out->StripNode("G4HIT_ABSORBER_CEMC");
out->StripNode("G4HIT_CEMC_SPT");
out->StripNode("G4HIT_ABSORBER_HCALIN");
out->StripNode("G4HIT_HCALIN");
out->StripNode("G4HIT_HCALIN_SPT");
out->StripNode("G4HIT_MAGNET");
out->StripNode("G4HIT_ABSORBER_HCALOUT");
out->StripNode("G4HIT_HCALOUT");
out->StripNode("G4HIT_BH_1");
out->StripNode("G4HIT_BH_FORWARD_PLUS");
out->StripNode("G4HIT_BH_FORWARD_NEG");
out->StripNode("G4HIT_BBC");
out->StripNode("G4CELL_CEMC");
out->StripNode("G4CELL_HCALIN");
out->StripNode("G4CELL_HCALOUT");
out->StripNode("G4HIT_FEMC");
out->StripNode("G4HIT_ABSORBER_FEMC");
out->StripNode("G4CELL_FEMC");
}
}
#endif