-
Notifications
You must be signed in to change notification settings - Fork 31
/
G4_FEMC_EIC.C
392 lines (351 loc) · 14.7 KB
/
G4_FEMC_EIC.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
#ifndef MACRO_G4FEMCEIC_C
#define MACRO_G4FEMCEIC_C
#include <GlobalVariables.C>
#include <g4calo/RawTowerBuilderByHitIndex.h>
#include <g4calo/RawTowerDigitizer.h>
#include <g4eiccalos/PHG4ForwardCalCellReco.h>
#include <g4eiccalos/PHG4ForwardEcalSubsystem.h>
#include <g4eval/CaloEvaluator.h>
#include <g4main/PHG4Reco.h>
#include <eiccaloreco/RawClusterBuilderkMA.h>
#include <eiccaloreco/RawClusterBuilderHelper.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 FEMC = false;
bool FEMC_ABSORBER = false;
bool FEMC_CELL = false;
bool FEMC_TOWER = false;
bool FEMC_CLUSTER = false;
bool FEMC_EVAL = false;
bool FEMC_OVERLAPCHECK = false;
int FEMC_VERBOSITY = 0;
} // namespace Enable
namespace G4FEMC
{
// from ForwardEcal/mapping/towerMap_FEMC_v007.txt
const double Gz0 = 310.;
const double Gdz = 36.5;
const double outer_radius = 182.655;
enum enu_Femc_clusterizer
{
kFemcGraphClusterizer,
kFemcTemplateClusterizer
};
//template clusterizer, as developed by Sasha Bazilevsky
enu_Femc_clusterizer Femc_clusterizer = kFemcTemplateClusterizer;
// graph clusterizer
//enu_Femc_clusterizer Femc_clusterizer = kFemcGraphClusterizer;
namespace SETTING
{
bool FullEtaAcc = false;
bool fsPHENIX = false;
bool EC2x = false;
bool readoutsplit = true;
bool asymmetric = true;
bool wDR = false;
bool FwdSquare = false;
} // namespace SETTING
} // namespace G4FEMC
void FEMCInit()
{
// simple way to check if only 1 of the settings is true
if ((G4FEMC::SETTING::FullEtaAcc ? 1 : 0) + (G4FEMC::SETTING::fsPHENIX ? 1 : 0) + (G4FEMC::SETTING::wDR ? 1 : 0) + (G4FEMC::SETTING::FwdSquare ? 1 : 0) + (G4FEMC::SETTING::asymmetric ? 1 : 0) > 1)
{
cout << "use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::fsPHENIX=true or G4FHCAL::SETTING::wDR=true or G4FHCAL::SETTING::asymmetric=true" << endl;
gSystem->Exit(1);
}
BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, G4FEMC::outer_radius);
BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, G4FEMC::Gz0 + G4FEMC::Gdz / 2.);
BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -10.);
}
void FEMCSetup(PHG4Reco *g4Reco)
{
bool AbsorberActive = Enable::ABSORBER || Enable::FEMC_ABSORBER;
bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FEMC_OVERLAPCHECK;
Fun4AllServer *se = Fun4AllServer::instance();
/** Use dedicated FEMC module */
PHG4ForwardEcalSubsystem *femc = new PHG4ForwardEcalSubsystem("FEMC");
ostringstream mapping_femc;
// PbScint ECAL with nominal eta coverage
if (G4FEMC::SETTING::FullEtaAcc)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt";
}
// doubled granularity ECAL
else if (G4FEMC::SETTING::EC2x)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_2x.txt";
}
// fsPHENIX ECAL
else if (G4FEMC::SETTING::fsPHENIX)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
}
// asymmetric ECAL around beampipe
else if (G4FEMC::SETTING::asymmetric)
{
if (Enable::IP6){
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt";
} else {
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt";
}
}
// ECAL surrounding dual readout calorimeter
else if (G4FEMC::SETTING::FwdSquare)
{
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
}
// ECAL surrounding dual readout calorimeter
else if (G4FEMC::SETTING::wDR)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_wDR.txt";
}
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
else
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_v007.txt";
}
cout << mapping_femc.str() << endl;
femc->SetTowerMappingFile(mapping_femc.str());
femc->OverlapCheck(OverlapCheck);
femc->SetActive();
femc->SetDetailed(false);
femc->SuperDetector("FEMC");
if (AbsorberActive) femc->SetAbsorberActive();
g4Reco->registerSubsystem(femc);
}
void FEMC_Cells()
{
return;
}
void FEMC_Towers()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FEMC_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
ostringstream mapping_femc;
// // fsPHENIX ECAL
// mapping_femc << getenv("CALIBRATIONROOT") <<
// "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
// PbScint ECAL with nominal eta coverage
if (G4FEMC::SETTING::FullEtaAcc)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt";
}
// doubled granularity ECAL
else if (G4FEMC::SETTING::EC2x)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_2x.txt";
}
// fsPHENIX ECAL
else if (G4FEMC::SETTING::fsPHENIX)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
}
// ECAL surrounding dual readout calorimeter
else if (G4FEMC::SETTING::FwdSquare)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
}
// ECAL surrounding dual readout calorimeter
else if (G4FEMC::SETTING::wDR)
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_wDR.txt";
}
// asymmetric ECAL around beampipe
else if (G4FEMC::SETTING::asymmetric)
{
if (Enable::IP6){
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt";
} else {
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt";
}
}
// ECAL surrounding dual readout calorimeter
else if (G4FEMC::SETTING::FwdSquare)
{
if (G4FEMC::SETTING::readoutsplit)
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt";
else
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
}
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
else
{
mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_v007.txt";
}
RawTowerBuilderByHitIndex *tower_FEMC = new RawTowerBuilderByHitIndex("TowerBuilder_FEMC");
tower_FEMC->Detector("FEMC");
tower_FEMC->set_sim_tower_node_prefix("SIM");
tower_FEMC->GeometryTableFile(mapping_femc.str());
se->registerSubsystem(tower_FEMC);
// PbW crystals
//RawTowerDigitizer *TowerDigitizer1 = new RawTowerDigitizer("FEMCRawTowerDigitizer1");
//TowerDigitizer1->Detector("FEMC");
//TowerDigitizer1->TowerType(1);
//TowerDigitizer1->Verbosity(verbosity);
//TowerDigitizer1->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
//se->registerSubsystem( TowerDigitizer1 );
// PbSc towers
RawTowerDigitizer *TowerDigitizer2 = new RawTowerDigitizer("FEMCRawTowerDigitizer2");
TowerDigitizer2->Detector("FEMC");
TowerDigitizer2->TowerType(2);
TowerDigitizer2->Verbosity(verbosity);
TowerDigitizer2->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
se->registerSubsystem(TowerDigitizer2);
// // E864 towers (three types for three sizes)
// RawTowerDigitizer *TowerDigitizer3 = new RawTowerDigitizer("FEMCRawTowerDigitizer3");
// TowerDigitizer3->Detector("FEMC");
// TowerDigitizer3->TowerType(3);
// TowerDigitizer3->Verbosity(verbosity);
// TowerDigitizer3->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
// se->registerSubsystem( TowerDigitizer3 );
//
// RawTowerDigitizer *TowerDigitizer4 = new RawTowerDigitizer("FEMCRawTowerDigitizer4");
// TowerDigitizer4->Detector("FEMC");
// TowerDigitizer4->TowerType(4);
// TowerDigitizer4->Verbosity(verbosity);
// TowerDigitizer4->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
// se->registerSubsystem( TowerDigitizer4 );
//
// RawTowerDigitizer *TowerDigitizer5 = new RawTowerDigitizer("FEMCRawTowerDigitizer5");
// TowerDigitizer5->Detector("FEMC");
// TowerDigitizer5->TowerType(5);
// TowerDigitizer5->Verbosity(verbosity);
// TowerDigitizer5->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
// se->registerSubsystem( TowerDigitizer5 );
//
// RawTowerDigitizer *TowerDigitizer6 = new RawTowerDigitizer("FEMCRawTowerDigitizer6");
// TowerDigitizer6->Detector("FEMC");
// TowerDigitizer6->TowerType(6);
// TowerDigitizer6->Verbosity(verbosity);
// TowerDigitizer6->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
// se->registerSubsystem( TowerDigitizer6 );
// PbW crystals
//RawTowerCalibration *TowerCalibration1 = new RawTowerCalibration("FEMCRawTowerCalibration1");
//TowerCalibration1->Detector("FEMC");
//TowerCalibration1->TowerType(1);
//TowerCalibration1->Verbosity(verbosity);
//TowerCalibration1->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
//TowerCalibration1->set_calib_const_GeV_ADC(1.0); // sampling fraction = 1.0
//TowerCalibration1->set_pedstal_ADC(0);
//se->registerSubsystem( TowerCalibration1 );
// PbSc towers
RawTowerCalibration *TowerCalibration2 = new RawTowerCalibration("FEMCRawTowerCalibration2");
TowerCalibration2->Detector("FEMC");
TowerCalibration2->TowerType(2);
TowerCalibration2->Verbosity(verbosity);
TowerCalibration2->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
if (G4FEMC::SETTING::readoutsplit)
TowerCalibration2->set_calib_const_GeV_ADC(1.0 / (0.249*0.84)); // sampling fraction = 0.249 for e-
else
TowerCalibration2->set_calib_const_GeV_ADC(1.0 / 0.249); // sampling fraction = 0.249 for e-
TowerCalibration2->set_pedstal_ADC(0);
se->registerSubsystem(TowerCalibration2);
// // E864 towers (three types for three sizes)
// RawTowerCalibration *TowerCalibration3 = new RawTowerCalibration("FEMCRawTowerCalibration3");
// TowerCalibration3->Detector("FEMC");
// TowerCalibration3->TowerType(3);
// TowerCalibration3->Verbosity(verbosity);
// TowerCalibration3->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
// TowerCalibration3->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
// TowerCalibration3->set_pedstal_ADC(0);
// se->registerSubsystem( TowerCalibration3 );
//
// RawTowerCalibration *TowerCalibration4 = new RawTowerCalibration("FEMCRawTowerCalibration4");
// TowerCalibration4->Detector("FEMC");
// TowerCalibration4->TowerType(4);
// TowerCalibration4->Verbosity(verbosity);
// TowerCalibration4->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
// TowerCalibration4->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
// TowerCalibration4->set_pedstal_ADC(0);
// se->registerSubsystem( TowerCalibration4 );
//
// RawTowerCalibration *TowerCalibration5 = new RawTowerCalibration("FEMCRawTowerCalibration5");
// TowerCalibration5->Detector("FEMC");
// TowerCalibration5->TowerType(5);
// TowerCalibration5->Verbosity(verbosity);
// TowerCalibration5->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
// TowerCalibration5->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
// TowerCalibration5->set_pedstal_ADC(0);
// se->registerSubsystem( TowerCalibration5 );
//
// RawTowerCalibration *TowerCalibration6 = new RawTowerCalibration("FEMCRawTowerCalibration6");
// TowerCalibration6->Detector("FEMC");
// TowerCalibration6->TowerType(6);
// TowerCalibration6->Verbosity(verbosity);
// TowerCalibration6->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
// TowerCalibration6->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
// TowerCalibration6->set_pedstal_ADC(0);
// se->registerSubsystem( TowerCalibration6 );
}
void FEMC_Clusters()
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FEMC_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
if (G4FEMC::Femc_clusterizer == G4FEMC::kFemcTemplateClusterizer)
{
RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkMA("FEMCRawClusterBuilderkMA");
ClusterBuilder->Detector("FEMC");
ClusterBuilder->set_seed_e(0.1);
ClusterBuilder->set_agg_e(0.005);
se->registerSubsystem(ClusterBuilder);
/*
RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplateFEMC");
ClusterBuilder->Detector("FEMC");
ClusterBuilder->Verbosity(verbosity);
ClusterBuilder->set_threshold_energy(0.020); // This threshold should be the same as in FEMCprof_Thresh**.root file below
std::string femc_prof = getenv("CALIBRATIONROOT");
femc_prof += "/EmcProfile/FEMCprof_Thresh20MeV.root";
ClusterBuilder->LoadProfile(femc_prof.c_str());
se->registerSubsystem(ClusterBuilder);
*/
}
else if (G4FEMC::Femc_clusterizer == G4FEMC::kFemcGraphClusterizer)
{
RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FEMCRawClusterBuilderFwd");
ClusterBuilder->Detector("FEMC");
ClusterBuilder->Verbosity(verbosity);
ClusterBuilder->set_threshold_energy(0.010);
se->registerSubsystem(ClusterBuilder);
}
else
{
cout << "FEMC_Clusters - unknown clusterizer setting!" << endl;
exit(1);
}
return;
}
void FEMC_Eval(const std::string &outputfile)
{
int verbosity = std::max(Enable::VERBOSITY, Enable::FEMC_VERBOSITY);
Fun4AllServer *se = Fun4AllServer::instance();
CaloEvaluator *eval = new CaloEvaluator("FEMCEVALUATOR", "FEMC", outputfile);
eval->Verbosity(verbosity);
se->registerSubsystem(eval);
return;
}
#endif