Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,24 @@

#include "CommonConstants/LHCConstants.h"
#include <Rtypes.h>
#include <TH1F.h>
#include <memory>

namespace o2::ft0
{
struct EventsPerBc {
std::array<double, o2::constants::lhc::LHCMaxBunches> histogram;

std::unique_ptr<TH1F> toTH1F(const char* name = "eventsPerBc") const
{
constexpr int N = o2::constants::lhc::LHCMaxBunches;
auto h = std::make_unique<TH1F>(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
Expand Down
2 changes: 1 addition & 1 deletion Steer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions Steer/src/CollisionContextTool.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "DataFormatsCalibration/MeanVertexObject.h"
#include "SimulationDataFormat/DigitizationContext.h"
#include "SimConfig/InteractionDiamondParam.h"
#include "DataFormatsFT0/EventsPerBc.h"
#include <cmath>
#include <TRandom.h>
#include <numeric>
Expand Down Expand Up @@ -424,7 +425,7 @@ int main(int argc, char* argv[])
auto mode = ispecs[id].syncmode;
if (mode == InteractionLockMode::NOLOCK) {
auto sampler = std::make_unique<o2::steer::InteractionSampler>();
TH1F* mu_hist = nullptr;
std::unique_ptr<TH1F> mu_hist;

// we check if there is a realistic bunch crossing distribution available
const auto& mu_distr_source = options.nontrivial_mu_distribution;
Expand All @@ -441,7 +442,11 @@ int main(int argc, char* argv[])
ccdb_inst.setFatalWhenNull(false);
auto local_hist = ccdb_inst.getForTimeStamp<TH1F>(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<o2::ft0::EventsPerBc>(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";
}
Expand All @@ -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<TH1F>("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();
}
}
Expand Down
Loading