Skip to content

Commit 759c24e

Browse files
authored
[PWGLF] Add a trigger counter in hStrangeCorrelation.cxx (#17580)
1 parent 0c88d6b commit 759c24e

1 file changed

Lines changed: 33 additions & 2 deletions

File tree

PWGLF/Tasks/Strangeness/hStrangeCorrelation.cxx

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@
5454
#include <Framework/StaticFor.h>
5555
#include <Framework/runDataProcessing.h>
5656

57+
#include <TAxis.h>
5758
#include <TH1.h>
5859
#include <TH2.h>
5960
#include <TH3.h>
6061
#include <THn.h>
62+
#include <THnSparse.h>
6163
#include <TList.h>
6264
#include <TPDGCode.h>
6365
#include <TString.h>
@@ -2543,6 +2545,9 @@ struct HStrangeCorrelation {
25432545
histos.add("PairLossK0/Stage/hPhysicsFindable", "stages in h-K0 physics variables for findable K0", kTHnF, {axisPairLossStage, axisPairLossTruthDeltaPhi, axisPairLossTruthDeltaEta, axisPairLossTruthK0Pt, axisPairLossTruthTriggerPt, axisMultNDim});
25442546
histos.add("PairLossK0/Stage/hClose", "stages in trigger-daughter close-pair variables", kTHnF, {axisPairLossStage, axisPairLossMinDeltaPhiStar, axisPairLossDaughterDeltaEta, axisPairLossTruthK0Pt, axisPairLossTruthTriggerPt, axisPairLossFieldSign, axisPairLossChargeProduct});
25452547
histos.add("PairLossK0/Stage/hTriggerTracksFailureReason", "first-failing TriggerTracks condition for best-collision triggers, in h-K0 physics variables", kTHnF, {axisPairLossTriggerTracksFailureReason, axisPairLossTruthDeltaPhi, axisPairLossTruthDeltaEta, axisPairLossTruthK0Pt, axisPairLossTruthTriggerPt});
2548+
// 1/N_trigger denominator of the stage ladder: same stage axis as hCounts/hPhysics, generated trigger pT, eta, phi.
2549+
// Sparse because the eta-phi part would cost tens of MB dense for an occupancy of a few percent.
2550+
histos.add("PairLossK0/Stage/hTriggers", "triggers per stage: the 1/#it{N}_{trigger} normalisation of the stage ladder", kTHnSparseF, {axisPairLossStage, axisPairLossTruthTriggerPt, axesConfigurations.axisEta, axesConfigurations.axisPhi, axisVtxZNDim, axisMultNDim});
25462551

25472552
histos.add("PairLossK0/State/hFinalObjectStatePhysics", "00/01/10/11 final trigger-K0 object state", kTHnF, {axisPairLossFinalObjectState, axisPairLossTruthDeltaPhi, axisPairLossTruthDeltaEta, axisPairLossTruthK0Pt, axisPairLossTruthTriggerPt, axisPairLossFieldSign});
25482553
histos.add("PairLossK0/State/hFinalObjectStateClose", "00/01/10/11 final trigger-K0 object state in close-pair variables", kTHnF, {axisPairLossFinalObjectState, axisPairLossMinDeltaPhiStar, axisPairLossDaughterDeltaEta, axisPairLossTruthK0Pt, axisPairLossTruthTriggerPt, axisPairLossFieldSign, axisPairLossChargeProduct});
@@ -2584,15 +2589,19 @@ struct HStrangeCorrelation {
25842589
}
25852590
eventCounter->GetYaxis()->SetTitle("Entries");
25862591
histos.get<TH1>(HIST("PairLossK0/Event/hNRecoCollisions"))->GetYaxis()->SetTitle("MC collisions");
2587-
auto setStageLabels = [&](auto const& stageHistogram) {
2592+
auto setStageAxisLabels = [&](TAxis* stageAxis) {
25882593
for (int i = 0; i < PairLossK0NStages; ++i) {
2589-
stageHistogram->GetXaxis()->SetBinLabel(i + 1, PairLossK0StageNames[i].data());
2594+
stageAxis->SetBinLabel(i + 1, PairLossK0StageNames[i].data());
25902595
}
25912596
};
2597+
auto setStageLabels = [&](auto const& stageHistogram) {
2598+
setStageAxisLabels(stageHistogram->GetXaxis());
2599+
};
25922600
auto stageCounts = histos.get<TH1>(HIST("PairLossK0/Stage/hCounts"));
25932601
auto stageCountsFindable = histos.get<TH1>(HIST("PairLossK0/Stage/hCountsFindable"));
25942602
setStageLabels(stageCounts);
25952603
setStageLabels(stageCountsFindable);
2604+
setStageAxisLabels(histos.get<THnSparse>(HIST("PairLossK0/Stage/hTriggers"))->GetAxis(0));
25962605
stageCounts->GetYaxis()->SetTitle("Truth-pair entries");
25972606
stageCountsFindable->GetYaxis()->SetTitle("Findable truth-pair entries");
25982607

@@ -5083,6 +5092,28 @@ struct HStrangeCorrelation {
50835092
return &*std::max_element(iterator->second.begin(), iterator->second.end(), [](auto const& lhs, auto const& rhs) { return lhs.cosPA < rhs.cosPA; });
50845093
};
50855094

5095+
// Separate from the pair loop, which would count a trigger once per truth K0 and drop it entirely in events without one.
5096+
// Each stage holds the trigger-side condition of the same stage of hCounts/hPhysics, so the ratio keeps one trigger population.
5097+
for (auto const& truthTrigger : truthTriggers) {
5098+
const std::array<bool, PairLossK0NStages> triggerStagePassed = {
5099+
true, // Gen pair
5100+
true, // Findable K0->pi+pi-: K0 side only
5101+
contains(tracksBestCollision, truthTrigger.globalIndex), // Trigger pure reco (best collision)
5102+
contains(triggersInTable, truthTrigger.globalIndex), // Trigger in TriggerTracks
5103+
contains(triggersFinal, truthTrigger.globalIndex), // Trigger final selection
5104+
true, // V0 pure reco: K0 side only
5105+
true, // V0 candidate: K0 side only
5106+
true, // V0 in AssocV0s: K0 side only
5107+
true, // V0 final selection: K0 side only
5108+
contains(triggersFinal, truthTrigger.globalIndex)}; // Final reconstructed pair
5109+
for (int stage = 0; stage < PairLossK0NStages; ++stage) {
5110+
if (!triggerStagePassed[stage]) {
5111+
continue;
5112+
}
5113+
histos.fill(HIST("PairLossK0/Stage/hTriggers"), stage, truthTrigger.pt, truthTrigger.eta, truthTrigger.phi, collision.posZ(), multiplicity);
5114+
}
5115+
}
5116+
50865117
bool hasTruthPair = false;
50875118
for (auto const& truthTrigger : truthTriggers) {
50885119
for (auto const& truthK0 : truthK0s) {

0 commit comments

Comments
 (0)