ECCE @ 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 FwdConfig = false;
60  bool FwdSquare = false;
61  } // namespace SETTING
62 } // namespace G4DRCALO
63 
64 void DRCALOInit()
65 {
66  // simple way to check if only 1 of the settings is true
67  if (( (G4DRCALO::SETTING::Tungsten ? 1 : 0) + (G4DRCALO::SETTING::Quartz ? 1 : 0) + (G4DRCALO::SETTING::PMMA ? 1 : 0)) > 1)
68  {
69  cout << "use only G4DRCALO::SETTING::Tungsten=true or G4DRCALO::SETTING::Quartz=true or G4DRCALO::SETTING::PMMA=true" << endl;
70  gSystem->Exit(1);
71  }
72  if (( (G4DRCALO::SETTING::FwdSquare ? 1 : 0) + (G4DRCALO::SETTING::FwdConfig ? 1 : 0)) > 1)
73  {
74  cout << "use only G4DRCALO::SETTING::FwdSquare=true or G4DRCALO::SETTING::FwdConfig=true" << endl;
75  gSystem->Exit(1);
76  }
77 
80 }
81 
82 void DRCALOSetup(PHG4Reco *g4Reco)
83 {
84  const bool AbsorberActive = Enable::ABSORBER || Enable::DRCALO_ABSORBER;
87 
90  hhcal->OverlapCheck(OverlapCheck);
91  hhcal->SuperDetector("DRCALO");
92  hhcal->SetActive();
93 
94  ostringstream mapping_drcalo;
95 
96  // Switch to desired calo setup
97  if(G4DRCALO::SETTING::Tungsten) { // design with PMMA cerenkov fibers and tungsten absorber material
99  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten_FwdSquare.txt";
100  else
101  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten.txt";
102  } else if(G4DRCALO::SETTING::Quartz) { // design with Quartz cerenkov fibers
104  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz_FwdSquare.txt";
105  else
106  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz.txt";
107  } else if(G4DRCALO::SETTING::PMMA) { // design with PMMA cerenkov fibers
109  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA_FwdSquare.txt";
110  else
111  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA.txt";
112  } else { // NOTCHED design with PMMA cerenkov fiber
114  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdConfig.txt";
116  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdSquare.txt";
117  else
118  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default.txt";
119  }
120 
121  hhcal->SetTowerMappingFile(mapping_drcalo.str());
122 
123 
124  if (AbsorberActive) hhcal->SetAbsorberActive();
125 
126  g4Reco->registerSubsystem(hhcal);
127 }
128 
129 void DRCALO_Cells(int verbosity = 0)
130 {
131  return;
132 }
133 
135 {
137 
139 
140  ostringstream mapping_drcalo;
141 
142  // Switch to desired calo setup
143  if(G4DRCALO::SETTING::Tungsten) { // design with PMMA cerenkov fibers and tungsten absorber material
145  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten_FwdSquare.txt";
146  else
147  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_tungsten.txt";
148  } else if(G4DRCALO::SETTING::Quartz) { // design with Quartz cerenkov fibers
150  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz_FwdSquare.txt";
151  else
152  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_Quartz.txt";
153  } else if(G4DRCALO::SETTING::PMMA) { // design with PMMA cerenkov fibers
155  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA_FwdSquare.txt";
156  else
157  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_PMMA.txt";
158  } else { // NOTCHED design with PMMA cerenkov fiber
160  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdConfig.txt";
162  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default_FwdSquare.txt";
163  else
164  mapping_drcalo << getenv("CALIBRATIONROOT") << "/DRCALO/mapping/towerMap_DRCALO_default.txt";
165  }
166  cout << "using " << mapping_drcalo.str() << endl;
167 
168 
169  RawTowerBuilderDRCALO *tower_DRCALO = new RawTowerBuilderDRCALO("TowerBuilder_DRCALO");
170  tower_DRCALO->Detector("DRCALO");
171  tower_DRCALO->set_sim_tower_node_prefix("SIM");
172  tower_DRCALO->GeometryTableFile(mapping_drcalo.str());
173 
174  se->registerSubsystem(tower_DRCALO);
175 
176  cout << "def: using default for DRCALO towers" << endl;
177  RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("DRCALORawTowerDigitizer");
178  TowerDigitizer->Detector("DRCALO");
179  TowerDigitizer->Verbosity(1);
181  se->registerSubsystem(TowerDigitizer);
182 
183  RawTowerCalibration *TowerCalibration = new RawTowerCalibration("DRCALORawTowerCalibration");
184  TowerCalibration->Detector("DRCALO");
185  TowerCalibration->Verbosity(verbosity);
187  TowerCalibration->set_calib_const_GeV_ADC(1. / 0.03898); // calibrated with muons
188  TowerCalibration->set_pedstal_ADC(0);
189  se->registerSubsystem(TowerCalibration);
190 }
191 
193 {
194  // int verbosity = std::max(Enable::VERBOSITY, Enable::DRCALO_VERBOSITY);
195  // Fun4AllServer *se = Fun4AllServer::instance();
196 
197  // if (G4DRCALO::FHcal_clusterizer == G4DRCALO::kFHcalTemplateClusterizer)
198  // {
199  // RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("DRCALORawClusterBuilderTemplate");
200  // ClusterBuilder->Detector("DRCALO");
201  // ClusterBuilder->SetPlanarGeometry(); // has to be called after Detector()
202  // ClusterBuilder->Verbosity(verbosity);
203  // ClusterBuilder->set_threshold_energy(0.100);
204  // se->registerSubsystem(ClusterBuilder);
205  // }
206  // else if (G4DRCALO::FHcal_clusterizer == G4DRCALO::kFHcalTemplateClusterizer)
207  // {
208  // RawClusterBuilderFwd *ClusterBuilder = new RawClusterBuilderFwd("DRCALORawClusterBuilderFwd");
209  // ClusterBuilder->Detector("DRCALO");
210  // ClusterBuilder->Verbosity(verbosity);
211  // ClusterBuilder->set_threshold_energy(0.100);
212  // se->registerSubsystem(ClusterBuilder);
213  // }
214  // else
215  // {
216  // cout << "DRCALO_Clusters - unknown clusterizer setting " << G4DRCALO::FHcal_clusterizer << endl;
217  // gSystem->Exit(1);
218  // }
219 
220  return;
221 }
222 
223 void DRCALO_Eval(const std::string &outputfile)
224 {
225  // int verbosity = std::max(Enable::VERBOSITY, Enable::DRCALO_VERBOSITY);
226  // Fun4AllServer *se = Fun4AllServer::instance();
227 
228  // CaloEvaluator *eval = new CaloEvaluator("DRCALOEVALUATOR", "DRCALO", outputfile.c_str());
229  // eval->Verbosity(verbosity);
230  // se->registerSubsystem(eval);
231 
232  return;
233 }
234 #endif