ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_EEMC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_EEMC.C
1 #ifndef MACRO_G4EEMC_C
2 #define MACRO_G4EEMC_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 EEMC = false;
29  bool EEMC_ABSORBER = false;
30  bool EEMC_CELL = false;
31  bool EEMC_TOWER = false;
32  bool EEMC_CLUSTER = false;
33  bool EEMC_EVAL = false;
34  bool EEMC_OVERLAPCHECK = false;
35  int EEMC_VERBOSITY = 0;
36 } // namespace Enable
37 
38 namespace G4EEMC
39 {
41  double Gdz = 18. + 0.0001;
42  double Gz0 = -170.;
43  // Digitization (default photon digi):
45  // directly pass the energy of sim tower to digitized tower
46  // kNo_digitization
47  // simple digitization with photon statistics, single amplitude ADC conversion and pedestal
48  // kSimple_photon_digitization
49  // digitization with photon statistics on SiPM with an effective pixel N, ADC conversion and pedestal
50  // kSiPM_photon_digitization
51 
53  {
56  };
57  //default template clusterizer, as developed by Sasha Bazilevsky
59  // graph clusterizer
60  //enu_Eemc_clusterizer Eemc_clusterizer = kEemcGraphClusterizer;
61 
62 } // namespace G4EEMC
63 
64 void EEMCInit()
65 {
67  {
69  }
70  else
71  {
73  }
74  // from towerMap_EEMC_v006.txt
76 }
77 
78 void EEMCSetup(PHG4Reco *g4Reco)
79 {
80  bool AbsorberActive = Enable::ABSORBER || Enable::EEMC_ABSORBER;
81  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::EEMC_OVERLAPCHECK;
83 
86  eemc->SuperDetector("EEMC");
87  eemc->SetActive();
88  if (AbsorberActive)
89  {
90  eemc->SetAbsorberActive();
91  }
92 
93  /* path to central copy of calibrations repository */
94  ostringstream mapping_eemc;
95 
96  /* Use non-projective geometry */
98  {
99  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/towerMap_EEMC_v008.txt";
100  eemc->set_string_param("mappingtower", mapping_eemc.str());
101  }
102 
103  /* use projective geometry */
104  else
105  {
106  cout << "The projective version has serious problems with overlaps" << endl;
107  cout << "Do Not Use!" << endl;
108  cout << "If you insist, copy G4_EEMC.C locally and comment out this exit" << endl;
109  gSystem->Exit(1);
110  ostringstream mapping_eemc_4x4construct;
111 
112  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystals_v005.txt";
113  mapping_eemc_4x4construct << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/4_by_4_construction_v005.txt";
114  eemc->SetProjectiveGeometry(mapping_eemc.str(), mapping_eemc_4x4construct.str());
115  }
116 
117  eemc->OverlapCheck(OverlapCheck);
118 
119  /* register Ecal module */
120  g4Reco->registerSubsystem(eemc);
121 }
122 
124 {
125 }
126 
128 {
130 
132 
133  ostringstream mapping_eemc;
134  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/towerMap_EEMC_v006.txt";
135 
136  RawTowerBuilderByHitIndex *tower_EEMC = new RawTowerBuilderByHitIndex("TowerBuilder_EEMC");
137  tower_EEMC->Detector("EEMC");
138  tower_EEMC->set_sim_tower_node_prefix("SIM");
139  tower_EEMC->GeometryTableFile(mapping_eemc.str());
140 
141  se->registerSubsystem(tower_EEMC);
142 
143  /* Calorimeter digitization */
144 
145  // CMS lead tungstate barrel ECAL at 18 degree centrigrade: 4.5 photoelectrons per MeV
146  const double EEMC_photoelectron_per_GeV = 4500;
147 
148  RawTowerDigitizer *TowerDigitizer_EEMC = new RawTowerDigitizer("EEMCRawTowerDigitizer");
149  TowerDigitizer_EEMC->Detector("EEMC");
150  TowerDigitizer_EEMC->Verbosity(verbosity);
151  TowerDigitizer_EEMC->set_raw_tower_node_prefix("RAW");
152  TowerDigitizer_EEMC->set_digi_algorithm(G4EEMC::TowerDigi);
153  TowerDigitizer_EEMC->set_pedstal_central_ADC(0);
154  TowerDigitizer_EEMC->set_pedstal_width_ADC(8); // eRD1 test beam setting
155  TowerDigitizer_EEMC->set_photonelec_ADC(1); //not simulating ADC discretization error
156  TowerDigitizer_EEMC->set_photonelec_yield_visible_GeV(EEMC_photoelectron_per_GeV);
157  TowerDigitizer_EEMC->set_zero_suppression_ADC(16); // eRD1 test beam setting
158 
159  se->registerSubsystem(TowerDigitizer_EEMC);
160 
161  /* Calorimeter calibration */
162 
163  RawTowerCalibration *TowerCalibration_EEMC = new RawTowerCalibration("EEMCRawTowerCalibration");
164  TowerCalibration_EEMC->Detector("EEMC");
165  TowerCalibration_EEMC->Verbosity(verbosity);
168  {
169  TowerCalibration_EEMC->set_calib_const_GeV_ADC(1.);
170  }
171  else
172  {
173  TowerCalibration_EEMC->set_calib_const_GeV_ADC(1. / EEMC_photoelectron_per_GeV);
174  }
175  TowerCalibration_EEMC->set_pedstal_ADC(0);
176 
177  se->registerSubsystem(TowerCalibration_EEMC);
178 }
179 
181 {
183 
185 
187  {
188  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EEMCRawClusterBuilderTemplate");
189 
190  ClusterBuilder->Detector("EEMC");
191  ClusterBuilder->Verbosity(verbosity);
192  se->registerSubsystem(ClusterBuilder);
193  }
195  {
196  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("EEMCRawClusterBuilderFwd");
197 
198  ClusterBuilder->Detector("EEMC");
199  ClusterBuilder->Verbosity(verbosity);
200  se->registerSubsystem(ClusterBuilder);
201  }
202  else
203  {
204  cout << "EEMC_Clusters - unknown clusterizer setting " << G4EEMC::Eemc_clusterizer << endl;
205  gSystem->Exit(1);
206  }
207  return;
208 }
209 
210 void EEMC_Eval(const std::string &outputfile)
211 {
213 
215 
216  CaloEvaluator *eval = new CaloEvaluator("EEMCEVALUATOR", "EEMC", outputfile.c_str());
217  eval->Verbosity(verbosity);
218  se->registerSubsystem(eval);
219 
220  return;
221 }
222 #endif