ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_BECAL.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_BECAL.C
1 #ifndef MACRO_G4BECAL_C
2 #define MACRO_G4BECAL_C
3 
4 #include <GlobalVariables.C>
5 
7 
10 
11 #include <g4eval/CaloEvaluator.h>
12 
13 #include <g4main/PHG4Reco.h>
14 
17 
18 #include <caloreco/RawClusterBuilderFwd.h>
19 #include <caloreco/RawClusterBuilderTemplate.h>
20 #include <caloreco/RawTowerCalibration.h>
21 
22 #include <fun4all/Fun4AllServer.h>
23 
24 R__LOAD_LIBRARY(libcalo_reco.so)
25 R__LOAD_LIBRARY(libg4calo.so)
26 R__LOAD_LIBRARY(libg4eiccalos.so)
27 R__LOAD_LIBRARY(libg4eval.so)
28 
29 namespace Enable
30 {
31  bool BECAL = false;
32  bool BECAL_ABSORBER = false;
33  bool BECAL_CELL = false;
34  bool BECAL_TOWER = false;
35  bool BECAL_CLUSTER = false;
36  bool BECAL_EVAL = false;
37  bool BECAL_OVERLAPCHECK = false;
38  int BECAL_VERBOSITY = 0;
39 } // namespace Enable
40 
41 
42 
43 namespace G4BECAL
44 {
45 
46  //double minz = -273.6*cm;
47  //double maxz = 142.4*cm;
48  double minz = -453;
49  double maxz = 371;
50  double topradius = 138;
51  double radius = 80;
52 
53  // this is default set to -1.5<eta<1.24 for 2018 Letter of Intent
54  // if the user changes these, the z position of the
55 
56  // Digitization (default photon digi):
58  // directly pass the energy of sim tower to digitized tower
59  // kNo_digitization
60  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
61  // kSimple_photon_digitization
62  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
63  // kSiPM_photon_digitization
64 
65 } // namespace G4BECAL
66 
67 void BECALInit()
68 {
69 
70  // update black hole settings
74 
75 }
76 
77 double BECALSetup(PHG4Reco *g4Reco)
78 {
79 
80  bool AbsorberActive = Enable::ABSORBER || Enable::BECAL_ABSORBER;
81  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::BECAL_OVERLAPCHECK;
82 
83  // Update IR of BCAL to R~80cm
84  // From Nathaly Santiesteban:
85  // https://raw.githubusercontent.com/eic/fun4all_eiccalibrations/main/BarrelEcal/mapping/towerMap_BEMC_v002.txt
86  // It uses IR of 80.3.
87  ostringstream mapping_becal;
88  mapping_becal << getenv("CALIBRATIONROOT") << "/BarrelEcal/mapping/towerMap_BEMC_v002.txt";
89 
91  becal->set_string_param("mapping_file", mapping_becal.str());
92  becal->OverlapCheck(OverlapCheck);
93  becal->SetActive();
94  becal->SuperDetector("BECAL");
95  if (AbsorberActive) becal->SetAbsorberActive();
96 
97  g4Reco->registerSubsystem(becal);
98 
99  return G4BECAL::topradius;
100 
101 }
102 
103 void BECAL_Cells(int verbosity = 0)
104 {
105  return;
106 }
107 
109 {
110 
112 
114 
115  ostringstream mapping_BECAL;
116  mapping_BECAL << getenv("CALIBRATIONROOT") << "/BarrelEcal/mapping/towerMap_BEMC_v001.txt";
117 
118  const double photoelectron_per_GeV = 5000;
119 
120  RawTowerBuilderByHitIndexBECAL *tower_BECAL = new RawTowerBuilderByHitIndexBECAL("TowerBuilder_BECAL");
121  tower_BECAL->Detector("BECAL");
122  tower_BECAL->set_sim_tower_node_prefix("SIM");
123  tower_BECAL->EminCut(1e-7);
124  tower_BECAL->GeometryTableFile(mapping_BECAL.str());
125  tower_BECAL->Verbosity(verbosity);
126  se->registerSubsystem(tower_BECAL);
127 
128  RawTowerDigitizer *TowerDigitizer_BECAL = new RawTowerDigitizer("BECALRawTowerDigitizer");
129  TowerDigitizer_BECAL->Detector("BECAL");
130  TowerDigitizer_BECAL->Verbosity(verbosity);
131 // TowerDigitizer_BECAL->Verbosity(verbosity);
132  TowerDigitizer_BECAL->set_digi_algorithm(G4BECAL::TowerDigi);
133  TowerDigitizer_BECAL->set_raw_tower_node_prefix("RAW");
134  TowerDigitizer_BECAL->set_pedstal_central_ADC(0);
135  TowerDigitizer_BECAL->set_pedstal_width_ADC(0); // eRD1 test beam setting
136  TowerDigitizer_BECAL->set_photonelec_ADC(1); // not simulating ADC discretization error
137  TowerDigitizer_BECAL->set_photonelec_yield_visible_GeV(photoelectron_per_GeV);
138  TowerDigitizer_BECAL->set_zero_suppression_ADC(0); // eRD1 test beam setting
139  se->registerSubsystem(TowerDigitizer_BECAL);
140 
141  RawTowerCalibration *TowerCalibration_BECAL = new RawTowerCalibration("BECALRawTowerCalibration");
142  TowerCalibration_BECAL->Detector("BECAL");
143  TowerCalibration_BECAL->Verbosity(verbosity);
145  TowerCalibration_BECAL->set_calib_const_GeV_ADC(1. / photoelectron_per_GeV);
146  TowerCalibration_BECAL->set_pedstal_ADC(0);
147  se->registerSubsystem(TowerCalibration_BECAL);
148 
149 }
150 
152 {
154 
155  RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkV3("BECALRawClusterBuilderkV3");
156  ClusterBuilder->Detector("BECAL");
157  ClusterBuilder->set_seed_e(0.5);
158  ClusterBuilder->set_agg_e(0.1);
159  se->registerSubsystem(ClusterBuilder);
160 
161  return;
162 }
163 
164 void BECAL_Eval(const std::string &outputfile)
165 {
168 
169  CaloEvaluator *eval = new CaloEvaluator("BECALEVALUATOR", "BECAL", outputfile.c_str());
170  eval->set_do_cluster_eval(false);
171  eval->Verbosity(1);
172  se->registerSubsystem(eval);
173 
174  return;
175 }
176 #endif