ECCE @ 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 
9 #include <g4detectors/PHG4ForwardCalCellReco.h>
10 #include <g4detectors/PHG4ForwardEcalSubsystem.h>
11 
12 #include <g4eval/CaloEvaluator.h>
13 
14 #include <g4main/PHG4Reco.h>
15 
18 
19 #include <caloreco/RawClusterBuilderFwd.h>
20 #include <caloreco/RawClusterBuilderTemplate.h>
21 #include <caloreco/RawTowerCalibration.h>
22 
23 #include <fun4all/Fun4AllServer.h>
24 
25 R__LOAD_LIBRARY(libcalo_reco.so)
26 R__LOAD_LIBRARY(libg4calo.so)
27 R__LOAD_LIBRARY(libg4detectors.so)
28 R__LOAD_LIBRARY(libg4eval.so)
29 
30 namespace Enable
31 {
32  bool FEMC = false;
33  bool FEMC_ABSORBER = false;
34  bool FEMC_CELL = false;
35  bool FEMC_TOWER = false;
36  bool FEMC_CLUSTER = false;
37  bool FEMC_EVAL = false;
38  bool FEMC_OVERLAPCHECK = false;
39  int FEMC_VERBOSITY = 0;
40 } // namespace Enable
41 
42 namespace G4FEMC
43 {
44  // from ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt
45  double Gz0 = 305.;
46  double Gdz = 40.;
47  double outer_radius = 180.;
48  string calibfile = "/ForwardEcal/mapping/towerMap_FEMC_fsPHENIX_v004.txt";
50  {
53  };
54 
55  //template clusterizer, as developed by Sasha Bazilevsky
57  // graph clusterizer
58  //enu_Femc_clusterizer Femc_clusterizer = kFemcGraphClusterizer;
59 } // namespace G4FEMC
60 
61 void FEMCInit()
62 {
65 }
66 
67 void FEMCSetup(PHG4Reco *g4Reco, const int absorberactive = 0)
68 {
69  bool AbsorberActive = Enable::ABSORBER || Enable::FEMC_ABSORBER || (absorberactive > 0);
70  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::FEMC_OVERLAPCHECK;
71 
73 
76 
77  ostringstream mapping_femc;
78 
79  // fsPHENIX ECAL
80  femc->SetfsPHENIXDetector();
81  mapping_femc << getenv("CALIBRATIONROOT") << G4FEMC::calibfile;
82 
83  // cout << mapping_femc.str() << endl;
84  femc->SetTowerMappingFile(mapping_femc.str());
85  femc->OverlapCheck(OverlapCheck);
86  femc->SetActive();
87  femc->SuperDetector("FEMC");
88  if (AbsorberActive) femc->SetAbsorberActive(AbsorberActive);
89 
90  g4Reco->registerSubsystem(femc);
91 }
92 
93 void FEMC_Cells()
94 {
95  return;
96 }
97 
99 {
102 
103  ostringstream mapping_femc;
104 
105  // fsPHENIX ECAL
106  mapping_femc << getenv("CALIBRATIONROOT") << G4FEMC::calibfile;
107 
108  RawTowerBuilderByHitIndex *tower_FEMC = new RawTowerBuilderByHitIndex("TowerBuilder_FEMC");
109  tower_FEMC->Detector("FEMC");
110  tower_FEMC->set_sim_tower_node_prefix("SIM");
111  tower_FEMC->GeometryTableFile(mapping_femc.str());
112 
113  se->registerSubsystem(tower_FEMC);
114 
115  // PbW crystals
116  //RawTowerDigitizer *TowerDigitizer1 = new RawTowerDigitizer("FEMCRawTowerDigitizer1");
117  //TowerDigitizer1->Detector("FEMC");
118  //TowerDigitizer1->TowerType(1);
119  //TowerDigitizer1->Verbosity(verbosity);
120  //TowerDigitizer1->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
121  //se->registerSubsystem( TowerDigitizer1 );
122 
123  // PbSc towers
124  //RawTowerDigitizer *TowerDigitizer2 = new RawTowerDigitizer("FEMCRawTowerDigitizer2");
125  //TowerDigitizer2->Detector("FEMC");
126  //TowerDigitizer2->TowerType(2);
127  //TowerDigitizer2->Verbosity(verbosity);
128  //TowerDigitizer2->set_digi_algorithm(RawTowerDigitizer::kNo_digitization);
129  //se->registerSubsystem( TowerDigitizer2 );
130 
131  // E864 towers (three types for three sizes)
132  RawTowerDigitizer *TowerDigitizer3 = new RawTowerDigitizer("FEMCRawTowerDigitizer3");
133  TowerDigitizer3->Detector("FEMC");
134  TowerDigitizer3->TowerType(3);
135  TowerDigitizer3->Verbosity(verbosity);
137  se->registerSubsystem(TowerDigitizer3);
138 
139  RawTowerDigitizer *TowerDigitizer4 = new RawTowerDigitizer("FEMCRawTowerDigitizer4");
140  TowerDigitizer4->Detector("FEMC");
141  TowerDigitizer4->TowerType(4);
142  TowerDigitizer4->Verbosity(verbosity);
144  se->registerSubsystem(TowerDigitizer4);
145 
146  RawTowerDigitizer *TowerDigitizer5 = new RawTowerDigitizer("FEMCRawTowerDigitizer5");
147  TowerDigitizer5->Detector("FEMC");
148  TowerDigitizer5->TowerType(5);
149  TowerDigitizer5->Verbosity(verbosity);
151  se->registerSubsystem(TowerDigitizer5);
152 
153  RawTowerDigitizer *TowerDigitizer6 = new RawTowerDigitizer("FEMCRawTowerDigitizer6");
154  TowerDigitizer6->Detector("FEMC");
155  TowerDigitizer6->TowerType(6);
156  TowerDigitizer6->Verbosity(verbosity);
158  se->registerSubsystem(TowerDigitizer6);
159 
160  // PbW crystals
161  //RawTowerCalibration *TowerCalibration1 = new RawTowerCalibration("FEMCRawTowerCalibration1");
162  //TowerCalibration1->Detector("FEMC");
163  //TowerCalibration1->TowerType(1);
164  //TowerCalibration1->Verbosity(verbosity);
165  //TowerCalibration1->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
166  //TowerCalibration1->set_calib_const_GeV_ADC(1.0); // sampling fraction = 1.0
167  //TowerCalibration1->set_pedstal_ADC(0);
168  //se->registerSubsystem( TowerCalibration1 );
169 
170  // PbSc towers
171  //RawTowerCalibration *TowerCalibration2 = new RawTowerCalibration("FEMCRawTowerCalibration2");
172  //TowerCalibration2->Detector("FEMC");
173  //TowerCalibration2->TowerType(2);
174  //TowerCalibration2->Verbosity(verbosity);
175  //TowerCalibration2->set_calib_algorithm(RawTowerCalibration::kSimple_linear_calibration);
176  //TowerCalibration2->set_calib_const_GeV_ADC(1.0/0.249); // sampling fraction = 0.249 for e-
177  //TowerCalibration2->set_pedstal_ADC(0);
178  //se->registerSubsystem( TowerCalibration2 );
179 
180  // E864 towers (three types for three sizes)
181  RawTowerCalibration *TowerCalibration3 = new RawTowerCalibration("FEMCRawTowerCalibration3");
182  TowerCalibration3->Detector("FEMC");
183  TowerCalibration3->TowerType(3);
184  TowerCalibration3->Verbosity(verbosity);
186  TowerCalibration3->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
187  TowerCalibration3->set_pedstal_ADC(0);
188  se->registerSubsystem(TowerCalibration3);
189 
190  RawTowerCalibration *TowerCalibration4 = new RawTowerCalibration("FEMCRawTowerCalibration4");
191  TowerCalibration4->Detector("FEMC");
192  TowerCalibration4->TowerType(4);
193  TowerCalibration4->Verbosity(verbosity);
195  TowerCalibration4->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
196  TowerCalibration4->set_pedstal_ADC(0);
197  se->registerSubsystem(TowerCalibration4);
198 
199  RawTowerCalibration *TowerCalibration5 = new RawTowerCalibration("FEMCRawTowerCalibration5");
200  TowerCalibration5->Detector("FEMC");
201  TowerCalibration5->TowerType(5);
202  TowerCalibration5->Verbosity(verbosity);
204  TowerCalibration5->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
205  TowerCalibration5->set_pedstal_ADC(0);
206  se->registerSubsystem(TowerCalibration5);
207 
208  RawTowerCalibration *TowerCalibration6 = new RawTowerCalibration("FEMCRawTowerCalibration6");
209  TowerCalibration6->Detector("FEMC");
210  TowerCalibration6->TowerType(6);
211  TowerCalibration6->Verbosity(verbosity);
213  TowerCalibration6->set_calib_const_GeV_ADC(1.0 / 0.030); // sampling fraction = 0.030
214  TowerCalibration6->set_pedstal_ADC(0);
215  se->registerSubsystem(TowerCalibration6);
216 }
217 
219 {
221 
223 
225  {
226  RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkMA("FEMCRawClusterBuilderkMA");
227  ClusterBuilder->Detector("FEMC");
228  ClusterBuilder->set_seed_e(0.1);
229  ClusterBuilder->set_agg_e(0.005);
230  se->registerSubsystem(ClusterBuilder);
231  /*
232  RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplateFEMC");
233  ClusterBuilder->Detector("FEMC");
234  ClusterBuilder->Verbosity(verbosity);
235  ClusterBuilder->set_threshold_energy(0.020); // This threshold should be the same as in FEMCprof_Thresh**.root file below
236  std::string femc_prof = getenv("CALIBRATIONROOT");
237  femc_prof += "/EmcProfile/FEMCprof_Thresh20MeV.root";
238  ClusterBuilder->LoadProfile(femc_prof.c_str());
239  se->registerSubsystem(ClusterBuilder);
240  */
241  }
243  {
244  RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("FEMCRawClusterBuilderFwd");
245 
246  ClusterBuilder->Detector("FEMC");
247  ClusterBuilder->Verbosity(verbosity);
248  ClusterBuilder->set_threshold_energy(0.010);
249  se->registerSubsystem(ClusterBuilder);
250  }
251  else
252  {
253  cout << "FEMC_Clusters - unknown clusterizer setting!" << endl;
254  exit(1);
255  }
256 
257  return;
258 }
259 
260 void FEMC_Eval(std::string outputfile)
261 {
264 
265  CaloEvaluator *eval = new CaloEvaluator("FEMCEVALUATOR", "FEMC", outputfile.c_str());
266  eval->Verbosity(verbosity);
267  se->registerSubsystem(eval);
268 
269  return;
270 }
271 #endif