ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_HcalIn_ref.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_HcalIn_ref.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 
21 
22 #include <caloreco/RawClusterBuilderGraph.h>
23 #include <caloreco/RawClusterBuilderTemplate.h>
24 #include <caloreco/RawTowerCalibration.h>
25 #include <qa_modules/QAG4SimulationCalorimeter.h>
26 
27 #include <fun4all/Fun4AllServer.h>
28 
29 R__LOAD_LIBRARY(libcalo_reco.so)
30 R__LOAD_LIBRARY(libg4calo.so)
31 R__LOAD_LIBRARY(libg4detectors.so)
32 R__LOAD_LIBRARY(libg4eval.so)
33 R__LOAD_LIBRARY(libqa_modules.so)
34 
35 void HCalInner_SupportRing(PHG4Reco *g4Reco);
36 
37 namespace Enable
38 {
39  bool HCALIN = false;
40  bool HCALIN_ABSORBER = false;
41  bool HCALIN_OVERLAPCHECK = false;
42  bool HCALIN_CELL = false;
43  bool HCALIN_TOWER = false;
44  bool HCALIN_CLUSTER = false;
45  bool HCALIN_EVAL = false;
46  bool HCALIN_QA = false;
48 } // namespace Enable
49 
50 namespace G4HCALIN
51 {
52  double support_ring_outer_radius = 178.0 - 0.001;
53  double support_ring_z_ring2 = (2150 + 2175) / 2. / 10.;
54  double dz = 25. / 10.;
55 
56  //Inner HCal absorber material selector:
57  //false - old version, absorber material is SS310
58  //true - default Choose if you want Aluminum
60 
61  int inner_hcal_eic = 1;
62 
63  // Digitization (default photon digi):
65  // directly pass the energy of sim tower to digitized tower
66  // kNo_digitization
67  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
68  // kSimple_photon_digitization
69  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
70  // kSiPM_photon_digitization
71 
73  {
75 
77  };
78 
82  //enu_HCalIn_clusterizer HCalIn_clusterizer = kHCalInGraphClusterizer;
83 } // namespace G4HCALIN
84 
85 // Init is called by G4Setup.C
86 void HCalInnerInit(const int iflag = 0)
87 {
91  if (iflag == 1)
92  {
94  // ECCE version is stainless steel
96  }
97 }
98 
99 double HCalInner(PHG4Reco *g4Reco,
100  double radius,
101  const int crossings)
102 {
103  bool AbsorberActive = Enable::ABSORBER || Enable::HCALIN_ABSORBER;
104  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::HCALIN_OVERLAPCHECK;
106 
107  // all sizes are in cm!
108  PHG4InnerHcalSubsystem *hcal = new PHG4InnerHcalSubsystem("HCALIN");
109  // these are the parameters you can change with their default settings
110  // hcal->set_string_param("material","SS310");
112  {
113  if (verbosity > 0)
114  {
115  cout << "HCalInner - construct inner HCal absorber with G4_Al" << endl;
116  }
117  hcal->set_string_param("material", "G4_Al");
118  }
119  else
120  {
121  if (verbosity > 0)
122  {
123  cout << "HCalInner - construct inner HCal absorber with SS310" << endl;
124  }
125  hcal->set_string_param("material", "SS310");
126  }
127 
128  // ECCE Inner HCAL paremeters
129 
130  double z_end = G4HCALIN::support_ring_z_ring2 - 12.5 + (G4HCALIN::dz/2.0);
131  double z_start = -287; // DIRC prizm end
132  double length = z_end - z_start;
133  double z_shift = 0.5 * (z_end + z_start);
134 
135  hcal->set_double_param("outer_radius", 138.5);
136  hcal->set_double_param("scinti_outer_radius", 138.0);
137  hcal->set_double_param("inner_radius", 134.0);
138  hcal->set_double_param("tilt_angle", 36.15);
139  hcal->set_double_param("size_z", length);
140  hcal->set_int_param("n_scinti_tiles", 0);
141  hcal->set_int_param("n_scinti_tiles_pos", 12);
142  hcal->set_int_param("n_scinti_tiles_neg", 15);
143  hcal->set_double_param("place_z", z_shift);
144  hcal->set_double_param("scinti_eta_coverage", 0.0);
145  hcal->set_double_param("scinti_eta_coverage_pos", 1.15);
146  hcal->set_double_param("scinti_eta_coverage_neg", 1.45);
147 
148  // hcal->set_double_param("inner_radius", 117.27);
149  //-----------------------------------------
150  // the light correction can be set in a single call
151  // hcal->set_double_param("light_balance_inner_corr", NAN);
152  // hcal->set_double_param("light_balance_inner_radius", NAN);
153  // hcal->set_double_param("light_balance_outer_corr", NAN);
154  // hcal->set_double_param("light_balance_outer_radius", NAN);
155  // hcal->SetLightCorrection(NAN,NAN,NAN,NAN);
156  //-----------------------------------------
157  // hcal->set_double_param("outer_radius", 134.42);
158  // hcal->set_double_param("place_x", 0.);
159  // hcal->set_double_param("place_y", 0.);
160  // hcal->set_double_param("place_z", 0.);
161  // hcal->set_double_param("rot_x", 0.);
162  // hcal->set_double_param("rot_y", 0.);
163  // hcal->set_double_param("rot_z", 0.);
164 
165  // If scinti_eta_coverage>0 it will take precdence.
166  // Set to 0 (or <0) to use pos/neg values
167  // hcal->set_double_param("scinti_eta_coverage", 1.1);
168  // hcal->set_double_param("scinti_eta_coverage_pos", 1.1);
169  // hcal->set_double_param("scinti_eta_coverage_neg", 1.1);
170 
171  // hcal->set_double_param("scinti_gap_neighbor", 0.1);
172  // hcal->set_double_param("scinti_inner_gap", 0.85);
173  // hcal->set_double_param("scinti_outer_gap", 1.22 * (5.0 / 4.0));
174  // hcal->set_double_param("scinti_outer_radius", 133.3);
175  // hcal->set_double_param("scinti_tile_thickness", 0.7);
176  // hcal->set_double_param("size_z", 175.94 * 2);
177  // hcal->set_double_param("steplimits", NAN);
178  // hcal->set_double_param("tilt_angle", 36.15);
179  // hcal->set_int_param("light_scint_model", 1);
180  // hcal->set_int_param("ncross", 0);
181  // hcal->set_int_param("n_towers", 64);
182  // hcal->set_int_param("n_scinti_plates_per_tower", 4);
183  //
184  // If n_scinti_tiles>0 it will take precdence.
185  // Set to 0 (or <0) to use pos/neg values
186  // hcal->set_int_param("n_scinti_tiles", 12);
187  // hcal->set_int_param("n_scinti_tiles_pos", 12);
188  // hcal->set_int_param("n_scinti_tiles_neg", 12);
189 
190  // hcal->set_string_param("material", "SS310");
191 
192  hcal->SetActive();
193  hcal->SuperDetector("HCALIN");
194  if (AbsorberActive)
195  {
196  hcal->SetAbsorberActive();
197  }
198  hcal->OverlapCheck(OverlapCheck);
199 
200  g4Reco->registerSubsystem(hcal);
201 
202  radius = hcal->get_double_param("outer_radius");
203 
204  HCalInner_SupportRing(g4Reco);
205 
206  radius += no_overlapp;
207  return radius;
208 }
209 
212 {
213  bool AbsorberActive = Enable::ABSORBER || Enable::HCALIN_ABSORBER;
214 
215  const double z_ring1 = (2025 + 2050) / 2. / 10.;
216  const double innerradius_sphenix = 138.6;
217  const double innerradius_ephenix_hadronside = 138.6;
218  const double z_rings[] =
219  {-G4HCALIN::support_ring_z_ring2, -z_ring1, z_ring1 - 12.5, G4HCALIN::support_ring_z_ring2 - 12.5};
220 
222 
223  for (int i = 0; i < 4; i++)
224  {
225  double innerradius = innerradius_sphenix;
226  if (z_rings[i] > 0 && G4HCALIN::inner_hcal_eic == 1)
227  {
228  //continue; // skip positive support rings for now
229  innerradius = innerradius_ephenix_hadronside;
230  }
231  cyl = new PHG4CylinderSubsystem("HCALIN_SPT_N1", i);
232  cyl->set_double_param("place_z", z_rings[i]);
233  cyl->SuperDetector("HCALIN_SPT");
234  cyl->set_double_param("radius", innerradius);
235  cyl->set_int_param("lengthviarapidity", 0);
236  cyl->set_double_param("length", G4HCALIN::dz);
237  cyl->set_string_param("material", "SS310");
238  cyl->set_double_param("thickness", G4HCALIN::support_ring_outer_radius - innerradius);
239  if (AbsorberActive)
240  {
241  cyl->SetActive();
242  }
243  g4Reco->registerSubsystem(cyl);
244  }
245 
246  return;
247 }
248 
250 {
252 
254 
255  PHG4HcalCellReco *hc = new PHG4HcalCellReco("HCALIN_CELLRECO");
256  hc->Detector("HCALIN");
257  // hc->Verbosity(2);
258  // check for energy conservation - needs modified "infinite" timing cuts
259  // 0-999999999
260  // hc->checkenergy();
261  // timing cuts with their default settings
262  // hc->set_double_param("tmin",0.);
263  // hc->set_double_param("tmax",60.0);
264  // or all at once:
265  // hc->set_timing_window(0.0,60.0);
266  se->registerSubsystem(hc);
267 
268  return;
269 }
270 
272 {
275 
276  HcalRawTowerBuilder *TowerBuilder = new HcalRawTowerBuilder("HcalInRawTowerBuilder");
277  TowerBuilder->Detector("HCALIN");
278  TowerBuilder->set_sim_tower_node_prefix("SIM");
279  TowerBuilder->Verbosity(verbosity);
280  se->registerSubsystem(TowerBuilder);
281 
282  // From 2016 Test beam sim
283  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("HcalInRawTowerDigitizer");
284  TowerDigitizer->Detector("HCALIN");
285  // TowerDigitizer->set_raw_tower_node_prefix("RAW_LG");
286  TowerDigitizer->set_digi_algorithm(G4HCALIN::TowerDigi);
287  TowerDigitizer->set_pedstal_central_ADC(0);
288  TowerDigitizer->set_pedstal_width_ADC(1); // From Jin's guess. No EMCal High Gain data yet! TODO: update
289  TowerDigitizer->set_photonelec_ADC(32. / 5.);
290  TowerDigitizer->set_photonelec_yield_visible_GeV(32. / 5 / (0.4e-3));
291  TowerDigitizer->set_zero_suppression_ADC(-0); // no-zero suppression
292  se->registerSubsystem(TowerDigitizer);
293 
294  //Default sampling fraction for SS310
295  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
296 
297  if (G4HCALIN::inner_hcal_material_Al) visible_sample_fraction_HCALIN = 0.162166; //for "G4_Al", Abhisek Sen <sen.abhisek@gmail.com>
298 
299  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("HcalInRawTowerCalibration");
300  TowerCalibration->Detector("HCALIN");
301  // TowerCalibration->set_raw_tower_node_prefix("RAW_LG");
302  // TowerCalibration->set_calib_tower_node_prefix("CALIB_LG");
305  {
306  TowerCalibration->set_calib_const_GeV_ADC(1. / visible_sample_fraction_HCALIN);
307  }
308  else
309  {
310  TowerCalibration->set_calib_const_GeV_ADC(0.4e-3 / visible_sample_fraction_HCALIN);
311  }
312  TowerCalibration->set_pedstal_ADC(0);
313  se->registerSubsystem(TowerCalibration);
314 
315  return;
316 }
317 
319 {
321 
323 
325  {
326  RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkV3("HcalInRawClusterBuilderkV3");
327  ClusterBuilder->Detector("HCALIN");
328  ClusterBuilder->set_seed_e(0.5);
329  ClusterBuilder->set_agg_e(0.1);
330  se->registerSubsystem(ClusterBuilder);
331  /*
332  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("HcalInRawClusterBuilderTemplate");
333  ClusterBuilder->Detector("HCALIN");
334  ClusterBuilder->SetCylindricalGeometry(); // has to be called after Detector()
335  ClusterBuilder->Verbosity(verbosity);
336  se->registerSubsystem(ClusterBuilder);
337  */
338  }
340  {
341  RawClusterBuilderGraph *ClusterBuilder = new RawClusterBuilderGraph("HcalInRawClusterBuilderGraph");
342  ClusterBuilder->Detector("HCALIN");
343  ClusterBuilder->Verbosity(verbosity);
344  se->registerSubsystem(ClusterBuilder);
345  }
346  else
347  {
348  cout << "HCalIn_Clusters - unknown clusterizer setting!" << endl;
349  exit(1);
350  }
351  return;
352 }
353 
354 void HCALInner_Eval(const std::string &outputfile)
355 {
358 
359  CaloEvaluator *eval = new CaloEvaluator("HCALINEVALUATOR", "HCALIN", outputfile);
360  eval->Verbosity(verbosity);
361  se->registerSubsystem(eval);
362 
363  return;
364 }
365 
367 {
369 
372  qa->Verbosity(verbosity);
373  se->registerSubsystem(qa);
374 
375  return;
376 }
377 
378 #endif