ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_LFHCAL.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_LFHCAL.C
1 #ifndef MACRO_G4LFHCAL_C
2 #define MACRO_G4LFHCAL_C
3 
4 #include <GlobalVariables.C>
5 
7 
10 
11 #include <g4eval/CaloEvaluator.h>
12 
13 #include <g4main/PHG4Reco.h>
14 
17 
18 #include <caloreco/RawClusterBuilderFwd.h>
19 #include <caloreco/RawClusterBuilderTemplate.h>
20 #include <caloreco/RawTowerCalibration.h>
21 
22 #include <fun4all/Fun4AllServer.h>
23 
24 R__LOAD_LIBRARY(libcalo_reco.so)
25 R__LOAD_LIBRARY(libg4calo.so)
26 R__LOAD_LIBRARY(libg4detectors.so)
27 R__LOAD_LIBRARY(libg4eval.so)
28 
29 namespace Enable
30 {
31  bool LFHCAL = false;
32  bool LFHCAL_ABSORBER = false;
33  bool LFHCAL_CELL = false;
34  bool LFHCAL_TOWER = false;
35  bool LFHCAL_CLUSTER = false;
36  bool LFHCAL_EVAL = false;
37  bool LFHCAL_OVERLAPCHECK = false;
39 } // namespace Enable
40 
41 namespace G4LFHCAL
42 {
43  // from LFHcal/mapping/towerMap_LFHCAL_v005.txt
44  double Gz0 = 400.;
45  double Gdz = 100.;
46  double outer_radius = 265.;
48  {
51  };
52  //template clusterizer, as developed by Sasha Bazilevsky
54  // graph clusterizer
55  //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
56  namespace SETTING
57  {
58  bool FullEtaAcc = false;
59  bool HC2x = false;
60  bool asymmetric = true;
61  bool wDR = false;
62  bool FwdSquare = false;
63  bool FwdConfig = false;
64  bool longer = true;
65  bool tailcatcher = true;
66  } // namespace SETTING
67 } // namespace G4LFHCAL
68 
69 TString GetMappingFile(){
70  TString mappinFileName = getenv("CALIBRATIONROOT");
72  {
74  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_2x-long.txt";
75  else
76  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_2x.txt";
77  }
78  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
79  else if (G4LFHCAL::SETTING::wDR)
80  {
82  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_wDR-long.txt";
83  else
84  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_wDR.txt";
85  }
86  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
88  {
90  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdConfig-long.txt";
91  else
92  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdConfig.txt";
93  }
94  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
96  {
98  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdSquare-long.txt";
99  else
100  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdSquare.txt";
101  }
102  // full HCal Fe-Scint with asymmetric centering around beampipe
104  {
105  if (Enable::IP6){
108  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long-tailcatcher.txt";
109  else
110  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long.txt";
111  } else
112  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric.txt";
113  } else {
115  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_asymmetric-long.txt";
116  else
117  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_asymmetric.txt";
118  }
119  }
120  // PSD like HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
121  else
122  {
124  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_default-long.txt";
125  else
126  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_default.txt";
127  }
128 
129  return mappinFileName;
130 
131 }
132 
133 
135 {
137  G4LFHCAL::Gz0 = 420;
138  G4LFHCAL::Gdz = 140;
139  }
140  // simple way to check if only 1 of the settings is true
141  if ((G4LFHCAL::SETTING::FullEtaAcc ? 1 : 0) + (G4LFHCAL::SETTING::HC2x ? 1 : 0) > 1)
142  {
143  cout << "use only G4LFHCAL::SETTING::FullEtaAcc=true or G4LFHCAL::SETTING::HC2x=true or G4LFHCAL::SETTING::HC4x=true" << endl;
144  gSystem->Exit(1);
145  }
146 
150 }
151 
152 void LFHCALSetup(PHG4Reco *g4Reco)
153 {
154  const bool AbsorberActive = Enable::ABSORBER || Enable::LFHCAL_ABSORBER;
155  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::LFHCAL_OVERLAPCHECK;
157 
159  PHG4LFHcalSubsystem *fhcal = new PHG4LFHcalSubsystem("LFHCAL");
160 
161  TString mapping_fhcal = GetMappingFile();
162  cout << "LFHCAL: "<< mapping_fhcal.Data() << endl;
163  ostringstream mapping_fhcal_s;
164  mapping_fhcal_s << mapping_fhcal.Data();
165 
166  fhcal->SetTowerMappingFile(mapping_fhcal_s.str());
167  fhcal->OverlapCheck(OverlapCheck);
168  fhcal->SetActive();
169  //fhcal->SetDetailed(true);
170  fhcal->SuperDetector("LFHCAL");
171  if (AbsorberActive) fhcal->SetAbsorberActive();
172 
173  g4Reco->registerSubsystem(fhcal);
174 }
175 
176 void LFHCAL_Cells(int verbosity = 0)
177 {
178  return;
179 }
180 
182 {
184 
186 
187  // Switch to desired calo setup;
188  // PSD like HCal Fe-Scint with doubled granularity
189  TString mapping_fhcal = GetMappingFile();
190  ostringstream mapping_fhcal_s;
191  mapping_fhcal_s << mapping_fhcal.Data();
192 
193  RawTowerBuilderByHitIndexLHCal *tower_LFHCAL = new RawTowerBuilderByHitIndexLHCal("TowerBuilder_LFHCAL");
194  tower_LFHCAL->Detector("LFHCAL");
195  tower_LFHCAL->set_sim_tower_node_prefix("SIM");
196  tower_LFHCAL->GeometryTableFile(mapping_fhcal_s.str());
197 
198  se->registerSubsystem(tower_LFHCAL);
199 
200  cout << "def: using default for LFHCAL towers" << endl;
201  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("LFHCALRawTowerDigitizer");
202  TowerDigitizer->Detector("LFHCAL");
203  TowerDigitizer->Verbosity(verbosity);
205  se->registerSubsystem(TowerDigitizer);
206 
207 
208  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("LFHCALRawTowerCalibration");
209  TowerCalibration->Detector("LFHCAL");
210  TowerCalibration->Verbosity(verbosity);
212  TowerCalibration->set_calib_const_GeV_ADC(1. / (0.03898*0.93)); // temporary factor 0.93 to fix calibration for new tower design
213  TowerCalibration->set_pedstal_ADC(0);
214  se->registerSubsystem(TowerCalibration);
215 }
216 
218 {
220 
221  RawClusterBuilderHelper *ClusterBuilder = new RawClusterBuilderkMA("LFHCALRawClusterBuilderkMA");
222  ClusterBuilder->Detector("LFHCAL");
223  ClusterBuilder->set_seed_e(0.1);
224  ClusterBuilder->set_agg_e(0.001);
225  se->registerSubsystem(ClusterBuilder);
226 
227  return;
228 }
229 
230 void LFHCAL_Eval(const std::string &outputfile)
231 {
234 
235  CaloEvaluator *eval = new CaloEvaluator("LFHCALEVALUATOR", "LFHCAL", outputfile.c_str());
236  eval->Verbosity(verbosity);
237  se->registerSubsystem(eval);
238 
239  return;
240 }
241 #endif