diff --git a/run2auau/CaloProduction/Fun4All_HCalCosmics.C b/run2auau/CaloProduction/Fun4All_HCalCosmics.C new file mode 100644 index 0000000..4ad40be --- /dev/null +++ b/run2auau/CaloProduction/Fun4All_HCalCosmics.C @@ -0,0 +1,164 @@ +#ifndef FUN4ALL_YEAR1_C +#define FUN4ALL_YEAR1_C + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libfun4allraw.so) +R__LOAD_LIBRARY(libcalo_reco.so) +R__LOAD_LIBRARY(libcentrality.so) +R__LOAD_LIBRARY(libffamodules.so) +R__LOAD_LIBRARY(libLiteCaloEvalTowSlope.so) + +void Fun4All_HCalCosmics(int nEvents = 0, + const std::string &fname = "dst_triggered_raw_cosmics-00040174.list", + const std::string& outdir = ".", + const std::string& outfile = "DST_HCAL_TOWERS_cosmics", + const std::string& outfile1 = "HIST1", + const std::string& outfile2 = "HIST2" + ) +{ + bool useDSTRAW = true; + // v1 uncomment: + // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs:::kPRDFTowerv1; + // v2 uncomment: + CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2; + // v3 uncomment: + // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform; + + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(0); + + recoConsts *rc = recoConsts::instance(); + + ifstream file(fname); + std::string first_file; + getline(file, first_file); + + + pair runseg = Fun4AllUtils::GetRunSegment(first_file); + int runnumber = runseg.first; + int segment = runseg.second; + + std::string outfile_hist1 = "HIST_HCALOUT_" + outfile1; + std::string outfile_hist2 = "HIST_HCALIN_" + outfile2; + + std::string fulloutfile = std::string("./") + outfile; + std::string fulloutfile_hist1 = std::string("./") + outfile_hist1; + std::string fulloutfile_hist2 = std::string("./") + outfile_hist2; + + //=============== + // conditions DB flags + //=============== + // ENABLE::CDB = true; + // global tag + rc->set_StringFlag("CDB_GLOBALTAG", "ProdA_2023"); + // // 64 bit timestamp + rc->set_uint64Flag("TIMESTAMP", runnumber); + CDBInterface::instance()->Verbosity(1); + + FlagHandler *flag = new FlagHandler(); + se->registerSubsystem(flag); + + + ///////////////// + // build towers + CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER"); + ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN); + ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbIHCal->set_builder_type(buildertype); + //ctbIHCal->set_nsamples(31); + if (useDSTRAW) ctbIHCal->set_offlineflag(); + ctbIHCal->set_softwarezerosuppression(true, 200); + se->registerSubsystem(ctbIHCal); + + CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER"); + ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT); + ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbOHCal->set_builder_type(buildertype); + //ctbOHCal->set_nsamples(31); + if (useDSTRAW) ctbOHCal->set_offlineflag(); + ctbOHCal->set_softwarezerosuppression(true, 200); + se->registerSubsystem(ctbOHCal); + + //////////////////// + // Calibrate towers + std::cout << "Calibrating OHcal" << std::endl; + CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT"); + calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT); + se->registerSubsystem(calibOHCal); + + std::cout << "Calibrating IHcal" << std::endl; + CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN"); + calibIHCal->set_detector_type(CaloTowerDefs::HCALIN); + se->registerSubsystem(calibIHCal); + + std::cout << "Adding Geometry file" << std::endl; + Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO"); + std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo"); + intrue2->AddFile(geoLocation); + se->registerInputManager(intrue2); + + /////////////////////////////////////////// + // Cosmics histMaker + HCalCosmics *wt2 = new HCalCosmics("HCalCalib_HCALIN",fulloutfile_hist2); + wt2->Detector("HCALIN"); + se->registerSubsystem(wt2); + + HCalCosmics *wt3 = new HCalCosmics("HCalCosmics_HCALOUT",fulloutfile_hist1); + wt3->Detector("HCALOUT"); + se->registerSubsystem(wt3); + +/* + /////////////////////////////////// + // Validation + CaloValid *ca = new CaloValid("calomodulename",fulloutfile_hist); + ca->set_timing_cut_width(200); //integers for timing width, > 1 : wider cut around max peak time + ca->apply_vertex_cut(false); + ca->set_vertex_cut(20.); + se->registerSubsystem(ca); +*/ + + Fun4AllInputManager *In; + if(!useDSTRAW) In = new Fun4AllPrdfInputManager("in"); + if(useDSTRAW) In = new Fun4AllDstInputManager("in"); + In->AddListFile(fname); + se->registerInputManager(In); + + Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fulloutfile); + se->registerOutputManager(out); + + se->run(nEvents); + se->End(); + CDBInterface::instance()->Print(); // print used DB files + se->PrintTimer(); + delete se; + + std::cout << "All done!" << std::endl; + gSystem->Exit(0); +} + +#endif diff --git a/run2auau/CaloProduction/Fun4All_Year2.C b/run2auau/CaloProduction/Fun4All_Year2.C new file mode 100644 index 0000000..983a216 --- /dev/null +++ b/run2auau/CaloProduction/Fun4All_Year2.C @@ -0,0 +1,317 @@ +#ifndef FUN4ALL_YEAR1_C +#define FUN4ALL_YEAR1_C + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libfun4allraw.so) +R__LOAD_LIBRARY(libcalo_reco.so) +R__LOAD_LIBRARY(libcalotrigger.so) +R__LOAD_LIBRARY(libcentrality.so) +R__LOAD_LIBRARY(libffamodules.so) +R__LOAD_LIBRARY(libmbd.so) +R__LOAD_LIBRARY(libzdcinfo.so) +R__LOAD_LIBRARY(libglobalvertex.so) +R__LOAD_LIBRARY(libcalovalid.so) +R__LOAD_LIBRARY(libglobalQA.so) + +void Fun4All_Year2(int nEvents=0, + const std::string &fname = "/sphenix/lustre01/sphnxpro/commissioning/slurp/calobeam/run_00040700_00040800/DST_TRIGGERED_RAW_beam_new_2023p015-00040797-0001.root", + const std::string& outfile="", + const std::string& outfile_hist="", + const std::string& dbtag="-nope-" + ) +{ + bool addZeroSupCaloNodes = 0; + // v1 uncomment: + // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv1; + // v2 uncomment: + // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kWaveformTowerv2; + CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv4; + // v3 uncomment: + // CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFWaveform; + + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(0); + + recoConsts *rc = recoConsts::instance(); + + pair runseg = Fun4AllUtils::GetRunSegment(fname); + int runnumber = runseg.first; + int segment = runseg.second; +// char outfile[100]; +// char outfile_hist[100]; +// sprintf(outfile, "DST_CALOR-%08d-%04d.root", runnumber, segment); +// sprintf(outfile_hist, "HIST_CALOR-%08d-%04d.root", runnumber, segment); + string fulloutfile = string("./") + outfile; + string fulloutfile_hist = string("./") + outfile_hist; + //=============== + // conditions DB flags + //=============== + // ENABLE::CDB = true; + // global tag + rc->set_StringFlag("CDB_GLOBALTAG", dbtag ); + // // 64 bit timestamp + rc->set_uint64Flag("TIMESTAMP", runnumber); + CDBInterface::instance()->Verbosity(1); + + FlagHandler *flag = new FlagHandler(); + se->registerSubsystem(flag); + + // MBD/BBC Reconstruction + MbdReco *mbdreco = new MbdReco(); + se->registerSubsystem(mbdreco); + + CaloTowerBuilder *caZDC = new CaloTowerBuilder("ZDCBUILDER"); + caZDC->set_detector_type(CaloTowerDefs::ZDC); + caZDC->set_builder_type(buildertype); + caZDC->set_processing_type(CaloWaveformProcessing::FAST); + caZDC->set_nsamples(16); + caZDC->set_offlineflag(); + se->registerSubsystem(caZDC); + + //ZDC Reconstruction--Calib Info + ZdcReco *zdcreco = new ZdcReco(); + se->registerSubsystem(zdcreco); + + // Official vertex storage + GlobalVertexReco *gvertex = new GlobalVertexReco(); + se->registerSubsystem(gvertex); + + ///////////////// + // build towers + CaloTowerBuilder *ctbEMCal = new CaloTowerBuilder("EMCalBUILDER"); + ctbEMCal->set_detector_type(CaloTowerDefs::CEMC); + ctbEMCal->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbEMCal->set_builder_type(buildertype); + ctbEMCal->set_offlineflag(true); + ctbEMCal->set_nsamples(12); + ctbEMCal->set_bitFlipRecovery(true); + se->registerSubsystem(ctbEMCal); + + CaloTowerBuilder *ctbIHCal = new CaloTowerBuilder("HCALINBUILDER"); + ctbIHCal->set_detector_type(CaloTowerDefs::HCALIN); + ctbIHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbIHCal->set_builder_type(buildertype); + ctbIHCal->set_offlineflag(); + ctbIHCal->set_nsamples(12); + ctbIHCal->set_bitFlipRecovery(true); + se->registerSubsystem(ctbIHCal); + + CaloTowerBuilder *ctbOHCal = new CaloTowerBuilder("HCALOUTBUILDER"); + ctbOHCal->set_detector_type(CaloTowerDefs::HCALOUT); + ctbOHCal->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbOHCal->set_builder_type(buildertype); + ctbOHCal->set_offlineflag(); + ctbOHCal->set_nsamples(12); + ctbOHCal->set_bitFlipRecovery(true); + se->registerSubsystem(ctbOHCal); + + CaloTowerBuilder *caEPD = new CaloTowerBuilder("SEPDBUILDER"); + caEPD->set_detector_type(CaloTowerDefs::SEPD); + caEPD->set_builder_type(buildertype); + caEPD->set_processing_type(CaloWaveformProcessing::FAST); + caEPD->set_nsamples(12); + caEPD->set_offlineflag(); + se->registerSubsystem(caEPD); + + + ////////////////////////////// + // set statuses on raw towers + + std::cout << "status setters" << std::endl; + CaloTowerStatus *statusEMC = new CaloTowerStatus("CEMCSTATUS"); + statusEMC->set_detector_type(CaloTowerDefs::CEMC); + statusEMC->set_time_cut(1); + se->registerSubsystem(statusEMC); + + CaloTowerStatus *statusHCalIn = new CaloTowerStatus("HCALINSTATUS"); + statusHCalIn->set_detector_type(CaloTowerDefs::HCALIN); + statusHCalIn->set_time_cut(2); + se->registerSubsystem(statusHCalIn); + + CaloTowerStatus *statusHCALOUT = new CaloTowerStatus("HCALOUTSTATUS"); + statusHCALOUT->set_detector_type(CaloTowerDefs::HCALOUT); + statusHCALOUT->set_time_cut(2); + se->registerSubsystem(statusHCALOUT); + + //////////////////// + // Calibrate towers + std::cout << "Calibrating EMCal" << std::endl; + CaloTowerCalib *calibEMC = new CaloTowerCalib("CEMCCALIB"); + calibEMC->set_detector_type(CaloTowerDefs::CEMC); + se->registerSubsystem(calibEMC); + + std::cout << "Calibrating OHcal" << std::endl; + CaloTowerCalib *calibOHCal = new CaloTowerCalib("HCALOUT"); + calibOHCal->set_detector_type(CaloTowerDefs::HCALOUT); + se->registerSubsystem(calibOHCal); + + std::cout << "Calibrating IHcal" << std::endl; + CaloTowerCalib *calibIHCal = new CaloTowerCalib("HCALIN"); + calibIHCal->set_detector_type(CaloTowerDefs::HCALIN); + se->registerSubsystem(calibIHCal); + + std::cout << "Calibrating ZDC" << std::endl; + CaloTowerCalib *calibZDC = new CaloTowerCalib("ZDC"); + calibZDC->set_detector_type(CaloTowerDefs::ZDC); + se->registerSubsystem(calibZDC); + + ///////////////////// + // Geometry + std::cout << "Adding Geometry file" << std::endl; + Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO"); + std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo"); + intrue2->AddFile(geoLocation); + se->registerInputManager(intrue2); + + ////////////////// + // Clusters + + std::cout << "Building clusters" << std::endl; + RawClusterBuilderTemplate *ClusterBuilder = new RawClusterBuilderTemplate("EmcRawClusterBuilderTemplate"); + ClusterBuilder->Detector("CEMC"); + ClusterBuilder->set_threshold_energy(0.030); // for when using basic calibration + std::string emc_prof = getenv("CALIBRATIONROOT"); + emc_prof += "/EmcProfile/CEMCprof_Thresh30MeV.root"; + ClusterBuilder->LoadProfile(emc_prof); + ClusterBuilder->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower + se->registerSubsystem(ClusterBuilder); + + std::cout << "Applying Position Dependent Correction" << std::endl; + RawClusterPositionCorrection *clusterCorrection = new RawClusterPositionCorrection("CEMC"); + clusterCorrection->set_UseTowerInfo(1); // to use towerinfo objects rather than old RawTower + se->registerSubsystem(clusterCorrection); + + /////////////////////////////////////////// + // Calo node with software zero supression + if (addZeroSupCaloNodes) + { + CaloTowerBuilder *ctbEMCal_SZ = new CaloTowerBuilder("EMCalBUILDER_ZS"); + ctbEMCal_SZ->set_detector_type(CaloTowerDefs::CEMC); + ctbEMCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbEMCal_SZ->set_nsamples(8); + ctbEMCal_SZ->set_offlineflag(); + ctbEMCal_SZ->set_outputNodePrefix("TOWERS_SZ_"); + ctbEMCal_SZ->set_softwarezerosuppression(true, 100000000); + se->registerSubsystem(ctbEMCal_SZ); + + CaloTowerBuilder *ctbIHCal_SZ = new CaloTowerBuilder("HCALINBUILDER_ZS"); + ctbIHCal_SZ->set_detector_type(CaloTowerDefs::HCALIN); + ctbIHCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbIHCal_SZ->set_offlineflag(); + ctbIHCal_SZ->set_nsamples(8); + ctbIHCal_SZ->set_outputNodePrefix("TOWERS_SZ_"); + ctbIHCal_SZ->set_softwarezerosuppression(true, 100000000); + se->registerSubsystem(ctbIHCal_SZ); + + CaloTowerBuilder *ctbOHCal_SZ = new CaloTowerBuilder("HCALOUTBUILDER_SZ"); + ctbOHCal_SZ->set_detector_type(CaloTowerDefs::HCALOUT); + ctbOHCal_SZ->set_processing_type(CaloWaveformProcessing::TEMPLATE); + ctbIHCal_SZ->set_nsamples(8); + ctbOHCal_SZ->set_offlineflag(); + ctbOHCal_SZ->set_outputNodePrefix("TOWERS_SZ_"); + ctbOHCal_SZ->set_softwarezerosuppression(true, 100000000); + se->registerSubsystem(ctbOHCal_SZ); + + CaloTowerCalib *calibEMC_SZ = new CaloTowerCalib("CEMCCALIB_SZ"); + calibEMC_SZ->set_detector_type(CaloTowerDefs::CEMC); + calibEMC_SZ->set_inputNodePrefix("TOWERS_SZ_"); + calibEMC_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_"); + se->registerSubsystem(calibEMC_SZ); + + CaloTowerCalib *calibIHCal_SZ = new CaloTowerCalib("IHCALCALIB_SZ"); + calibIHCal_SZ->set_detector_type(CaloTowerDefs::HCALIN); + calibIHCal_SZ->set_inputNodePrefix("TOWERS_SZ_"); + calibIHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_"); + se->registerSubsystem(calibIHCal_SZ); + + CaloTowerCalib *calibOHCal_SZ = new CaloTowerCalib("OHCALCALIB_SZ"); + calibOHCal_SZ->set_detector_type(CaloTowerDefs::HCALOUT); + calibOHCal_SZ->set_inputNodePrefix("TOWERS_SZ_"); + calibOHCal_SZ->set_outputNodePrefix("TOWERINFO_SZ_CALIB_"); + se->registerSubsystem(calibOHCal_SZ); + } + + ///////////////// + // Centrality + //MinimumBiasClassifier *minimumbiasclassifier = new MinimumBiasClassifier(); + //se->registerSubsystem(minimumbiasclassifier); +// + //CentralityReco *centralityreco = new CentralityReco(); + //se->registerSubsystem(centralityreco); + + /////////////////////////////////// + // Validation + CaloValid *ca = new CaloValid("CaloValid"); + ca->set_timing_cut_width(200); //integers for timing width, > 1 : wider cut around max peak time + se->registerSubsystem(ca); + + GlobalQA *gqa = new GlobalQA("GlobalQA"); + se->registerSubsystem(gqa); + + Fun4AllInputManager *In = new Fun4AllDstInputManager("in"); + In->AddFile(fname); + se->registerInputManager(In); + + Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", fulloutfile); + out->StripNode("CEMCPackets"); + out->StripNode("HCALPackets"); + out->StripNode("ZDCPackets"); + out->StripNode("SEPDPackets"); + out->StripNode("MBDPackets"); + se->registerOutputManager(out); + + se->run(nEvents); + se->End(); + + TString qaname = fulloutfile_hist + "_qa.root"; + std::string qaOutputFileName(qaname.Data()); + QAHistManagerDef::saveQARootFile(qaOutputFileName); + + CDBInterface::instance()->Print(); // print used DB files + se->PrintTimer(); + delete se; + std::cout << "All done!" << std::endl; + gSystem->Exit(0); +} + +#endif diff --git a/run2auau/CaloProduction/Fun4All_Year2_Calib.C b/run2auau/CaloProduction/Fun4All_Year2_Calib.C new file mode 100644 index 0000000..9e15a3f --- /dev/null +++ b/run2auau/CaloProduction/Fun4All_Year2_Calib.C @@ -0,0 +1,142 @@ +#ifndef FUN4ALL_YEAR2_C +#define FUN4ALL_YEAR2_C + +#include +#include + +#include + +#include + +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include + +#include +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libfun4allraw.so) +R__LOAD_LIBRARY(libcalo_reco.so) +R__LOAD_LIBRARY(libcalotrigger.so) +R__LOAD_LIBRARY(libcentrality.so) +R__LOAD_LIBRARY(libffamodules.so) +R__LOAD_LIBRARY(libmbd.so) +R__LOAD_LIBRARY(libepd.so) +R__LOAD_LIBRARY(libzdcinfo.so) +R__LOAD_LIBRARY(libglobalvertex.so) +R__LOAD_LIBRARY(libcalovalid.so) +R__LOAD_LIBRARY(libglobalQA.so) + +void Fun4All_Year2_Calib(int nEvents=100, + const std::string &fname = "DST_CALOFITTING-00000000-000000.root", + const std::string& outfile= "DST_CALO-00000000-000000.root", + const std::string& outfile_hist= "HIST_CALOQA-00000000-000000.root", + const std::string& dbtag= "ProdA_2024" + ) +{ + // towerinfov1=kPRDFTowerv1, v2=:kWaveformTowerv2, v3=kPRDFWaveform, v4=kPRDFTowerv4 + CaloTowerDefs::BuilderType buildertype = CaloTowerDefs::kPRDFTowerv4; + + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(1); + + recoConsts *rc = recoConsts::instance(); + + pair runseg = Fun4AllUtils::GetRunSegment(fname); + int runnumber = runseg.first; + + // conditions DB flags and timestamp + rc->set_StringFlag("CDB_GLOBALTAG", dbtag); + rc->set_uint64Flag("TIMESTAMP", runnumber); + CDBInterface::instance()->Verbosity(1); + + FlagHandler *flag = new FlagHandler(); + se->registerSubsystem(flag); + + // MBD/BBC Reconstruction + MbdReco *mbdreco = new MbdReco(); + se->registerSubsystem(mbdreco); + + //sEPD Reconstruction--Calib Info + EpdReco *epdreco = new EpdReco(); + se->registerSubsystem(epdreco); + + //ZDC Reconstruction--Calib Info + ZdcReco *zdcreco = new ZdcReco(); + zdcreco->set_zdc1_cut(0.0); + zdcreco->set_zdc2_cut(0.0); + se->registerSubsystem(zdcreco); + + // Official vertex storage + GlobalVertexReco *gvertex = new GlobalVertexReco(); + se->registerSubsystem(gvertex); + + ///////////////////// + // Geometry + std::cout << "Adding Geometry file" << std::endl; + Fun4AllInputManager *intrue2 = new Fun4AllRunNodeInputManager("DST_GEO"); + std::string geoLocation = CDBInterface::instance()->getUrl("calo_geo"); + intrue2->AddFile(geoLocation); + se->registerInputManager(intrue2); + + + ///////////////////////////////////////////////////// + // Set status of towers, Calibrate towers, Cluster + Process_Calo_Calib(); + + /////////////////////////////////// + // Validation + CaloValid *ca = new CaloValid("CaloValid"); + ca->set_timing_cut_width(200); + se->registerSubsystem(ca); + + GlobalQA *gqa = new GlobalQA("GlobalQA"); + se->registerSubsystem(gqa); + + Fun4AllInputManager *In = new Fun4AllDstInputManager("in"); + In->AddFile(fname); + se->registerInputManager(In); + + Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile); + out->StripNode("TOWERS_CEMC"); + out->StripNode("TOWERS_HCALIN"); + out->StripNode("TOWERS_HCALOUT"); + out->StripNode("TOWERS_ZDC"); + out->StripNode("TOWERS_SEPD"); + out->StripNode("MBDPackets"); + se->registerOutputManager(out); + + se->run(nEvents); + se->End(); + + QAHistManagerDef::saveQARootFile(outfile_hist); + + CDBInterface::instance()->Print(); // print used DB files + se->PrintTimer(); + delete se; + std::cout << "All done!" << std::endl; + gSystem->Exit(0); +} + +#endif diff --git a/run2auau/CaloProduction/Fun4All_Year2_Fitting.C b/run2auau/CaloProduction/Fun4All_Year2_Fitting.C new file mode 100644 index 0000000..b8848b2 --- /dev/null +++ b/run2auau/CaloProduction/Fun4All_Year2_Fitting.C @@ -0,0 +1,67 @@ +#ifndef FUN4ALL_YEAR2_FITTING_C +#define FUN4ALL_YEAR2_FITTING_C + +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +R__LOAD_LIBRARY(libfun4all.so) +R__LOAD_LIBRARY(libfun4allraw.so) +// this pass containis the reco process that's stable wrt time stamps(raw tower building) +void Fun4All_Year2_Fitting(int nEvents = 100, + const std::string &fname = "DST_TRIGGERED_EVENT_run2pp_new_2024p003-00048185-0000.root", + const std::string &outfile = "DST_CALOFITTING-00000000-000000.root", + const std::string &dbtag = "ProdA_2024") +{ + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(1); + + recoConsts *rc = recoConsts::instance(); + + pair runseg = Fun4AllUtils::GetRunSegment(fname); + int runnumber = runseg.first; + + // conditions DB flags and timestamp + rc->set_StringFlag("CDB_GLOBALTAG", dbtag); + rc->set_uint64Flag("TIMESTAMP", runnumber); + CDBInterface::instance()->Verbosity(1); + + FlagHandler *flag = new FlagHandler(); + se->registerSubsystem(flag); + + Process_Calo_Fitting(); + + Fun4AllInputManager *In = new Fun4AllDstInputManager("in"); + In->AddFile(fname); + se->registerInputManager(In); + + Fun4AllDstOutputManager *out = new Fun4AllDstOutputManager("DSTOUT", outfile); + out->StripNode("CEMCPackets"); + out->StripNode("HCALPackets"); + out->StripNode("ZDCPackets"); + out->StripNode("SEPDPackets"); + se->registerOutputManager(out); + + se->run(nEvents); + se->End(); + + CDBInterface::instance()->Print(); // print used DB files + se->PrintTimer(); + delete se; + std::cout << "All done!" << std::endl; + gSystem->Exit(0); +} +#endif \ No newline at end of file diff --git a/run2auau/CaloProduction/GetEntries.C b/run2auau/CaloProduction/GetEntries.C new file mode 100644 index 0000000..077fe94 --- /dev/null +++ b/run2auau/CaloProduction/GetEntries.C @@ -0,0 +1,26 @@ +#ifndef MACRO_GETENTRIES_C +#define MACRO_GETENTRIES_C +#include +R__LOAD_LIBRARY(libFROG.so) +void GetEntries(const std::string &file) +{ + gSystem->Load("libFROG.so"); + gSystem->Load("libg4dst.so"); + // prevent root to start gdb-backtrace.sh + // in case of crashes, it hangs the condor job + for (int i = 0; i < kMAXSIGNALS; i++) + { + gSystem->IgnoreSignal((ESignals)i); + } + FROG *fr = new FROG(); + TFile *f = TFile::Open(fr->location(file)); + cout << "Getting events for " << file << endl; + TTree *T = (TTree *) f->Get("T"); + int nEntries = -1; + if (T) + { + nEntries = T->GetEntries(); + } + cout << "Number of Entries: " << nEntries << endl; +}; +#endif diff --git a/run2auau/CaloProduction/run.sh b/run2auau/CaloProduction/run.sh new file mode 100644 index 0000000..bbe4197 --- /dev/null +++ b/run2auau/CaloProduction/run.sh @@ -0,0 +1,91 @@ +#!/usr/bin/bash + +nevents=${1} +outbase=${2} +logbase=${3} +runnumber=${4} +segment=${5} +outdir=${6} +build=${7/./} +dbtag=${8} +inputs=(`echo ${9} | tr "," " "`) # array of input files +ranges=(`echo ${10} | tr "," " "`) # array of input files with ranges appended +neventsper=${11:-1000} +#----- +export cupsid=${@: -1} + +{ + +export USER="$(id -u -n)" +export LOGNAME=${USER} +export HOME=/sphenix/u/${USER} +hostname + +source /opt/sphenix/core/bin/sphenix_setup.sh -n ${7} + +export ODBCINI=./odbc.ini + +#______________________________________________________________________________________ started __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} started +#_________________________________________________________________________________________________ + +echo .............................................................................................. +echo $@ +echo .............................................................................................. +echo nevents: $nevents +echo outbase: $outbase +echo logbase: $logbase +echo runnumb: $runnumber +echo segment: $segment +echo outdir: $outdir +echo build: $build +echo dbtag: $dbtag +echo inputs: ${inputs[@]} +echo nper: $neventsper +echo .............................................................................................. + +ls ${inputs[@]} > input.list + +#______________________________________________________________________________________ running __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} inputs --files ${inputlist} +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} running +#_________________________________________________________________________________________________ + + + +out0=${logbase}.root +out1=HIST_HCALOUT_${logbase#DST_}.root +out2=HIST_HCALIN_${logbase#DST_}.root + + +echo root.exe -q -b Fun4All_HCalCosmics.C\(${nevents},\"input.list\",\"${outdir}\",\"${out0}\",\"${out1}\",\"${out2}\"\); + root.exe -q -b Fun4All_HCalCosmics.C\(${nevents},\"input.list\",\"${outdir}\",\"${out0}\",\"${out1}\",\"${out2}\"\); + + +ls -lah + + # Stage each output file to output directory + for filename in *.root; do + echo Stageout $filename + ./stageout.sh ${filename} ${outdir} + done + + + +#______________________________________________________________________________________ finished __ +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents 0 --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents 0 --inc +#_________________________________________________________________________________________________ + + + +echo "bdee bdee bdee, That's All Folks!" +} >${logbase}.out 2>${logbase}.err + +exit ${status_f4a} + + + + diff --git a/run2auau/CaloProduction/runy2.sh b/run2auau/CaloProduction/runy2.sh new file mode 100644 index 0000000..4185884 --- /dev/null +++ b/run2auau/CaloProduction/runy2.sh @@ -0,0 +1,119 @@ +#!/usr/bin/bash + +nevents=${1} +outbase=${2} +logbase=${3} +runnumber=${4} +segment=${5} +outdir=${6} +build=${7/./} +dbtag=${8} +inputs=(`echo ${9} | tr "," " "`) # array of input files +ranges=(`echo ${10} | tr "," " "`) # array of input files with ranges appended +neventsper=${11:-1000} +logdir=${12:-.} +histdir=${13:-.} +#----- +export cupsid=${@: -1} + +sighandler() +{ +echo "signal handler" +mv ${logbase}.out ${logdir#file:/} +mv ${logbase}.err ${logdir#file:/} +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents 0 --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e 255 --nevents 0 +} + +# On evict (term,stp) or hold (kill) branch to signal handler +trap sighandler SIGTERM SIGINT SIGKILL + +{ + +export USER="$(id -u -n)" +export LOGNAME=${USER} +export HOME=/sphenix/u/${USER} +hostname + +source /opt/sphenix/core/bin/sphenix_setup.sh -n ${7} + +export ODBCINI=./odbc.ini + +#______________________________________________________________________________________ started __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} started +#_________________________________________________________________________________________________ + +echo .............................................................................................. +echo $@ +echo .............................................................................................. +echo nevents: $nevents +echo outbase: $outbase +echo logbase: $logbase +echo runnumb: $runnumber +echo segment: $segment +echo outdir: $outdir +echo build: $build +echo dbtag: $dbtag +echo inputs: ${inputs[@]} +echo nper: $neventsper +echo logdir: $logdir +echo histdir: $histdir +echo .............................................................................................. + +#______________________________________________________________________________________ running __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} inputs --files ${inputs[@]} +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} running +#_________________________________________________________________________________________________ + + +dstname=${logbase%%-*} +echo ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + +out0=${logbase}.root +out1=HIST_${logbase#DST_}.root + +nevents=-1 +status_f4a=0 + +for infile_ in ${inputs[@]}; do + infile=$( basename ${infile_} ) + cp -v ${infile_} . + root.exe -q -b Fun4All_Year2.C\(${nevents},\"${infile}\",\"${out0}\",\"${out1}\",\"${dbtag}\"\); status_f4a=$? + # Stageout the (single) DST created in the macro run + for rfile in `ls DST_CALO_*.root`; do + nevents_=$( root.exe -q -b GetEntries.C\(\"${out0}\"\) | awk '/Number of Entries/{ print $4; }' ) + nevents=${nevents_:--1} + echo Stageout ${rfile} to ${outdir} + ./stageout.sh ${rfile} ${outdir} + done + for hfile in `ls HIST_*.root`; do + echo Stageout ${hfile} to ${histdir} + ./stageout.sh ${hfile} ${histdir} + done +done + +if [ "${status_f4a}" -eq 0 ]; then + echo ./bachi.py --blame cups finalized ${dstname} ${runnumber} + ./bachi.py --blame cups finalized ${dstname} ${runnumber} +fi + +# In principle, stageout should have moved the files to their final location +rm *.root + +ls -lah + +#______________________________________________________________________________________ finished __ +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc +#_________________________________________________________________________________________________ + +echo "bdee bdee bdee, That's All Folks!" +} > ${logbase}.out 2>${logbase}.err + +mv ${logbase}.out ${logdir#file:/} +mv ${logbase}.err ${logdir#file:/} + +exit ${status_f4a} diff --git a/run2auau/CaloProduction/runy2calib.sh b/run2auau/CaloProduction/runy2calib.sh new file mode 100644 index 0000000..1befd4f --- /dev/null +++ b/run2auau/CaloProduction/runy2calib.sh @@ -0,0 +1,132 @@ +#!/usr/bin/bash + +nevents=${1} +outbase=${2} +logbase=${3} +runnumber=${4} +segment=${5} +outdir=${6} +build=${7/./} +dbtag=${8} +inputs=(`echo ${9} | tr "," " "`) # array of input files +ranges=(`echo ${10} | tr "," " "`) # array of input files with ranges appended +neventsper=${11:-1000} +logdir=${12:-.} +histdir=${13:-.} +subdir=${14} +payload=(`echo ${15} | tr "," " "`) # array of files to be rsynced +#----- +export cupsid=${@: -1} + +sighandler() +{ +echo "signal handler" +mv ${logbase}.out ${logdir#file:/} +mv ${logbase}.err ${logdir#file:/} +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents 0 --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e 255 --nevents 0 +} + +# On evict (term,stp) or hold (kill) branch to signal handler +trap sighandler SIGTERM SIGINT SIGKILL + +{ + +export USER="$(id -u -n)" +export LOGNAME=${USER} +export HOME=/sphenix/u/${USER} +hostname + +source /opt/sphenix/core/bin/sphenix_setup.sh -n ${7} + +export ODBCINI=./odbc.ini + +# Stagein +for i in ${payload[@]}; do + cp --verbose ${subdir}/${i} . +done + +#______________________________________________________________________________________ started __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} started +#_________________________________________________________________________________________________ + +echo .............................................................................................. +echo $@ +echo .............................................................................................. +echo nevents: $nevents +echo outbase: $outbase +echo logbase: $logbase +echo runnumb: $runnumber +echo segment: $segment +echo outdir: $outdir +echo build: $build +echo dbtag: $dbtag +echo inputs: ${inputs[@]} +echo nper: $neventsper +echo logdir: $logdir +echo histdir: $histdir +echo .............................................................................................. + +#______________________________________________________________________________________ running __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} inputs --files ${inputs[@]} +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} running +#_________________________________________________________________________________________________ + + +dstname=${logbase%%-*} +echo ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + +out0=${logbase}.root +out1=HIST_${logbase#DST_}.root + +nevents=-1 +status_f4a=0 + +for infile_ in ${inputs[@]}; do + infile=$( basename ${infile_} ) + cp -v ${infile_} . + outfile=${infile/CALOFITTING/CALO} + outhist=${outfile/DST_CALO/HIST_CALOQA} + root.exe -q -b Fun4All_Year2_Calib.C\(${nevents},\"${infile}\",\"${outfile}\",\"${outhist}\",\"${dbtag}\"\); status_f4a=$? + + # Stageout the (single) DST created in the macro run + #for rfile in ${outfile}; do + # #nevents_=$( root.exe -q -b GetEntries.C\(\"${filename}\"\) | awk '/Number of Entries/{ print $4; }' ) + nevents=${nevents_:--1} + echo Stageout ${outfile} to ${outdir} + ./stageout.sh ${outfile} ${outdir} + #done + for hfile in `ls HIST_*.root`; do + echo Stageout ${hfile} to ${histdir} + ./stageout.sh ${hfile} ${histdir} + #mv --verbose ${hfile} ${histdir} + done +done + +if [ "${status_f4a}" -eq 0 ]; then + echo ./bachi.py --blame cups finalized ${dstname} ${runnumber} + ./bachi.py --blame cups finalized ${dstname} ${runnumber} +fi + +# In principle, stageout should have moved the files to their final location +#rm *.root + +ls -lah + +#______________________________________________________________________________________ finished __ +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc +#_________________________________________________________________________________________________ + + + +echo "bdee bdee bdee, That's All Folks!" +} > ${logdir#file:/}/${logbase}.out 2 ${logdir#file:/}/>${logbase}.err + +#mv ${logbase}.out ${logdir#file:/} +#mv ${logbase}.err ${logdir#file:/} + +exit $status_f4a diff --git a/run2auau/CaloProduction/runy2fitting.sh b/run2auau/CaloProduction/runy2fitting.sh new file mode 100644 index 0000000..10ca007 --- /dev/null +++ b/run2auau/CaloProduction/runy2fitting.sh @@ -0,0 +1,129 @@ +#!/usr/bin/bash + +nevents=${1} +outbase=${2} +logbase=${3} +runnumber=${4} +segment=${5} +outdir=${6} +build=${7/./} +dbtag=${8} +inputs=(`echo ${9} | tr "," " "`) # array of input files +ranges=(`echo ${10} | tr "," " "`) # array of input files with ranges appended +neventsper=${11:-1000} +logdir=${12:-.} +histdir=${13:-.} +subdir=${14} +payload=(`echo ${15} | tr "," " "`) # array of files to be rsynced +#----- +export cupsid=${@: -1} + +sighandler() +{ +echo "signal handler" +mv ${logbase}.out ${logdir#file:/} +mv ${logbase}.err ${logdir#file:/} +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents 0 --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e 255 --nevents 0 +} + +# On evict (term,stp) or hold (kill) branch to signal handler +trap sighandler SIGTERM SIGINT SIGKILL + +{ + +export USER="$(id -u -n)" +export LOGNAME=${USER} +export HOME=/sphenix/u/${USER} +hostname + +source /opt/sphenix/core/bin/sphenix_setup.sh -n ${7} + +export ODBCINI=./odbc.ini + +echo .............................................................................................. +echo $@ +echo .............................................................................................. +echo nevents: $nevents +echo outbase: $outbase +echo logbase: $logbase +echo runnumb: $runnumber +echo segment: $segment +echo outdir: $outdir +echo build: $build +echo dbtag: $dbtag +echo inputs: ${inputs[@]} +echo nper: $neventsper +echo logdir: $logdir +echo histdir: $histdir +echo .............................................................................................. + +# Stagein +for i in ${payload[@]}; do + cp --verbose ${subdir}/${i} . +done + +#______________________________________________________________________________________ started __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} started +#_________________________________________________________________________________________________ + + +#______________________________________________________________________________________ running __ +# +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} inputs --files ${inputs[@]} +./cups.py -r ${runnumber} -s ${segment} -d ${outbase} running +#_________________________________________________________________________________________________ + + +dstname=${logbase%%-*} +echo ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + ./bachi.py --blame cups created ${dstname} ${runnumber} --parent ${inputs[0]} + +out0=${logbase}.root +out1=HIST_${logbase#DST_}.root + +nevents=-1 +status_f4a=0 + +for infile_ in ${inputs[@]}; do + + infile=$( basename ${infile_} ) + cp -v ${infile_} . + outfile=${logbase}.root + root.exe -q -b Fun4All_Year2_Fitting.C\(${nevents},\"${infile}\",\"${outfile}\",\"${dbtag}\"\); status_f4a=$? + + nevents=${nevents_:--1} + echo Stageout ${outfile} to ${outdir} + ./stageout.sh ${outfile} ${outdir} + + for hfile in `ls HIST_*.root`; do + echo Stageout ${hfile} to ${histdir} + ./stageout.sh ${hfile} ${histdir} + done + +done + +if [ "${status_f4a}" -eq 0 ]; then + echo ./bachi.py --blame cups finalized ${dstname} ${runnumber} + ./bachi.py --blame cups finalized ${dstname} ${runnumber} +fi + +ls -lah + +#______________________________________________________________________________________ finished __ +echo ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc + ./cups.py -v -r ${runnumber} -s ${segment} -d ${outbase} finished -e ${status_f4a} --nevents ${nevents} --inc +#_________________________________________________________________________________________________ + + + +echo "bdee bdee bdee, That's All Folks!" +#cp ${logbase}.out ${logdir#file:/} +#cp ${logbase}.err ${logdir#file:/} + + +} > ${logdir#file:/}/${logbase}.out 2> ${logdir#file:/}/${logbase}.err + + +exit ${status_f4a} diff --git a/run2auau/CaloProduction/stageout.sh b/run2auau/CaloProduction/stageout.sh new file mode 100755 index 0000000..b619d8f --- /dev/null +++ b/run2auau/CaloProduction/stageout.sh @@ -0,0 +1,56 @@ +#!/usr/bin/bash + +filename=`basename ${1}` # must be a local file +destination=${2} + +echo stageout ${filename} ${destination} start `date` + +regex_dsttype_run="([A-Z]+_[A-Z_]+[a-z0-9]+)_([a-z0-9]+)_(202[345]p[0-9][0-9][0-9])-([0-9]+)-([0-9]+)" +regex_dsttype_range="([A-Z]+_[A-Z_]+[a-z0-9]+)_([a-z0-9]+)_(202[345]p[0-9][0-9][0-9])-([0-9]+)-([0-9]+)-([0-9]+)" + +# decode filename +base=${filename/.root/} +dstname=${base%%-*} + +# Filename matches a dsttype with a single run +if [[ $base =~ $regex_dsttype_run ]]; then + dsttype=${BASH_REMATCH[1]} + echo $dsttype ... + build=${BASH_REMATCH[2]} + echo $build + dbtag=${BASH_REMATCH[3]} + echo $dbtag + runnumber=${BASH_REMATCH[4]} + echo $runnumber + segment=${BASH_REMATCH[5]} + echo $segment +fi +# Filename matches a dst "run range" type +if [[ $base =~ $regex_dsttype_range ]]; then + dsttype=${BASH_REMATCH[1]} + echo $dsttype ... + build=${BASH_REMATCH[2]} + echo $build + dbtag=${BASH_REMATCH[3]} + echo $dbtag + runnumber=${BASH_REMATCH[4]} + echo $runnumber + runnumber2=${BASH_REMATCH[5]} + echo $runnumber + segment=${BASH_REMATCH[6]} + echo $segment +fi + +nevents_=$( root.exe -q -b GetEntries.C\(\"${filename}\"\) | awk '/Number of Entries/{ print $4; }' ) +nevents=${nevents_:--1} + +# prodtype is required... specifies whether the production status entry manages a single output file (only) or many output files (many). +echo ./cups.py -r ${runnumber} -s ${segment} -d ${dstname} stageout ${filename} ${destination} --dsttype ${dsttype} --dataset ${build}_${dbtag} --nevents ${nevents} --inc --prodtype only + ./cups.py -r ${runnumber} -s ${segment} -d ${dstname} stageout ${filename} ${destination} --dsttype ${dsttype} --dataset ${build}_${dbtag} --nevents ${nevents} --inc --prodtype only + + +echo stageout ${filename} ${destination} finish `date` + + + +