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 
16 #include <caloreco/RawClusterBuilderFwd.h>
17 #include <caloreco/RawClusterBuilderTemplate.h>
18 #include <caloreco/RawTowerCalibration.h>
19 
20 #include <fun4all/Fun4AllServer.h>
21 
22 R__LOAD_LIBRARY(libcalo_reco.so)
23 R__LOAD_LIBRARY(libg4calo.so)
24 R__LOAD_LIBRARY(libg4eiccalos.so)
25 R__LOAD_LIBRARY(libg4eval.so)
26 
27 namespace Enable
28 {
29  bool FHCAL = false;
30  bool FHCAL_ABSORBER = false;
31  bool FHCAL_SUPPORT = false;
32  bool FHCAL_CELL = false;
33  bool FHCAL_TOWER = false;
34  bool FHCAL_CLUSTER = false;
35  bool FHCAL_EVAL = false;
36  bool FHCAL_OVERLAPCHECK = false;
37  int FHCAL_VERBOSITY = 0;
38 } // namespace Enable
39 
40 namespace G4FHCAL
41 {
42  // from ForwardHcal/mapping/towerMap_FHCAL_v005.txt
43  double Gz0 = 400.;
44  double Gdz = 100.;
45  double outer_radius = 262.;
46  double sampling_fraction = 0.03898; // calibrated with muons
48  {
51  };
52  //template clusterizer, as developed by Sasha Bazilevsky
54  // graph clusterizer
55  //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
56  namespace SETTING
57  {
59  bool FullEtaAcc = false;
60  bool HC2x = false;
61  bool HC4x = false;
62  bool asymmetric = false;
63  bool extradepth = false;
64  bool wDR = false;
65  bool FwdSquare = false;
66  bool towercalib1 = false;
67  bool towercalibSiPM = false;
68  bool towercalibHCALIN = false;
69  bool towercalib3 = false;
70  } // namespace SETTING
71 } // namespace G4FHCAL
72 
73 void FHCALInit()
74 {
75  // simple way to check if only 1 of the settings is true
77  {
78  cout << "use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::HC2x=true or G4FHCAL::SETTING::HC4x=true" << endl;
79  gSystem->Exit(1);
80  }
83  1)
84  {
85  cout << "use only G4FHCAL::SETTING::towercalib1 = true or G4FHCAL::SETTING::towercalibSiPM = true"
86  << " or G4FHCAL::SETTING::towercalibHCALIN = true or G4FHCAL::SETTING::towercalib3 = true" << endl;
87  gSystem->Exit(1);
88  }
89 
93 }
94 
95 void FHCALSetup(PHG4Reco *g4Reco)
96 {
97  bool AbsorberActive = Enable::ABSORBER || Enable::FHCAL_ABSORBER;
98  bool SupportActive = Enable::SUPPORT || Enable::FHCAL_SUPPORT;
99  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FHCAL_OVERLAPCHECK;
101 
104 
105  ostringstream mapping_fhcal;
106 
107  // Switch to desired calo setup
108  // HCal Fe-Scint with doubled granularity
110  {
111  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
112  }
113  // full HCal Fe-Scint with nominal acceptance doubled granularity
115  {
116  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
117  }
118  // HCal Fe-Scint with four times granularity
119  else if (G4FHCAL::SETTING::HC4x)
120  {
121  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
122  }
123  // full HCal Fe-Scint with nominal acceptance four times granularity
125  {
126  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
127  }
128  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
129  else if (G4FHCAL::SETTING::wDR)
130  {
131  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_wDR.txt";
132  }
133  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
135  {
137  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare_XL.txt";
138  else
139  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare.txt";
140  }
141  // full HCal Fe-Scint with asymmetric centering around beampipe
143  {
145  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric_XL.txt";
146  else
147  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric.txt";
148  }
149  // full HCal Fe-Scint with nominal acceptance
151  {
152  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
153  }
154  // full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
155  else
156  {
157  mapping_fhcal << getenv("CALIBRATIONROOT")
158  << "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
159  }
161  fhcal->SetTowerMappingFile(mapping_fhcal.str());
162  fhcal->OverlapCheck(OverlapCheck);
163  fhcal->SetActive();
164  fhcal->SetDetailed(false);
165  fhcal->SuperDetector("FHCAL");
166  if (AbsorberActive) fhcal->SetAbsorberActive();
167  if (SupportActive) fhcal->SetSupportActive();
168  g4Reco->registerSubsystem(fhcal);
169 }
170 
171 void FHCAL_Cells(int verbosity = 0)
172 {
173  return;
174 }
175 
177 {
179 
181 
182  ostringstream mapping_fhcal;
183 
184  // Switch to desired calo setup
185  // HCal Fe-Scint with doubled granularity
187  {
188  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x.txt";
189  }
190  // full HCal Fe-Scint with nominal acceptance doubled granularity
192  {
193  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_2x_fullEtaCov.txt";
194  }
195  // HCal Fe-Scint with four times granularity
196  else if (G4FHCAL::SETTING::HC4x)
197  {
198  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x.txt";
199  }
200  // full HCal Fe-Scint with nominal acceptance four times granularity
202  {
203  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_4x_fullEtaCov.txt";
204  }
205  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
206  else if (G4FHCAL::SETTING::wDR)
207  {
208  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_wDR.txt";
209  }
210  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
212  {
214  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare_XL.txt";
215  else
216  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_FwdSquare.txt";
217  }
218  // full HCal Fe-Scint with asymmetric centering around beampipe
220  {
222  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric_XL.txt";
223  else
224  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_asymmetric.txt";
225  }
226  // full HCal Fe-Scint with nominal acceptance
228  {
229  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_default_fullEtaCov.txt";
230  }
231  // full HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
232  else
233  {
234  mapping_fhcal << getenv("CALIBRATIONROOT") << "/ForwardHcal/mapping/towerMap_FHCAL_v005.txt";
235  }
236 
237  RawTowerBuilderByHitIndex *tower_FHCAL = new RawTowerBuilderByHitIndex("TowerBuilder_FHCAL");
238  tower_FHCAL->Detector("FHCAL");
239  tower_FHCAL->set_sim_tower_node_prefix("SIM");
240  tower_FHCAL->GeometryTableFile(mapping_fhcal.str());
241 
242  se->registerSubsystem(tower_FHCAL);
243 
244  // enable usage of different tower calibrations for systematic studies
246  {
247  cout << "1: using towercalib1 for FHCAL towers" << endl;
248  const double FHCAL_photoelectron_per_GeV = 500;
249  RawTowerDigitizer *TowerDigitizer_FHCAL = new RawTowerDigitizer("FHCALRawTowerDigitizer");
250 
251  TowerDigitizer_FHCAL->Detector("FHCAL");
252  TowerDigitizer_FHCAL->Verbosity(verbosity);
253  TowerDigitizer_FHCAL->set_raw_tower_node_prefix("RAW");
255  TowerDigitizer_FHCAL->set_pedstal_central_ADC(0);
256  TowerDigitizer_FHCAL->set_pedstal_width_ADC(8); // eRD1 test beam setting
257  TowerDigitizer_FHCAL->set_photonelec_ADC(1); //not simulating ADC discretization error
258  TowerDigitizer_FHCAL->set_photonelec_yield_visible_GeV(FHCAL_photoelectron_per_GeV);
259  TowerDigitizer_FHCAL->set_zero_suppression_ADC(16); // eRD1 test beam setting
260 
261  se->registerSubsystem(TowerDigitizer_FHCAL);
262 
263  RawTowerCalibration *TowerCalibration_FHCAL = new RawTowerCalibration("FHCALRawTowerCalibration");
264  TowerCalibration_FHCAL->Detector("FHCAL");
265  TowerCalibration_FHCAL->Verbosity(verbosity);
267  TowerCalibration_FHCAL->set_calib_const_GeV_ADC(1. / FHCAL_photoelectron_per_GeV);
268  TowerCalibration_FHCAL->set_pedstal_ADC(0);
269 
270  se->registerSubsystem(TowerCalibration_FHCAL);
271  }
273  {
274  //from https://sphenix-collaboration.github.io/doxygen/d4/d58/Fun4All__G4__Prototype4_8C_source.html
275  const double sampling_fraction = 0.019441; // +/- 0.019441 from 0 Degree indenting 12 GeV electron showers
276  const double photoelectron_per_GeV = 500; //500 photon per total GeV deposition
277  const double ADC_per_photoelectron_HG = 3.8; // From Sean Stoll, Mar 29
278  const double ADC_per_photoelectron_LG = 0.24; // From Sean Stoll, Mar 29
279 
280  cout << "2: using towercalibSiPM for FHCAL towers" << endl;
281  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
282  TowerDigitizer->Detector("FHCAL");
283  TowerDigitizer->set_raw_tower_node_prefix("RAW");
285  TowerDigitizer->set_pedstal_central_ADC(0);
286  TowerDigitizer->set_pedstal_width_ADC(1);
287  TowerDigitizer->set_photonelec_ADC(1. / ADC_per_photoelectron_LG);
288  TowerDigitizer->set_photonelec_yield_visible_GeV(photoelectron_per_GeV / sampling_fraction);
289  TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
290  se->registerSubsystem(TowerDigitizer);
291 
292  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
293  TowerCalibration->Detector("FHCAL");
294  TowerCalibration->set_raw_tower_node_prefix("RAW");
296  TowerCalibration->set_calib_const_GeV_ADC(1. / ADC_per_photoelectron_LG / photoelectron_per_GeV);
297  TowerCalibration->set_pedstal_ADC(0);
298  TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
299  se->registerSubsystem(TowerCalibration);
300  }
302  {
303  const double visible_sample_fraction_HCALIN = 7.19505e-02; // 1.34152e-02
304  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
305  TowerDigitizer->Detector("FHCAL");
306  TowerDigitizer->set_raw_tower_node_prefix("RAW");
308  TowerDigitizer->set_pedstal_central_ADC(0);
309  TowerDigitizer->set_pedstal_width_ADC(1);
310  TowerDigitizer->set_photonelec_ADC(32. / 5.);
311  TowerDigitizer->set_photonelec_yield_visible_GeV(32. / 5 / (0.4e-3));
312  TowerDigitizer->set_zero_suppression_ADC(-1000); // no-zero suppression
313  se->registerSubsystem(TowerDigitizer);
314 
315  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
316  TowerCalibration->Detector("FHCAL");
317  TowerCalibration->set_raw_tower_node_prefix("RAW");
319  TowerCalibration->set_calib_const_GeV_ADC(0.4e-3 / visible_sample_fraction_HCALIN);
320  TowerCalibration->set_pedstal_ADC(0);
321  TowerCalibration->set_zero_suppression_GeV(-1); // no-zero suppression
322  se->registerSubsystem(TowerCalibration);
323  }
325  {
326  cout << "3: using towercalib3 for FHCAL towers" << endl;
327  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
328  TowerDigitizer->Detector("FHCAL");
329  TowerDigitizer->set_pedstal_central_ADC(0);
330  TowerDigitizer->set_pedstal_width_ADC(8); // eRD1 test beam setting
331  TowerDigitizer->Verbosity(verbosity);
333  se->registerSubsystem(TowerDigitizer);
334 
335  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
336  TowerCalibration->Detector("FHCAL");
337  TowerCalibration->Verbosity(verbosity);
339  TowerCalibration->set_calib_const_GeV_ADC(1. / G4FHCAL::sampling_fraction);
340  TowerCalibration->set_pedstal_ADC(0);
341  se->registerSubsystem(TowerCalibration);
342  }
343  else
344  {
345  cout << "def: using default for FHCAL towers" << endl;
346  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("FHCALRawTowerDigitizer");
347  TowerDigitizer->Detector("FHCAL");
348  TowerDigitizer->Verbosity(verbosity);
350  se->registerSubsystem(TowerDigitizer);
351 
352  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("FHCALRawTowerCalibration");
353  TowerCalibration->Detector("FHCAL");
354  TowerCalibration->Verbosity(verbosity);
356  TowerCalibration->set_calib_const_GeV_ADC(1. / (G4FHCAL::sampling_fraction * 0.5)); // temporary factor 0.5 to fix calibration for new tower design
357  TowerCalibration->set_pedstal_ADC(0);
358  se->registerSubsystem(TowerCalibration);
359  }
360 }
361 
363 {
366 
368  {
369  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("FHCALRawClusterBuilderTemplate");
370  ClusterBuilder->Detector("FHCAL");
371  ClusterBuilder->SetPlanarGeometry(); // has to be called after Detector()
372  ClusterBuilder->Verbosity(verbosity);
373  ClusterBuilder->set_threshold_energy(0.100);
374  se->registerSubsystem(ClusterBuilder);
375  }
377  {
378  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FHCALRawClusterBuilderFwd");
379  ClusterBuilder->Detector("FHCAL");
380  ClusterBuilder->Verbosity(verbosity);
381  ClusterBuilder->set_threshold_energy(0.100);
382  se->registerSubsystem(ClusterBuilder);
383  }
384  else
385  {
386  cout << "FHCAL_Clusters - unknown clusterizer setting " << G4FHCAL::FHcal_clusterizer << endl;
387  gSystem->Exit(1);
388  }
389 
390  return;
391 }
392 
393 void FHCAL_Eval(const std::string &outputfile)
394 {
397 
398  CaloEvaluator *eval = new CaloEvaluator("FHCALEVALUATOR", "FHCAL", outputfile.c_str());
399  eval->Verbosity(verbosity);
400  se->registerSubsystem(eval);
401 
402  return;
403 }
404 #endif