EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_EEMC_hybrid.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_EEMC_hybrid.C
1 #ifndef MACRO_G4EEMCHYBRID_C
2 #define MACRO_G4EEMCHYBRID_C
3 
4 #include <GlobalVariables.C>
5 
10 
11 #include <g4eval/CaloEvaluator.h>
12 
13 #include <g4main/PHG4Reco.h>
14 
15 #include <caloreco/RawClusterBuilderFwd.h>
16 #include <caloreco/RawClusterBuilderTemplate.h>
17 #include <caloreco/RawTowerCalibration.h>
18 
19 #include <fun4all/Fun4AllServer.h>
20 
21 R__LOAD_LIBRARY(libcalo_reco.so)
22 R__LOAD_LIBRARY(libg4eiccalos.so)
23 R__LOAD_LIBRARY(libg4detectors.so)
24 R__LOAD_LIBRARY(libg4eval.so)
25 
26 namespace Enable
27 {
28  bool EEMCH = false;
29  bool EEMCH_ABSORBER = false;
30  bool EEMCH_CELL = false;
31  bool EEMCH_TOWER = false;
32  bool EEMCH_CLUSTER = false;
33  bool EEMCH_EVAL = false;
34  bool EEMCH_OVERLAPCHECK = false;
35  int EEMCH_VERBOSITY = 0;
36 } // namespace Enable
37 
38 
39 namespace G4EEMCH
40 {
42 
43  // double Gdz = 18. + 0.0001; // These 2 paras are only served as the dimension of the black hole
44  // double Gz0 = -170.;
45  double Gdz = 20. + 0.1;
46  double Gz0 = -180.;
47 
48  namespace SETTING
49  {
50  bool USEHYBRID = true;
51  bool USECEMCGeo = false;
52  } // namespace SETTING
53 
54  // Digitization (default photon digi):
56  // directly pass the energy of sim tower to digitized tower
57  // kNo_digitization
58  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
59  // kSimple_photon_digitization
60  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
61  // kSiPM_photon_digitization
62 
64  {
67  };
68  //default template clusterizer, as developed by Sasha Bazilevsky
70  // graph clusterizer
71  //enu_Eemc_clusterizer Eemc_clusterizer = kEemcGraphClusterizer;
72 
73 } // namespace G4EEMC
74 
75 
76 void EEMCHInit()
77 {
79  // from towerMap_EEMC_v006.txt
81 }
82 
83 
84 void EEMCHSetup(PHG4Reco *g4Reco)
85 {
86  bool AbsorberActive = Enable::ABSORBER || Enable::EEMCH_ABSORBER;
87  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::EEMCH_OVERLAPCHECK;
89 
91  ostringstream mapping_eemc_1, mapping_eemc_2;
92 
93  cout << "hybrid: " << G4EEMCH::SETTING::USEHYBRID << "\t CEMC:" << G4EEMCH::SETTING::USECEMCGeo << endl;
94 
96  eemc_crystal->SuperDetector("EEMC");
97  eemc_crystal->SetActive();
98  if (AbsorberActive)
99  eemc_crystal->SetAbsorberActive();
100 
102  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_SciGlassBarrel.txt";
104  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_CEMCBarrel.txt";
106 // mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_200cm_SciGlassBarrel.txt";
107  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm.txt";
109  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_200cm_CEMCBarrel.txt";
110  else {
111  cout << "*******************************************************************************" << endl;
112  cout << "****** ATTENTION no EEMC set as your settings aren't correct ******" << endl;
113  cout << "*******************************************************************************" << endl;
114  return;
115  }
116  cout << "setting EEMC crystal mapping: " << mapping_eemc_1.str() << endl;
117  eemc_crystal->set_string_param("mappingtower", mapping_eemc_1.str());
118  eemc_crystal->OverlapCheck(OverlapCheck);
119 // eemc_crystal->OverlapCheck(true);
120 
121  g4Reco->registerSubsystem(eemc_crystal);
122 
125  mapping_eemc_2 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_glass_200cm_SciGlassBarrel.txt";
127  mapping_eemc_2 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_glass_200cm_CEMCBarrel.txt";
128  else {
129  cout << "*******************************************************************************" << endl;
130  cout << "****** requested hybrid option but no glass mapping set ******" << endl;
131  cout << "*******************************************************************************" << endl;
132  return;
133  }
134 
135  cout << "setting EEMC glass mapping: " << mapping_eemc_2.str() << endl;
137  eemc_glass->SuperDetector("EEMC_glass");
138  eemc_glass->SetActive();
139  if (AbsorberActive)
140  eemc_glass->SetAbsorberActive();
141 
142  eemc_glass->set_string_param("mappingtower", mapping_eemc_2.str());
143 
144  eemc_glass->OverlapCheck(OverlapCheck);
145  g4Reco->registerSubsystem(eemc_glass);
146 
147  }
148 
149 }
150 
152 {}
153 
155 {
157 
159 
160  ostringstream mapping_eemc_1, mapping_eemc_2;
162  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_SciGlassBarrel.txt";
164  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_crystal_200cm_CEMCBarrel.txt";
166 // mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_200cm_SciGlassBarrel.txt";
167  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_185cm.txt";
169  mapping_eemc_1 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_purecrystal_200cm_CEMCBarrel.txt";
170 
171  // CMS lead tungstate barrel ECAL at 18 degree centrigrade: 4.5 photoelectrons per MeV
172  // lead tungsten test in Orsay is 15~20 p.e. per MeV, sci-glass is 5 p.e. per MeV
173  const double EEMC_photoelectron_per_GeV_crystal = 15000;
174  const double EEMC_photoelectron_per_GeV_glass = 5000;
175 
176  //the original values are [8, 16], no noise case[0, 0], really high case[80, 160]
177  const double crystal_pedestal_ADC = 0, crystal_zero_suppression_ADC = 0;
178  const double glass_pedestal_ADC = 0, glass_zero_suppression_ADC = 0;
179 
180  RawTowerBuilderByHitIndex *tower_EEMC_crystal = new RawTowerBuilderByHitIndex("TowerBuilder_EEMC_crystal");
181  tower_EEMC_crystal->Detector("EEMC");
182  tower_EEMC_crystal->set_sim_tower_node_prefix("SIM");
183  tower_EEMC_crystal->GeometryTableFile(mapping_eemc_1.str());
184  se->registerSubsystem(tower_EEMC_crystal);
185 
186  // Calorimeter digitization
187  RawTowerDigitizer *TowerDigitizer_EEMC_crystal = new RawTowerDigitizer("EEMCRawTowerDigitizer_crystal");
188  TowerDigitizer_EEMC_crystal->Detector("EEMC");
189  TowerDigitizer_EEMC_crystal->Verbosity(verbosity);
190  TowerDigitizer_EEMC_crystal->set_raw_tower_node_prefix("RAW");
191  TowerDigitizer_EEMC_crystal->set_digi_algorithm(G4EEMCH::TowerDigi);
192  TowerDigitizer_EEMC_crystal->set_pedstal_central_ADC(0);
193  TowerDigitizer_EEMC_crystal->set_pedstal_width_ADC(crystal_pedestal_ADC); // eRD1 test beam setting
194  TowerDigitizer_EEMC_crystal->set_photonelec_ADC(1); //not simulating ADC discretization error
195  TowerDigitizer_EEMC_crystal->set_photonelec_yield_visible_GeV(EEMC_photoelectron_per_GeV_crystal);
196  TowerDigitizer_EEMC_crystal->set_zero_suppression_ADC(crystal_zero_suppression_ADC); // eRD1 test beam setting
197  se->registerSubsystem(TowerDigitizer_EEMC_crystal);
198 
199  // Calorimeter calibration
200  RawTowerCalibration *TowerCalibration_EEMC_crystal = new RawTowerCalibration("EEMCRawTowerCalibration_crystal");
201  TowerCalibration_EEMC_crystal->Detector("EEMC");
202  TowerCalibration_EEMC_crystal->Verbosity(verbosity);
205  TowerCalibration_EEMC_crystal->set_calib_const_GeV_ADC(1.);
206  else
207  TowerCalibration_EEMC_crystal->set_calib_const_GeV_ADC(1. / EEMC_photoelectron_per_GeV_crystal);
208  TowerCalibration_EEMC_crystal->set_pedstal_ADC(0);
209  se->registerSubsystem(TowerCalibration_EEMC_crystal);
210 
213  mapping_eemc_2 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_glass_200cm_SciGlassBarrel.txt";
215  mapping_eemc_2 << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystal_mapping/tower_map_glass_200cm_CEMCBarrel.txt";
216 
217  RawTowerBuilderByHitIndex *tower_EEMC_glass = new RawTowerBuilderByHitIndex("TowerBuilder_EEMC_glass");
218  tower_EEMC_glass->Detector("EEMC_glass");
219  tower_EEMC_glass->set_sim_tower_node_prefix("SIM");
220  tower_EEMC_glass->GeometryTableFile(mapping_eemc_2.str());
221  se->registerSubsystem(tower_EEMC_glass);
222 
223  RawTowerDigitizer *TowerDigitizer_EEMC_glass = new RawTowerDigitizer("EEMCRawTowerDigitizer_glass");
224  TowerDigitizer_EEMC_glass->Detector("EEMC_glass");
225  TowerDigitizer_EEMC_glass->Verbosity(verbosity);
226  TowerDigitizer_EEMC_glass->set_raw_tower_node_prefix("RAW");
227  TowerDigitizer_EEMC_glass->set_digi_algorithm(G4EEMCH::TowerDigi);
228  TowerDigitizer_EEMC_glass->set_pedstal_central_ADC(0);
229  TowerDigitizer_EEMC_glass->set_pedstal_width_ADC(glass_pedestal_ADC); // eRD1 test beam setting
230  TowerDigitizer_EEMC_glass->set_photonelec_ADC(1); //not simulating ADC discretization error
231  TowerDigitizer_EEMC_glass->set_photonelec_yield_visible_GeV(EEMC_photoelectron_per_GeV_glass);
232  TowerDigitizer_EEMC_glass->set_zero_suppression_ADC(glass_zero_suppression_ADC); // eRD1 test beam setting
233  se->registerSubsystem(TowerDigitizer_EEMC_glass);
234 
235  RawTowerCalibration *TowerCalibration_EEMC_glass = new RawTowerCalibration("EEMCRawTowerCalibration_glass");
236  TowerCalibration_EEMC_glass->Detector("EEMC_glass");
237  TowerCalibration_EEMC_glass->Verbosity(verbosity);
240  TowerCalibration_EEMC_glass->set_calib_const_GeV_ADC(1.);
241  else
242  TowerCalibration_EEMC_glass->set_calib_const_GeV_ADC(1. / EEMC_photoelectron_per_GeV_glass);
243  TowerCalibration_EEMC_glass->set_pedstal_ADC(0);
244  se->registerSubsystem(TowerCalibration_EEMC_glass);
245  }
246 }
247 
248 
250 {
253 
255  {
256 
257  RawClusterBuilderTemplate *ClusterBuilder_crystal = new RawClusterBuilderTemplate("EEMCRawClusterBuilderTemplate_crystal");
258  ClusterBuilder_crystal->Detector("EEMC");
259  ClusterBuilder_crystal->Verbosity(2);
260  se->registerSubsystem(ClusterBuilder_crystal);
261 
263  RawClusterBuilderTemplate *ClusterBuilder_glass = new RawClusterBuilderTemplate("EEMCRawClusterBuilderTemplate_glass");
264  ClusterBuilder_glass->Detector("EEMC_glass");
265  ClusterBuilder_glass->Verbosity(verbosity);
266  se->registerSubsystem(ClusterBuilder_glass);
267  }
268  }
270  {
271 
272  RawClusterBuilderFwd *ClusterBuilder_crystal = new RawClusterBuilderFwd("EEMCRawClusterBuilderFwd_crystal");
273  ClusterBuilder_crystal->Detector("EEMC");
274  ClusterBuilder_crystal->Verbosity(verbosity);
275  ClusterBuilder_crystal->Verbosity(2);
276  se->registerSubsystem(ClusterBuilder_crystal);
277 
279  RawClusterBuilderFwd *ClusterBuilder_glass = new RawClusterBuilderFwd("EEMCRawClusterBuilderFwd_glass");
280  ClusterBuilder_glass->Detector("EEMC_glass");
281  ClusterBuilder_glass->Verbosity(verbosity);
282  se->registerSubsystem(ClusterBuilder_glass);
283  }
284  }
285  else
286  {
287  cout << "EEMC_Clusters - unknown clusterizer setting " << G4EEMCH::Eemc_clusterizer << endl;
288  gSystem->Exit(1);
289  }
290  return;
291 }
292 
293 
294 void EEMCH_Eval(const std::string &outputfile)
295 {
297 
299 
300  string outputroot = outputfile;
301  string remove_this = ".root";
302  size_t pos = outputroot.find(remove_this);
303  if (pos != string::npos){
304  outputroot.erase(pos, remove_this.length());
305  }
306  string outputrootc = outputroot+"_crystal.root";
307  string outputrootg = outputroot+"_glass.root";
308 
309  CaloEvaluator *eval_crystal = new CaloEvaluator("EEMCEVALUATOR", "EEMC", outputrootc.c_str());
310  eval_crystal->Verbosity(verbosity);
311  eval_crystal->set_do_cluster_eval(true);
312  se->registerSubsystem(eval_crystal);
313 
315  CaloEvaluator *eval_glass = new CaloEvaluator("EEMCGLASSEVALUATOR", "EEMC_glass", outputrootg.c_str());
316  eval_glass->Verbosity(verbosity);
317  eval_glass->set_do_cluster_eval(true);
318  se->registerSubsystem(eval_glass);
319  }
320  return;
321 }
322 #endif