From 49d79b66d548ba438f3f80c1f63bb0c4365c9d53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Ku=C4=8Dera?= Date: Fri, 11 Jul 2025 14:20:26 +0200 Subject: [PATCH] Zorro: Fix various C++ issues. --- EventFiltering/Zorro.cxx | 31 ++++++++++++++++++++++++------- EventFiltering/Zorro.h | 26 ++++++++++++++------------ EventFiltering/ZorroHelper.h | 3 ++- EventFiltering/ZorroSummary.cxx | 11 ++++++++--- EventFiltering/ZorroSummary.h | 9 +++++---- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index 8b47d0c2d3f..2b78c157399 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -12,13 +12,30 @@ #include "Zorro.h" -#include -#include +#include "EventFiltering/ZorroHelper.h" + +#include +#include +#include +#include +#include +#include +#include -#include +#include +#include +#include -#include "CCDB/BasicCCDBManager.h" -#include "CommonDataFormat/InteractionRecord.h" +#include + +#include +#include +#include +#include +#include +#include +#include +#include using o2::InteractionRecord; @@ -212,7 +229,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) { mLastResult.reset(); if (bcGlobalId < mBCranges.front().getMin().toLong() - tolerance || bcGlobalId > mBCranges.back().getMax().toLong() + tolerance) { - setupHelpers((mOrbitResetTimestamp + int64_t(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000); + setupHelpers((mOrbitResetTimestamp + static_cast(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000); } o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance}; @@ -306,7 +323,7 @@ void Zorro::setupHelpers(int64_t timestamp) std::sort(mZorroHelpers->begin(), mZorroHelpers->end(), [](const auto& a, const auto& b) { return std::min(a.bcAOD, a.bcEvSel) < std::min(b.bcAOD, b.bcEvSel); }); mBCranges.clear(); mAccountedBCranges.clear(); - for (auto helper : *mZorroHelpers) { + for (const auto& helper : *mZorroHelpers) { mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel))); } mAccountedBCranges.resize(mBCranges.size(), false); diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index 16da5d578ca..f03badab2ce 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -19,19 +19,21 @@ #ifndef EVENTFILTERING_ZORRO_H_ #define EVENTFILTERING_ZORRO_H_ +#include "ZorroHelper.h" +#include "ZorroSummary.h" + +#include +#include + +#include +#include + #include -#include +#include #include #include #include -#include "TH1D.h" -#include "TH2D.h" -#include "CommonDataFormat/IRFrame.h" -#include "Framework/HistogramRegistry.h" -#include "ZorroHelper.h" -#include "ZorroSummary.h" - namespace o2 { namespace ccdb @@ -61,8 +63,8 @@ class Zorro std::vector getTriggerOfInterestResults() const; int getNTOIs() const { return mTOIs.size(); } - void setCCDBpath(std::string path) { mBaseCCDBPath = path; } - void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; } + void setCCDBpath(const std::string& path) { mBaseCCDBPath = path; } + void setBaseCCDBPath(const std::string& path) { mBaseCCDBPath = path; } void setBCtolerance(int tolerance) { mBCtolerance = tolerance; } ZorroSummary* getZorroSummary() { return &mZorroSummary; } @@ -76,8 +78,8 @@ class Zorro int mRunNumber = 0; std::pair mRunDuration; int64_t mOrbitResetTimestamp = 0; - TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run - TH1* mAnalysedTriggersOfInterest; /// Accounting for triggers of interest in the current run + TH1* mAnalysedTriggers = nullptr; /// Accounting for all triggers in the current run + TH1* mAnalysedTriggersOfInterest = nullptr; /// Accounting for triggers of interest in the current run std::vector mRunNumberHistos; std::vector mAnalysedTriggersList; /// Per run histograms diff --git a/EventFiltering/ZorroHelper.h b/EventFiltering/ZorroHelper.h index 8bcc6240bc0..e80a07ef994 100644 --- a/EventFiltering/ZorroHelper.h +++ b/EventFiltering/ZorroHelper.h @@ -13,7 +13,8 @@ #ifndef EVENTFILTERING_ZORROHELPER_H_ #define EVENTFILTERING_ZORROHELPER_H_ -#include "Rtypes.h" +#include +#include struct ZorroHelper { ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; diff --git a/EventFiltering/ZorroSummary.cxx b/EventFiltering/ZorroSummary.cxx index ee241f49108..0a1012c3edc 100644 --- a/EventFiltering/ZorroSummary.cxx +++ b/EventFiltering/ZorroSummary.cxx @@ -11,7 +11,12 @@ #include "ZorroSummary.h" -#include "TCollection.h" +#include +#include + +#include + +#include void ZorroSummary::Copy(TObject& c) const { @@ -42,7 +47,7 @@ Long64_t ZorroSummary::Merge(TCollection* list) mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber); } else { auto& thisCounters = mAnalysedTOIcounters[runNumber]; - for (size_t i = 0; i < thisCounters.size(); ++i) { + for (std::size_t i = 0; i < thisCounters.size(); ++i) { thisCounters[i] += currentAnalysedToiCounters[i]; } } @@ -66,4 +71,4 @@ double ZorroSummary::getNormalisationFactor(int toiId) const } return totalTVX * totalAnalysedTOI / totalTOI; -} \ No newline at end of file +} diff --git a/EventFiltering/ZorroSummary.h b/EventFiltering/ZorroSummary.h index b4d401adba4..8987d8cd5cd 100644 --- a/EventFiltering/ZorroSummary.h +++ b/EventFiltering/ZorroSummary.h @@ -15,6 +15,9 @@ #include +#include +#include + #include #include #include @@ -41,9 +44,7 @@ class ZorroSummary : public TNamed mRunNumber = runNumber; mTVXcounters[runNumber] = tvxCountes; mTOIcounters[runNumber] = toiCounters; - if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) { - mAnalysedTOIcounters[runNumber] = std::vector(mNtois, 0ull); - } + mAnalysedTOIcounters.try_emplace(runNumber, std::vector(mNtois, 0ull)); mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber]; } double getNormalisationFactor(int toiId) const; @@ -73,4 +74,4 @@ class ZorroSummary : public TNamed ClassDef(ZorroSummary, 1); }; -#endif // EVENTFILTERING_ZORROSUMMARY_H_ \ No newline at end of file +#endif // EVENTFILTERING_ZORROSUMMARY_H_