Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zorro: support chunked CCDB objects #7869

Merged
merged 1 commit into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 27 additions & 12 deletions EventFiltering/Zorro.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,14 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
mBCtolerance = bcRange;
std::map<std::string, std::string> metadata;
metadata["runNumber"] = std::to_string(runNumber);
mScalers = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "FilterCounters", timestamp, metadata);
mSelections = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "SelectionCounters", timestamp, metadata);
mInspectedTVX = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "InspectedTVX", timestamp, metadata);
mZorroHelpers = mCCDB->getSpecific<std::vector<ZorroHelper>>(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();
mAccountedBCranges.clear();
for (auto helper : *mZorroHelpers) {
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel)));
}
mAccountedBCranges.resize(mBCranges.size(), false);

mRunDuration = mCCDB->getRunDuration(runNumber, true);
int64_t runTs = (mRunDuration.first / 2 + mRunDuration.second / 2);
auto ctp = ccdb->getForTimeStamp<std::vector<Long64_t>>("CTP/Calib/OrbitReset", runTs);
mOrbitResetTimestamp = (*ctp)[0];
mScalers = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "FilterCounters", runTs, metadata);
mSelections = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "SelectionCounters", runTs, metadata);
mInspectedTVX = mCCDB->getSpecific<TH1D>(mBaseCCDBPath + "InspectedTVX", runTs, metadata);
setupHelpers(timestamp);
mLastBCglobalId = 0;
mLastSelectedIdx = 0;
mTOIs.clear();
Expand Down Expand Up @@ -148,6 +144,10 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
{
mLastResult.reset();
if (bcGlobalId < mBCranges.front().getMin().toLong() - tolerance || bcGlobalId > mBCranges.back().getMax().toLong() + tolerance) {
setupHelpers(mOrbitResetTimestamp + int64_t(bcGlobalId * o2::constants::lhc::LHCBunchSpacingNS * 1e-3) / 1000);
}

o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance};
if (bcGlobalId < mLastBCglobalId) { /// Handle the possible discontinuity in the BC processed by the analyses
mLastSelectedIdx = 0;
Expand Down Expand Up @@ -221,3 +221,18 @@ bool Zorro::isNotSelectedByAny(uint64_t bcGlobalId, uint64_t tolerance)
fetch(bcGlobalId, tolerance);
return mLastResult.none();
}

void Zorro::setupHelpers(int64_t timestamp)
{
if (mCCDB->isCachedObjectValid(mBaseCCDBPath + "ZorroHelpers", timestamp)) {
return;
}
mZorroHelpers = mCCDB->getSpecific<std::vector<ZorroHelper>>(mBaseCCDBPath + "ZorroHelpers", timestamp, {{"runNumber", std::to_string(mRunNumber)}});
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();
mAccountedBCranges.clear();
for (auto helper : *mZorroHelpers) {
mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel)));
}
mAccountedBCranges.resize(mBCranges.size(), false);
}
5 changes: 5 additions & 0 deletions EventFiltering/Zorro.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <bitset>
#include <memory>
#include <string>
#include <utility>
#include <vector>

#include "TH1D.h"
Expand Down Expand Up @@ -59,10 +60,14 @@ class Zorro
ZorroSummary* getZorroSummary() { return &mZorroSummary; }

private:
void setupHelpers(int64_t timestamp);

ZorroSummary mZorroSummary{"ZorroSummary", "ZorroSummary"};

std::string mBaseCCDBPath = "Users/m/mpuccio/EventFiltering/OTS/";
int mRunNumber = 0;
std::pair<int64_t, int64_t> mRunDuration;
int64_t mOrbitResetTimestamp = 0;
TH1* mAnalysedTriggers; /// Accounting for all triggers in the current run
TH1* mAnalysedTriggersOfInterest; /// Accounting for triggers of interest in the current run

Expand Down
Loading