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