ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_FHCAL.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_FHCAL.C
1 #ifndef MACRO_G4FHCAL_C
2 #define MACRO_G4FHCAL_C
3 
4 #include <GlobalVariables.C>
5 
8 
11 
12 #include <g4eval/CaloEvaluator.h>
13 
14 #include <g4main/PHG4Reco.h>
15 
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 FHCAL = false;
33  bool FHCAL_ABSORBER = false;
34  bool FHCAL_CELL = false;
35  bool FHCAL_TOWER = false;
36  bool FHCAL_CLUSTER = false;
37  bool FHCAL_EVAL = false;
38  bool FHCAL_OVERLAPCHECK = false;
39  int FHCAL_VERBOSITY = 0;
40 } // namespace Enable
41 
42 namespace G4FHCAL
43 {
44  // from ForwardHcal/mapping/towerMap_FHCAL_v005.txt
45  double Gz0 = 400.;
46  double Gdz = 100.;
47  double outer_radius = 262.;
49  {
52  };
53  //template clusterizer, as developed by Sasha Bazilevsky
55  // graph clusterizer
56  //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
57  namespace SETTING
58  {
59  bool FullEtaAcc = false;
60  bool HC2x = false;
61  bool HC4x = false;
62  bool towercalib1 = false;
63  bool towercalibSiPM = false;
64  bool towercalibHCALIN = false;
65  bool towercalib3 = false;
66  } // namespace SETTING
67 } // namespace G4FHCAL
68 
69 void FHCALInit()
70 {
71  // simple way to check if only 1 of the settings is true
72  if ((G4FHCAL::SETTING::FullEtaAcc ? 1 : 0) + (G4FHCAL::SETTING::HC4x ? 1 : 0) + (G4FHCAL::SETTING::HC2x ? 1 : 0) > 1)
73  {
74  cout << "use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::HC2x=true or G4FHCAL::SETTING::HC4x=true" << endl;
75  gSystem->Exit(1);
76  }
79  1)
80  {
81  cout << "use only G4FHCAL::SETTING::towercalib1 = true or G4FHCAL::SETTING::towercalibSiPM = true"
82  << " or G4FHCAL::SETTING::towercalibHCALIN = true or G4FHCAL::SETTING::towercalib3 = true" << endl;
83  gSystem->Exit(1);
84  }
85 
88 }
89 
90 void FHCALSetup(PHG4Reco *g4Reco)
91 {
92  const bool AbsorberActive = Enable::ABSORBER || Enable::FHCAL_ABSORBER;
93  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FHCAL_OVERLAPCHECK;
95 
98 
99  ostringstream mapping_fhcal;
100 
101  // Switch to desired calo setup
102  // HCal Fe-Scint with doubled granularity
104  {
105  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
106  }
107  // full HCal Fe-Scint with nominal acceptance doubled granularity
109  {
110  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
111  }
112  // HCal Fe-Scint with four times granularity
113  else if (G4FHCAL::SETTING::HC4x )
114  {
115  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
116  }
117  // full HCal Fe-Scint with nominal acceptance four times granularity
119  {
120  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
121  }
122  // full HCal Fe-Scint with nominal acceptance
124  {
125  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
126  }
127  // full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
128  else
129  {
130  mapping_fhcal << getenv("CALIBRATIONROOT")
131  << "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
132  }
133 
134  fhcal->SetTowerMappingFile(mapping_fhcal.str());
135  fhcal->OverlapCheck(OverlapCheck);
136  fhcal->SetActive();
137  fhcal->SuperDetector("FHCAL");
138  if (AbsorberActive) fhcal->SetAbsorberActive();
139 
140  g4Reco->registerSubsystem(fhcal);
141 }
142 
143 void FHCAL_Cells(int verbosity = 0)
144 {
145  return;
146 }
147 
149 {
151 
153 
154  ostringstream mapping_fhcal;
155 
156  // Switch to desired calo setup
157  // HCal Fe-Scint with doubled granularity
159  {
160  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
161  }
162  // full HCal Fe-Scint with nominal acceptance doubled granularity
164  {
165  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
166  }
167  // HCal Fe-Scint with four times granularity
168  else if (G4FHCAL::SETTING::HC4x )
169  {
170  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
171  }
172  // full HCal Fe-Scint with nominal acceptance four times granularity
174  {
175  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
176  }
177  // full HCal Fe-Scint with nominal acceptance
179  {
180  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
181  }
182  // full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
183  else
184  {
185  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
186  }
187 
188  RawTowerBuilderByHitIndex *tower_FHCAL = new RawTowerBuilderByHitIndex("TowerBuilder_FHCAL");
189  tower_FHCAL->Detector("FHCAL");
190  tower_FHCAL->set_sim_tower_node_prefix("SIM");
191  tower_FHCAL->GeometryTableFile(mapping_fhcal.str());
192 
193  se->registerSubsystem(tower_FHCAL);
194 
195  // enable usage of different tower calibrations for systematic studies
197  {
198  cout << "1: using towercalib1 for FHCAL towers" << endl;
199  const double FHCAL_photoelectron_per_GeV = 500;
200  RawTowerDigitizer *TowerDigitizer_FHCAL = new RawTowerDigitizer("FHCALRawTowerDigitizer");
201 
202  TowerDigitizer_FHCAL->Detector("FHCAL");
203  TowerDigitizer_FHCAL->Verbosity(verbosity);
204  TowerDigitizer_FHCAL->set_raw_tower_node_prefix("RAW");
206  TowerDigitizer_FHCAL->set_pedstal_central_ADC(0);
207  TowerDigitizer_FHCAL->set_pedstal_width_ADC(8); // eRD1 test beam setting
208  TowerDigitizer_FHCAL->set_photonelec_ADC(1); //not simulating ADC discretization error
209  TowerDigitizer_FHCAL->set_photonelec_yield_visible_GeV(FHCAL_photoelectron_per_GeV);
210  TowerDigitizer_FHCAL->set_zero_suppression_ADC(16); // eRD1 test beam setting
211 
212  se->registerSubsystem(TowerDigitizer_FHCAL);
213 
214  RawTowerCalibration *TowerCalibration_FHCAL = new RawTowerCalibration("FHCALRawTowerCalibration");
215  TowerCalibration_FHCAL->Detector("FHCAL");
216  TowerCalibration_FHCAL->Verbosity(verbosity);
218  TowerCalibration_FHCAL->set_calib_const_GeV_ADC(1. / FHCAL_photoelectron_per_GeV);
219  TowerCalibration_FHCAL->set_pedstal_ADC(0);
220 
221  se->registerSubsystem(TowerCalibration_FHCAL);
222  }
224  {
225  //from https://sphenix-collaboration.github.io/doxygen/d4/d58/Fun4All__G4__Prototype4_8C_source.html
226  const double sampling_fraction = 0.019441; // +/- 0.019441 from 0 Degree indenting 12 GeV electron showers
227  const double photoelectron_per_GeV = 500; //500 photon per total GeV deposition
228  const double ADC_per_photoelectron_HG = 3.8; // From Sean Stoll, Mar 29
229  const double ADC_per_photoelectron_LG = 0.24; // From Sean Stoll, Mar 29
230 
231  cout << "2: using towercalibSiPM for FHCAL towers" << endl;
232  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
233  TowerDigitizer->Detector("FHCAL");
234  TowerDigitizer->set_raw_tower_node_prefix("RAW");
236  TowerDigitizer->set_pedstal_central_ADC(0);
237  TowerDigitizer->set_pedstal_width_ADC(1);
238  TowerDigitizer->set_photonelec_ADC(1. / ADC_per_photoelectron_LG);
239  TowerDigitizer->set_photonelec_yield_visible_GeV(photoelectron_per_GeV / sampling_fraction);
240  TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
241  se->registerSubsystem(TowerDigitizer);
242 
243  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
244  TowerCalibration->Detector("FHCAL");
245  TowerCalibration->set_raw_tower_node_prefix("RAW");
247  TowerCalibration->set_calib_const_GeV_ADC(1. / ADC_per_photoelectron_LG / photoelectron_per_GeV);
248  TowerCalibration->set_pedstal_ADC(0);
249  TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
250  se->registerSubsystem(TowerCalibration);
251  }
253  {
254  const double visible_sample_fraction_HCALIN = 7.19505e-02; // 1.34152e-02
255  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
256  TowerDigitizer->Detector("FHCAL");
257  TowerDigitizer->set_raw_tower_node_prefix("RAW");
259  TowerDigitizer->set_pedstal_central_ADC(0);
260  TowerDigitizer->set_pedstal_width_ADC(1);
261  TowerDigitizer->set_photonelec_ADC(32. / 5.);
262  TowerDigitizer->set_photonelec_yield_visible_GeV(32. / 5 / (0.4e-3));
263  TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
264  se->registerSubsystem(TowerDigitizer);
265 
266  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
267  TowerCalibration->Detector("FHCAL");
268  TowerCalibration->set_raw_tower_node_prefix("RAW");
270  TowerCalibration->set_calib_const_GeV_ADC(0.4e-3 / visible_sample_fraction_HCALIN);
271  TowerCalibration->set_pedstal_ADC(0);
272  TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
273  se->registerSubsystem(TowerCalibration);
274  }
276  {
277  cout << "3: using towercalib3 for FHCAL towers" << endl;
278  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
279  TowerDigitizer->Detector("FHCAL");
280  TowerDigitizer->set_pedstal_central_ADC(0);
281  TowerDigitizer->set_pedstal_width_ADC(8); // eRD1 test beam setting
282  TowerDigitizer->Verbosity(verbosity);
284  se->registerSubsystem(TowerDigitizer);
285 
286  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
287  TowerCalibration->Detector("FHCAL");
288  TowerCalibration->Verbosity(verbosity);
290  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.03898); // calibrated with muons
291  TowerCalibration->set_pedstal_ADC(0);
292  se->registerSubsystem(TowerCalibration);
293  }
294  else
295  {
296  cout << "def: using default for FHCAL towers" << endl;
297  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
298  TowerDigitizer->Detector("FHCAL");
299  TowerDigitizer->Verbosity(verbosity);
301  se->registerSubsystem(TowerDigitizer);
302 
303  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
304  TowerCalibration->Detector("FHCAL");
305  TowerCalibration->Verbosity(verbosity);
307  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.03898); // calibrated with muons
308  TowerCalibration->set_pedstal_ADC(0);
309  se->registerSubsystem(TowerCalibration);
310  }
311 }
312 
314 {
317 
319  {
320  RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkMA("FHCALRawClusterBuilderkMA");
321  ClusterBuilder->Detector("FHCAL");
322  ClusterBuilder->set_seed_e(0.1);
323  ClusterBuilder->set_agg_e(0.001);
324  se->registerSubsystem(ClusterBuilder);
325  /*
326  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("FHCALRawClusterBuilderTemplate");
327  ClusterBuilder->Detector("FHCAL");
328  ClusterBuilder->SetPlanarGeometry(); // has to be called after Detector()
329  ClusterBuilder->Verbosity(verbosity);
330  ClusterBuilder->set_threshold_energy(0.100);
331  se->registerSubsystem(ClusterBuilder);
332  */
333  }
335  {
336  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FHCALRawClusterBuilderFwd");
337  ClusterBuilder->Detector("FHCAL");
338  ClusterBuilder->Verbosity(verbosity);
339  ClusterBuilder->set_threshold_energy(0.100);
340  se->registerSubsystem(ClusterBuilder);
341  }
342  else
343  {
344  cout << "FHCAL_Clusters - unknown clusterizer setting " << G4FHCAL::FHcal_clusterizer << endl;
345  gSystem->Exit(1);
346  }
347 
348  return;
349 }
350 
351 void FHCAL_Eval(const std::string &outputfile)
352 {
355 
356  CaloEvaluator *eval = new CaloEvaluator("FHCALEVALUATOR", "FHCAL", outputfile.c_str());
357  eval->Verbosity(verbosity);
358  se->registerSubsystem(eval);
359 
360  return;
361 }
362 #endif