Skip to content

Commit 2cdec0f

Browse files
authored
[Trigger] Zorro: Fix various C++ issues (#12019)
1 parent be29a25 commit 2cdec0f

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

EventFiltering/Zorro.cxx

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,30 @@
1212

1313
#include "Zorro.h"
1414

15-
#include <algorithm>
16-
#include <map>
15+
#include "EventFiltering/ZorroHelper.h"
16+
17+
#include <CCDB/BasicCCDBManager.h>
18+
#include <CommonConstants/LHCConstants.h>
19+
#include <CommonDataFormat/IRFrame.h>
20+
#include <CommonDataFormat/InteractionRecord.h>
21+
#include <Framework/HistogramRegistry.h>
22+
#include <Framework/HistogramSpec.h>
23+
#include <Framework/Logger.h>
1724

18-
#include <TList.h>
25+
#include <TH1.h>
26+
#include <TH2.h>
27+
#include <TString.h>
1928

20-
#include "CCDB/BasicCCDBManager.h"
21-
#include "CommonDataFormat/InteractionRecord.h"
29+
#include <RtypesCore.h>
30+
31+
#include <algorithm>
32+
#include <bitset>
33+
#include <cstddef>
34+
#include <cstdint>
35+
#include <map>
36+
#include <memory>
37+
#include <string>
38+
#include <vector>
2239

2340
using o2::InteractionRecord;
2441

@@ -212,7 +229,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
212229
{
213230
mLastResult.reset();
214231
if (bcGlobalId < mBCranges.front().getMin().toLong() - tolerance || bcGlobalId > mBCranges.back().getMax().toLong() + tolerance) {
215-
setupHelpers((mOrbitResetTimestamp + int64_t(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000);
232+
setupHelpers((mOrbitResetTimestamp + static_cast<int64_t>(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3)) / 1000);
216233
}
217234

218235
o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance};
@@ -306,7 +323,7 @@ void Zorro::setupHelpers(int64_t timestamp)
306323
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); });
307324
mBCranges.clear();
308325
mAccountedBCranges.clear();
309-
for (auto helper : *mZorroHelpers) {
326+
for (const auto& helper : *mZorroHelpers) {
310327
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel)));
311328
}
312329
mAccountedBCranges.resize(mBCranges.size(), false);

EventFiltering/Zorro.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@
1919
#ifndef EVENTFILTERING_ZORRO_H_
2020
#define EVENTFILTERING_ZORRO_H_
2121

22+
#include "ZorroHelper.h"
23+
#include "ZorroSummary.h"
24+
25+
#include <CommonDataFormat/IRFrame.h>
26+
#include <Framework/HistogramRegistry.h>
27+
28+
#include <TH1.h>
29+
#include <TH2.h>
30+
2231
#include <bitset>
23-
#include <memory>
32+
#include <cstdint>
2433
#include <string>
2534
#include <utility>
2635
#include <vector>
2736

28-
#include "TH1D.h"
29-
#include "TH2D.h"
30-
#include "CommonDataFormat/IRFrame.h"
31-
#include "Framework/HistogramRegistry.h"
32-
#include "ZorroHelper.h"
33-
#include "ZorroSummary.h"
34-
3537
namespace o2
3638
{
3739
namespace ccdb
@@ -61,8 +63,8 @@ class Zorro
6163
std::vector<bool> getTriggerOfInterestResults() const;
6264
int getNTOIs() const { return mTOIs.size(); }
6365

64-
void setCCDBpath(std::string path) { mBaseCCDBPath = path; }
65-
void setBaseCCDBPath(std::string path) { mBaseCCDBPath = path; }
66+
void setCCDBpath(const std::string& path) { mBaseCCDBPath = path; }
67+
void setBaseCCDBPath(const std::string& path) { mBaseCCDBPath = path; }
6668
void setBCtolerance(int tolerance) { mBCtolerance = tolerance; }
6769

6870
ZorroSummary* getZorroSummary() { return &mZorroSummary; }
@@ -76,8 +78,8 @@ class Zorro
7678
int mRunNumber = 0;
7779
std::pair<int64_t, int64_t> mRunDuration;
7880
int64_t mOrbitResetTimestamp = 0;
79-
TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run
80-
TH1* mAnalysedTriggersOfInterest; /// Accounting for triggers of interest in the current run
81+
TH1* mAnalysedTriggers = nullptr; /// Accounting for all triggers in the current run
82+
TH1* mAnalysedTriggersOfInterest = nullptr; /// Accounting for triggers of interest in the current run
8183

8284
std::vector<int> mRunNumberHistos;
8385
std::vector<TH1*> mAnalysedTriggersList; /// Per run histograms

EventFiltering/ZorroHelper.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
#ifndef EVENTFILTERING_ZORROHELPER_H_
1414
#define EVENTFILTERING_ZORROHELPER_H_
1515

16-
#include "Rtypes.h"
16+
#include <Rtypes.h>
17+
#include <RtypesCore.h>
1718

1819
struct ZorroHelper {
1920
ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2];

EventFiltering/ZorroSummary.cxx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
#include "ZorroSummary.h"
1313

14-
#include "TCollection.h"
14+
#include <TCollection.h>
15+
#include <TObject.h>
16+
17+
#include <RtypesCore.h>
18+
19+
#include <cstddef>
1520

1621
void ZorroSummary::Copy(TObject& c) const
1722
{
@@ -42,7 +47,7 @@ Long64_t ZorroSummary::Merge(TCollection* list)
4247
mTOIcounters[runNumber] = entry->getTOIcounters().at(runNumber);
4348
} else {
4449
auto& thisCounters = mAnalysedTOIcounters[runNumber];
45-
for (size_t i = 0; i < thisCounters.size(); ++i) {
50+
for (std::size_t i = 0; i < thisCounters.size(); ++i) {
4651
thisCounters[i] += currentAnalysedToiCounters[i];
4752
}
4853
}
@@ -66,4 +71,4 @@ double ZorroSummary::getNormalisationFactor(int toiId) const
6671
}
6772

6873
return totalTVX * totalAnalysedTOI / totalTOI;
69-
}
74+
}

EventFiltering/ZorroSummary.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515

1616
#include <TNamed.h>
1717

18+
#include <Rtypes.h>
19+
#include <RtypesCore.h>
20+
1821
#include <string>
1922
#include <unordered_map>
2023
#include <vector>
@@ -41,9 +44,7 @@ class ZorroSummary : public TNamed
4144
mRunNumber = runNumber;
4245
mTVXcounters[runNumber] = tvxCountes;
4346
mTOIcounters[runNumber] = toiCounters;
44-
if (mAnalysedTOIcounters.find(runNumber) == mAnalysedTOIcounters.end()) {
45-
mAnalysedTOIcounters[runNumber] = std::vector<ULong64_t>(mNtois, 0ull);
46-
}
47+
mAnalysedTOIcounters.try_emplace(runNumber, std::vector<ULong64_t>(mNtois, 0ull));
4748
mCurrentAnalysedTOIcounters = &mAnalysedTOIcounters[runNumber];
4849
}
4950
double getNormalisationFactor(int toiId) const;
@@ -73,4 +74,4 @@ class ZorroSummary : public TNamed
7374
ClassDef(ZorroSummary, 1);
7475
};
7576

76-
#endif // EVENTFILTERING_ZORROSUMMARY_H_
77+
#endif // EVENTFILTERING_ZORROSUMMARY_H_

0 commit comments

Comments
 (0)