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