/
G4_FHCAL.C
404 lines (365 loc) · 16.4 KB
/
G4_FHCAL.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#ifndef MACRO_G4FHCAL_C
#define MACRO_G4FHCAL_C
#include <GlobalVariables.C>
#include <g4calo/RawTowerBuilderByHitIndex.h>
#include <g4calo/RawTowerDigitizer.h>
#include <g4eiccalos/PHG4ForwardCalCellReco.h>
#include <g4eiccalos/PHG4ForwardHcalSubsystem.h>
#include <g4eval/CaloEvaluator.h>
#include <g4main/PHG4Reco.h>
#include <caloreco/RawClusterBuilderFwd.h>
#include <caloreco/RawClusterBuilderTemplate.h>
#include <caloreco/RawTowerCalibration.h>
#include <fun4all/Fun4AllServer.h>
R__LOAD_LIBRARY(libcalo_reco.so)
R__LOAD_LIBRARY(libg4calo.so)
R__LOAD_LIBRARY(libg4eiccalos.so)
R__LOAD_LIBRARY(libg4eval.so)
namespace Enable
{
bool FHCAL = false;
bool FHCAL_ABSORBER = false;
bool FHCAL_SUPPORT = false;
bool FHCAL_CELL = false;
bool FHCAL_TOWER = false;
bool FHCAL_CLUSTER = false;
bool FHCAL_EVAL = false;
bool FHCAL_OVERLAPCHECK = false;
int FHCAL_VERBOSITY = 0;
} // namespace Enable
namespace G4FHCAL
{
// from ForwardHcal/mapping/towerMap_FHCAL_v005.txt
double Gz0 = 400.;
double Gdz = 100.;
double outer_radius = 262.;
double sampling_fraction = 0.03898; // calibrated with muons
enum enu_FHcal_clusterizer
{
kFHcalGraphClusterizer,
kFHcalTemplateClusterizer
};
//template clusterizer, as developed by Sasha Bazilevsky
enu_FHcal_clusterizer FHcal_clusterizer = kFHcalTemplateClusterizer;
// graph clusterizer
//enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
namespace SETTING
{
int Absorber_FeTungsten = 0;
bool FullEtaAcc = false;
bool HC2x = false;
bool HC4x = false;
bool asymmetric = false;
bool extradepth = false;
bool wDR = false;
bool FwdSquare = false;
bool towercalib1 = false;
bool towercalibSiPM = false;
bool towercalibHCALIN = false;
bool towercalib3 = false;
} // namespace SETTING
} // namespace G4FHCAL
void FHCALInit()
{
// simple way to check if only 1 of the settings is true
if ((G4FHCAL::SETTING::FullEtaAcc ? 1 : 0) + (G4FHCAL::SETTING::HC4x ? 1 : 0) + (G4FHCAL::SETTING::HC2x ? 1 : 0) + (G4FHCAL::SETTING::wDR ? 1 : 0) + (G4FHCAL::SETTING::FwdSquare ? 1 : 0) + (G4FHCAL::SETTING::asymmetric ? 1 : 0) > 1)
{
cout << "use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::HC2x=true or G4FHCAL::SETTING::HC4x=true" << endl;
gSystem->Exit(1);
}
if ((G4FHCAL::SETTING::towercalib1 ? 1 : 0) + (G4FHCAL::SETTING::towercalibSiPM ? 1 : 0) +
(G4FHCAL::SETTING::towercalibHCALIN ? 1 : 0) + (G4FHCAL::SETTING::towercalib3 ? 1 : 0) >
1)
{
cout << "use only G4FHCAL::SETTING::towercalib1 = true or G4FHCAL::SETTING::towercalibSiPM = true"
<< " or G4FHCAL::SETTING::towercalibHCALIN = true or G4FHCAL::SETTING::towercalib3 = true" << endl;
gSystem->Exit(1);
}
BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, G4FHCAL::outer_radius);
BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, G4FHCAL::Gz0 + G4FHCAL::Gdz / 2.);
BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -10.);
}
void FHCALSetup(PHG4Reco *g4Reco)
{
bool AbsorberActive = Enable::ABSORBER || Enable::FHCAL_ABSORBER;
bool SupportActive = Enable::SUPPORT || Enable::FHCAL_SUPPORT;
bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FHCAL_OVERLAPCHECK;
Fun4AllServer *se = Fun4AllServer::instance();
/** Use dedicated FHCAL module */
PHG4ForwardHcalSubsystem *fhcal = new PHG4ForwardHcalSubsystem("FHCAL");
ostringstream mapping_fhcal;
// Switch to desired calo setup
// HCal Fe-Scint with doubled granularity
if (G4FHCAL::SETTING::HC2x)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
}
// full HCal Fe-Scint with nominal acceptance doubled granularity
else if (G4FHCAL::SETTING::HC2x && G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
}
// HCal Fe-Scint with four times granularity
else if (G4FHCAL::SETTING::HC4x)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
}
// full HCal Fe-Scint with nominal acceptance four times granularity
else if (G4FHCAL::SETTING::HC4x && G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
}
// HCal Fe-Scint surrounding dual readout calorimeter R>50cm
else if (G4FHCAL::SETTING::wDR)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_wDR.txt";
}
// HCal Fe-Scint surrounding dual readout calorimeter R>50cm
else if (G4FHCAL::SETTING::FwdSquare)
{
if (G4FHCAL::SETTING::extradepth)
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare_XL.txt";
else
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare.txt";
}
// full HCal Fe-Scint with asymmetric centering around beampipe
else if (G4FHCAL::SETTING::asymmetric)
{
if (G4FHCAL::SETTING::extradepth)
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric_XL.txt";
else
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric.txt";
}
// full HCal Fe-Scint with nominal acceptance
else if (G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
}
// full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
else
{
mapping_fhcal << getenv("CALIBRATIONROOT")
<< "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
}
if(G4FHCAL::SETTING::Absorber_FeTungsten)fhcal->SetUseFeTungstenAbsorber(1);
fhcal->SetTowerMappingFile(mapping_fhcal.str());
fhcal->OverlapCheck(OverlapCheck);
fhcal->SetActive();
fhcal->SetDetailed(false);
fhcal->SuperDetector("FHCAL");
if (AbsorberActive) fhcal->SetAbsorberActive();
if (SupportActive) fhcal->SetSupportActive();
g4Reco->registerSubsystem(fhcal);
}
void FHCAL_Cells(int verbosity = 0)
{
return;
}
void FHCAL_Towers()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FHCAL_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
ostringstream mapping_fhcal;
// Switch to desired calo setup
// HCal Fe-Scint with doubled granularity
if (G4FHCAL::SETTING::HC2x)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
}
// full HCal Fe-Scint with nominal acceptance doubled granularity
else if (G4FHCAL::SETTING::HC2x && G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
}
// HCal Fe-Scint with four times granularity
else if (G4FHCAL::SETTING::HC4x)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
}
// full HCal Fe-Scint with nominal acceptance four times granularity
else if (G4FHCAL::SETTING::HC4x && G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
}
// HCal Fe-Scint surrounding dual readout calorimeter R>50cm
else if (G4FHCAL::SETTING::wDR)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_wDR.txt";
}
// HCal Fe-Scint surrounding dual readout calorimeter R>50cm
else if (G4FHCAL::SETTING::FwdSquare)
{
if (G4FHCAL::SETTING::extradepth)
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare_XL.txt";
else
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare.txt";
}
// full HCal Fe-Scint with asymmetric centering around beampipe
else if (G4FHCAL::SETTING::asymmetric)
{
if (G4FHCAL::SETTING::extradepth)
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric_XL.txt";
else
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric.txt";
}
// full HCal Fe-Scint with nominal acceptance
else if (G4FHCAL::SETTING::FullEtaAcc)
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
}
// full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
else
{
mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
}
RawTowerBuilderByHitIndex *tower_FHCAL = new RawTowerBuilderByHitIndex("TowerBuilder_FHCAL");
tower_FHCAL->Detector("FHCAL");
tower_FHCAL->set_sim_tower_node_prefix("SIM");
tower_FHCAL->GeometryTableFile(mapping_fhcal.str());
se->registerSubsystem(tower_FHCAL);
// enable usage of different tower calibrations for systematic studies
if (G4FHCAL::SETTING::towercalib1)
{
cout << "1: using towercalib1 for FHCAL towers" << endl;
const double FHCAL_photoelectron_per_GeV = 500;
RawTowerDigitizer *TowerDigitizer_FHCAL = new RawTowerDigitizer("FHCALRawTowerDigitizer");
TowerDigitizer_FHCAL->Detector("FHCAL");
TowerDigitizer_FHCAL->Verbosity(verbosity);
TowerDigitizer_FHCAL->set_raw_tower_node_prefix("RAW");
TowerDigitizer_FHCAL->set_digi_algorithm(RawTowerDigitizer::kSiPM_photon_digitization);
TowerDigitizer_FHCAL->set_pedstal_central_ADC(0);
TowerDigitizer_FHCAL->set_pedstal_width_ADC(8); // eRD1 test beam setting
TowerDigitizer_FHCAL->set_photonelec_ADC(1); //not simulating ADC discretization error
TowerDigitizer_FHCAL->set_photonelec_yield_visible_GeV(FHCAL_photoelectron_per_GeV);
TowerDigitizer_FHCAL->set_zero_suppression_ADC(16); // eRD1 test beam setting
se->registerSubsystem(TowerDigitizer_FHCAL);
RawTowerCalibration *TowerCalibration_FHCAL = new RawTowerCalibration("FHCALRawTowerCalibration");
TowerCalibration_FHCAL->Detector("FHCAL");
TowerCalibration_FHCAL->Verbosity(verbosity);
TowerCalibration_FHCAL->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration_FHCAL->set_calib_const_GeV_ADC(1. / FHCAL_photoelectron_per_GeV);
TowerCalibration_FHCAL->set_pedstal_ADC(0);
se->registerSubsystem(TowerCalibration_FHCAL);
}
else if (G4FHCAL::SETTING::towercalibSiPM)
{
//from https://sphenix-collaboration.github.io/doxygen/d4/d58/Fun4All__G4__Prototype4_8C_source.html
const double sampling_fraction = 0.019441; // +/- 0.019441 from 0 Degree indenting 12 GeV electron showers
const double photoelectron_per_GeV = 500; //500 photon per total GeV deposition
const double ADC_per_photoelectron_HG = 3.8; // From Sean Stoll, Mar 29
const double ADC_per_photoelectron_LG = 0.24; // From Sean Stoll, Mar 29
cout << "2: using towercalibSiPM for FHCAL towers" << endl;
RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
TowerDigitizer->Detector("FHCAL");
TowerDigitizer->set_raw_tower_node_prefix("RAW");
TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kSiPM_photon_digitization);
TowerDigitizer->set_pedstal_central_ADC(0);
TowerDigitizer->set_pedstal_width_ADC(1);
TowerDigitizer->set_photonelec_ADC(1. / ADC_per_photoelectron_LG);
TowerDigitizer->set_photonelec_yield_visible_GeV(photoelectron_per_GeV / sampling_fraction);
TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
se->registerSubsystem(TowerDigitizer);
RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
TowerCalibration->Detector("FHCAL");
TowerCalibration->set_raw_tower_node_prefix("RAW");
TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration->set_calib_const_GeV_ADC(1. / ADC_per_photoelectron_LG / photoelectron_per_GeV);
TowerCalibration->set_pedstal_ADC(0);
TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
se->registerSubsystem(TowerCalibration);
}
else if (G4FHCAL::SETTING::towercalibHCALIN)
{
const double visible_sample_fraction_HCALIN = 7.19505e-02; // 1.34152e-02
RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
TowerDigitizer->Detector("FHCAL");
TowerDigitizer->set_raw_tower_node_prefix("RAW");
TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kSimple_photon_digitalization);
TowerDigitizer->set_pedstal_central_ADC(0);
TowerDigitizer->set_pedstal_width_ADC(1);
TowerDigitizer->set_photonelec_ADC(32. / 5.);
TowerDigitizer->set_photonelec_yield_visible_GeV(32. / 5 / (0.4e-3));
TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
se->registerSubsystem(TowerDigitizer);
RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
TowerCalibration->Detector("FHCAL");
TowerCalibration->set_raw_tower_node_prefix("RAW");
TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration->set_calib_const_GeV_ADC(0.4e-3 / visible_sample_fraction_HCALIN);
TowerCalibration->set_pedstal_ADC(0);
TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
se->registerSubsystem(TowerCalibration);
}
else if (G4FHCAL::SETTING::towercalib3)
{
cout << "3: using towercalib3 for FHCAL towers" << endl;
RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
TowerDigitizer->Detector("FHCAL");
TowerDigitizer->set_pedstal_central_ADC(0);
TowerDigitizer->set_pedstal_width_ADC(8); // eRD1 test beam setting
TowerDigitizer->Verbosity(verbosity);
TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
se->registerSubsystem(TowerDigitizer);
RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
TowerCalibration->Detector("FHCAL");
TowerCalibration->Verbosity(verbosity);
TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration->set_calib_const_GeV_ADC(1. / G4FHCAL::sampling_fraction);
TowerCalibration->set_pedstal_ADC(0);
se->registerSubsystem(TowerCalibration);
}
else
{
cout << "def: using default for FHCAL towers" << endl;
RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
TowerDigitizer->Detector("FHCAL");
TowerDigitizer->Verbosity(verbosity);
TowerDigitizer->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
se->registerSubsystem(TowerDigitizer);
RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
TowerCalibration->Detector("FHCAL");
TowerCalibration->Verbosity(verbosity);
TowerCalibration->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
TowerCalibration->set_calib_const_GeV_ADC(1. / (G4FHCAL::sampling_fraction * 0.5)); // temporary factor 0.5 to fix calibration for new tower design
TowerCalibration->set_pedstal_ADC(0);
se->registerSubsystem(TowerCalibration);
}
}
void FHCAL_Clusters()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FHCAL_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
if (G4FHCAL::FHcal_clusterizer == G4FHCAL::kFHcalTemplateClusterizer)
{
RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("FHCALRawClusterBuilderTemplate");
ClusterBuilder->Detector("FHCAL");
ClusterBuilder->SetPlanarGeometry(); // has to be called after Detector()
ClusterBuilder->Verbosity(verbosity);
ClusterBuilder->set_threshold_energy(0.100);
se->registerSubsystem(ClusterBuilder);
}
else if (G4FHCAL::FHcal_clusterizer == G4FHCAL::kFHcalTemplateClusterizer)
{
RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FHCALRawClusterBuilderFwd");
ClusterBuilder->Detector("FHCAL");
ClusterBuilder->Verbosity(verbosity);
ClusterBuilder->set_threshold_energy(0.100);
se->registerSubsystem(ClusterBuilder);
}
else
{
cout << "FHCAL_Clusters - unknown clusterizer setting " << G4FHCAL::FHcal_clusterizer << endl;
gSystem->Exit(1);
}
return;
}
void FHCAL_Eval(const std::string &outputfile)
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FHCAL_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
CaloEvaluator *eval = new CaloEvaluator("FHCALEVALUATOR", "FHCAL", outputfile.c_str());
eval->Verbosity(verbosity);
se->registerSubsystem(eval);
return;
}
#endif