From 14e81742854a941a282ce37fc4d175f398f36b76 Mon Sep 17 00:00:00 2001 From: Maximiliano Puccio Date: Wed, 24 Jul 2024 18:59:45 +0200 Subject: [PATCH 1/2] feat: Add ZorroHelper class and update Zorro code to use it --- EventFiltering/EventFilteringUtilsLinkDef.h | 3 ++- EventFiltering/Zorro.cxx | 15 ++++++-------- EventFiltering/Zorro.h | 9 ++++++-- EventFiltering/macros/uploadOTSobjects.C | 23 ++++++--------------- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/EventFiltering/EventFilteringUtilsLinkDef.h b/EventFiltering/EventFilteringUtilsLinkDef.h index e06cef4e78a..a008c7ac1e4 100644 --- a/EventFiltering/EventFilteringUtilsLinkDef.h +++ b/EventFiltering/EventFilteringUtilsLinkDef.h @@ -13,4 +13,5 @@ #pragma link off all classes; #pragma link off all functions; -#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ; +#pragma link C++ class ZorroHelper + ; +#pragma link C++ class std::vector + ; diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index bd5f10423b6..fdb34cb679f 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -34,15 +34,12 @@ std::vector Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber mScalers = mCCDB->getSpecific(mBaseCCDBPath + "FilterCounters", timestamp, metadata); mSelections = mCCDB->getSpecific(mBaseCCDBPath + "SelectionCounters", timestamp, metadata); mInspectedTVX = mCCDB->getSpecific(mBaseCCDBPath + "InspectedTVX", timestamp, metadata); - auto selectedBCs = mCCDB->getSpecific>>(mBaseCCDBPath + "SelectedBCs", timestamp, metadata); + mZorroHelpers = mCCDB->getSpecific>(mBaseCCDBPath + "ZorroHelpers", timestamp, metadata); + 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(); - for (auto bc : *selectedBCs) { - mBCranges.emplace_back(InteractionRecord::long2IR(std::min(bc[0], bc[1])), InteractionRecord::long2IR(std::max(bc[0], bc[1]))); + for (auto helper : *mZorroHelpers) { + mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel))); } - std::sort(mBCranges.begin(), mBCranges.end(), [](const auto& a, const auto& b) { return a.getMin() < b.getMin(); }); - - mSelectionBitMask = mCCDB->getSpecific>>(mBaseCCDBPath + "SelectionBitMask", timestamp, metadata); - mFilterBitMask = mCCDB->getSpecific>>(mBaseCCDBPath + "FilterBitMask", timestamp, metadata); mLastBCglobalId = 0; mLastSelectedIdx = 0; @@ -74,7 +71,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) if (!bcFrame.getOverlap(mBCranges[i]).isZeroLength()) { for (int iMask{0}; iMask < 2; ++iMask) { for (int iTOI{0}; iTOI < 64; ++iTOI) { - result.set(iMask * 64 + iTOI, mFilterBitMask->at(i)[iMask] & (1ull << iTOI)); + result.set(iMask * 64 + iTOI, mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI)); } } mLastSelectedIdx = i; @@ -86,7 +83,7 @@ std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance) bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance) { - int lastSelectedIdx = mLastSelectedIdx; + uint64_t lastSelectedIdx = mLastSelectedIdx; std::bitset<128> result = fetch(bcGlobalId, tolerance); for (size_t i{0}; i < mTOIidx.size(); ++i) { if (mTOIidx[i] < 0) { diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index 6cde3d44aa3..be5f5607b93 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -29,6 +29,12 @@ class BasicCCDBManager; }; }; // namespace o2 +struct ZorroHelper +{ + uint64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; + ClassDefNV(ZorroHelper, 1); +}; + class Zorro { public: @@ -53,8 +59,7 @@ class Zorro TH1D* mSelections = nullptr; TH1D* mInspectedTVX = nullptr; std::vector mBCranges; - std::vector>* mFilterBitMask = nullptr; - std::vector>* mSelectionBitMask = nullptr; + std::vector* mZorroHelpers = nullptr; std::vector mTOIs; std::vector mTOIidx; std::vector mTOIcounts; diff --git a/EventFiltering/macros/uploadOTSobjects.C b/EventFiltering/macros/uploadOTSobjects.C index fcbcdb74271..cf09274a73d 100644 --- a/EventFiltering/macros/uploadOTSobjects.C +++ b/EventFiltering/macros/uploadOTSobjects.C @@ -25,16 +25,10 @@ #include "TTree.h" #include "CCDB/BasicCCDBManager.h" +#include "EventFiltering/zorro.h" const std::string kBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/"; -#pragma link C++ class std::vector < std::array < uint64_t, 2>> + ; -struct bcInfo { - bcInfo() = default; - ULong64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; - void print() const; -}; - void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien) { std::string baseCCDBpath = passName.empty() ? kBaseCCDBPath : kBaseCCDBPath + passName + "/"; @@ -66,14 +60,14 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien TH1* hCounterTVX = (TH1*)scalersFile->Get("bc-selection-task/hCounterTVX"); api.storeAsTFile(hCounterTVX, baseCCDBpath + "InspectedTVX", metadata, duration.first, duration.second); - std::vector> bcRanges, filterBitMask, selectionBitMask; + std::vector zorroHelpers; std::unique_ptr bcRangesFile{TFile::Open((path + "/bcRanges_fullrun.root").data(), "READ")}; int Nmax = 0; for (auto key : *(bcRangesFile->GetListOfKeys())) { TTree* cefpTree = (TTree*)bcRangesFile->Get(Form("%s/selectedBC", key->GetName())); if (!cefpTree) continue; - bcInfo bci; + ZorroHelper bci; cefpTree->SetBranchAddress("bcAO2D", &bci.bcAOD); cefpTree->SetBranchAddress("bcEvSel", &bci.bcEvSel); if (cefpTree->GetBranch("selMask") && cefpTree->GetBranch("triMask")) { @@ -88,20 +82,15 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien for (int i = 0; i < cefpTree->GetEntries(); i++) { if ((i < Nmax) || (Nmax == 0)) { cefpTree->GetEntry(i); - bcRanges.push_back({bci.bcAOD, bci.bcEvSel}); - filterBitMask.push_back({bci.trigMask[0], bci.trigMask[1]}); - selectionBitMask.push_back({bci.selMask[0], bci.selMask[1]}); + zorroHelpers.push_back(bci); } } } - api.storeAsTFileAny(&bcRanges, baseCCDBpath + "SelectedBCs", metadata, duration.first, duration.second); - api.storeAsTFileAny(&filterBitMask, baseCCDBpath + "FilterBitMasks", metadata, duration.first, duration.second); - api.storeAsTFileAny(&selectionBitMask, baseCCDBpath + "SelectionBitMasks", metadata, duration.first, duration.second); + api.storeAsTFileAny(&zorroHelpers, baseCCDBpath + "ZorroHelpers", metadata, duration.first, duration.second); } } -void uploadOTSobjects(std::string periodName) -{ +void uploadOTSobjects(std::string periodName) { int year = 2000 + std::stoi(periodName.substr(3, 2)); gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root | sed 's:/AnalysisResults_fullrun\\.root::' > list_%s.txt", year, periodName.data(), periodName.data())); uploadOTSobjects(Form("list_%s.txt", periodName.data()), "", true); From f198bc3b2fe96e05af53b858735a86c8141f6e15 Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Wed, 24 Jul 2024 19:03:52 +0200 Subject: [PATCH 2/2] Please consider the following formatting changes (#6976) --- EventFiltering/EventFilteringUtilsLinkDef.h | 2 +- EventFiltering/Zorro.h | 3 +-- EventFiltering/macros/uploadOTSobjects.C | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/EventFiltering/EventFilteringUtilsLinkDef.h b/EventFiltering/EventFilteringUtilsLinkDef.h index a008c7ac1e4..61def8978aa 100644 --- a/EventFiltering/EventFilteringUtilsLinkDef.h +++ b/EventFiltering/EventFilteringUtilsLinkDef.h @@ -14,4 +14,4 @@ #pragma link off all functions; #pragma link C++ class ZorroHelper + ; -#pragma link C++ class std::vector + ; +#pragma link C++ class std::vector < ZorroHelper> + ; diff --git a/EventFiltering/Zorro.h b/EventFiltering/Zorro.h index be5f5607b93..4f74aca0db9 100644 --- a/EventFiltering/Zorro.h +++ b/EventFiltering/Zorro.h @@ -29,8 +29,7 @@ class BasicCCDBManager; }; }; // namespace o2 -struct ZorroHelper -{ +struct ZorroHelper { uint64_t bcAOD, bcEvSel, trigMask[2], selMask[2]; ClassDefNV(ZorroHelper, 1); }; diff --git a/EventFiltering/macros/uploadOTSobjects.C b/EventFiltering/macros/uploadOTSobjects.C index cf09274a73d..ba827ff200a 100644 --- a/EventFiltering/macros/uploadOTSobjects.C +++ b/EventFiltering/macros/uploadOTSobjects.C @@ -90,7 +90,8 @@ void uploadOTSobjects(std::string inputList, std::string passName, bool useAlien } } -void uploadOTSobjects(std::string periodName) { +void uploadOTSobjects(std::string periodName) +{ int year = 2000 + std::stoi(periodName.substr(3, 2)); gSystem->Exec(Form("alien_find /alice/data/%i/%s/ ctf_skim_full/AnalysisResults_fullrun.root | sed 's:/AnalysisResults_fullrun\\.root::' > list_%s.txt", year, periodName.data(), periodName.data())); uploadOTSobjects(Form("list_%s.txt", periodName.data()), "", true);