From d8a8307d815c59ee7a643553f76a4edd3e59d337 Mon Sep 17 00:00:00 2001 From: Lucamicheletti93 Date: Tue, 8 Apr 2025 16:57:03 +0200 Subject: [PATCH 1/3] Adding to external histograms the AnalysedTriggers --- EventFiltering/Zorro.cxx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index ec661548d09..bebdf72192d 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -113,7 +113,7 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) } if (!ToiHisto) { LOGF(info, "TOI histogram not set, creating a new one"); - ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto = new TH2D("TOI", "TOI", 1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); } // if it is the first run, initialize the histogram if (mRunNumberHistos.size() == 0) { @@ -126,10 +126,11 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) ZorroHisto->GetYaxis()->SetBinLabel(i + 2 + mTOIs.size(), Form("%s scalers", mTOIs[i].data())); } // TOI histogram - ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size(), -0.5, mTOIs.size() - 0.5); + ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); for (size_t i{0}; i < mTOIs.size(); ++i) { ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); + ToiHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s AnalysedTriggers", mTOIs[i].data())); } } if (mInspectedTVX) { @@ -137,6 +138,10 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) ZorroHisto->SetBinError(mRunNumberHistos.size() + 1, 1, mInspectedTVX->GetBinError(1)); } if (mSelections) { + mAnalysedTriggers = new TH1D("AnalysedTriggers", "", mSelections->GetNbinsX() - 2, -0.5, mSelections->GetNbinsX() - 2.5); + for (int iBin{2}; iBin < mSelections->GetNbinsX(); ++iBin) { // Exclude first and last bins as they are total number of analysed and selected events, respectively + mAnalysedTriggers->GetXaxis()->SetBinLabel(iBin - 1, mSelections->GetXaxis()->GetBinLabel(iBin)); + } for (size_t i{0}; i < mTOIs.size(); ++i) { int bin = findBin(mSelections, mTOIs[i]); 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) if (mTOIidx[i] < 0) { continue; } else if (mLastResult.test(mTOIidx[i])) { + if (ToiHisto && mAnalysedTriggers) { + int binX = ToiHisto->GetXaxis()->FindBin(Form("%d", mRunNumber)); + int binY = ToiHisto->GetYaxis()->FindBin(Form("%s AnalysedTriggers", mTOIs[i].data())); + ToiHisto->SetBinContent(binX, binY, mAnalysedTriggers->GetBinContent(mAnalysedTriggers->GetXaxis()->FindBin(mTOIs[i].data()))); + } mTOIcounts[i] += (lastSelectedIdx != mLastSelectedIdx); /// Avoid double counting if (mAnalysedTriggersOfInterest && lastSelectedIdx != mLastSelectedIdx) { mAnalysedTriggersOfInterest->Fill(i); @@ -300,4 +310,4 @@ void Zorro::setupHelpers(int64_t timestamp) mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel))); } mAccountedBCranges.resize(mBCranges.size(), false); -} +} \ No newline at end of file From edd2adad6653c0bdf00b1bfa0e69305478c13578 Mon Sep 17 00:00:00 2001 From: Lucamicheletti93 Date: Tue, 8 Apr 2025 16:59:06 +0200 Subject: [PATCH 2/3] Fix index --- EventFiltering/Zorro.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index bebdf72192d..010dc6590cb 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -129,8 +129,8 @@ void Zorro::populateExternalHists(int runNumber, TH2* ZorroHisto, TH2* ToiHisto) ToiHisto->SetBins(1, -0.5, 0.5, mTOIs.size() * 2, -0.5, mTOIs.size() * 2 - 0.5); ToiHisto->GetXaxis()->SetBinLabel(1, Form("%d", runNumber)); for (size_t i{0}; i < mTOIs.size(); ++i) { - ToiHisto->GetYaxis()->SetBinLabel(i + 1, mTOIs[i].data()); - ToiHisto->GetYaxis()->SetBinLabel(i + 2, Form("%s AnalysedTriggers", mTOIs[i].data())); + ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 1, mTOIs[i].data()); + ToiHisto->GetYaxis()->SetBinLabel(i * 2 + 2, Form("%s AnalysedTriggers", mTOIs[i].data())); } } if (mInspectedTVX) { From 0016ad5bd8d8f5d582e893449694bc38b436cba3 Mon Sep 17 00:00:00 2001 From: Lucamicheletti93 Date: Tue, 8 Apr 2025 17:08:58 +0200 Subject: [PATCH 3/3] Fix Clang --- EventFiltering/Zorro.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EventFiltering/Zorro.cxx b/EventFiltering/Zorro.cxx index 010dc6590cb..8b47d0c2d3f 100644 --- a/EventFiltering/Zorro.cxx +++ b/EventFiltering/Zorro.cxx @@ -310,4 +310,4 @@ void Zorro::setupHelpers(int64_t timestamp) mBCranges.emplace_back(InteractionRecord::long2IR(std::min(helper.bcAOD, helper.bcEvSel)), InteractionRecord::long2IR(std::max(helper.bcAOD, helper.bcEvSel))); } mAccountedBCranges.resize(mBCranges.size(), false); -} \ No newline at end of file +}