EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4_FEMC_EIC.C
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4_FEMC_EIC.C
1
#ifndef MACRO_G4FEMCEIC_C
2
#define MACRO_G4FEMCEIC_C
3
4
#include <GlobalVariables.C>
5
6
#include <
G4_hFarFwdBeamLine_EIC.C
>
7
8
#include <
g4calo/RawTowerBuilderByHitIndex.h
>
9
#include <
g4calo/RawTowerDigitizer.h
>
10
11
#include <
g4eiccalos/PHG4ForwardCalCellReco.h
>
12
#include <
g4eiccalos/PHG4ForwardEcalSubsystem.h
>
13
14
#include <
g4eval/CaloEvaluator.h
>
15
16
#include <
g4main/PHG4Reco.h
>
17
18
#include <caloreco/RawClusterBuilderFwd.h>
19
#include <caloreco/RawClusterBuilderTemplate.h>
20
#include <caloreco/RawTowerCalibration.h>
21
22
#include <
fun4all/Fun4AllServer.h
>
23
24
#include <algorithm>
25
26
R__LOAD_LIBRARY
(libcalo_reco.so)
27
R__LOAD_LIBRARY
(libg4calo.so)
28
R__LOAD_LIBRARY
(libg4eiccalos.so)
29
R__LOAD_LIBRARY
(libg4eval.so)
30
31
namespace Enable
32
{
33
bool
FEMC
=
false
;
34
bool
FEMC_ABSORBER
=
false
;
35
bool
FEMC_CELL
=
false
;
36
bool
FEMC_TOWER
=
false
;
37
bool
FEMC_CLUSTER
=
false
;
38
bool
FEMC_EVAL
=
false
;
39
bool
FEMC_OVERLAPCHECK
=
false
;
40
int
FEMC_VERBOSITY
= 0;
41
}
// namespace Enable
42
43
namespace
G4FEMC
44
{
45
// from ForwardEcal/mapping/towerMap_FEMC_v007.txt
46
double
sampling_fraction
= 0.4;
// for pi, 0.249 for e
47
const
double
Gz0
= 310.;
48
const
double
Gdz
= 36.5;
49
const
double
outer_radius
= 182.655;
50
enum
enu_Femc_clusterizer
51
{
52
kFemcGraphClusterizer
,
53
kFemcTemplateClusterizer
54
};
55
//template clusterizer, as developed by Sasha Bazilevsky
56
enu_Femc_clusterizer
Femc_clusterizer
=
kFemcTemplateClusterizer
;
57
// graph clusterizer
58
//enu_Femc_clusterizer Femc_clusterizer = kFemcGraphClusterizer;
59
namespace
SETTING
60
{
61
bool
FullEtaAcc
=
false
;
62
bool
fsPHENIX
=
false
;
63
bool
EC2x
=
false
;
64
bool
readoutsplit
=
false
;
65
bool
asymmetric
=
false
;
66
bool
wDR
=
false
;
67
bool
FwdSquare
=
false
;
68
}
// namespace SETTING
69
}
// namespace G4FEMC
70
71
void
FEMCInit
()
72
{
73
// simple way to check if only 1 of the settings is true
74
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)
75
{
76
cout <<
"use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::fsPHENIX=true or G4FHCAL::SETTING::wDR=true or G4FHCAL::SETTING::asymmetric=true"
<< endl;
77
gSystem->Exit(1);
78
}
79
80
BlackHoleGeometry::max_radius
=
std::max
(
BlackHoleGeometry::max_radius
,
G4FEMC::outer_radius
);
81
BlackHoleGeometry::max_z
=
std::max
(
BlackHoleGeometry::max_z
,
G4FEMC::Gz0
+
G4FEMC::Gdz
/ 2.);
82
BlackHoleGeometry::min_z
=
std::min
(
BlackHoleGeometry::min_z
, -10.);
83
}
84
85
void
FEMCSetup
(
PHG4Reco
*g4Reco)
86
{
87
bool
AbsorberActive =
Enable::ABSORBER
||
Enable::FEMC_ABSORBER
;
88
bool
OverlapCheck =
Enable::OVERLAPCHECK
||
Enable::FEMC_OVERLAPCHECK
;
89
90
Fun4AllServer
*se =
Fun4AllServer::instance
();
91
93
PHG4ForwardEcalSubsystem
*
femc
=
new
PHG4ForwardEcalSubsystem
(
"FEMC"
);
94
95
ostringstream mapping_femc;
96
97
// PbScint ECAL with nominal eta coverage
98
if
(
G4FEMC::SETTING::FullEtaAcc
)
99
{
100
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt"
;
101
}
102
// doubled granularity ECAL
103
else
if
(
G4FEMC::SETTING::EC2x
)
104
{
105
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_2x.txt"
;
106
}
107
// fsPHENIX ECAL
108
else
if
(
G4FEMC::SETTING::fsPHENIX
)
109
{
110
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt"
;
111
}
112
// asymmetric ECAL around beampipe
113
else
if
(
G4FEMC::SETTING::asymmetric
)
114
{
115
if
(
Enable::IP6
)
116
{
117
if
(
G4FEMC::SETTING::readoutsplit
)
118
{
119
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt"
;
120
}
121
else
122
{
123
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt"
;
124
}
125
}
126
else
127
{
128
if
(
G4FEMC::SETTING::readoutsplit
)
129
{
130
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt"
;
131
}
132
else
133
{
134
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt"
;
135
}
136
}
137
}
138
// ECAL surrounding dual readout calorimeter
139
else
if
(
G4FEMC::SETTING::FwdSquare
)
140
{
141
if
(
G4FEMC::SETTING::readoutsplit
)
142
{
143
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt"
;
144
}
145
else
146
{
147
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt"
;
148
}
149
}
150
// ECAL surrounding dual readout calorimeter
151
else
if
(
G4FEMC::SETTING::wDR
)
152
{
153
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_wDR.txt"
;
154
}
155
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
156
else
157
{
158
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_v007.txt"
;
159
}
160
cout << mapping_femc.str() << endl;
161
femc->
SetTowerMappingFile
(mapping_femc.str());
162
femc->
OverlapCheck
(OverlapCheck);
163
femc->
SetActive
();
164
femc->
SetDetailed
(
false
);
165
femc->
SuperDetector
(
"FEMC"
);
166
if
(AbsorberActive) femc->
SetAbsorberActive
();
167
168
g4Reco->
registerSubsystem
(femc);
169
}
170
171
void
FEMC_Cells
()
172
{
173
return
;
174
}
175
176
void
FEMC_Towers
()
177
{
178
int
verbosity =
std::max
(
Enable::VERBOSITY
,
Enable::FEMC_VERBOSITY
);
179
180
Fun4AllServer
*se =
Fun4AllServer::instance
();
181
182
ostringstream mapping_femc;
183
184
// // fsPHENIX ECAL
185
// mapping_femc << getenv("CALIBRATIONROOT") <<
186
// "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
187
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
188
// PbScint ECAL with nominal eta coverage
189
if
(
G4FEMC::SETTING::FullEtaAcc
)
190
{
191
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt"
;
192
}
193
// doubled granularity ECAL
194
else
if
(
G4FEMC::SETTING::EC2x
)
195
{
196
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_2x.txt"
;
197
}
198
// fsPHENIX ECAL
199
else
if
(
G4FEMC::SETTING::fsPHENIX
)
200
{
201
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt"
;
202
}
203
// ECAL surrounding dual readout calorimeter
204
else
if
(
G4FEMC::SETTING::FwdSquare
)
205
{
206
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt"
;
207
}
208
// ECAL surrounding dual readout calorimeter
209
else
if
(
G4FEMC::SETTING::wDR
)
210
{
211
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_wDR.txt"
;
212
}
213
// asymmetric ECAL around beampipe
214
else
if
(
G4FEMC::SETTING::asymmetric
)
215
{
216
if
(
Enable::IP6
)
217
{
218
if
(
G4FEMC::SETTING::readoutsplit
)
219
{
220
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt"
;
221
}
222
else
223
{
224
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt"
;
225
}
226
}
227
else
228
{
229
if
(
G4FEMC::SETTING::readoutsplit
)
230
{
231
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt"
;
232
}
233
else
234
{
235
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt"
;
236
}
237
}
238
}
239
// ECAL surrounding dual readout calorimeter
240
else
if
(
G4FEMC::SETTING::FwdSquare
)
241
{
242
if
(
G4FEMC::SETTING::readoutsplit
)
243
{
244
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt"
;
245
}
246
else
247
{
248
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt"
;
249
}
250
}
251
// PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
252
else
253
{
254
mapping_femc << getenv(
"CALIBRATIONROOT"
) <<
"/ForwardEcal/mapping/towerMap_FEMC_v007.txt"
;
255
}
256
257
RawTowerBuilderByHitIndex
*tower_FEMC =
new
RawTowerBuilderByHitIndex
(
"TowerBuilder_FEMC"
);
258
tower_FEMC->
Detector
(
"FEMC"
);
259
tower_FEMC->
set_sim_tower_node_prefix
(
"SIM"
);
260
tower_FEMC->
GeometryTableFile
(mapping_femc.str());
261
262
se->
registerSubsystem
(tower_FEMC);
263
264
// PbW crystals
265
//RawTowerDigitizer *TowerDigitizer1 = new RawTowerDigitizer("FEMCRawTowerDigitizer1");
266
//TowerDigitizer1->Detector("FEMC");
267
//TowerDigitizer1->TowerType(1);
268
//TowerDigitizer1->Verbosity(verbosity);
269
//TowerDigitizer1->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
270
//se->registerSubsystem( TowerDigitizer1 );
271
272
// PbSc towers
273
RawTowerDigitizer
*TowerDigitizer2 =
new
RawTowerDigitizer
(
"FEMCRawTowerDigitizer2"
);
274
TowerDigitizer2->
Detector
(
"FEMC"
);
275
TowerDigitizer2->
TowerType
(2);
276
TowerDigitizer2->
Verbosity
(verbosity);
277
TowerDigitizer2->
set_digi_algorithm
(
RawTowerDigitizer::kNo_digitization
);
278
se->
registerSubsystem
(TowerDigitizer2);
279
280
// // E864 towers (three types for three sizes)
281
// RawTowerDigitizer *TowerDigitizer3 = new RawTowerDigitizer("FEMCRawTowerDigitizer3");
282
// TowerDigitizer3->Detector("FEMC");
283
// TowerDigitizer3->TowerType(3);
284
// TowerDigitizer3->Verbosity(verbosity);
285
// TowerDigitizer3->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
286
// se->registerSubsystem( TowerDigitizer3 );
287
//
288
// RawTowerDigitizer *TowerDigitizer4 = new RawTowerDigitizer("FEMCRawTowerDigitizer4");
289
// TowerDigitizer4->Detector("FEMC");
290
// TowerDigitizer4->TowerType(4);
291
// TowerDigitizer4->Verbosity(verbosity);
292
// TowerDigitizer4->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
293
// se->registerSubsystem( TowerDigitizer4 );
294
//
295
// RawTowerDigitizer *TowerDigitizer5 = new RawTowerDigitizer("FEMCRawTowerDigitizer5");
296
// TowerDigitizer5->Detector("FEMC");
297
// TowerDigitizer5->TowerType(5);
298
// TowerDigitizer5->Verbosity(verbosity);
299
// TowerDigitizer5->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
300
// se->registerSubsystem( TowerDigitizer5 );
301
//
302
// RawTowerDigitizer *TowerDigitizer6 = new RawTowerDigitizer("FEMCRawTowerDigitizer6");
303
// TowerDigitizer6->Detector("FEMC");
304
// TowerDigitizer6->TowerType(6);
305
// TowerDigitizer6->Verbosity(verbosity);
306
// TowerDigitizer6->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
307
// se->registerSubsystem( TowerDigitizer6 );
308
309
// PbW crystals
310
//RawTowerCalibration *TowerCalibration1 = new RawTowerCalibration("FEMCRawTowerCalibration1");
311
//TowerCalibration1->Detector("FEMC");
312
//TowerCalibration1->TowerType(1);
313
//TowerCalibration1->Verbosity(verbosity);
314
//TowerCalibration1->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
315
//TowerCalibration1->set_calib_const_GeV_ADC(1.0); // sampling fraction = 1.0
316
//TowerCalibration1->set_pedstal_ADC(0);
317
//se->registerSubsystem( TowerCalibration1 );
318
319
// PbSc towers
320
RawTowerCalibration
*TowerCalibration2 =
new
RawTowerCalibration
(
"FEMCRawTowerCalibration2"
);
321
TowerCalibration2->
Detector
(
"FEMC"
);
322
TowerCalibration2->
TowerType
(2);
323
TowerCalibration2->
Verbosity
(verbosity);
324
TowerCalibration2->
set_calib_algorithm
(
RawTowerCalibration::kSimple_linear_calibration
);
325
if
(
G4FEMC::SETTING::readoutsplit
)
326
{
327
TowerCalibration2->
set_calib_const_GeV_ADC
(1.0 / (
sampling_fraction
* 0.84));
328
}
329
else
330
{
331
TowerCalibration2->
set_calib_const_GeV_ADC
(1.0 /
sampling_fraction
);
332
}
333
TowerCalibration2->
set_pedstal_ADC
(0);
334
se->
registerSubsystem
(TowerCalibration2);
335
336
// // E864 towers (three types for three sizes)
337
// RawTowerCalibration *TowerCalibration3 = new RawTowerCalibration("FEMCRawTowerCalibration3");
338
// TowerCalibration3->Detector("FEMC");
339
// TowerCalibration3->TowerType(3);
340
// TowerCalibration3->Verbosity(verbosity);
341
// TowerCalibration3->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
342
// TowerCalibration3->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
343
// TowerCalibration3->set_pedstal_ADC(0);
344
// se->registerSubsystem( TowerCalibration3 );
345
//
346
// RawTowerCalibration *TowerCalibration4 = new RawTowerCalibration("FEMCRawTowerCalibration4");
347
// TowerCalibration4->Detector("FEMC");
348
// TowerCalibration4->TowerType(4);
349
// TowerCalibration4->Verbosity(verbosity);
350
// TowerCalibration4->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
351
// TowerCalibration4->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
352
// TowerCalibration4->set_pedstal_ADC(0);
353
// se->registerSubsystem( TowerCalibration4 );
354
//
355
// RawTowerCalibration *TowerCalibration5 = new RawTowerCalibration("FEMCRawTowerCalibration5");
356
// TowerCalibration5->Detector("FEMC");
357
// TowerCalibration5->TowerType(5);
358
// TowerCalibration5->Verbosity(verbosity);
359
// TowerCalibration5->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
360
// TowerCalibration5->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
361
// TowerCalibration5->set_pedstal_ADC(0);
362
// se->registerSubsystem( TowerCalibration5 );
363
//
364
// RawTowerCalibration *TowerCalibration6 = new RawTowerCalibration("FEMCRawTowerCalibration6");
365
// TowerCalibration6->Detector("FEMC");
366
// TowerCalibration6->TowerType(6);
367
// TowerCalibration6->Verbosity(verbosity);
368
// TowerCalibration6->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
369
// TowerCalibration6->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
370
// TowerCalibration6->set_pedstal_ADC(0);
371
// se->registerSubsystem( TowerCalibration6 );
372
}
373
374
void
FEMC_Clusters
()
375
{
376
int
verbosity =
std::max
(
Enable::VERBOSITY
,
Enable::FEMC_VERBOSITY
);
377
378
Fun4AllServer
*se =
Fun4AllServer::instance
();
379
380
if
(
G4FEMC::Femc_clusterizer
==
G4FEMC::kFemcTemplateClusterizer
)
381
{
382
RawClusterBuilderTemplate
*ClusterBuilder =
new
RawClusterBuilderTemplate
(
"EmcRawClusterBuilderTemplateFEMC"
);
383
ClusterBuilder->
Detector
(
"FEMC"
);
384
ClusterBuilder->
Verbosity
(verbosity);
385
ClusterBuilder->
set_threshold_energy
(0.020);
// This threshold should be the same as in FEMCprof_Thresh**.root file below
386
std::string femc_prof = getenv(
"CALIBRATIONROOT"
);
387
femc_prof +=
"/EmcProfile/FEMCprof_Thresh20MeV.root"
;
388
ClusterBuilder->
LoadProfile
(femc_prof.c_str());
389
se->
registerSubsystem
(ClusterBuilder);
390
}
391
else
if
(
G4FEMC::Femc_clusterizer
==
G4FEMC::kFemcGraphClusterizer
)
392
{
393
RawClusterBuilderFwd
*ClusterBuilder =
new
RawClusterBuilderFwd
(
"FEMCRawClusterBuilderFwd"
);
394
395
ClusterBuilder->
Detector
(
"FEMC"
);
396
ClusterBuilder->
Verbosity
(verbosity);
397
ClusterBuilder->
set_threshold_energy
(0.010);
398
se->
registerSubsystem
(ClusterBuilder);
399
}
400
else
401
{
402
cout <<
"FEMC_Clusters - unknown clusterizer setting!"
<< endl;
403
exit
(1);
404
}
405
406
return
;
407
}
408
409
void
FEMC_Eval
(
const
std::string &
outputfile
)
410
{
411
int
verbosity =
std::max
(
Enable::VERBOSITY
,
Enable::FEMC_VERBOSITY
);
412
413
Fun4AllServer
*se =
Fun4AllServer::instance
();
414
415
CaloEvaluator
*eval =
new
CaloEvaluator
(
"FEMCEVALUATOR"
,
"FEMC"
, outputfile);
416
eval->
Verbosity
(verbosity);
417
se->
registerSubsystem
(eval);
418
419
return
;
420
}
421
#endif
fun4all_eic_qa
blob
master
macros
G4_FEMC_EIC.C
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:53
using
1.8.2 with
EIC GitHub integration