EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_HcalOut_ref.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_HcalOut_ref.C
1 #ifndef MACRO_G4HCALOUTREF_C
2 #define MACRO_G4HCALOUTREF_C
3 
4 #include <GlobalVariables.C>
5 #include <QA.C>
6 
9 
12 
13 #include <g4eval/CaloEvaluator.h>
14 
15 #include <g4main/PHG4Reco.h>
16 
17 #include <caloreco/RawClusterBuilderGraph.h>
18 #include <caloreco/RawClusterBuilderTemplate.h>
19 #include <caloreco/RawTowerCalibration.h>
20 #include <qa_modules/QAG4SimulationCalorimeter.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(libg4detectors.so)
27 R__LOAD_LIBRARY(libg4eval.so)
28 R__LOAD_LIBRARY(libqa_modules.so)
29 
30 namespace Enable
31 {
32  bool HCALOUT = false;
33  bool HCALOUT_ABSORBER = false;
34  bool HCALOUT_OVERLAPCHECK = false;
35  bool HCALOUT_CELL = false;
36  bool HCALOUT_TOWER = false;
37  bool HCALOUT_CLUSTER = false;
38  bool HCALOUT_EVAL = false;
39  bool HCALOUT_QA = false;
41 } // namespace Enable
42 
43 namespace G4HCALOUT
44 {
45  double outer_radius = 264.71;
46  double size_z = 304.91 * 2;
47 
48  // Digitization (default photon digi):
50  // directly pass the energy of sim tower to digitized tower
51  // kNo_digitization
52  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
53  // kSimple_photon_digitization
54  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
55  // kSiPM_photon_digitization
56 
58  {
61  };
62 
66  //enu_HCalOut_clusterizer HCalOut_clusterizer = kHCalOutGraphClusterizer;
67 } // namespace G4HCALOUT
68 
69 // Init is called by G4Setup.C
71 {
75 }
76 
77 double HCalOuter(PHG4Reco *g4Reco,
78  double radius,
79  const int crossings)
80 {
81  bool AbsorberActive = Enable::ABSORBER || Enable::HCALOUT_ABSORBER;
84 
86  // hcal->set_double_param("inner_radius", 183.3);
87  //-----------------------------------------
88  // the light correction can be set in a single call
89  // hcal->set_double_param("light_balance_inner_corr", NAN);
90  // hcal->set_double_param("light_balance_inner_radius", NAN);
91  // hcal->set_double_param("light_balance_outer_corr", NAN);
92  // hcal->set_double_param("light_balance_outer_radius", NAN);
93  // hcal->set_double_param("magnet_cutout_radius", 195.31);
94  // hcal->set_double_param("magnet_cutout_scinti_radius", 195.96);
95  // hcal->SetLightCorrection(NAN,NAN,NAN,NAN);
96  //-----------------------------------------
97  // hcal->set_double_param("outer_radius", G4HCALOUT::outer_radius);
98  // hcal->set_double_param("place_x", 0.);
99  // hcal->set_double_param("place_y", 0.);
100  // hcal->set_double_param("place_z", 0.);
101  // hcal->set_double_param("rot_x", 0.);
102  // hcal->set_double_param("rot_y", 0.);
103  // hcal->set_double_param("rot_z", 0.);
104  // hcal->set_double_param("scinti_eta_coverage", 1.1);
105  // hcal->set_double_param("scinti_gap", 0.85);
106  // hcal->set_double_param("scinti_gap_neighbor", 0.1);
107  // hcal->set_double_param("scinti_inner_radius",183.89);
108  // hcal->set_double_param("scinti_outer_radius",263.27);
109  // hcal->set_double_param("scinti_tile_thickness", 0.7);
110  // hcal->set_double_param("size_z", G4HCALOUT::size_z);
111  // hcal->set_double_param("steplimits", NAN);
112  // hcal->set_double_param("tilt_angle", -11.23);
113 
114  // hcal->set_int_param("light_scint_model", 1);
115  // hcal->set_int_param("magnet_cutout_first_scinti", 8);
116  // hcal->set_int_param("ncross", 0);
117  // hcal->set_int_param("n_towers", 64);
118  // hcal->set_int_param("n_scinti_plates_per_tower", 5);
119  // hcal->set_int_param("n_scinti_tiles", 12);
120 
121  // hcal->set_string_param("material", "Steel_1006");
122 
123  hcal->SetActive();
124  hcal->SuperDetector("HCALOUT");
125  if (AbsorberActive)
126  {
127  hcal->SetAbsorberActive();
128  }
129  hcal->OverlapCheck(OverlapCheck);
130  g4Reco->registerSubsystem(hcal);
131 
132  radius = hcal->get_double_param("outer_radius");
133 
134  radius += no_overlapp;
135 
136  return radius;
137 }
138 
140 {
142 
144 
145  PHG4HcalCellReco *hc = new PHG4HcalCellReco("HCALOUT_CELLRECO");
146  hc->Detector("HCALOUT");
147  // hc->Verbosity(2);
148  // check for energy conservation - needs modified "infinite" timing cuts
149  // 0-999999999
150  // hc->checkenergy();
151  // timing cuts with their default settings
152  // hc->set_double_param("tmin",0.);
153  // hc->set_double_param("tmax",60.0);
154  // or all at once:
155  // hc->set_timing_window(0.0,60.0);
156  // this sets all cells to a fixed energy for debugging
157  // hc->set_fixed_energy(1.);
158  se->registerSubsystem(hc);
159 
160  return;
161 }
162 
164 {
166 
168 
169  HcalRawTowerBuilder *TowerBuilder = new HcalRawTowerBuilder("HcalOutRawTowerBuilder");
170  TowerBuilder->Detector("HCALOUT");
171  TowerBuilder->set_sim_tower_node_prefix("SIM");
172  // this sets specific decalibration factors
173  // for a given cell
174  // TowerBuilder->set_cell_decal_factor(1,10,0.1);
175  // for a whole tower
176  // TowerBuilder->set_tower_decal_factor(0,10,0.2);
177  // TowerBuilder->set_cell_decal_factor(1,10,0.1);
178  // TowerBuilder->set_tower_decal_factor(0,10,0.2);
179  TowerBuilder->Verbosity(verbosity);
180  se->registerSubsystem(TowerBuilder);
181 
182  // From 2016 Test beam sim
183  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("HcalOutRawTowerDigitizer");
184  TowerDigitizer->Detector("HCALOUT");
185  // TowerDigitizer->set_raw_tower_node_prefix("RAW_LG");
186  TowerDigitizer->set_digi_algorithm(G4HCALOUT::TowerDigi);
187  TowerDigitizer->set_pedstal_central_ADC(0);
188  TowerDigitizer->set_pedstal_width_ADC(1); // From Jin's guess. No EMCal High Gain data yet! TODO: update
189  TowerDigitizer->set_photonelec_ADC(16. / 5.);
190  TowerDigitizer->set_photonelec_yield_visible_GeV(16. / 5 / (0.2e-3));
191  TowerDigitizer->set_zero_suppression_ADC(-0); // no-zero suppression
192  se->registerSubsystem(TowerDigitizer);
193 
194  const double visible_sample_fraction_HCALOUT = 3.38021e-02; // /gpfs/mnt/gpfs04/sphenix/user/jinhuang/prod_analysis/hadron_shower_res_nightly/./G4Hits_sPHENIX_pi-_eta0_16GeV.root_qa.rootQA_Draw_HCALOUT_G4Hit.pdf
195 
196  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("HcalOutRawTowerCalibration");
197  TowerCalibration->Detector("HCALOUT");
198  // TowerCalibration->set_raw_tower_node_prefix("RAW_LG");
199  // TowerCalibration->set_calib_tower_node_prefix("CALIB_LG");
202  {
203  // 0.033 extracted from electron sims (edep(scintillator)/edep(total))
204  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.033);
205  }
206  else
207  {
208  TowerCalibration->set_calib_const_GeV_ADC(0.2e-3 / visible_sample_fraction_HCALOUT);
209  }
210  TowerCalibration->set_pedstal_ADC(0);
211  se->registerSubsystem(TowerCalibration);
212 
213  return;
214 }
215 
217 {
219 
221 
223  {
224  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("HcalOutRawClusterBuilderTemplate");
225  ClusterBuilder->Detector("HCALOUT");
226  ClusterBuilder->SetCylindricalGeometry(); // has to be called after Detector()
227  ClusterBuilder->Verbosity(verbosity);
228  se->registerSubsystem(ClusterBuilder);
229  }
231  {
232  RawClusterBuilderGraph *ClusterBuilder = new RawClusterBuilderGraph("HcalOutRawClusterBuilderGraph");
233  ClusterBuilder->Detector("HCALOUT");
234  ClusterBuilder->Verbosity(verbosity);
235  se->registerSubsystem(ClusterBuilder);
236  }
237  else
238  {
239  cout << "HCALOuter_Clusters - unknown clusterizer setting!" << endl;
240  exit(1);
241  }
242 
243  return;
244 }
245 
246 void HCALOuter_Eval(const std::string &outputfile)
247 {
249 
251 
252  CaloEvaluator *eval = new CaloEvaluator("HCALOUTEVALUATOR", "HCALOUT", outputfile);
253  eval->Verbosity(verbosity);
254  se->registerSubsystem(eval);
255 
256  return;
257 }
258 
260 {
262 
265  qa->Verbosity(verbosity);
266  se->registerSubsystem(qa);
267 
268  return;
269 }
270 
271 #endif