EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_FEMC_EIC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_FEMC_EIC.C
1 #ifndef MACRO_G4FEMCEIC_C
2 #define MACRO_G4FEMCEIC_C
3 
4 #include <GlobalVariables.C>
5 
7 
10 
13 
14 #include <g4eval/CaloEvaluator.h>
15 
16 #include <g4main/PHG4Reco.h>
17 
18 #include <caloreco/RawClusterBuilderFwd.h>
19 #include <caloreco/RawClusterBuilderTemplate.h>
20 #include <caloreco/RawTowerCalibration.h>
21 
22 #include <fun4all/Fun4AllServer.h>
23 
24 #include <algorithm>
25 
26 R__LOAD_LIBRARY(libcalo_reco.so)
27 R__LOAD_LIBRARY(libg4calo.so)
28 R__LOAD_LIBRARY(libg4eiccalos.so)
29 R__LOAD_LIBRARY(libg4eval.so)
30 
31 namespace Enable
32 {
33  bool FEMC = false;
34  bool FEMC_ABSORBER = false;
35  bool FEMC_CELL = false;
36  bool FEMC_TOWER = false;
37  bool FEMC_CLUSTER = false;
38  bool FEMC_EVAL = false;
39  bool FEMC_OVERLAPCHECK = false;
40  int FEMC_VERBOSITY = 0;
41 } // namespace Enable
42 
43 namespace G4FEMC
44 {
45  // from ForwardEcal/mapping/towerMap_FEMC_v007.txt
46  const double Gz0 = 310.;
47  const double Gdz = 36.5;
48  const double outer_radius = 182.655;
50  {
53  };
54  //template clusterizer, as developed by Sasha Bazilevsky
56  // graph clusterizer
57  //enu_Femc_clusterizer Femc_clusterizer = kFemcGraphClusterizer;
58  namespace SETTING
59  {
60  bool FullEtaAcc = false;
61  bool fsPHENIX = false;
62  bool EC2x = false;
63  bool readoutsplit = false;
64  bool asymmetric = false;
65  bool wDR = false;
66  bool FwdSquare = false;
67  } // namespace SETTING
68 } // namespace G4FEMC
69 
70 void FEMCInit()
71 {
72  // simple way to check if only 1 of the settings is true
74  {
75  cout << "use only G4FHCAL::SETTING::FullEtaAcc=true or G4FHCAL::SETTING::fsPHENIX=true or G4FHCAL::SETTING::wDR=true or G4FHCAL::SETTING::asymmetric=true" << endl;
76  gSystem->Exit(1);
77  }
78 
82 }
83 
84 void FEMCSetup(PHG4Reco *g4Reco)
85 {
86  bool AbsorberActive = Enable::ABSORBER || Enable::FEMC_ABSORBER;
87  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FEMC_OVERLAPCHECK;
88 
90 
93 
94  ostringstream mapping_femc;
95 
96  // PbScint ECAL with nominal eta coverage
98  {
99  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt";
100  }
101  // doubled granularity ECAL
102  else if (G4FEMC::SETTING::EC2x)
103  {
104  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_2x.txt";
105  }
106  // fsPHENIX ECAL
107  else if (G4FEMC::SETTING::fsPHENIX)
108  {
109  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
110  }
111  // asymmetric ECAL around beampipe
113  {
114  if (Enable::IP6)
115  {
117  {
118  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt";
119  }
120  else
121  {
122  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt";
123  }
124  }
125  else
126  {
128  {
129  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt";
130  }
131  else
132  {
133  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt";
134  }
135  }
136  }
137  // ECAL surrounding dual readout calorimeter
139  {
141  {
142  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt";
143  }
144  else
145  {
146  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
147  }
148  }
149  // ECAL surrounding dual readout calorimeter
150  else if (G4FEMC::SETTING::wDR)
151  {
152  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_wDR.txt";
153  }
154  // PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
155  else
156  {
157  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_v007.txt";
158  }
159  cout << mapping_femc.str() << endl;
160  femc->SetTowerMappingFile(mapping_femc.str());
161  femc->OverlapCheck(OverlapCheck);
162  femc->SetActive();
163  femc->SetDetailed(false);
164  femc->SuperDetector("FEMC");
165  if (AbsorberActive) femc->SetAbsorberActive();
166 
167  g4Reco->registerSubsystem(femc);
168 }
169 
171 {
172  return;
173 }
174 
176 {
178 
180 
181  ostringstream mapping_femc;
182 
183  // // fsPHENIX ECAL
184  // mapping_femc << getenv("CALIBRATIONROOT") <<
185  // "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
186  // PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
187  // PbScint ECAL with nominal eta coverage
189  {
190  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fullEtaCov.txt";
191  }
192  // doubled granularity ECAL
193  else if (G4FEMC::SETTING::EC2x)
194  {
195  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_2x.txt";
196  }
197  // fsPHENIX ECAL
198  else if (G4FEMC::SETTING::fsPHENIX)
199  {
200  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
201  }
202  // ECAL surrounding dual readout calorimeter
204  {
205  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
206  }
207  // ECAL surrounding dual readout calorimeter
208  else if (G4FEMC::SETTING::wDR)
209  {
210  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_wDR.txt";
211  }
212  // asymmetric ECAL around beampipe
214  {
215  if (Enable::IP6)
216  {
218  {
219  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric_ROS.txt";
220  }
221  else
222  {
223  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_IP6-asymmetric.txt";
224  }
225  }
226  else
227  {
229  {
230  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric_ROS.txt";
231  }
232  else
233  {
234  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_asymmetric.txt";
235  }
236  }
237  }
238  // ECAL surrounding dual readout calorimeter
240  {
242  {
243  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare_ROS.txt";
244  }
245  else
246  {
247  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_FwdSquare.txt";
248  }
249  }
250  // PbScint ECAL with enlarged beam pipe opening for Mar 2020 beam pipe
251  else
252  {
253  mapping_femc << getenv("CALIBRATIONROOT") << "/ForwardEcal/mapping/towerMap_FEMC_v007.txt";
254  }
255 
256  RawTowerBuilderByHitIndex *tower_FEMC = new RawTowerBuilderByHitIndex("TowerBuilder_FEMC");
257  tower_FEMC->Detector("FEMC");
258  tower_FEMC->set_sim_tower_node_prefix("SIM");
259  tower_FEMC->GeometryTableFile(mapping_femc.str());
260 
261  se->registerSubsystem(tower_FEMC);
262 
263  // PbW crystals
264  //RawTowerDigitizer *TowerDigitizer1 = new RawTowerDigitizer("FEMCRawTowerDigitizer1");
265  //TowerDigitizer1->Detector("FEMC");
266  //TowerDigitizer1->TowerType(1);
267  //TowerDigitizer1->Verbosity(verbosity);
268  //TowerDigitizer1->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
269  //se->registerSubsystem( TowerDigitizer1 );
270 
271  // PbSc towers
272  RawTowerDigitizer *TowerDigitizer2 = new RawTowerDigitizer("FEMCRawTowerDigitizer2");
273  TowerDigitizer2->Detector("FEMC");
274  TowerDigitizer2->TowerType(2);
275  TowerDigitizer2->Verbosity(verbosity);
277  se->registerSubsystem(TowerDigitizer2);
278 
279  // // E864 towers (three types for three sizes)
280  // RawTowerDigitizer *TowerDigitizer3 = new RawTowerDigitizer("FEMCRawTowerDigitizer3");
281  // TowerDigitizer3->Detector("FEMC");
282  // TowerDigitizer3->TowerType(3);
283  // TowerDigitizer3->Verbosity(verbosity);
284  // TowerDigitizer3->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
285  // se->registerSubsystem( TowerDigitizer3 );
286  //
287  // RawTowerDigitizer *TowerDigitizer4 = new RawTowerDigitizer("FEMCRawTowerDigitizer4");
288  // TowerDigitizer4->Detector("FEMC");
289  // TowerDigitizer4->TowerType(4);
290  // TowerDigitizer4->Verbosity(verbosity);
291  // TowerDigitizer4->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
292  // se->registerSubsystem( TowerDigitizer4 );
293  //
294  // RawTowerDigitizer *TowerDigitizer5 = new RawTowerDigitizer("FEMCRawTowerDigitizer5");
295  // TowerDigitizer5->Detector("FEMC");
296  // TowerDigitizer5->TowerType(5);
297  // TowerDigitizer5->Verbosity(verbosity);
298  // TowerDigitizer5->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
299  // se->registerSubsystem( TowerDigitizer5 );
300  //
301  // RawTowerDigitizer *TowerDigitizer6 = new RawTowerDigitizer("FEMCRawTowerDigitizer6");
302  // TowerDigitizer6->Detector("FEMC");
303  // TowerDigitizer6->TowerType(6);
304  // TowerDigitizer6->Verbosity(verbosity);
305  // TowerDigitizer6->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
306  // se->registerSubsystem( TowerDigitizer6 );
307 
308  // PbW crystals
309  //RawTowerCalibration *TowerCalibration1 = new RawTowerCalibration("FEMCRawTowerCalibration1");
310  //TowerCalibration1->Detector("FEMC");
311  //TowerCalibration1->TowerType(1);
312  //TowerCalibration1->Verbosity(verbosity);
313  //TowerCalibration1->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
314  //TowerCalibration1->set_calib_const_GeV_ADC(1.0); // sampling fraction = 1.0
315  //TowerCalibration1->set_pedstal_ADC(0);
316  //se->registerSubsystem( TowerCalibration1 );
317 
318  // PbSc towers
319  RawTowerCalibration *TowerCalibration2 = new RawTowerCalibration("FEMCRawTowerCalibration2");
320  TowerCalibration2->Detector("FEMC");
321  TowerCalibration2->TowerType(2);
322  TowerCalibration2->Verbosity(verbosity);
325  {
326  TowerCalibration2->set_calib_const_GeV_ADC(1.0 / (0.249 * 0.84)); // sampling fraction = 0.249 for e-
327  }
328  else
329  {
330  TowerCalibration2->set_calib_const_GeV_ADC(1.0 / 0.249); // sampling fraction = 0.249 for e-
331  }
332  TowerCalibration2->set_pedstal_ADC(0);
333  se->registerSubsystem(TowerCalibration2);
334 
335  // // E864 towers (three types for three sizes)
336  // RawTowerCalibration *TowerCalibration3 = new RawTowerCalibration("FEMCRawTowerCalibration3");
337  // TowerCalibration3->Detector("FEMC");
338  // TowerCalibration3->TowerType(3);
339  // TowerCalibration3->Verbosity(verbosity);
340  // TowerCalibration3->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
341  // TowerCalibration3->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
342  // TowerCalibration3->set_pedstal_ADC(0);
343  // se->registerSubsystem( TowerCalibration3 );
344  //
345  // RawTowerCalibration *TowerCalibration4 = new RawTowerCalibration("FEMCRawTowerCalibration4");
346  // TowerCalibration4->Detector("FEMC");
347  // TowerCalibration4->TowerType(4);
348  // TowerCalibration4->Verbosity(verbosity);
349  // TowerCalibration4->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
350  // TowerCalibration4->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
351  // TowerCalibration4->set_pedstal_ADC(0);
352  // se->registerSubsystem( TowerCalibration4 );
353  //
354  // RawTowerCalibration *TowerCalibration5 = new RawTowerCalibration("FEMCRawTowerCalibration5");
355  // TowerCalibration5->Detector("FEMC");
356  // TowerCalibration5->TowerType(5);
357  // TowerCalibration5->Verbosity(verbosity);
358  // TowerCalibration5->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
359  // TowerCalibration5->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
360  // TowerCalibration5->set_pedstal_ADC(0);
361  // se->registerSubsystem( TowerCalibration5 );
362  //
363  // RawTowerCalibration *TowerCalibration6 = new RawTowerCalibration("FEMCRawTowerCalibration6");
364  // TowerCalibration6->Detector("FEMC");
365  // TowerCalibration6->TowerType(6);
366  // TowerCalibration6->Verbosity(verbosity);
367  // TowerCalibration6->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
368  // TowerCalibration6->set_calib_const_GeV_ADC(1.0/0.030); // sampling fraction = 0.030
369  // TowerCalibration6->set_pedstal_ADC(0);
370  // se->registerSubsystem( TowerCalibration6 );
371 }
372 
374 {
376 
378 
380  {
381  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplateFEMC");
382  ClusterBuilder->Detector("FEMC");
383  ClusterBuilder->Verbosity(verbosity);
384  ClusterBuilder->set_threshold_energy(0.020); // This threshold should be the same as in FEMCprof_Thresh**.root file below
385  std::string femc_prof = getenv("CALIBRATIONROOT");
386  femc_prof += "/EmcProfile/FEMCprof_Thresh20MeV.root";
387  ClusterBuilder->LoadProfile(femc_prof.c_str());
388  se->registerSubsystem(ClusterBuilder);
389  }
391  {
392  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FEMCRawClusterBuilderFwd");
393 
394  ClusterBuilder->Detector("FEMC");
395  ClusterBuilder->Verbosity(verbosity);
396  ClusterBuilder->set_threshold_energy(0.010);
397  se->registerSubsystem(ClusterBuilder);
398  }
399  else
400  {
401  cout << "FEMC_Clusters - unknown clusterizer setting!" << endl;
402  exit(1);
403  }
404 
405  return;
406 }
407 
408 void FEMC_Eval(const std::string &outputfile)
409 {
411 
413 
414  CaloEvaluator *eval = new CaloEvaluator("FEMCEVALUATOR", "FEMC", outputfile);
415  eval->Verbosity(verbosity);
416  se->registerSubsystem(eval);
417 
418  return;
419 }
420 #endif