Skip to content
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
3 changes: 2 additions & 1 deletion EventFiltering/EventFilteringUtilsLinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 < ZorroHelper> + ;
15 changes: 6 additions & 9 deletions EventFiltering/Zorro.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,12 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int 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);
auto selectedBCs = mCCDB->getSpecific<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "SelectedBCs", 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();
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<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "SelectionBitMask", timestamp, metadata);
mFilterBitMask = mCCDB->getSpecific<std::vector<std::array<uint64_t, 2>>>(mBaseCCDBPath + "FilterBitMask", timestamp, metadata);

mLastBCglobalId = 0;
mLastSelectedIdx = 0;
Expand Down Expand Up @@ -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;
Expand All @@ -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) {
Expand Down
8 changes: 6 additions & 2 deletions EventFiltering/Zorro.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class BasicCCDBManager;
};
}; // namespace o2

struct ZorroHelper {
uint64_t bcAOD, bcEvSel, trigMask[2], selMask[2];
ClassDefNV(ZorroHelper, 1);
};

class Zorro
{
public:
Expand All @@ -53,8 +58,7 @@ class Zorro
TH1D* mSelections = nullptr;
TH1D* mInspectedTVX = nullptr;
std::vector<o2::dataformats::IRFrame> mBCranges;
std::vector<std::array<uint64_t, 2>>* mFilterBitMask = nullptr;
std::vector<std::array<uint64_t, 2>>* mSelectionBitMask = nullptr;
std::vector<ZorroHelper>* mZorroHelpers = nullptr;
std::vector<std::string> mTOIs;
std::vector<int> mTOIidx;
std::vector<int> mTOIcounts;
Expand Down
20 changes: 5 additions & 15 deletions EventFiltering/macros/uploadOTSobjects.C
Original file line number Diff line number Diff line change
Expand Up @@ -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 + "/";
Expand Down Expand Up @@ -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<std::array<uint64_t, 2>> bcRanges, filterBitMask, selectionBitMask;
std::vector<ZorroHelper> zorroHelpers;
std::unique_ptr<TFile> 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")) {
Expand All @@ -88,15 +82,11 @@ 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);
}
}

Expand Down