File indexing completed on 2025-12-16 09:24:01
0001 #ifndef FUN4ALL_HCALCOSMICS_C
0002 #define FUN4ALL_HCALCOSMICS_C
0003
0004 #include <calovalid/CaloValid.h>
0005
0006 #include <litecaloeval/HCalCosmics.h>
0007
0008 #include <caloreco/CaloTowerBuilder.h>
0009 #include <caloreco/CaloTowerCalib.h>
0010 #include <caloreco/CaloTowerStatus.h>
0011 #include <caloreco/CaloWaveformProcessing.h>
0012
0013 #include <ffamodules/CDBInterface.h>
0014 #include <ffamodules/FlagHandler.h>
0015 #include <ffamodules/HeadReco.h>
0016 #include <ffamodules/SyncReco.h>
0017
0018 #include <fun4allraw/Fun4AllPrdfInputManager.h>
0019
0020 #include <fun4all/Fun4AllDstInputManager.h>
0021 #include <fun4all/Fun4AllDstOutputManager.h>
0022 #include <fun4all/Fun4AllInputManager.h>
0023 #include <fun4all/Fun4AllRunNodeInputManager.h>
0024 #include <fun4all/Fun4AllServer.h>
0025 #include <fun4all/Fun4AllUtils.h>
0026 #include <fun4all/SubsysReco.h>
0027
0028 #include <phool/recoConsts.h>
0029
0030 #include <Rtypes.h> // for R__LOAD_LIBRARY
0031 #include <TSystem.h>
0032
0033 R__LOAD_LIBRARY(libfun4all.so)
0034 R__LOAD_LIBRARY(libfun4allraw.so)
0035 R__LOAD_LIBRARY(libcalo_reco.so)
0036 R__LOAD_LIBRARY(libcentrality.so)
0037 R__LOAD_LIBRARY(libffamodules.so)
0038 R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so)
0039
0040 void Fun4All_HCalCosmics(int nEvents = 100,
0041 const std::string &fname = "DST_TRIGGERED_EVENT_run2pp_new_2024p003-00048185-0000.root",
0042 const std::string &outfile = "DST_CALOFITTING-00000000-000000.root",
0043 const std::string& outfile_hist1= "HIST_HCALOUT-00000000-000000.root",
0044 const std::string& outfile_hist2= "HIST_HCALIN-00000000-000000.root",
0045 const std::string &dbtag = "ProdA_2024")
0046 {
0047 bool useDSTRAW = true;
0048
0049
0050
0051 CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2;
0052
0053
0054
0055 Fun4AllServer *se = Fun4AllServer::instance();
0056 se->Verbosity(0);
0057
0058 recoConsts *rc = recoConsts::instance();
0059
0060 std::pair<int, int> runseg = Fun4AllUtils::GetRunSegment(fname);
0061 int runnumber = runseg.first;
0062
0063
0064 rc->set_StringFlag("CDB_GLOBALTAG", dbtag);
0065 rc->set_uint64Flag("TIMESTAMP", runnumber);
0066 CDBInterface::instance()->Verbosity(1);
0067
0068 FlagHandler *flag = new FlagHandler();
0069 se->registerSubsystem(flag);
0070
0071
0072
0073 CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER");
0074 ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0075 ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0076 ctbIHCal->set_builder_type(buildertype);
0077 ctbIHCal->set_nsamples(12);
0078 if (useDSTRAW) ctbIHCal->set_offlineflag();
0079 ctbIHCal->set_softwarezerosuppression(true, 200);
0080 se->registerSubsystem(ctbIHCal);
0081
0082 CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER");
0083 ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0084 ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE);
0085 ctbOHCal->set_builder_type(buildertype);
0086 ctbOHCal->set_nsamples(12);
0087 if (useDSTRAW) ctbOHCal->set_offlineflag();
0088 ctbOHCal->set_softwarezerosuppression(true, 200);
0089 se->registerSubsystem(ctbOHCal);
0090
0091 CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS");
0092 statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN);
0093 statusHCalIn->set_time_cut(10);
0094 se->registerSubsystem(statusHCalIn);
0095
0096 CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS");
0097 statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT);
0098 statusHCALOUT->set_time_cut(10);
0099 se->registerSubsystem(statusHCALOUT);
0100
0101
0102
0103 std::cout << "Calibrating OHcal" << std::endl;
0104 CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT");
0105 calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT);
0106 se->registerSubsystem(calibOHCal);
0107
0108 std::cout << "Calibrating IHcal" << std::endl;
0109 CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN");
0110 calibIHCal->set_detector_type(CaloTowerDefs::HCALIN);
0111 se->registerSubsystem(calibIHCal);
0112
0113 std::cout << "Adding Geometry file" << std::endl;
0114 Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO");
0115 std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo");
0116 intrue2->AddFile(geoLocation);
0117 se->registerInputManager(intrue2);
0118
0119
0120
0121 HCalCosmics *wt2 = new HCalCosmics("HCalCalib_HCALIN",outfile_hist2);
0122 wt2->set_tower_threshold(0.2498);
0123 wt2->set_vert_threshold(0.2498);
0124 wt2->set_veto_threshold(0.17486);
0125 wt2->HistBinWidth(0.01);
0126 wt2->Detector("HCALIN");
0127 wt2->TowerPrefix("TOWERINFO_CALIB_");
0128 se->registerSubsystem(wt2);
0129
0130 HCalCosmics *wt3 = new HCalCosmics("HCalCosmics_HCALOUT",outfile_hist1);
0131 wt3->set_tower_threshold(1.665);
0132 wt3->set_vert_threshold(1.665);
0133 wt3->set_veto_threshold(1.1655);
0134 wt3->HistBinWidth(0.05);
0135 wt3->Detector("HCALOUT");
0136 wt3->TowerPrefix("TOWERINFO_CALIB_");
0137 se->registerSubsystem(wt3);
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148 Fun4AllInputManager *In;
0149 if(!useDSTRAW) In = new Fun4AllPrdfInputManager("in");
0150 if(useDSTRAW) In = new Fun4AllDstInputManager("in");
0151 In->AddFile(fname);
0152 se->registerInputManager(In);
0153
0154 Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile);
0155 out->StripNode("CEMCPackets");
0156 out->StripNode("HCALPackets");
0157 out->StripNode("ZDCPackets");
0158 out->StripNode("SEPDPackets");
0159 out->StripNode("MBDPackets");
0160 se->registerOutputManager(out);
0161
0162 se->run(nEvents);
0163 se->End();
0164 CDBInterface::instance()->Print();
0165 se->PrintTimer();
0166 delete se;
0167
0168 std::cout << "All done!" << std::endl;
0169 gSystem->Exit(0);
0170 }
0171
0172 #endif