EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4_DRCALO.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4_DRCALO.C
1 #ifndef MACRO_G4DR_C
2 #define MACRO_G4DR_C
3 
4 #include <GlobalVariables.C>
5 
7 
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 DRCALO = false;
30  bool DRCALO_ABSORBER = false;
31  bool DRCALO_CELL = false;
32  bool DRCALO_TOWER = false;
33  bool DRCALO_CLUSTER = false;
34  bool DRCALO_EVAL = false;
35  bool DRCALO_OVERLAPCHECK = false;
37 } // namespace Enable
38 
39 namespace G4DRCALO
40 {
41  // from ForwardDualReadout/mapping/towerMap_DRCALO_v005.txt
42  double Gz0 = 400.;
43  double Gdz = 100.;
44  double outer_radius = 262.;
46  {
49  };
50  //template clusterizer, as developed by Sasha Bazilevsky
52  // graph clusterizer
53  //enu_FHcal_clusterizer FHcal_clusterizer = kFHcalGraphClusterizer;
54  namespace SETTING
55  {
56  bool Tungsten = false;
57  bool Quartz = false;
58  bool PMMA = false;
59  bool Tubes = false;
60  bool FwdConfig = false;
61  bool FwdSquare = false;
62  } // namespace SETTING
63 } // namespace G4DRCALO
64 
65 void DRCALOInit()
66 {
67  // simple way to check if only 1 of the settings is true
68  if (( (G4DRCALO::SETTING::Tungsten ? 1 : 0) + (G4DRCALO::SETTING::Quartz ? 1 : 0) + (G4DRCALO::SETTING::PMMA ? 1 : 0)) > 1)
69  {
70  cout << "use only G4DRCALO::SETTING::Tungsten=true or G4DRCALO::SETTING::Quartz=true or G4DRCALO::SETTING::PMMA=true" << endl;
71  gSystem->Exit(1);
72  }
73  if (( (G4DRCALO::SETTING::FwdSquare ? 1 : 0) + (G4DRCALO::SETTING::FwdConfig ? 1 : 0)) > 1)
74  {
75  cout << "use only G4DRCALO::SETTING::FwdSquare=true or G4DRCALO::SETTING::FwdConfig=true" << endl;
76  gSystem->Exit(1);
77  }
78 
82 }
83 
84 void DRCALOSetup(PHG4Reco *g4Reco)
85 {
86  const bool AbsorberActive = Enable::ABSORBER || Enable::DRCALO_ABSORBER;
89 
92  hhcal->OverlapCheck(OverlapCheck);
93  hhcal->SuperDetector("DRCALO");
94  hhcal->SetActive();
95 
96  ostringstream mapping_drcalo;
97 
98  // Switch to desired calo setup
99  if(G4DRCALO::SETTING::Tungsten) { // design with PMMA cerenkov fibers and tungsten absorber material
101  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten_FwdSquare.txt";
102  else
103  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten.txt";
104  } else if(G4DRCALO::SETTING::Quartz) { // design with Quartz cerenkov fibers
106  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz_FwdSquare.txt";
107  else
108  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz.txt";
109  } else if(G4DRCALO::SETTING::PMMA) { // design with PMMA cerenkov fibers
111  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA_FwdSquare.txt";
112  else
113  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA.txt";
114  } else { // NOTCHED design with PMMA cerenkov fiber
117  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Tubes_FwdConfig.txt";
118  } else {
119  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdConfig.txt";
120  }
121  }else if (G4DRCALO::SETTING::FwdSquare){
123  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Tubes_FwdSquare.txt";
124  } else {
125  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdSquare.txt";
126  }
127  } else{
129  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Tubes.txt";
130  } else {
131  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default.txt";
132  }
133  }
134  }
135 
136  hhcal->SetTowerMappingFile(mapping_drcalo.str());
137 
138 
139  if (AbsorberActive) hhcal->SetAbsorberActive();
140 
141  g4Reco->registerSubsystem(hhcal);
142 }
143 
144 void DRCALO_Cells(int verbosity = 0)
145 {
146  return;
147 }
148 
150 {
152 
154 
155  ostringstream mapping_drcalo;
156 
157  // Switch to desired calo setup
158  if(G4DRCALO::SETTING::Tungsten) { // design with PMMA cerenkov fibers and tungsten absorber material
160  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten_FwdSquare.txt";
161  else
162  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten.txt";
163  } else if(G4DRCALO::SETTING::Quartz) { // design with Quartz cerenkov fibers
165  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz_FwdSquare.txt";
166  else
167  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz.txt";
168  } else if(G4DRCALO::SETTING::PMMA) { // design with PMMA cerenkov fibers
170  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA_FwdSquare.txt";
171  else
172  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA.txt";
173  } else { // NOTCHED design with PMMA cerenkov fiber
175  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdConfig.txt";
177  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdSquare.txt";
178  else
179  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default.txt";
180  }
181  cout << "using " << mapping_drcalo.str() << endl;
182 
183 
184  RawTowerBuilderDRCALO *tower_DRCALO = new RawTowerBuilderDRCALO("TowerBuilder_DRCALO");
185  tower_DRCALO->Detector("DRCALO");
186  tower_DRCALO->set_sim_tower_node_prefix("SIM");
187  tower_DRCALO->GeometryTableFile(mapping_drcalo.str());
188 
189  se->registerSubsystem(tower_DRCALO);
190 
191  cout << "def: using default for DRCALO towers" << endl;
192  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("DRCALORawTowerDigitizer");
193  TowerDigitizer->Detector("DRCALO");
194  TowerDigitizer->Verbosity(0);
196  se->registerSubsystem(TowerDigitizer);
197 
198  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("DRCALORawTowerCalibration");
199  TowerCalibration->Detector("DRCALO");
200  TowerCalibration->Verbosity(verbosity);
202  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.03898); // calibrated with muons
203  TowerCalibration->set_pedstal_ADC(0);
204  se->registerSubsystem(TowerCalibration);
205 }
206 
208 {
209  // int verbosity = std::max(Enable::VERBOSITY, Enable::DRCALO_VERBOSITY);
210  // Fun4AllServer *se = Fun4AllServer::instance();
211 
212  // if (G4DRCALO::FHcal_clusterizer == G4DRCALO::kFHcalTemplateClusterizer)
213  // {
214  // RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("DRCALORawClusterBuilderTemplate");
215  // ClusterBuilder->Detector("DRCALO");
216  // ClusterBuilder->SetPlanarGeometry(); // has to be called after Detector()
217  // ClusterBuilder->Verbosity(verbosity);
218  // ClusterBuilder->set_threshold_energy(0.100);
219  // se->registerSubsystem(ClusterBuilder);
220  // }
221  // else if (G4DRCALO::FHcal_clusterizer == G4DRCALO::kFHcalTemplateClusterizer)
222  // {
223  // RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("DRCALORawClusterBuilderFwd");
224  // ClusterBuilder->Detector("DRCALO");
225  // ClusterBuilder->Verbosity(verbosity);
226  // ClusterBuilder->set_threshold_energy(0.100);
227  // se->registerSubsystem(ClusterBuilder);
228  // }
229  // else
230  // {
231  // cout << "DRCALO_Clusters - unknown clusterizer setting " << G4DRCALO::FHcal_clusterizer << endl;
232  // gSystem->Exit(1);
233  // }
234 
235  return;
236 }
237 
238 void DRCALO_Eval(const std::string &outputfile)
239 {
240  // int verbosity = std::max(Enable::VERBOSITY, Enable::DRCALO_VERBOSITY);
241  // Fun4AllServer *se = Fun4AllServer::instance();
242 
243  // CaloEvaluator *eval = new CaloEvaluator("DRCALOEVALUATOR", "DRCALO", outputfile.c_str());
244  // eval->Verbosity(verbosity);
245  // se->registerSubsystem(eval);
246 
247  return;
248 }
249 #endif