Skip to content

Commit 66c0be2

Browse files
authored
feat: Add ZorroHelper class and update Zorro code to use it (#6975)
1 parent 0373a88 commit 66c0be2

4 files changed

Lines changed: 19 additions & 27 deletions

File tree

EventFiltering/EventFilteringUtilsLinkDef.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
#pragma link off all classes;
1414
#pragma link off all functions;
1515

16-
#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ;
16+
#pragma link C++ class ZorroHelper + ;
17+
#pragma link C++ class std::vector < ZorroHelper> + ;

EventFiltering/Zorro.cxx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,12 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
3434
mScalers = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "FilterCounters", timestamp, metadata);
3535
mSelections = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "SelectionCounters", timestamp, metadata);
3636
mInspectedTVX = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "InspectedTVX", timestamp, metadata);
37-
auto selectedBCs = mCCDB->getSpecific<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "SelectedBCs", timestamp, metadata);
37+
mZorroHelpers = mCCDB->getSpecific<std::vector<ZorroHelper>>(mBaseCCDBPath + "ZorroHelpers", timestamp, metadata);
38+
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); });
3839
mBCranges.clear();
39-
for (auto bc : *selectedBCs) {
40-
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(bc[0], bc[1])), InteractionRecord::long2IR(std::max(bc[0], bc[1])));
40+
for (auto helper : *mZorroHelpers) {
41+
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel)));
4142
}
42-
std::sort(mBCranges.begin(), mBCranges.end(), [](const auto& a, const auto& b) { return a.getMin() < b.getMin(); });
43-
44-
mSelectionBitMask = mCCDB->getSpecific<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "SelectionBitMask", timestamp, metadata);
45-
mFilterBitMask = mCCDB->getSpecific<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "FilterBitMask", timestamp, metadata);
4643

4744
mLastBCglobalId = 0;
4845
mLastSelectedIdx = 0;
@@ -74,7 +71,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
7471
if (!bcFrame.getOverlap(mBCranges[i]).isZeroLength()) {
7572
for (int iMask{0}; iMask < 2; ++iMask) {
7673
for (int iTOI{0}; iTOI < 64; ++iTOI) {
77-
result.set(iMask * 64 + iTOI, mFilterBitMask->at(i)[iMask] & (1ull << iTOI));
74+
result.set(iMask * 64 + iTOI, mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI));
7875
}
7976
}
8077
mLastSelectedIdx = i;
@@ -86,7 +83,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
8683

8784
bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
8885
{
89-
int lastSelectedIdx = mLastSelectedIdx;
86+
uint64_t lastSelectedIdx = mLastSelectedIdx;
9087
std::bitset<128> result = fetch(bcGlobalId, tolerance);
9188
for (size_t i{0}; i < mTOIidx.size(); ++i) {
9289
if (mTOIidx[i] < 0) {

EventFiltering/Zorro.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ class BasicCCDBManager;
2929
};
3030
}; // namespace o2
3131

32+
struct ZorroHelper {
33+
uint64_t bcAOD, bcEvSel, trigMask[2], selMask[2];
34+
ClassDefNV(ZorroHelper, 1);
35+
};
36+
3237
class Zorro
3338
{
3439
public:
@@ -53,8 +58,7 @@ class Zorro
5358
TH1D* mSelections = nullptr;
5459
TH1D* mInspectedTVX = nullptr;
5560
std::vector<o2::dataformats::IRFrame> mBCranges;
56-
std::vector<std::array<uint64_t, 2>>* mFilterBitMask = nullptr;
57-
std::vector<std::array<uint64_t, 2>>* mSelectionBitMask = nullptr;
61+
std::vector<ZorroHelper>* mZorroHelpers = nullptr;
5862
std::vector<std::string> mTOIs;
5963
std::vector<int> mTOIidx;
6064
std::vector<int> mTOIcounts;

EventFiltering/macros/uploadOTSobjects.C

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,10 @@
2525
#include "TTree.h"
2626

2727
#include "CCDB/BasicCCDBManager.h"
28+
#include "EventFiltering/zorro.h"
2829

2930
const std::string kBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/";
3031

31-
#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ;
32-
struct bcInfo {
33-
bcInfo() = default;
34-
ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2];
35-
void print() const;
36-
};
37-
3832
void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien)
3933
{
4034
std::string baseCCDBpath = passName.empty() ? kBaseCCDBPath : kBaseCCDBPath + passName + "/";
@@ -66,14 +60,14 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien
6660
TH1* hCounterTVX = (TH1*)scalersFile->Get("bc-selection-task/hCounterTVX");
6761
api.storeAsTFile(hCounterTVX, baseCCDBpath + "InspectedTVX", metadata, duration.first, duration.second);
6862

69-
std::vector<std::array<uint64_t, 2>> bcRanges, filterBitMask, selectionBitMask;
63+
std::vector<ZorroHelper> zorroHelpers;
7064
std::unique_ptr<TFile> bcRangesFile{TFile::Open((path + "/bcRanges_fullrun.root").data(), "READ")};
7165
int Nmax = 0;
7266
for (auto key : *(bcRangesFile->GetListOfKeys())) {
7367
TTree* cefpTree = (TTree*)bcRangesFile->Get(Form("%s/selectedBC", key->GetName()));
7468
if (!cefpTree)
7569
continue;
76-
bcInfo bci;
70+
ZorroHelper bci;
7771
cefpTree->SetBranchAddress("bcAO2D", &bci.bcAOD);
7872
cefpTree->SetBranchAddress("bcEvSel", &bci.bcEvSel);
7973
if (cefpTree->GetBranch("selMask") && cefpTree->GetBranch("triMask")) {
@@ -88,15 +82,11 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien
8882
for (int i = 0; i < cefpTree->GetEntries(); i++) {
8983
if ((i < Nmax) || (Nmax == 0)) {
9084
cefpTree->GetEntry(i);
91-
bcRanges.push_back({bci.bcAOD, bci.bcEvSel});
92-
filterBitMask.push_back({bci.trigMask[0], bci.trigMask[1]});
93-
selectionBitMask.push_back({bci.selMask[0], bci.selMask[1]});
85+
zorroHelpers.push_back(bci);
9486
}
9587
}
9688
}
97-
api.storeAsTFileAny(&bcRanges, baseCCDBpath + "SelectedBCs", metadata, duration.first, duration.second);
98-
api.storeAsTFileAny(&filterBitMask, baseCCDBpath + "FilterBitMasks", metadata, duration.first, duration.second);
99-
api.storeAsTFileAny(&selectionBitMask, baseCCDBpath + "SelectionBitMasks", metadata, duration.first, duration.second);
89+
api.storeAsTFileAny(&zorroHelpers, baseCCDBpath + "ZorroHelpers", metadata, duration.first, duration.second);
10090
}
10191
}
10292

0 commit comments

Comments
 (0)