Skip to content

Commit 14f244d

Browse files
Merge branch 'AliceO2Group:master' into master
2 parents d2d6efc + a5d678f commit 14f244d

3 files changed

Lines changed: 66 additions & 13 deletions

File tree

EventFiltering/Zorro.cxx

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,46 @@
1414

1515
#include <map>
1616

17-
#include "TH1D.h"
17+
#include "TList.h"
1818

1919
#include "CCDB/BasicCCDBManager.h"
2020
#include "CommonDataFormat/InteractionRecord.h"
2121

2222
using o2::InteractionRecord;
2323

24+
void Zorro::populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, std::string prefix)
25+
{
26+
TList* list = histRegistry.getListOfHistograms();
27+
if (mSelections && list->FindObject((std::to_string(mRunNumber) + "/" + prefix + "Selections").data()) == nullptr) {
28+
mAnalysedTriggers = histRegistry.add<TH1>((std::to_string(mRunNumber) + "/" + prefix + "AnalysedTriggers").data(), "", o2::framework::HistType::kTH1D, {{mSelections->GetNbinsX() - 2, -0.5, mSelections->GetNbinsX() - 2.5}});
29+
for (int iBin{2}; iBin < mSelections->GetNbinsX(); ++iBin) { // Exclude first and last bins as they are total number of analysed and selected events, respectively
30+
mAnalysedTriggers->GetXaxis()->SetBinLabel(iBin - 1, mSelections->GetXaxis()->GetBinLabel(iBin));
31+
}
32+
std::shared_ptr<TH1> selections = histRegistry.add<TH1>((std::to_string(mRunNumber) + "/" + prefix + "Selections").data(), "", o2::framework::HistType::kTH1D, {{mSelections->GetNbinsX(), -0.5, static_cast<double>(mSelections->GetNbinsX() - 0.5)}});
33+
for (int iBin{1}; iBin <= mSelections->GetNbinsX(); ++iBin) {
34+
selections->GetXaxis()->SetBinLabel(iBin, mSelections->GetXaxis()->GetBinLabel(iBin));
35+
selections->SetBinContent(iBin, mSelections->GetBinContent(iBin));
36+
selections->SetBinError(iBin, mSelections->GetBinError(iBin));
37+
}
38+
}
39+
if (mScalers && list->FindObject((std::to_string(mRunNumber) + "/" + prefix + "Scalers").data()) == nullptr) {
40+
std::shared_ptr<TH1> scalers = histRegistry.add<TH1>((std::to_string(mRunNumber) + "/" + prefix + "Scalers").data(), "", o2::framework::HistType::kTH1D, {{mScalers->GetNbinsX(), -0.5, static_cast<double>(mScalers->GetNbinsX() - 0.5)}});
41+
for (int iBin{1}; iBin <= mScalers->GetNbinsX(); ++iBin) {
42+
scalers->GetXaxis()->SetBinLabel(iBin, mScalers->GetXaxis()->GetBinLabel(iBin));
43+
scalers->SetBinContent(iBin, mScalers->GetBinContent(iBin));
44+
scalers->SetBinError(iBin, mScalers->GetBinError(iBin));
45+
}
46+
}
47+
if (mInspectedTVX && list->FindObject((std::to_string(mRunNumber) + "/" + prefix + "InspectedTVX").data()) == nullptr) {
48+
std::shared_ptr<TH1> inspectedTVX = histRegistry.add<TH1>((std::to_string(mRunNumber) + "/" + prefix + "InspectedTVX").data(), "", o2::framework::HistType::kTH1D, {{mInspectedTVX->GetNbinsX(), -0.5, static_cast<double>(mInspectedTVX->GetNbinsX() - 0.5)}});
49+
for (int iBin{1}; iBin <= mInspectedTVX->GetNbinsX(); ++iBin) {
50+
inspectedTVX->GetXaxis()->SetBinLabel(iBin, mInspectedTVX->GetXaxis()->GetBinLabel(iBin));
51+
inspectedTVX->SetBinContent(iBin, mInspectedTVX->GetBinContent(iBin));
52+
inspectedTVX->SetBinError(iBin, mInspectedTVX->GetBinError(iBin));
53+
}
54+
}
55+
}
56+
2457
std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber, uint64_t timestamp, std::string tois, int bcRange)
2558
{
2659
if (mRunNumber == runNumber) {
@@ -45,50 +78,61 @@ std::vector<int> Zorro::initCCDB(o2::ccdb::BasicCCDBManager* ccdb, int runNumber
4578
mLastSelectedIdx = 0;
4679
mTOIs.clear();
4780
mTOIidx.clear();
48-
size_t pos = 0;
49-
while ((pos = tois.find(",")) != std::string::npos) {
81+
while (!tois.empty()) {
82+
size_t pos = tois.find(",");
83+
pos = (pos == std::string::npos) ? tois.size() : pos;
5084
std::string token = tois.substr(0, pos);
5185
// Trim leading and trailing whitespaces from the token
5286
token.erase(0, token.find_first_not_of(" "));
5387
token.erase(token.find_last_not_of(" ") + 1);
5488
int bin = mScalers->GetXaxis()->FindBin(token.c_str()) - 2;
5589
mTOIs.push_back(token);
5690
mTOIidx.push_back(bin);
57-
tois.erase(0, pos + 1);
91+
tois = tois.erase(0, pos + 1);
5892
}
5993
mTOIcounts.resize(mTOIs.size(), 0);
6094
return mTOIidx;
6195
}
6296

6397
std::bitset<128> Zorro::fetch(uint64_t bcGlobalId, uint64_t tolerance)
6498
{
65-
std::bitset<128> result;
99+
mLastResult.reset();
66100
o2::dataformats::IRFrame bcFrame{InteractionRecord::long2IR(bcGlobalId) - tolerance, InteractionRecord::long2IR(bcGlobalId) + tolerance};
67101
if (bcGlobalId < mLastBCglobalId) {
68102
mLastSelectedIdx = 0;
69103
}
104+
mLastBCglobalId = bcGlobalId;
70105
for (size_t i = mLastSelectedIdx; i < mBCranges.size(); i++) {
71-
if (!bcFrame.getOverlap(mBCranges[i]).isZeroLength()) {
106+
if (!mBCranges[i].isOutside(bcFrame)) {
72107
for (int iMask{0}; iMask < 2; ++iMask) {
73108
for (int iTOI{0}; iTOI < 64; ++iTOI) {
74-
result.set(iMask * 64 + iTOI, mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI));
109+
if (mZorroHelpers->at(i).selMask[iMask] & (1ull << iTOI)) {
110+
mLastResult.set(iMask * 64 + iTOI, 1);
111+
if (mAnalysedTriggers) {
112+
mAnalysedTriggers->Fill(iMask * 64 + iTOI);
113+
}
114+
}
75115
}
76116
}
77117
mLastSelectedIdx = i;
78-
return result;
118+
return mLastResult;
119+
} else if (mBCranges[i].getMax() < bcFrame.getMin()) {
120+
mLastSelectedIdx = i;
121+
} else if (mBCranges[i].getMin() > bcFrame.getMax()) {
122+
break;
79123
}
80124
}
81-
return result;
125+
return mLastResult;
82126
}
83127

84128
bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance)
85129
{
86130
uint64_t lastSelectedIdx = mLastSelectedIdx;
87-
std::bitset<128> result = fetch(bcGlobalId, tolerance);
131+
fetch(bcGlobalId, tolerance);
88132
for (size_t i{0}; i < mTOIidx.size(); ++i) {
89133
if (mTOIidx[i] < 0) {
90134
continue;
91-
} else if (result.test(mTOIidx[i])) {
135+
} else if (mLastResult.test(mTOIidx[i])) {
92136
mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting
93137
return true;
94138
}

EventFiltering/Zorro.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
#include <string>
1919
#include <vector>
2020

21+
#include "TH1D.h"
2122
#include "CommonDataFormat/IRFrame.h"
23+
#include "Framework/HistogramRegistry.h"
2224

23-
class TH1D;
2425
namespace o2
2526
{
2627
namespace ccdb
@@ -42,6 +43,12 @@ class Zorro
4243
std::bitset<128> fetch(uint64_t bcGlobalId, uint64_t tolerance = 100);
4344
bool isSelected(uint64_t bcGlobalId, uint64_t tolerance = 100);
4445

46+
void populateHistRegistry(o2::framework::HistogramRegistry& histRegistry, std::string prefix = "");
47+
48+
TH1D* getScalers() const { return mScalers; }
49+
TH1D* getSelections() const { return mSelections; }
50+
TH1D* getInspectedTVX() const { return mInspectedTVX; }
51+
std::bitset<128> getLastResult() const { return mLastResult; }
4552
std::vector<int> getTOIcounters() const { return mTOIcounts; }
4653

4754
void setCCDBpath(std::string path) { mBaseCCDBPath = path; }
@@ -57,6 +64,8 @@ class Zorro
5764
TH1D* mScalers = nullptr;
5865
TH1D* mSelections = nullptr;
5966
TH1D* mInspectedTVX = nullptr;
67+
std::shared_ptr<TH1> mAnalysedTriggers;
68+
std::bitset<128> mLastResult;
6069
std::vector<o2::dataformats::IRFrame> mBCranges;
6170
std::vector<ZorroHelper>* mZorroHelpers = nullptr;
6271
std::vector<std::string> mTOIs;

PWGHF/HFC/Tasks/taskCorrelationDplusHadrons.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,8 @@ struct HfTaskCorrelationDplusHadrons {
150150
// Histograms for data analysis
151151
registry.add("hBdtScorePrompt", "D+ BDT prompt score", {HistType::kTH1F, {axisBdtScore}});
152152
registry.add("hBdtScoreBkg", "D+ BDT bkg score", {HistType::kTH1F, {axisBdtScore}});
153+
registry.add("hMassDplusVsPt", "D+ candidates massVsPt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}});
153154
if (fillHistoData) {
154-
registry.add("hMassDplusVsPt", "D+ candidates massVsPt", {HistType::kTH2F, {{axisMassD}, {axisPtD}}});
155155
registry.add("hDeltaEtaPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaEta + "entries", {HistType::kTH1F, {axisDeltaEta}});
156156
registry.add("hDeltaPhiPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + "entries", {HistType::kTH1F, {axisDeltaPhi}});
157157
registry.add("hCorrel2DPtIntSignalRegion", stringDHadron + stringSignal + stringDeltaPhi + stringDeltaEta + "entries", {HistType::kTH2F, {{axisDeltaPhi}, {axisDeltaEta}}});

0 commit comments

Comments
 (0)