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 
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(libg4calo.so)
23 R__LOAD_LIBRARY(libg4detectors.so)
24 R__LOAD_LIBRARY(libg4eval.so)
25 
26 namespace Enable
27 {
28  bool LFHCAL = false;
29  bool LFHCAL_ABSORBER = false;
30  bool LFHCAL_CELL = false;
31  bool LFHCAL_TOWER = false;
32  bool LFHCAL_CLUSTER = false;
33  bool LFHCAL_EVAL = false;
34  bool LFHCAL_OVERLAPCHECK = false;
36 } // namespace Enable
37 
38 namespace G4LFHCAL
39 {
40  // from LFHcal/mapping/towerMap_LFHCAL_v005.txt
41  double Gz0 = 400.;
42  double Gdz = 100.;
43  double outer_radius = 262.;
45  {
48  };
49  //template clusterizer, as developed by Sasha Bazilevsky
51  // graph clusterizer
52  //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
53  namespace SETTING
54  {
55  bool FullEtaAcc = false;
56  bool HC2x = false;
57  bool asymmetric = false;
58  bool wDR = false;
59  bool FwdSquare = false;
60  bool FwdConfig = false;
61  bool longer = false;
62  } // namespace SETTING
63 } // namespace G4LFHCAL
64 
65 TString GetMappingFile(){
66  TString mappinFileName = getenv("CALIBRATIONROOT");
68  {
70  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_2x-long.txt";
71  else
72  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_2x.txt";
73  }
74  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
75  else if (G4LFHCAL::SETTING::wDR)
76  {
78  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_wDR-long.txt";
79  else
80  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_wDR.txt";
81  }
82  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
84  {
86  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdConfig-long.txt";
87  else
88  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdConfig.txt";
89  }
90  // HCal Fe-Scint surrounding dual readout calorimeter R>50cm
92  {
94  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdSquare-long.txt";
95  else
96  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_FwdSquare.txt";
97  }
98  // full HCal Fe-Scint with asymmetric centering around beampipe
100  {
101  if (Enable::IP6){
103  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric-long.txt";
104  else
105  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_IP6-asymmetric.txt";
106  } else {
108  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_asymmetric-long.txt";
109  else
110  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_asymmetric.txt";
111  }
112  }
113  // PSD like HCal Fe-Scint with enlarged beam pipe opening for Mar 2020 beam pipe
114  else
115  {
117  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_default-long.txt";
118  else
119  mappinFileName += "/LFHcal/mapping/towerMap_LFHCAL_default.txt";
120  }
121 
122  return mappinFileName;
123 
124 }
125 
126 
128 {
130  G4LFHCAL::Gz0 = 420;
131  G4LFHCAL::Gdz = 140;
132  }
133  // simple way to check if only 1 of the settings is true
134  if ((G4LFHCAL::SETTING::FullEtaAcc ? 1 : 0) + (G4LFHCAL::SETTING::HC2x ? 1 : 0) > 1)
135  {
136  cout << "use only G4LFHCAL::SETTING::FullEtaAcc=true or G4LFHCAL::SETTING::HC2x=true or G4LFHCAL::SETTING::HC4x=true" << endl;
137  gSystem->Exit(1);
138  }
139 
143 }
144 
145 void LFHCALSetup(PHG4Reco *g4Reco)
146 {
147  const bool AbsorberActive = Enable::ABSORBER || Enable::LFHCAL_ABSORBER;
148  bool OverlapCheck = Enable::OVERLAPCHECK || Enable::LFHCAL_OVERLAPCHECK;
150 
152  PHG4LFHcalSubsystem *fhcal = new PHG4LFHcalSubsystem("LFHCAL");
153 
154  TString mapping_fhcal = GetMappingFile();
155  cout << "LFHCAL: "<< mapping_fhcal.Data() << endl;
156  ostringstream mapping_fhcal_s;
157  mapping_fhcal_s << mapping_fhcal.Data();
158 
159  fhcal->SetTowerMappingFile(mapping_fhcal_s.str());
160  fhcal->OverlapCheck(OverlapCheck);
161  fhcal->SetActive();
162  fhcal->SetDetailed(true);
163  fhcal->SuperDetector("LFHCAL");
164  if (AbsorberActive) fhcal->SetAbsorberActive();
165 
166  g4Reco->registerSubsystem(fhcal);
167 }
168 
169 void LFHCAL_Cells(int verbosity = 0)
170 {
171  return;
172 }
173 
175 {
177 
179 
180  // Switch to desired calo setup;
181  // PSD like HCal Fe-Scint with doubled granularity
182  TString mapping_fhcal = GetMappingFile();
183  ostringstream mapping_fhcal_s;
184  mapping_fhcal_s << mapping_fhcal.Data();
185 
186  RawTowerBuilderByHitIndexLHCal *tower_LFHCAL = new RawTowerBuilderByHitIndexLHCal("TowerBuilder_LFHCAL");
187  tower_LFHCAL->Detector("LFHCAL");
188  tower_LFHCAL->set_sim_tower_node_prefix("SIM");
189  tower_LFHCAL->GeometryTableFile(mapping_fhcal_s.str());
190 
191  se->registerSubsystem(tower_LFHCAL);
192 
193  cout << "def: using default for LFHCAL towers" << endl;
194  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("LFHCALRawTowerDigitizer");
195  TowerDigitizer->Detector("LFHCAL");
196  TowerDigitizer->Verbosity(verbosity);
198  se->registerSubsystem(TowerDigitizer);
199 
200 
201  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("LFHCALRawTowerCalibration");
202  TowerCalibration->Detector("LFHCAL");
203  TowerCalibration->Verbosity(verbosity);
205  TowerCalibration->set_calib_const_GeV_ADC(1. / (0.03898*0.93)); // temporary factor 0.93 to fix calibration for new tower design
206  TowerCalibration->set_pedstal_ADC(0);
207  se->registerSubsystem(TowerCalibration);
208 }
209 
211 {
212 
213  return;
214 }
215 
216 void LFHCAL_Eval(const std::string &outputfile)
217 {
220 
221  CaloEvaluator *eval = new CaloEvaluator("LFHCALEVALUATOR", "LFHCAL", outputfile.c_str());
222  eval->Verbosity(verbosity);
223  se->registerSubsystem(eval);
224 
225  return;
226 }
227 #endif