EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_HCalIn_EIC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_HCalIn_EIC.C
1 //Inner HCal reconstruction macro
2 #ifndef MACRO_G4HCALINREF_C
3 #define MACRO_G4HCALINREF_C
4 
5 #include <GlobalVariables.C>
6 #include <QA.C>
7 
10 
14 
15 #include <g4eval/CaloEvaluator.h>
16 
17 #include <g4main/PHG4Reco.h>
18 
19 #include <caloreco/RawClusterBuilderGraph.h>
20 #include <caloreco/RawClusterBuilderTemplate.h>
21 #include <caloreco/RawTowerCalibration.h>
22 #include <qa_modules/QAG4SimulationCalorimeter.h>
23 
24 #include <fun4all/Fun4AllServer.h>
25 
26 R__LOAD_LIBRARY(libcalo_reco.so)
27 R__LOAD_LIBRARY(libg4calo.so)
28 R__LOAD_LIBRARY(libg4detectors.so)
29 R__LOAD_LIBRARY(libg4eval.so)
30 R__LOAD_LIBRARY(libqa_modules.so)
31 
32 void HCalInner_SupportRing(PHG4Reco *g4Reco);
33 
34 namespace Enable
35 {
36  bool HCALIN = false;
37  bool HCALIN_ABSORBER = false;
38  bool HCALIN_OVERLAPCHECK = false;
39  bool HCALIN_CELL = false;
40  bool HCALIN_TOWER = false;
41  bool HCALIN_CLUSTER = false;
42  bool HCALIN_EVAL = false;
43  bool HCALIN_QA = false;
44  bool HCALIN_SUPPORT = false;
46 } // namespace Enable
47 
48 namespace G4HCALIN
49 {
50  double support_ring_outer_radius = 178.0 - 0.001;
51  double support_ring_z_ring2 = (2150 + 2175) / 2. / 10.;
52  double dz = 25. / 10.;
53 
54  //Inner HCal absorber material selector:
55  //false - old version, absorber material is SS310
56  //true - default Choose if you want Aluminum
58 
59  int inner_hcal_eic = 0;
60 
61  // Digitization (default photon digi):
63  // directly pass the energy of sim tower to digitized tower
64  // kNo_digitization
65  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
66  // kSimple_photon_digitization
67  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
68  // kSiPM_photon_digitization
69 
71  {
73 
75  };
76 
77  namespace SETTING
78  {
79  bool USECEMCGeo = true;
80  }
81 
85  //enu_HCalIn_clusterizer HCalIn_clusterizer = kHCalInGraphClusterizer;
86 } // namespace G4HCALIN
87 
88 // Init is called by G4Setup.C
89 void HCalInnerInit(const int iflag = 0)
90 {
94  if (iflag == 1)
95  {
97  }
98 
101 }
102 
103 double HCalInner(PHG4Reco *g4Reco,
104  double radius,
105  const int crossings)
106 {
107  bool AbsorberActive = Enable::ABSORBER || Enable::HCALIN_ABSORBER;
108  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::HCALIN_OVERLAPCHECK;
110 
111  // all sizes are in cm!
113  // these are the parameters you can change with their default settings
114  // hcal->set_string_param("material","SS310");
116  {
117  if (verbosity > 0)
118  {
119  cout << "HCalInner - construct inner HCal absorber with G4_Al" << endl;
120  }
121  hcal->set_string_param("material", "G4_Al");
122  }
123  else
124  {
125  if (verbosity > 0)
126  {
127  cout << "HCalInner - construct inner HCal absorber with SS310" << endl;
128  }
129  hcal->set_string_param("material", "SS310");
130  }
131 
132  // ECCE Inner HCAL paremeters
133  // First pass - JGL - 06/14/2021
134  // adjust inner radius to make the inner HCAL less deep,
135  // but keep the tilt angle and tiles the same shape.
136  // NOTES:
137  // (1) Inner and Outer radii from Sketchup, but very likely too
138  // close to cryostat.
139 
141  cout << "Setting up with inner HCAL for BECAL setup" << endl;
142  double z_end = G4HCALIN::support_ring_z_ring2 - 12.5 + (G4HCALIN::dz/2.0);
143  double z_start = -287; // DIRC prizm beginning
144  double length = z_end - z_start;
145  double z_shift = 0.5 * (z_end + z_start);
146 
147  hcal->set_double_param("outer_radius", 138.5);
148  hcal->set_double_param("scinti_outer_radius", 138.0);
149  hcal->set_double_param("inner_radius", 134.0);
150  hcal->set_double_param("tilt_angle", 36.15);
151  hcal->set_int_param("n_scinti_tiles", 0);
152  hcal->set_int_param("n_scinti_tiles_pos", 12);
153  hcal->set_int_param("n_scinti_tiles_neg", 15);
154  hcal->set_double_param("size_z", length);
155  hcal->set_double_param("place_z", z_shift);
156  hcal->set_double_param("scinti_eta_coverage", 0.0);
157  hcal->set_double_param("scinti_eta_coverage_pos", 1.15);
158  hcal->set_double_param("scinti_eta_coverage_neg", 1.45);
159  }
160  hcal->SetActive();
161  hcal->SuperDetector("HCALIN");
162  if (AbsorberActive)
163  {
164  hcal->SetAbsorberActive();
165  }
166  hcal->OverlapCheck(OverlapCheck);
167 
168  g4Reco->registerSubsystem(hcal);
169 
170  radius = hcal->get_double_param("outer_radius");
171 
172  HCalInner_SupportRing(g4Reco);
173 
174  radius += no_overlapp;
175  return radius;
176 }
177 
180 {
181  bool AbsorberActive = Enable::SUPPORT || Enable::HCALIN_SUPPORT;
182 
183  const double z_ring1 = (2025 + 2050) / 2. / 10.;
184  double innerradius_sphenix = 116.;
185  double innerradius_ephenix_hadronside = 138.;
187  innerradius_sphenix = 138.6;
188  innerradius_ephenix_hadronside = 138.6;
189  }
190  double z_rings[] =
193  z_rings[2] = z_ring1 - 12.5;
194  z_rings[3] = G4HCALIN::support_ring_z_ring2 - 12.5;
195  }
196 
197 
199 
200  for (int i = 0; i < 4; i++)
201  {
202  double innerradius = innerradius_sphenix;
203  if (z_rings[i] > 0 && G4HCALIN::inner_hcal_eic == 1)
204  {
205  innerradius = innerradius_ephenix_hadronside;
206  }
207  cyl = new PHG4CylinderSubsystem("HCALIN_SPT_N1", i);
208  cyl->set_double_param("place_z", z_rings[i]);
209  cyl->SuperDetector("HCALIN_SPT");
210  cyl->set_double_param("radius", innerradius);
211  cyl->set_int_param("lengthviarapidity", 0);
212  cyl->set_double_param("length", G4HCALIN::dz);
213  cyl->set_string_param("material", "SS310");
214  cyl->set_double_param("thickness", G4HCALIN::support_ring_outer_radius - innerradius);
215  if (AbsorberActive)
216  {
217  cyl->SetActive();
218  }
219  g4Reco->registerSubsystem(cyl);
220  }
221 
222  return;
223 }
224 
226 {
228 
230 
231  PHG4HcalCellReco *hc = new PHG4HcalCellReco("HCALIN_CELLRECO");
232  hc->Detector("HCALIN");
233  // hc->Verbosity(2);
234  // check for energy conservation - needs modified "infinite" timing cuts
235  // 0-999999999
236  // hc->checkenergy();
237  // timing cuts with their default settings
238  // hc->set_double_param("tmin",0.);
239  // hc->set_double_param("tmax",60.0);
240  // or all at once:
241  // hc->set_timing_window(0.0,60.0);
242  se->registerSubsystem(hc);
243 
244  return;
245 }
246 
248 {
251 
252  HcalRawTowerBuilder *TowerBuilder = new HcalRawTowerBuilder("HcalInRawTowerBuilder");
253  TowerBuilder->Detector("HCALIN");
254  TowerBuilder->set_sim_tower_node_prefix("SIM");
255  TowerBuilder->Verbosity(verbosity);
256  se->registerSubsystem(TowerBuilder);
257 
258  // From 2016 Test beam sim
259  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("HcalInRawTowerDigitizer");
260  TowerDigitizer->Detector("HCALIN");
261  // TowerDigitizer->set_raw_tower_node_prefix("RAW_LG");
262  TowerDigitizer->set_digi_algorithm(G4HCALIN::TowerDigi);
263  TowerDigitizer->set_pedstal_central_ADC(0);
264  TowerDigitizer->set_pedstal_width_ADC(1); // From Jin's guess. No EMCal High Gain data yet! TODO: update
265  TowerDigitizer->set_photonelec_ADC(32. / 5.);
266  TowerDigitizer->set_photonelec_yield_visible_GeV(32. / 5 / (0.4e-3));
267  TowerDigitizer->set_zero_suppression_ADC(-0); // no-zero suppression
268  se->registerSubsystem(TowerDigitizer);
269 
270  //Default sampling fraction for SS310
271  double visible_sample_fraction_HCALIN = 0.0631283; //, /gpfs/mnt/gpfs04/sphenix/user/jinhuang/prod_analysis/hadron_shower_res_nightly/./G4Hits_sPHENIX_pi-_eta0_16GeV-0000.root_qa.rootQA_Draw_HCALIN_G4Hit.pdf
272 
273  if (G4HCALIN::inner_hcal_material_Al) visible_sample_fraction_HCALIN = 0.162166; //for "G4_Al", Abhisek Sen <sen.abhisek@gmail.com>
274 
275  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("HcalInRawTowerCalibration");
276  TowerCalibration->Detector("HCALIN");
277  // TowerCalibration->set_raw_tower_node_prefix("RAW_LG");
278  // TowerCalibration->set_calib_tower_node_prefix("CALIB_LG");
281  {
282  // 0.176 extracted from electron sims (edep(scintillator)/edep(total))
283  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.176);
284  }
285  else
286  {
287  TowerCalibration->set_calib_const_GeV_ADC(0.4e-3 / visible_sample_fraction_HCALIN);
288  }
289  TowerCalibration->set_pedstal_ADC(0);
290  se->registerSubsystem(TowerCalibration);
291 
292  return;
293 }
294 
296 {
298 
300 
302  {
303  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("HcalInRawClusterBuilderTemplate");
304  ClusterBuilder->Detector("HCALIN");
305  ClusterBuilder->SetCylindricalGeometry(); // has to be called after Detector()
306  ClusterBuilder->Verbosity(verbosity);
307  se->registerSubsystem(ClusterBuilder);
308  }
310  {
311  RawClusterBuilderGraph *ClusterBuilder = new RawClusterBuilderGraph("HcalInRawClusterBuilderGraph");
312  ClusterBuilder->Detector("HCALIN");
313  ClusterBuilder->Verbosity(verbosity);
314  se->registerSubsystem(ClusterBuilder);
315  }
316  else
317  {
318  cout << "HCalIn_Clusters - unknown clusterizer setting!" << endl;
319  exit(1);
320  }
321  return;
322 }
323 
324 void HCALInner_Eval(const std::string &outputfile)
325 {
328 
329  CaloEvaluator *eval = new CaloEvaluator("HCALINEVALUATOR", "HCALIN", outputfile);
330  eval->Verbosity(verbosity);
331  se->registerSubsystem(eval);
332 
333  return;
334 }
335 
337 {
339 
342  qa->Verbosity(verbosity);
343  se->registerSubsystem(qa);
344 
345  return;
346 }
347 
348 #endif