File indexing completed on 2025-08-03 08:20:23
0001 #ifndef FUN4ALL_NEW_HCALCOSMICS_C
0002 #define FUN4ALL_NEW_HCALCOSMICS_C
0003
0004 #include <caloreco/CaloTowerBuilder.h>
0005 #include <caloreco/CaloTowerCalib.h>
0006 #include <caloreco/CaloTowerStatus.h>
0007 #include <caloreco/CaloWaveformProcessing.h>
0008
0009 #include <ffamodules/CDBInterface.h>
0010 #include <ffamodules/FlagHandler.h>
0011 #include <ffamodules/HeadReco.h>
0012 #include <ffamodules/SyncReco.h>
0013
0014 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0015
0016 #include <fun4all/Fun4AllDstInputManager.h>
0017 #include <fun4all/Fun4AllDstOutputManager.h>
0018 #include <fun4all/Fun4AllInputManager.h>
0019 #include <fun4all/Fun4AllRunNodeInputManager.h>
0020 #include <fun4all/Fun4AllServer.h>
0021 #include <fun4all/Fun4AllUtils.h>
0022 #include <fun4all/SubsysReco.h>
0023
0024 #include <phool/recoConsts.h>
0025
0026 #include <calovalid/CaloValid.h>
0027
0028 #include <litecaloeval/HCalCosmics.h>
0029
0030 R__LOAD_LIBRARY(libfun4all.so)
0031 R__LOAD_LIBRARY(libfun4allraw.so)
0032 R__LOAD_LIBRARY(libcalo_reco.so)
0033 R__LOAD_LIBRARY(libcentrality.so)
0034 R__LOAD_LIBRARY(libffamodules.so)
0035 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0036
0037 void Fun4All_New_HCalCosmics(int nEvents = 100,
0038 const std::string inlist = "files.list",
0039 const std::string &outfile = "DST_CALOFITTING_run2auau_ana487_2024p018_v001",
0040 const std::string &outfile_hist1 = "HIST_COSMIC_HCALOUT_run2auau_ana487_2024p018_v001",
0041 const std::string &outfile_hist2 = "HIST_COSMIC_HCALIN_run2auau_ana487_2024p018_v001",
0042 const std::string &dbtag = "ProdA_2024")
0043 {
0044 bool useDSTRAW = true;
0045
0046
0047
0048 CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2;
0049
0050
0051 Fun4AllServer *se = Fun4AllServer::instance();
0052 se->Verbosity(1);
0053 se->VerbosityDownscale(1000);
0054
0055 recoConsts *rc = recoConsts::instance();
0056
0057
0058 rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0059 CDBInterface::instance()->Verbosity(1);
0060
0061 FlagHandler *flag = new FlagHandler();
0062 se->registerSubsystem(flag);
0063
0064
0065
0066 CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0067 ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0068 ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0069 ctbIHCal->set_builder_type(buildertype);
0070 ctbIHCal->set_nsamples(12);
0071 if (useDSTRAW) ctbIHCal->set_offlineflag();
0072 ctbIHCal->set_softwarezerosuppression(true, 200);
0073 se->registerSubsystem(ctbIHCal);
0074
0075 CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0076 ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0077 ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0078 ctbOHCal->set_builder_type(buildertype);
0079 ctbOHCal->set_nsamples(12);
0080 if (useDSTRAW) ctbOHCal->set_offlineflag();
0081 ctbOHCal->set_softwarezerosuppression(true, 200);
0082 se->registerSubsystem(ctbOHCal);
0083
0084 CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0085 statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0086 statusHCalIn->set_time_cut(10);
0087 se->registerSubsystem(statusHCalIn);
0088
0089 CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0090 statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0091 statusHCALOUT->set_time_cut(10);
0092 se->registerSubsystem(statusHCALOUT);
0093
0094
0095
0096 std::cout << "Calibrating OHcal" << std::endl;
0097 CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0098 calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0099 se->registerSubsystem(calibOHCal);
0100
0101 std::cout << "Calibrating IHcal" << std::endl;
0102 CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0103 calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0104 se->registerSubsystem(calibIHCal);
0105
0106
0107 Fun4AllInputManager *In = nullptr;
0108 ifstream infile;
0109 infile.open(inlist);
0110 int iman = 0;
0111 std::string line;
0112 bool first{true};
0113 int runnumber = 0;
0114 int segment = 99999;
0115 if (infile.is_open())
0116 {
0117 while (std::getline(infile, line))
0118 {
0119 if (line[0] == '#')
0120 {
0121 std::cout << "found commented out line " << line << std::endl;
0122 continue;
0123 }
0124
0125 if (first)
0126 {
0127 pair<int, int> runseg = Fun4AllUtils::GetRunSegment(line);
0128 runnumber = runseg.first;
0129 segment = runseg.second;
0130 rc->set_uint64Flag("TIMESTAMP", runnumber);
0131 first = false;
0132 }
0133 std::string magname = "DSTin_" + std::to_string(iman);
0134 In = new Fun4AllDstInputManager(magname);
0135 In->Verbosity(1);
0136 In->AddFile(line);
0137 se->registerInputManager(In);
0138 iman++;
0139 }
0140 infile.close();
0141 }
0142 std::cout << "Adding Geometry file" << std::endl;
0143 Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0144 std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0145 intrue2->AddFile(geoLocation);
0146 se->registerInputManager(intrue2);
0147
0148
0149
0150 char outfile_hist[500];
0151 sprintf(outfile_hist, "%s-%08d-%05d.root", outfile_hist2.c_str(), runnumber, segment);
0152 HCalCosmics *wt2 = new HCalCosmics("HCalCalib_HCALIN", outfile_hist);
0153 wt2->set_tower_threshold(0.2498);
0154 wt2->set_vert_threshold(0.2498);
0155 wt2->set_veto_threshold(0.17486);
0156 wt2->HistBinWidth(0.01);
0157 wt2->Detector("HCALIN");
0158 wt2->TowerPrefix("TOWERINFO_CALIB_");
0159 se->registerSubsystem(wt2);
0160
0161 sprintf(outfile_hist, "%s-%08d-%05d.root", outfile_hist1.c_str(), runnumber, segment);
0162 HCalCosmics *wt3 = new HCalCosmics("HCalCosmics_HCALOUT", outfile_hist);
0163 wt3->set_tower_threshold(1.665);
0164 wt3->set_vert_threshold(1.665);
0165 wt3->set_veto_threshold(1.1655);
0166 wt3->HistBinWidth(0.05);
0167 wt3->Detector("HCALOUT");
0168 wt3->TowerPrefix("TOWERINFO_CALIB_");
0169 se->registerSubsystem(wt3);
0170
0171
0172
0173 char dstoutfile[500];
0174 sprintf(dstoutfile, "%s-%08d-%05d.root", outfile.c_str(), runnumber, segment);
0175 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", dstoutfile);
0176 out->StripCompositeNode("Packets");
0177 se->registerOutputManager(out);
0178
0179 se->run(nEvents);
0180 se->End();
0181 CDBInterface::instance()->Print();
0182 se->PrintTimer();
0183 delete se;
0184
0185 std::cout << "All done!" << std::endl;
0186 gSystem->Exit(0);
0187 }
0188
0189 #endif