File indexing completed on 2025-12-16 09:24:01
0001 #ifndef FUN4ALL_YEAR1_C
0002 #define FUN4ALL_YEAR1_C
0003
0004 #include <QA.C>
0005
0006 #include <centrality/CentralityReco.h>
0007
0008 #include <calotrigger/MinimumBiasClassifier.h>
0009
0010 #include <calovalid/CaloValid.h>
0011
0012 #include <caloreco/CaloTowerBuilder.h>
0013 #include <caloreco/CaloTowerCalib.h>
0014 #include <caloreco/CaloTowerStatus.h>
0015 #include <caloreco/CaloWaveformProcessing.h>
0016 #include <caloreco/DeadHotMapLoader.h>
0017 #include <caloreco/RawClusterBuilderTemplate.h>
0018 #include <caloreco/RawClusterDeadHotMask.h>
0019 #include <caloreco/RawClusterPositionCorrection.h>
0020 #include <caloreco/TowerInfoDeadHotMask.h>
0021
0022 #include <mbd/MbdReco.h>
0023
0024 #include <globalvertex/GlobalVertexReco.h>
0025
0026 #include <ffamodules/CDBInterface.h>
0027 #include <ffamodules/FlagHandler.h>
0028 #include <ffamodules/HeadReco.h>
0029 #include <ffamodules/SyncReco.h>
0030
0031 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0032
0033 #include <fun4all/Fun4AllDstInputManager.h>
0034 #include <fun4all/Fun4AllDstOutputManager.h>
0035 #include <fun4all/Fun4AllInputManager.h>
0036 #include <fun4all/Fun4AllRunNodeInputManager.h>
0037 #include <fun4all/Fun4AllServer.h>
0038 #include <fun4all/Fun4AllUtils.h>
0039 #include <fun4all/SubsysReco.h>
0040
0041 #include <phool/recoConsts.h>
0042
0043 #include <TSystem.h>
0044
0045 #include <format>
0046
0047 R__LOAD_LIBRARY(libfun4all.so)
0048 R__LOAD_LIBRARY(libfun4allraw.so)
0049 R__LOAD_LIBRARY(libcalo_reco.so)
0050 R__LOAD_LIBRARY(libcalotrigger.so)
0051 R__LOAD_LIBRARY(libcentrality.so)
0052 R__LOAD_LIBRARY(libffamodules.so)
0053 R__LOAD_LIBRARY(libmbd.so)
0054 R__LOAD_LIBRARY(libglobalvertex.so)
0055 R__LOAD_LIBRARY(libcalovalid.so)
0056
0057 void Fun4All_Year1(const std::string &fname = "/sphenix/lustre01/sphnxpro/commissioning/aligned_prdf/beam-00021774-0000.prdf", int nEvents = 10)
0058 {
0059 bool enableMasking = false;
0060 bool addZeroSupCaloNodes = true;
0061
0062
0063
0064 CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2;
0065
0066
0067
0068 Fun4AllServer *se = Fun4AllServer::instance();
0069 se->Verbosity(0);
0070
0071 recoConsts *rc = recoConsts::instance();
0072
0073 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname);
0074 int runnumber = runseg.first;
0075 int segment = runseg.second;
0076 std::string fulloutfile = std::format("./DST_CALOR-{:08}-{:04}.root",runnumber, segment);
0077 std::string fulloutfile_hist = std::string("./HIST_CALOR--{:08}-{:04}.root",runnumber, segment);
0078
0079
0080
0081
0082
0083 rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023");
0084
0085 rc->set_uint64Flag("TIMESTAMP", runnumber);
0086 CDBInterface::instance()->Verbosity(1);
0087
0088
0089 SyncReco *sync = new SyncReco();
0090 se->registerSubsystem(sync);
0091
0092 HeadReco *head = new HeadReco();
0093 se->registerSubsystem(head);
0094
0095 FlagHandler *flag = new FlagHandler();
0096 se->registerSubsystem(flag);
0097
0098
0099 MbdReco *mbdreco = new MbdReco();
0100 se->registerSubsystem(mbdreco);
0101
0102
0103 GlobalVertexReco *gvertex = new GlobalVertexReco();
0104 se->registerSubsystem(gvertex);
0105
0106
0107
0108 CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCalBUILDER");
0109 ctbEMCal->set_detector_type(CaloTowerDefs::CEMC);
0110 ctbEMCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0111 ctbEMCal->set_builder_type(buildertype);
0112 ctbEMCal->set_nsamples(16);
0113 se->registerSubsystem(ctbEMCal);
0114
0115 CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0116 ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0117 ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0118 ctbIHCal->set_builder_type(buildertype);
0119 ctbIHCal->set_nsamples(31);
0120 se->registerSubsystem(ctbIHCal);
0121
0122 CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0123 ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0124 ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0125 ctbOHCal->set_builder_type(buildertype);
0126 ctbOHCal->set_nsamples(31);
0127 se->registerSubsystem(ctbOHCal);
0128
0129 CaloTowerBuilder *ca4 = new CaloTowerBuilder("zdc");
0130 ca4->set_detector_type(CaloTowerDefs::ZDC);
0131 ca4->set_nsamples(31);
0132 ca4->set_builder_type(CaloTowerDefs::kPRDFWaveform);
0133 ca4->set_processing_type(CaloWaveformProcessing::FAST);
0134 se->registerSubsystem(ca4);
0135
0136
0137
0138 std::cout << "status setters" << std::endl;
0139 CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS");
0140 statusEMC->set_detector_type(CaloTowerDefs::CEMC);
0141 statusEMC->set_time_cut(1);
0142 se->registerSubsystem(statusEMC);
0143
0144 CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0145 statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0146 statusHCalIn->set_time_cut(2);
0147 se->registerSubsystem(statusHCalIn);
0148
0149 CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0150 statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0151 statusHCALOUT->set_time_cut(2);
0152 se->registerSubsystem(statusHCALOUT);
0153
0154
0155
0156 std::cout << "Calibrating EMCal" << std::endl;
0157 CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB");
0158 calibEMC->set_detector_type(CaloTowerDefs::CEMC);
0159 se->registerSubsystem(calibEMC);
0160
0161 std::cout << "Calibrating OHcal" << std::endl;
0162 CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0163 calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0164 se->registerSubsystem(calibOHCal);
0165
0166 std::cout << "Calibrating IHcal" << std::endl;
0167 CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0168 calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0169 se->registerSubsystem(calibIHCal);
0170
0171 std::cout << "Calibrating ZDC" << std::endl;
0172 CaloTowerCalib *calibZDC = new CaloTowerCalib("ZDC");
0173 calibZDC->set_detector_type(CaloTowerDefs::ZDC);
0174 se->registerSubsystem(calibZDC);
0175
0176
0177
0178 if (enableMasking)
0179 {
0180 std::cout << "Loading EMCal deadmap" << std::endl;
0181 DeadHotMapLoader *towerMapCemc = new DeadHotMapLoader("CEMC");
0182 towerMapCemc->detector("CEMC");
0183 se->registerSubsystem(towerMapCemc);
0184
0185 std::cout << "Loading ihcal deadmap" << std::endl;
0186 DeadHotMapLoader *towerMapHCalin = new DeadHotMapLoader("HCALIN");
0187 towerMapHCalin->detector("HCALIN");
0188 se->registerSubsystem(towerMapHCalin);
0189
0190 std::cout << "Loading ohcal deadmap" << std::endl;
0191 DeadHotMapLoader *towerMapHCalout = new DeadHotMapLoader("HCALOUT");
0192 towerMapHCalout->detector("HCALOUT");
0193 se->registerSubsystem(towerMapHCalout);
0194
0195 std::cout << "Loading cemc masker" << std::endl;
0196 TowerInfoDeadHotMask *towerMaskCemc = new TowerInfoDeadHotMask("CEMC");
0197 towerMaskCemc->detector("CEMC");
0198 se->registerSubsystem(towerMaskCemc);
0199
0200 std::cout << "Loading hcal maskers" << std::endl;
0201 TowerInfoDeadHotMask *towerMaskHCalin = new TowerInfoDeadHotMask("HCALIN");
0202 towerMaskHCalin->detector("HCALIN");
0203 se->registerSubsystem(towerMaskHCalin);
0204
0205 TowerInfoDeadHotMask *towerMaskHCalout = new TowerInfoDeadHotMask("HCALOUT");
0206 towerMaskHCalout->detector("HCALOUT");
0207 se->registerSubsystem(towerMaskHCalout);
0208 }
0209
0210 std::cout << "Adding Geometry file" << std::endl;
0211 Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0212 std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0213 intrue2->AddFile(geoLocation);
0214 se->registerInputManager(intrue2);
0215
0216
0217
0218 std::cout << "Building clusters" << std::endl;
0219 RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate");
0220 ClusterBuilder->Detector("CEMC");
0221 ClusterBuilder->set_threshold_energy(0.030);
0222 std::string emc_prof = getenv("CALIBRATIONROOT");
0223 emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root";
0224 ClusterBuilder->LoadProfile(emc_prof);
0225 ClusterBuilder->set_UseTowerInfo(1);
0226 se->registerSubsystem(ClusterBuilder);
0227
0228 if (enableMasking)
0229 {
0230 std::cout << "Masking clusters" << std::endl;
0231 RawClusterDeadHotMask *clusterMask = new RawClusterDeadHotMask("clusterMask");
0232 clusterMask->detector("CEMC");
0233 se->registerSubsystem(clusterMask);
0234 }
0235
0236 std::cout << "Applying Position Dependent Correction" << std::endl;
0237 RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC");
0238 clusterCorrection->set_UseTowerInfo(1);
0239 se->registerSubsystem(clusterCorrection);
0240
0241
0242
0243 if (addZeroSupCaloNodes)
0244 {
0245 CaloTowerBuilder *ctbEMCal_SZ = new CaloTowerBuilder("EMCalBUILDER_ZS");
0246 ctbEMCal_SZ->set_detector_type(CaloTowerDefs::CEMC);
0247 ctbEMCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0248 ctbEMCal_SZ->set_nsamples(8);
0249 ctbEMCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
0250 ctbEMCal_SZ->set_softwarezerosuppression(true, 100000000);
0251 se->registerSubsystem(ctbEMCal_SZ);
0252
0253 CaloTowerBuilder *ctbIHCal_SZ = new CaloTowerBuilder("HCALINBUILDER_ZS");
0254 ctbIHCal_SZ->set_detector_type(CaloTowerDefs::HCALIN);
0255 ctbIHCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0256 ctbIHCal_SZ->set_nsamples(8);
0257 ctbIHCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
0258 ctbIHCal_SZ->set_softwarezerosuppression(true, 100000000);
0259 se->registerSubsystem(ctbIHCal_SZ);
0260
0261 CaloTowerBuilder *ctbOHCal_SZ = new CaloTowerBuilder("HCALOUTBUILDER_SZ");
0262 ctbOHCal_SZ->set_detector_type(CaloTowerDefs::HCALOUT);
0263 ctbOHCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0264 ctbOHCal_SZ->set_nsamples(8);
0265 ctbOHCal_SZ->set_outputNodePrefix("TOWERS_SZ_");
0266 ctbOHCal_SZ->set_softwarezerosuppression(true, 100000000);
0267 se->registerSubsystem(ctbOHCal_SZ);
0268
0269 CaloTowerCalib *calibEMC_SZ = new CaloTowerCalib("CEMCCALIB_SZ");
0270 calibEMC_SZ->set_detector_type(CaloTowerDefs::CEMC);
0271 calibEMC_SZ->set_inputNodePrefix("TOWERS_SZ_");
0272 calibEMC_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
0273 se->registerSubsystem(calibEMC_SZ);
0274
0275 CaloTowerCalib *calibIHCal_SZ = new CaloTowerCalib("IHCALCALIB_SZ");
0276 calibIHCal_SZ->set_detector_type(CaloTowerDefs::HCALIN);
0277 calibIHCal_SZ->set_inputNodePrefix("TOWERS_SZ_");
0278 calibIHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
0279 se->registerSubsystem(calibIHCal_SZ);
0280
0281 CaloTowerCalib *calibOHCal_SZ = new CaloTowerCalib("OHCALCALIB_SZ");
0282 calibOHCal_SZ->set_detector_type(CaloTowerDefs::HCALOUT);
0283 calibOHCal_SZ->set_inputNodePrefix("TOWERS_SZ_");
0284 calibOHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_");
0285 se->registerSubsystem(calibOHCal_SZ);
0286 }
0287
0288 MinimumBiasClassifier *minimumbiasclassifier = new MinimumBiasClassifier();
0289 se->registerSubsystem(minimumbiasclassifier);
0290
0291 CentralityReco *centralityreco = new CentralityReco();
0292 se->registerSubsystem(centralityreco);
0293
0294
0295 CaloValid *ca = new CaloValid("CaloValid");
0296 ca->set_timing_cut_width(200);
0297 se->registerSubsystem(ca);
0298
0299
0300 Fun4AllInputManager *In = new Fun4AllPrdfInputManager("in");
0301 In->AddFile(fname);
0302 se->registerInputManager(In);
0303
0304 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fulloutfile);
0305 se->registerOutputManager(out);
0306
0307 se->run(nEvents);
0308 se->End();
0309
0310 std::string qaOutputFileName = fulloutfile_hist + "_qa.root";
0311 QAHistManagerDef::saveQARootFile(qaOutputFileName);
0312
0313 CDBInterface::instance()->Print();
0314 se->PrintTimer();
0315 delete se;
0316 std::cout << "All done!" << std::endl;
0317 gSystem->Exit(0);
0318 }
0319
0320 #endif