Skip to content

Commit bbeb057

Browse files
[Trigger] Adding to external histograms the AnalysedTriggers (#10789)
Co-authored-by: Lucamicheletti93 <luca.mike93@gmail.com>
1 parent 6a9369f commit bbeb057

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

EventFiltering/Zorro.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto)
113113
}
114114
if (!ToiHisto) {
115115
LOGF(info, "TOI histogram not set, creating a new one");
116-
ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5);
116+
ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5);
117117
}
118118
// if it is the first run, initialize the histogram
119119
if (mRunNumberHistos.size() == 0) {
@@ -126,17 +126,22 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto)
126126
ZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data()));
127127
}
128128
// TOI histogram
129-
ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5);
129+
ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5);
130130
ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber));
131131
for (size_t i{0}; i < mTOIs.size(); ++i) {
132-
ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data());
132+
ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 1, mTOIs[i].data());
133+
ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 2, Form("%s AnalysedTriggers", mTOIs[i].data()));
133134
}
134135
}
135136
if (mInspectedTVX) {
136137
ZorroHisto->Fill(Form("%d", runNumber), "inspected TVX", mInspectedTVX->GetBinContent(1));
137138
ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1));
138139
}
139140
if (mSelections) {
141+
mAnalysedTriggers = new TH1D("AnalysedTriggers", "", mSelections->GetNbinsX() - 2, -0.5, mSelections->GetNbinsX() - 2.5);
142+
for (int iBin{2}; iBin < mSelections->GetNbinsX(); ++iBin) { // Exclude first and last bins as they are total number of analysed and selected events, respectively
143+
mAnalysedTriggers->GetXaxis()->SetBinLabel(iBin - 1, mSelections->GetXaxis()->GetBinLabel(iBin));
144+
}
140145
for (size_t i{0}; i < mTOIs.size(); ++i) {
141146
int bin = findBin(mSelections, mTOIs[i]);
142147
ZorroHisto->Fill(Form("%d", runNumber), Form("%s selections", mTOIs[i].data()), mSelections->GetBinContent(bin));
@@ -248,6 +253,11 @@ bool Zorro::isSelected(uint64_t bcGlobalId, uint64_t tolerance, TH2* ToiHisto)
248253
if (mTOIidx[i] < 0) {
249254
continue;
250255
} else if (mLastResult.test(mTOIidx[i])) {
256+
if (ToiHisto && mAnalysedTriggers) {
257+
int binX = ToiHisto->GetXaxis()->FindBin(Form("%d", mRunNumber));
258+
int binY = ToiHisto->GetYaxis()->FindBin(Form("%s AnalysedTriggers", mTOIs[i].data()));
259+
ToiHisto->SetBinContent(binX, binY, mAnalysedTriggers->GetBinContent(mAnalysedTriggers->GetXaxis()->FindBin(mTOIs[i].data())));
260+
}
251261
mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting
252262
if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) {
253263
mAnalysedTriggersOfInterest->Fill(i);

0 commit comments

Comments
 (0)