Skip to content

Commit 7b7dc3d

Browse files
authored
[Trigger] ZorroSummary fix (#12157)
1 parent 177d6ad commit 7b7dc3d

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

EventFiltering/Zorro.cxx

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <CommonConstants/LHCConstants.h>
1919
#include <CommonDataFormat/IRFrame.h>
2020
#include <CommonDataFormat/InteractionRecord.h>
21+
#include <CommonUtils/StringUtils.h>
2122
#include <Framework/HistogramRegistry.h>
2223
#include <Framework/HistogramSpec.h>
2324
#include <Framework/Logger.h>
@@ -198,24 +199,18 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
198199
mLastSelectedIdx = 0;
199200
mTOIs.clear();
200201
mTOIidx.clear();
201-
while (!tois.empty()) {
202-
size_t pos = tois.find(",");
203-
pos = (pos == std::string::npos) ? tois.size() : pos;
204-
std::string token = tois.substr(0, pos);
205-
// Trim leading and trailing whitespaces from the token
206-
token.erase(0, token.find_first_not_of(" "));
207-
token.erase(token.find_last_not_of(" ") + 1);
202+
std::vector<std::string> tokens = o2::utils::Str::tokenize(tois, ','); // tokens are trimmed
203+
for (auto const& token : tokens) {
208204
int bin = findBin(mSelections, token) - 2;
209205
mTOIs.push_back(token);
210206
mTOIidx.push_back(bin);
211-
tois = tois.erase(0, pos + 1);
212207
}
213208
mTOIcounts.resize(mTOIs.size(), 0);
214209
LOGF(info, "Zorro initialized for run %d, triggers of interest:", runNumber);
215210
for (size_t i{0}; i < mTOIs.size(); ++i) {
216211
LOGF(info, ">>> %s : %i", mTOIs[i].data(), mTOIidx[i]);
217212
}
218-
mZorroSummary.setupTOIs(mTOIs.size(), tois);
213+
mZorroSummary.setupTOIs(mTOIs.size(), mTOIs);
219214
std::vector<double> toiCounters(mTOIs.size(), 0.);
220215
for (size_t i{0}; i < mTOIs.size(); ++i) {
221216
toiCounters[i] = mSelections->GetBinContent(mTOIidx[i] + 2);

EventFiltering/ZorroSummary.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,16 @@ class ZorroSummary : public TNamed
3131
virtual void Copy(TObject& c) const; // NOLINT: Making this override breaks compilation for unknown reason
3232
virtual Long64_t Merge(TCollection* list);
3333

34-
void setupTOIs(int ntois, const std::string& toinames)
34+
void setupTOIs(int ntois, const std::vector<std::string>& toinames)
3535
{
3636
mNtois = ntois;
37-
mTOInames = toinames;
37+
if (toinames.size() == 0) {
38+
return;
39+
}
40+
mTOInames = toinames[0];
41+
for (size_t i = 1; i < toinames.size(); i++) {
42+
mTOInames += "," + toinames[i];
43+
}
3844
}
3945
void setupRun(int runNumber, double tvxCountes, const std::vector<double>& toiCounters)
4046
{
@@ -56,7 +62,7 @@ class ZorroSummary : public TNamed
5662
mCurrentAnalysedTOIcounters->at(toiId)++;
5763
}
5864

59-
std::string getTOInames() const { return mTOInames; }
65+
const auto& getTOInames() const { return mTOInames; }
6066
const auto& getTOIcounters() const { return mTOIcounters; }
6167
const auto& getTVXcounters() const { return mTVXcounters; }
6268
const auto& getAnalysedTOIcounters() const { return mAnalysedTOIcounters; }

0 commit comments

Comments
 (0)