diff --git a/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/EventsPerBc.h b/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/EventsPerBc.h index 9fcd1318914bd..632eac342fdc9 100644 --- a/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/EventsPerBc.h +++ b/DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/EventsPerBc.h @@ -14,11 +14,24 @@ #include "CommonConstants/LHCConstants.h" #include +#include +#include namespace o2::ft0 { struct EventsPerBc { std::array histogram; + + std::unique_ptr toTH1F(const char* name = "eventsPerBc") const + { + constexpr int N = o2::constants::lhc::LHCMaxBunches; + auto h = std::make_unique(name, name, N, 0, N); + for (int i = 0; i < N; ++i) { + h->SetBinContent(i + 1, histogram[i]); + } + return h; + } + ClassDefNV(EventsPerBc, 1); }; } // namespace o2::ft0 diff --git a/Steer/CMakeLists.txt b/Steer/CMakeLists.txt index 8e2706d31bb0a..0d7f300c5513e 100644 --- a/Steer/CMakeLists.txt +++ b/Steer/CMakeLists.txt @@ -23,7 +23,7 @@ o2_add_library(Steer o2_add_executable(colcontexttool COMPONENT_NAME steer SOURCES src/CollisionContextTool.cxx - PUBLIC_LINK_LIBRARIES Boost::program_options O2::Algorithm O2::Steer O2::SimulationDataFormat) + PUBLIC_LINK_LIBRARIES Boost::program_options O2::Algorithm O2::Steer O2::SimulationDataFormat O2::DataFormatsFT0) o2_target_root_dictionary(Steer HEADERS include/Steer/HitProcessingManager.h diff --git a/Steer/src/CollisionContextTool.cxx b/Steer/src/CollisionContextTool.cxx index 6bee407c01264..e97eeada3fd0c 100644 --- a/Steer/src/CollisionContextTool.cxx +++ b/Steer/src/CollisionContextTool.cxx @@ -19,6 +19,7 @@ #include "DataFormatsCalibration/MeanVertexObject.h" #include "SimulationDataFormat/DigitizationContext.h" #include "SimConfig/InteractionDiamondParam.h" +#include "DataFormatsFT0/EventsPerBc.h" #include #include #include @@ -424,7 +425,7 @@ int main(int argc, char* argv[]) auto mode = ispecs[id].syncmode; if (mode == InteractionLockMode::NOLOCK) { auto sampler = std::make_unique(); - TH1F* mu_hist = nullptr; + std::unique_ptr mu_hist; // we check if there is a realistic bunch crossing distribution available const auto& mu_distr_source = options.nontrivial_mu_distribution; @@ -441,7 +442,11 @@ int main(int argc, char* argv[]) ccdb_inst.setFatalWhenNull(false); auto local_hist = ccdb_inst.getForTimeStamp(ccdb_info.fullPath, options.timestamp); if (local_hist) { - mu_hist = (TH1F*)(local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile + // case in which CCDB object contains directly a ROOT histogram + mu_hist.reset((TH1F*)local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile + } else if (auto events_per_bc = ccdb_inst.getForTimeStamp(ccdb_info.fullPath, options.timestamp)) { + // case in which CCDB object is from FT0 EventsPerBC calib (will be default) + mu_hist = events_per_bc->toTH1F(); } else { LOG(warn) << "No mu(bc) distribution found on CCDB. Using uniform one"; } @@ -451,7 +456,7 @@ int main(int argc, char* argv[]) auto mudistr_file = TFile::Open(mu_distr_source.c_str(), "OPEN"); if (mudistr_file && !mudistr_file->IsZombie()) { auto local_hist = mudistr_file->Get("hBcTVX"); - mu_hist = (TH1F*)(local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile + mu_hist.reset((TH1F*)local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile mudistr_file->Close(); } }