EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_FEMC.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_FEMC.C
1 #ifndef MACRO_G4FEMC_C
2 #define MACRO_G4FEMC_C
3 
4 #include <GlobalVariables.C>
5 
8 
11 
12 #include <g4eval/CaloEvaluator.h>
13 
14 #include <g4main/PHG4Reco.h>
15 
16 #include <caloreco/RawClusterBuilderFwd.h>
17 #include <caloreco/RawClusterBuilderTemplate.h>
18 #include <caloreco/RawTowerCalibration.h>
19 
20 #include <fun4all/Fun4AllServer.h>
21 
22 R__LOAD_LIBRARY(libcalo_reco.so)
23 R__LOAD_LIBRARY(libg4calo.so)
24 R__LOAD_LIBRARY(libg4detectors.so)
25 R__LOAD_LIBRARY(libg4eval.so)
26 
27 namespace Enable
28 {
29  bool FEMC = false;
30  bool FEMC_ABSORBER = false;
31  bool FEMC_CELL = false;
32  bool FEMC_TOWER = false;
33  bool FEMC_CLUSTER = false;
34  bool FEMC_EVAL = false;
35  bool FEMC_OVERLAPCHECK = false;
36  int FEMC_VERBOSITY = 0;
37 } // namespace Enable
38 
39 namespace G4FEMC
40 {
41  // from ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt
42  double Gz0 = 305.;
43  double Gdz = 40.;
44  double outer_radius = 180.;
45  string calibfile = "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
47  {
50  };
51 
52  //template clusterizer, as developed by Sasha Bazilevsky
54  // graph clusterizer
55  //enu_Femc_clusterizer Femc_clusterizer = kFemcGraphClusterizer;
56 } // namespace G4FEMC
57 
58 void FEMCInit()
59 {
63 }
64 
65 void FEMCSetup(PHG4Reco *g4Reco, const int absorberactive = 0)
66 {
67  bool AbsorberActive = Enable::ABSORBER || Enable::FEMC_ABSORBER || (absorberactive > 0);
68  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FEMC_OVERLAPCHECK;
69 
71 
74 
75  ostringstream mapping_femc;
76 
77  // fsPHENIX ECAL
78  femc->SetfsPHENIXDetector();
79  mapping_femc << getenv("CALIBRATIONROOT") << G4FEMC::calibfile;
80 
81  // cout << mapping_femc.str() << endl;
82  femc->SetTowerMappingFile(mapping_femc.str());
83  femc->OverlapCheck(OverlapCheck);
84  femc->SetActive();
85  femc->SetDetailed(true);
86  femc->SuperDetector("FEMC");
87  if (AbsorberActive) femc->SetAbsorberActive(AbsorberActive);
88 
89  g4Reco->registerSubsystem(femc);
90 }
91 
92 void FEMC_Cells()
93 {
94  return;
95 }
96 
98 {
101 
102  ostringstream mapping_femc;
103 
104  // fsPHENIX ECAL
105  mapping_femc << getenv("CALIBRATIONROOT") << G4FEMC::calibfile;
106 
107  RawTowerBuilderByHitIndex *tower_FEMC = new RawTowerBuilderByHitIndex("TowerBuilder_FEMC");
108  tower_FEMC->Detector("FEMC");
109  tower_FEMC->set_sim_tower_node_prefix("SIM");
110  tower_FEMC->GeometryTableFile(mapping_femc.str());
111 
112  se->registerSubsystem(tower_FEMC);
113 
114  // PbW crystals
115  //RawTowerDigitizer *TowerDigitizer1 = new RawTowerDigitizer("FEMCRawTowerDigitizer1");
116  //TowerDigitizer1->Detector("FEMC");
117  //TowerDigitizer1->TowerType(1);
118  //TowerDigitizer1->Verbosity(verbosity);
119  //TowerDigitizer1->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
120  //se->registerSubsystem( TowerDigitizer1 );
121 
122  // PbSc towers
123  //RawTowerDigitizer *TowerDigitizer2 = new RawTowerDigitizer("FEMCRawTowerDigitizer2");
124  //TowerDigitizer2->Detector("FEMC");
125  //TowerDigitizer2->TowerType(2);
126  //TowerDigitizer2->Verbosity(verbosity);
127  //TowerDigitizer2->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
128  //se->registerSubsystem( TowerDigitizer2 );
129 
130  // E864 towers (three types for three sizes)
131  RawTowerDigitizer *TowerDigitizer3 = new RawTowerDigitizer("FEMCRawTowerDigitizer3");
132  TowerDigitizer3->Detector("FEMC");
133  TowerDigitizer3->TowerType(3);
134  TowerDigitizer3->Verbosity(verbosity);
136  se->registerSubsystem(TowerDigitizer3);
137 
138  RawTowerDigitizer *TowerDigitizer4 = new RawTowerDigitizer("FEMCRawTowerDigitizer4");
139  TowerDigitizer4->Detector("FEMC");
140  TowerDigitizer4->TowerType(4);
141  TowerDigitizer4->Verbosity(verbosity);
143  se->registerSubsystem(TowerDigitizer4);
144 
145  RawTowerDigitizer *TowerDigitizer5 = new RawTowerDigitizer("FEMCRawTowerDigitizer5");
146  TowerDigitizer5->Detector("FEMC");
147  TowerDigitizer5->TowerType(5);
148  TowerDigitizer5->Verbosity(verbosity);
150  se->registerSubsystem(TowerDigitizer5);
151 
152  RawTowerDigitizer *TowerDigitizer6 = new RawTowerDigitizer("FEMCRawTowerDigitizer6");
153  TowerDigitizer6->Detector("FEMC");
154  TowerDigitizer6->TowerType(6);
155  TowerDigitizer6->Verbosity(verbosity);
157  se->registerSubsystem(TowerDigitizer6);
158 
159  // PbW crystals
160  //RawTowerCalibration *TowerCalibration1 = new RawTowerCalibration("FEMCRawTowerCalibration1");
161  //TowerCalibration1->Detector("FEMC");
162  //TowerCalibration1->TowerType(1);
163  //TowerCalibration1->Verbosity(verbosity);
164  //TowerCalibration1->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
165  //TowerCalibration1->set_calib_const_GeV_ADC(1.0); // sampling fraction = 1.0
166  //TowerCalibration1->set_pedstal_ADC(0);
167  //se->registerSubsystem( TowerCalibration1 );
168 
169  // PbSc towers
170  //RawTowerCalibration *TowerCalibration2 = new RawTowerCalibration("FEMCRawTowerCalibration2");
171  //TowerCalibration2->Detector("FEMC");
172  //TowerCalibration2->TowerType(2);
173  //TowerCalibration2->Verbosity(verbosity);
174  //TowerCalibration2->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
175  //TowerCalibration2->set_calib_const_GeV_ADC(1.0/0.249); // sampling fraction = 0.249 for e-
176  //TowerCalibration2->set_pedstal_ADC(0);
177  //se->registerSubsystem( TowerCalibration2 );
178 
179  // E864 towers (three types for three sizes)
180  RawTowerCalibration *TowerCalibration3 = new RawTowerCalibration("FEMCRawTowerCalibration3");
181  TowerCalibration3->Detector("FEMC");
182  TowerCalibration3->TowerType(3);
183  TowerCalibration3->Verbosity(verbosity);
185  TowerCalibration3->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
186  TowerCalibration3->set_pedstal_ADC(0);
187  se->registerSubsystem(TowerCalibration3);
188 
189  RawTowerCalibration *TowerCalibration4 = new RawTowerCalibration("FEMCRawTowerCalibration4");
190  TowerCalibration4->Detector("FEMC");
191  TowerCalibration4->TowerType(4);
192  TowerCalibration4->Verbosity(verbosity);
194  TowerCalibration4->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
195  TowerCalibration4->set_pedstal_ADC(0);
196  se->registerSubsystem(TowerCalibration4);
197 
198  RawTowerCalibration *TowerCalibration5 = new RawTowerCalibration("FEMCRawTowerCalibration5");
199  TowerCalibration5->Detector("FEMC");
200  TowerCalibration5->TowerType(5);
201  TowerCalibration5->Verbosity(verbosity);
203  TowerCalibration5->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
204  TowerCalibration5->set_pedstal_ADC(0);
205  se->registerSubsystem(TowerCalibration5);
206 
207  RawTowerCalibration *TowerCalibration6 = new RawTowerCalibration("FEMCRawTowerCalibration6");
208  TowerCalibration6->Detector("FEMC");
209  TowerCalibration6->TowerType(6);
210  TowerCalibration6->Verbosity(verbosity);
212  TowerCalibration6->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
213  TowerCalibration6->set_pedstal_ADC(0);
214  se->registerSubsystem(TowerCalibration6);
215 }
216 
218 {
220 
222 
224  {
225  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplateFEMC");
226  ClusterBuilder->Detector("FEMC");
227  ClusterBuilder->Verbosity(verbosity);
228  ClusterBuilder->set_threshold_energy(0.020); // This threshold should be the same as in FEMCprof_Thresh**.root file below
229  std::string femc_prof = getenv("CALIBRATIONROOT");
230  femc_prof += "/EmcProfile/FEMCprof_Thresh20MeV.root";
231  ClusterBuilder->LoadProfile(femc_prof.c_str());
232  se->registerSubsystem(ClusterBuilder);
233  }
235  {
236  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FEMCRawClusterBuilderFwd");
237 
238  ClusterBuilder->Detector("FEMC");
239  ClusterBuilder->Verbosity(verbosity);
240  ClusterBuilder->set_threshold_energy(0.010);
241  se->registerSubsystem(ClusterBuilder);
242  }
243  else
244  {
245  cout << "FEMC_Clusters - unknown clusterizer setting!" << endl;
246  exit(1);
247  }
248 
249  return;
250 }
251 
252 void FEMC_Eval(std::string outputfile)
253 {
256 
257  CaloEvaluator *eval = new CaloEvaluator("FEMCEVALUATOR", "FEMC", outputfile.c_str());
258  eval->Verbosity(verbosity);
259  se->registerSubsystem(eval);
260 
261  return;
262 }
263 #endif