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
77 
78 }
79 
80 void EEMCSetup(PHG4Reco *g4Reco)
81 {
82  bool AbsorberActive = Enable::ABSORBER || Enable::EEMC_ABSORBER;
83  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::EEMC_OVERLAPCHECK;
85 
88  eemc->SuperDetector("EEMC");
89  eemc->SetActive();
90  if (AbsorberActive)
91  {
92  eemc->SetAbsorberActive();
93  }
94 
95  /* path to central copy of calibrations repository */
96  ostringstream mapping_eemc;
97 
98  /* Use non-projective geometry */
100  {
101  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/towerMap_EEMC_v006.txt";
102  eemc->set_string_param("mappingtower", mapping_eemc.str());
103  }
104 
105  /* use projective geometry */
106  else
107  {
108  cout << "The projective version has serious problems with overlaps" << endl;
109  cout << "Do Not Use!" << endl;
110  cout << "If you insist, copy G4_EEMC.C locally and comment out this exit" << endl;
111  gSystem->Exit(1);
112  ostringstream mapping_eemc_4x4construct;
113 
114  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/crystals_v005.txt";
115  mapping_eemc_4x4construct << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/4_by_4_construction_v005.txt";
116  eemc->SetProjectiveGeometry(mapping_eemc.str(), mapping_eemc_4x4construct.str());
117  }
118 
119  eemc->OverlapCheck(OverlapCheck);
120 
121  /* register Ecal module */
122  g4Reco->registerSubsystem(eemc);
123 }
124 
126 {
127 }
128 
130 {
132 
134 
135  ostringstream mapping_eemc;
136  mapping_eemc << getenv("CALIBRATIONROOT") << "/CrystalCalorimeter/mapping/towerMap_EEMC_v006.txt";
137 
138  RawTowerBuilderByHitIndex *tower_EEMC = new RawTowerBuilderByHitIndex("TowerBuilder_EEMC");
139  tower_EEMC->Detector("EEMC");
140  tower_EEMC->set_sim_tower_node_prefix("SIM");
141  tower_EEMC->GeometryTableFile(mapping_eemc.str());
142 
143  se->registerSubsystem(tower_EEMC);
144 
145  /* Calorimeter digitization */
146 
147  // CMS lead tungstate barrel ECAL at 18 degree centrigrade: 4.5 photoelectrons per MeV
148  const double EEMC_photoelectron_per_GeV = 4500;
149 
150  RawTowerDigitizer *TowerDigitizer_EEMC = new RawTowerDigitizer("EEMCRawTowerDigitizer");
151  TowerDigitizer_EEMC->Detector("EEMC");
152  TowerDigitizer_EEMC->Verbosity(verbosity);
153  TowerDigitizer_EEMC->set_raw_tower_node_prefix("RAW");
154  TowerDigitizer_EEMC->set_digi_algorithm(G4EEMC::TowerDigi);
155  TowerDigitizer_EEMC->set_pedstal_central_ADC(0);
156  TowerDigitizer_EEMC->set_pedstal_width_ADC(8); // eRD1 test beam setting
157  TowerDigitizer_EEMC->set_photonelec_ADC(1); //not simulating ADC discretization error
158  TowerDigitizer_EEMC->set_photonelec_yield_visible_GeV(EEMC_photoelectron_per_GeV);
159  TowerDigitizer_EEMC->set_zero_suppression_ADC(16); // eRD1 test beam setting
160 
161  se->registerSubsystem(TowerDigitizer_EEMC);
162 
163  /* Calorimeter calibration */
164 
165  RawTowerCalibration *TowerCalibration_EEMC = new RawTowerCalibration("EEMCRawTowerCalibration");
166  TowerCalibration_EEMC->Detector("EEMC");
167  TowerCalibration_EEMC->Verbosity(verbosity);
170  {
171  TowerCalibration_EEMC->set_calib_const_GeV_ADC(1.);
172  }
173  else
174  {
175  TowerCalibration_EEMC->set_calib_const_GeV_ADC(1. / EEMC_photoelectron_per_GeV);
176  }
177  TowerCalibration_EEMC->set_pedstal_ADC(0);
178 
179  se->registerSubsystem(TowerCalibration_EEMC);
180 }
181 
183 {
185 
187 
189  {
190  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EEMCRawClusterBuilderTemplate");
191 
192  ClusterBuilder->Detector("EEMC");
193  ClusterBuilder->Verbosity(verbosity);
194  se->registerSubsystem(ClusterBuilder);
195  }
197  {
198  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("EEMCRawClusterBuilderFwd");
199 
200  ClusterBuilder->Detector("EEMC");
201  ClusterBuilder->Verbosity(verbosity);
202  se->registerSubsystem(ClusterBuilder);
203  }
204  else
205  {
206  cout << "EEMC_Clusters - unknown clusterizer setting " << G4EEMC::Eemc_clusterizer << endl;
207  gSystem->Exit(1);
208  }
209  return;
210 }
211 
212 void EEMC_Eval(const std::string &outputfile)
213 {
215 
217 
218  CaloEvaluator *eval = new CaloEvaluator("EEMCEVALUATOR", "EEMC", outputfile.c_str());
219  eval->Verbosity(verbosity);
220  se->registerSubsystem(eval);
221 
222  return;
223 }
224 #endif