File indexing completed on 2025-08-05 08:19:42
0001 #ifndef MACRO_G4HCALOUTREF_C
0002 #define MACRO_G4HCALOUTREF_C
0003
0004 #include <GlobalVariables.C>
0005 #include <QA.C>
0006
0007 #include <g4calo/HcalRawTowerBuilder.h>
0008 #include <g4calo/RawTowerDigitizer.h>
0009
0010 #include <g4detectors/PHG4HcalCellReco.h>
0011 #include <g4detectors/PHG4OuterHcalSubsystem.h>
0012
0013 #include <g4eval/CaloEvaluator.h>
0014
0015 #include <g4main/PHG4Reco.h>
0016
0017 #include <caloreco/RawClusterBuilderGraph.h>
0018 #include <caloreco/RawClusterBuilderTemplate.h>
0019 #include <caloreco/RawTowerCalibration.h>
0020 #include <qa_modules/QAG4SimulationCalorimeter.h>
0021
0022 #include <fun4all/Fun4AllServer.h>
0023
0024 R__LOAD_LIBRARY(libcalo_reco.so)
0025 R__LOAD_LIBRARY(libg4calo.so)
0026 R__LOAD_LIBRARY(libg4detectors.so)
0027 R__LOAD_LIBRARY(libg4eval.so)
0028 R__LOAD_LIBRARY(libqa_modules.so)
0029
0030 namespace Enable
0031 {
0032 bool HCALOUT = false;
0033 bool HCALOUT_ABSORBER = false;
0034 bool HCALOUT_OVERLAPCHECK = false;
0035 bool HCALOUT_CELL = false;
0036 bool HCALOUT_TOWER = false;
0037 bool HCALOUT_CLUSTER = false;
0038 bool HCALOUT_EVAL = false;
0039 bool HCALOUT_QA = false;
0040 int HCALOUT_VERBOSITY = 0;
0041 }
0042
0043 namespace G4HCALOUT
0044 {
0045 double outer_radius = 264.71;
0046 double size_z = 304.91 * 2;
0047
0048
0049 RawTowerDigitizer::enu_digi_algorithm TowerDigi = RawTowerDigitizer::kSimple_photon_digitization;
0050
0051
0052
0053
0054
0055
0056
0057 enum enu_HCalOut_clusterizer
0058 {
0059 kHCalOutGraphClusterizer,
0060 kHCalOutTemplateClusterizer
0061 };
0062
0063
0064 enu_HCalOut_clusterizer HCalOut_clusterizer = kHCalOutTemplateClusterizer;
0065
0066
0067 }
0068
0069
0070 void HCalOuterInit()
0071 {
0072 BlackHoleGeometry::max_radius = std::max(BlackHoleGeometry::max_radius, G4HCALOUT::outer_radius);
0073 BlackHoleGeometry::max_z = std::max(BlackHoleGeometry::max_z, G4HCALOUT::size_z / 2.);
0074 BlackHoleGeometry::min_z = std::min(BlackHoleGeometry::min_z, -G4HCALOUT::size_z / 2.);
0075 }
0076
0077 double HCalOuter(PHG4Reco *g4Reco,
0078 double radius,
0079 const int crossings)
0080 {
0081 bool AbsorberActive = Enable::ABSORBER || Enable::HCALOUT_ABSORBER;
0082 bool OverlapCheck = Enable::OVERLAPCHECK || Enable::HCALOUT_OVERLAPCHECK;
0083 int verbosity = std::max(Enable::VERBOSITY, Enable::HCALOUT_VERBOSITY);
0084
0085 PHG4OuterHcalSubsystem *hcal = new PHG4OuterHcalSubsystem("HCALOUT");
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123 hcal->SetActive();
0124 hcal->SuperDetector("HCALOUT");
0125 if (AbsorberActive)
0126 {
0127 hcal->SetAbsorberActive();
0128 }
0129 hcal->OverlapCheck(OverlapCheck);
0130 g4Reco->registerSubsystem(hcal);
0131
0132 radius = hcal->get_double_param("outer_radius");
0133
0134 radius += no_overlapp;
0135
0136 return radius;
0137 }
0138
0139 void HCALOuter_Cells()
0140 {
0141 int verbosity = std::max(Enable::VERBOSITY, Enable::HCALOUT_VERBOSITY);
0142
0143 Fun4AllServer *se = Fun4AllServer::instance();
0144
0145 PHG4HcalCellReco *hc = new PHG4HcalCellReco("HCALOUT_CELLRECO");
0146 hc->Detector("HCALOUT");
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158 se->registerSubsystem(hc);
0159
0160 return;
0161 }
0162
0163 void HCALOuter_Towers()
0164 {
0165 int verbosity = std::max(Enable::VERBOSITY, Enable::HCALOUT_VERBOSITY);
0166
0167 Fun4AllServer *se = Fun4AllServer::instance();
0168
0169 HcalRawTowerBuilder *TowerBuilder = new HcalRawTowerBuilder("HcalOutRawTowerBuilder");
0170 TowerBuilder->Detector("HCALOUT");
0171 TowerBuilder->set_sim_tower_node_prefix("SIM");
0172
0173
0174
0175
0176
0177
0178
0179 TowerBuilder->Verbosity(verbosity);
0180 se->registerSubsystem(TowerBuilder);
0181
0182
0183 RawTowerDigitizer *TowerDigitizer = new RawTowerDigitizer("HcalOutRawTowerDigitizer");
0184 TowerDigitizer->Detector("HCALOUT");
0185
0186 TowerDigitizer->set_digi_algorithm(G4HCALOUT::TowerDigi);
0187 TowerDigitizer->set_pedstal_central_ADC(0);
0188 TowerDigitizer->set_pedstal_width_ADC(1);
0189 TowerDigitizer->set_photonelec_ADC(16. / 5.);
0190 TowerDigitizer->set_photonelec_yield_visible_GeV(16. / 5 / (0.2e-3));
0191 TowerDigitizer->set_zero_suppression_ADC(-0);
0192 se->registerSubsystem(TowerDigitizer);
0193
0194 const double visible_sample_fraction_HCALOUT = 3.38021e-02;
0195
0196 RawTowerCalibration *TowerCalibration = new RawTowerCalibration("HcalOutRawTowerCalibration");
0197 TowerCalibration->Detector("HCALOUT");
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207 TowerCalibration->set_calib_algorithm(RawTowerCalibration::kDbfile_tbt_gain_corr);
0208 TowerCalibration->set_UseConditionsDB(false);
0209
0210
0211 TowerCalibration->set_CalibrationFileName("HCALOUT_GainsCalib1.12_PosEtaOnly_NegEta1.0.txt");
0212
0213
0214 if (G4HCALOUT::TowerDigi == RawTowerDigitizer::kNo_digitization)
0215 {
0216
0217 TowerCalibration->set_calib_const_GeV_ADC(1. / 0.033);
0218 }
0219 else
0220 {
0221 TowerCalibration->set_calib_const_GeV_ADC(0.2e-3 / visible_sample_fraction_HCALOUT);
0222 }
0223 TowerCalibration->set_pedstal_ADC(0);
0224 se->registerSubsystem(TowerCalibration);
0225
0226 return;
0227 }
0228
0229 void HCALOuter_Clusters()
0230 {
0231 int verbosity = std::max(Enable::VERBOSITY, Enable::HCALOUT_VERBOSITY);
0232
0233 Fun4AllServer *se = Fun4AllServer::instance();
0234
0235 if (G4HCALOUT::HCalOut_clusterizer == G4HCALOUT::kHCalOutTemplateClusterizer)
0236 {
0237 RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("HcalOutRawClusterBuilderTemplate");
0238 ClusterBuilder->Detector("HCALOUT");
0239 ClusterBuilder->SetCylindricalGeometry();
0240 ClusterBuilder->Verbosity(verbosity);
0241 se->registerSubsystem(ClusterBuilder);
0242 }
0243 else if (G4HCALOUT::HCalOut_clusterizer == G4HCALOUT::kHCalOutGraphClusterizer)
0244 {
0245 RawClusterBuilderGraph *ClusterBuilder = new RawClusterBuilderGraph("HcalOutRawClusterBuilderGraph");
0246 ClusterBuilder->Detector("HCALOUT");
0247 ClusterBuilder->Verbosity(verbosity);
0248 se->registerSubsystem(ClusterBuilder);
0249 }
0250 else
0251 {
0252 cout << "HCALOuter_Clusters - unknown clusterizer setting!" << endl;
0253 exit(1);
0254 }
0255
0256 return;
0257 }
0258
0259 void HCALOuter_Eval(const std::string &outputfile)
0260 {
0261 int verbosity = std::max(Enable::VERBOSITY, Enable::HCALOUT_VERBOSITY);
0262
0263 Fun4AllServer *se = Fun4AllServer::instance();
0264
0265 CaloEvaluator *eval = new CaloEvaluator("HCALOUTEVALUATOR", "HCALOUT", outputfile);
0266 eval->Verbosity(verbosity);
0267 se->registerSubsystem(eval);
0268
0269 return;
0270 }
0271
0272 void HCALOuter_QA()
0273 {
0274 int verbosity = std::max(Enable::QA_VERBOSITY, Enable::HCALOUT_VERBOSITY);
0275
0276 Fun4AllServer *se = Fun4AllServer::instance();
0277 QAG4SimulationCalorimeter *qa = new QAG4SimulationCalorimeter("HCALOUT");
0278 qa->Verbosity(verbosity);
0279 se->registerSubsystem(qa);
0280
0281 return;
0282 }
0283
0284 #endif