diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index 2b78c157399..ccdf063307d 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -198,24 +199,18 @@ std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber mLastSelectedIdx = 0; mTOIs.clear(); mTOIidx.clear(); - while (!tois.empty()) { - size_t pos = tois.find(","); - pos = (pos == std::string::npos) ? tois.size() : pos; - std::string token = tois.substr(0, pos); - // Trim leading and trailing whitespaces from the token - token.erase(0, token.find_first_not_of(" ")); - token.erase(token.find_last_not_of(" ") + 1); + std::vector tokens = o2::utils::Str::tokenize(tois, ','); // tokens are trimmed + for (auto const& token : tokens) { int bin = findBin(mSelections, token) - 2; mTOIs.push_back(token); mTOIidx.push_back(bin); - tois = tois.erase(0, pos + 1); } mTOIcounts.resize(mTOIs.size(), 0); LOGF(info, "Zorro initialized for run %d, triggers of interest:", runNumber); for (size_t i{0}; i < mTOIs.size(); ++i) { LOGF(info, ">>> %s : %i", mTOIs[i].data(), mTOIidx[i]); } - mZorroSummary.setupTOIs(mTOIs.size(), tois); + mZorroSummary.setupTOIs(mTOIs.size(), mTOIs); std::vector toiCounters(mTOIs.size(), 0.); for (size_t i{0}; i < mTOIs.size(); ++i) { toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2); diff --git a/EventFiltering/ZorroSummary.h b/EventFiltering/ZorroSummary.h index 8987d8cd5cd..51019aeef18 100644 --- a/EventFiltering/ZorroSummary.h +++ b/EventFiltering/ZorroSummary.h @@ -31,10 +31,16 @@ class ZorroSummary : public TNamed virtual void Copy(TObject& c) const; // NOLINT: Making this override breaks compilation for unknown reason virtual Long64_t Merge(TCollection* list); - void setupTOIs(int ntois, const std::string& toinames) + void setupTOIs(int ntois, const std::vector& toinames) { mNtois = ntois; - mTOInames = toinames; + if (toinames.size() == 0) { + return; + } + mTOInames = toinames[0]; + for (size_t i = 1; i < toinames.size(); i++) { + mTOInames += "," + toinames[i]; + } } void setupRun(int runNumber, double tvxCountes, const std::vector& toiCounters) { @@ -56,7 +62,7 @@ class ZorroSummary : public TNamed mCurrentAnalysedTOIcounters->at(toiId)++; } - std::string getTOInames() const { return mTOInames; } + const auto& getTOInames() const { return mTOInames; } const auto& getTOIcounters() const { return mTOIcounters; } const auto& getTVXcounters() const { return mTVXcounters; } const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; }