Skip to content

Commit 4bd0da6

Browse files
committed
CollisionContextTool: Ability to use o2::ft0::EventsPerBC calib object
1 parent f3a09ea commit 4bd0da6

3 files changed

Lines changed: 22 additions & 4 deletions

File tree

DataFormats/Detectors/FIT/FT0/include/DataFormatsFT0/EventsPerBc.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,24 @@
1414

1515
#include "CommonConstants/LHCConstants.h"
1616
#include <Rtypes.h>
17+
#include <TH1F.h>
18+
#include <memory>
1719

1820
namespace o2::ft0
1921
{
2022
struct EventsPerBc {
2123
std::array<double, o2::constants::lhc::LHCMaxBunches> histogram;
24+
25+
std::unique_ptr<TH1F> toTH1F(const char* name = "eventsPerBc") const
26+
{
27+
constexpr int N = o2::constants::lhc::LHCMaxBunches;
28+
auto h = std::make_unique<TH1F>(name, name, N, 0, N);
29+
for (int i = 0; i < N; ++i) {
30+
h->SetBinContent(i + 1, histogram[i]);
31+
}
32+
return h;
33+
}
34+
2235
ClassDefNV(EventsPerBc, 1);
2336
};
2437
} // namespace o2::ft0

Steer/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ o2_add_library(Steer
2323
o2_add_executable(colcontexttool
2424
COMPONENT_NAME steer
2525
SOURCES src/CollisionContextTool.cxx
26-
PUBLIC_LINK_LIBRARIES Boost::program_options O2::Algorithm O2::Steer O2::SimulationDataFormat)
26+
PUBLIC_LINK_LIBRARIES Boost::program_options O2::Algorithm O2::Steer O2::SimulationDataFormat O2::DataFormatsFT0)
2727

2828
o2_target_root_dictionary(Steer
2929
HEADERS include/Steer/HitProcessingManager.h

Steer/src/CollisionContextTool.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "DataFormatsCalibration/MeanVertexObject.h"
2020
#include "SimulationDataFormat/DigitizationContext.h"
2121
#include "SimConfig/InteractionDiamondParam.h"
22+
#include "DataFormatsFT0/EventsPerBc.h"
2223
#include <cmath>
2324
#include <TRandom.h>
2425
#include <numeric>
@@ -424,7 +425,7 @@ int main(int argc, char* argv[])
424425
auto mode = ispecs[id].syncmode;
425426
if (mode == InteractionLockMode::NOLOCK) {
426427
auto sampler = std::make_unique<o2::steer::InteractionSampler>();
427-
TH1F* mu_hist = nullptr;
428+
std::unique_ptr<TH1F> mu_hist;
428429

429430
// we check if there is a realistic bunch crossing distribution available
430431
const auto& mu_distr_source = options.nontrivial_mu_distribution;
@@ -441,7 +442,11 @@ int main(int argc, char* argv[])
441442
ccdb_inst.setFatalWhenNull(false);
442443
auto local_hist = ccdb_inst.getForTimeStamp<TH1F>(ccdb_info.fullPath, options.timestamp);
443444
if (local_hist) {
444-
mu_hist = (TH1F*)(local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile
445+
// case in which CCDB object contains directly a ROOT histogram
446+
mu_hist.reset((TH1F*)local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile
447+
} else if (auto events_per_bc = ccdb_inst.getForTimeStamp<o2::ft0::EventsPerBc>(ccdb_info.fullPath, options.timestamp)) {
448+
// case in which CCDB object is from FT0 EventsPerBC calib (will be default)
449+
mu_hist = events_per_bc->toTH1F();
445450
} else {
446451
LOG(warn) << "No mu(bc) distribution found on CCDB. Using uniform one";
447452
}
@@ -451,7 +456,7 @@ int main(int argc, char* argv[])
451456
auto mudistr_file = TFile::Open(mu_distr_source.c_str(), "OPEN");
452457
if (mudistr_file && !mudistr_file->IsZombie()) {
453458
auto local_hist = mudistr_file->Get<TH1F>("hBcTVX");
454-
mu_hist = (TH1F*)(local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile
459+
mu_hist.reset((TH1F*)local_hist->Clone("h2")); // we need to clone since ownership of local_hist is with TFile
455460
mudistr_file->Close();
456461
}
457462
}

0 commit comments

Comments
 (0)