From 1bd02f75f97cb21b7862182ed2d7cc5cbdeb0efb Mon Sep 17 00:00:00 2001 From: dajones2 Date: Mon, 6 Oct 2025 16:19:40 +0100 Subject: [PATCH 1/4] PWGJE: Adding task for denominator consistency for effieicncy calculation --- PWGJE/Tasks/jetHadronRecoil.cxx | 150 ++++++++++++++++++++++++++++++-- 1 file changed, 145 insertions(+), 5 deletions(-) diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 34af8f17272..40ab9d9779f 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -140,7 +140,7 @@ struct JetHadronRecoil { registry.add("hZvtxSelected", "Z vertex position;Z_{vtx};entries", {HistType::kTH1F, {{80, -20, 20}}}, doSumw); - if (doprocessData || doprocessDataWithRhoSubtraction || doprocessMCD || doprocessMCDWithRhoSubtraction || doprocessMCDWeighted || doprocessMCDWeightedWithRhoSubtraction || doprocessMCP || doprocessMCPWeighted) { + if (doprocessData || doprocessDataWithRhoSubtraction || doprocessMCD || doprocessMCDWithRhoSubtraction || doprocessMCDWeighted || doprocessMCDWeightedWithRhoSubtraction || doprocessMCP || doprocessMCPWeighted || doprocessMCPWeightedWithMatchedTracks) { registry.add("hNtrig", "number of triggers;trigger type;entries", {HistType::kTH1F, {{2, 0, 2}}}, doSumw); registry.add("hSignalTriggersPtHard", "Signal triggers vs PtHard", {HistType::kTH1F, {{20, 0, 5}}}, doSumw); registry.add("hReferenceTriggersPtHard", "Reference triggers vs PtHard", {HistType::kTH1F, {{20, 0, 5}}}, doSumw); @@ -181,7 +181,7 @@ struct JetHadronRecoil { registry.add("hDeltaRpTDPhiReferenceShifts", "testing shifts;p_{T,jet};#Delta#phi;#DeltaR;shifts", {HistType::kTHnSparseD, {{500, -100, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis, {20, 0.0, 2.0}}}, doSumw); } - if (doprocessMCP || doprocessMCPWeighted) { + if (doprocessMCP || doprocessMCPWeighted || doprocessMCPWeightedWithMatchedTracks) { registry.add("hPartvsJets", "comparing leading particles and jets;p_{T,part};p_{T,jet};#hat{p}", {HistType::kTH3F, {{200, 0, 200}, {500, -100, 400}, {195, 5, 200}}}, doSumw); registry.add("hPtPart", "Particle p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}, doSumw); registry.add("hEtaPart", "Particle #eta;#eta;entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}, doSumw); @@ -386,11 +386,13 @@ struct JetHadronRecoil { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; + registry.fill(HIST("hSignalTriggers"), track.pt(), weight); } if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; + registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); } registry.fill(HIST("hPtPart"), particle.pt(), weight); registry.fill(HIST("hEtaPart"), particle.eta(), weight); @@ -466,6 +468,116 @@ struct JetHadronRecoil { registry.fill(HIST("hPartvsJets"), leadingPartPt, leadingJetPt, pTHat, weight); } + template + void fillMCPHistogramsWithMatchedTracks(T const& jets, U const&, V const& tracks, float weight = 1.0, float pTHat = 999.0) + { + bool isSigCol; + std::vector phiTTAr; + std::vector ptTTAr; + double phiTT = 0; + double ptTT = 0; + int trigNumber = 0; + int nTT = 0; + double leadingPartPt = 0; + double leadingJetPt = 0; + float dice = rand->Rndm(); + if (dice < fracSig) + isSigCol = true; + else + isSigCol = false; + + for (const auto& track : tracks) { + if (!track.has_mcParticle()) { + continue; + } + auto particle = track.template mcParticle_as(); + if (particle.pt() > leadingPartPt) { + leadingPartPt = particle.pt(); + } + if (particle.pt() > pTHatTrackMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (!pdgParticle) { + continue; + } + if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) { + continue; + } + if (isSigCol && particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) { + phiTTAr.push_back(particle.phi()); + ptTTAr.push_back(particle.pt()); + nTT++; + registry.fill(HIST("hSignalTriggers"), track.pt(), weight); + } + if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { + phiTTAr.push_back(particle.phi()); + ptTTAr.push_back(particle.pt()); + nTT++; + registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); + } + registry.fill(HIST("hPtPart"), particle.pt(), weight); + registry.fill(HIST("hEtaPart"), particle.eta(), weight); + registry.fill(HIST("hPhiPart"), particle.phi(), weight); + registry.fill(HIST("hPart3D"), particle.pt(), particle.eta(), particle.phi(), weight); + registry.fill(HIST("hPtPartPtHard"), particle.pt(), particle.pt() / pTHat, weight); + } + + for (const auto& jet : jets) { + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); + } + if (jet.pt() > pTHatMaxMCP * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + for (const auto& constituent : jet.template tracks_as()) { + registry.fill(HIST("hConstituents3D"), constituent.pt(), constituent.eta(), constituent.phi()); + } + registry.fill(HIST("hJetPt"), jet.pt(), weight); + registry.fill(HIST("hJetEta"), jet.eta(), weight); + registry.fill(HIST("hJetPhi"), jet.phi(), weight); + registry.fill(HIST("hJet3D"), jet.pt(), jet.eta(), jet.phi(), weight); + + if (nTT > 0) { + float dphi = RecoDecay::constrainAngle(jet.phi() - phiTT); + double dR = getWTAaxisDifference(jet, particles); + if (isSigCol) { + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTSignalPart"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRSignalPart"), dR, weight); + } + registry.fill(HIST("hDeltaRpTDPhiSignalPart"), jet.pt(), dphi, dR, weight); + registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt(), weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hSignalPt"), jet.pt(), weight); + registry.fill(HIST("hSignalPtHard"), jet.pt(), ptTT / pTHat, weight); + } + } + if (!isSigCol) { + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTPartReference"), jet.pt(), dR, weight); + registry.fill(HIST("hDeltaRPartReference"), dR, weight); + } + registry.fill(HIST("hDeltaRpTDPhiReferencePart"), jet.pt(), dphi, dR, weight); + registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt(), weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hReferencePt"), jet.pt(), weight); + registry.fill(HIST("hReferencePtHard"), jet.pt(), ptTT / pTHat, weight); + } + } + } + } + registry.fill(HIST("hPartvsJets"), leadingPartPt, leadingJetPt, pTHat, weight); + } + template void fillMatchedHistograms(T const& jetsBase, U const&, X const& tracks, Y const& particles, float weight = 1.0, float rho = 0.0, float pTHat = 999.0) { @@ -534,10 +646,19 @@ struct JetHadronRecoil { } } if (track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { - phiTTAr.push_back(track.phi()); - nTT++; auto particle = track.template mcParticle_as(); - phiTTArPart.push_back(particle.phi()); + auto pdgParticle = pdg->GetParticle(particle.pdgCode()); + if (!pdgParticle) { + continue; + } + if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) { + continue; + } + if (particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) { + nTT++; + phiTTAr.push_back(track.phi()); + phiTTArPart.push_back(particle.phi()); + } } } @@ -758,6 +879,25 @@ struct JetHadronRecoil { } PROCESS_SWITCH(JetHadronRecoil, processMCPWeighted, "process MC particle level with event weights", false); + void processMCPWeightedWithMatchedTracks(aod::JetMcCollision const& collision, + soa::Filtered> const& jets, + soa::Filtered const& particles, + soa::Filtered const& tracks) + { + if (std::abs(collision.posZ()) > vertexZCut) { + return; + } + if (skipMBGapEvents && collision.subGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return; + } + if (collision.ptHard() < pTHatMinEvent) { + return; + } + registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.weight()); + fillMCPHistogramsWithMatchedTracks(jets, particles, tracks, collision.weight(), collision.ptHard()); + } + PROCESS_SWITCH(JetHadronRecoil, processMCPWeightedWithMatchedTracks, "process MC particle level with event weights - only triggers matched with detector level tracks", false); + void processJetsMCPMCDMatched(soa::Filtered>::iterator const& collision, soa::Filtered> const& mcdjets, aod::JetTracks const& tracks, From 009bba3bd4128dc801eaeb511aa5b31ea3a39323 Mon Sep 17 00:00:00 2001 From: dajones2 Date: Mon, 6 Oct 2025 18:13:40 +0100 Subject: [PATCH 2/4] Fixing bugs --- PWGJE/Tasks/jetHadronRecoil.cxx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 40ab9d9779f..8cadc53417a 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -386,13 +386,13 @@ struct JetHadronRecoil { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; - registry.fill(HIST("hSignalTriggers"), track.pt(), weight); + registry.fill(HIST("hSignalTriggers"), particle.pt(), weight); } if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; - registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); + registry.fill(HIST("hReferenceTriggers"), particle.pt(), weight); } registry.fill(HIST("hPtPart"), particle.pt(), weight); registry.fill(HIST("hEtaPart"), particle.eta(), weight); @@ -469,7 +469,7 @@ struct JetHadronRecoil { } template - void fillMCPHistogramsWithMatchedTracks(T const& jets, U const&, V const& tracks, float weight = 1.0, float pTHat = 999.0) + void fillMCPHistogramsWithMatchedTracks(T const& jets, U const& particles, V const& tracks, float weight = 1.0, float pTHat = 999.0) { bool isSigCol; std::vector phiTTAr; @@ -512,13 +512,13 @@ struct JetHadronRecoil { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; - registry.fill(HIST("hSignalTriggers"), track.pt(), weight); + registry.fill(HIST("hSignalTriggers"), particle.pt(), weight); } if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; - registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); + registry.fill(HIST("hReferenceTriggers"), particle.pt(), weight); } registry.fill(HIST("hPtPart"), particle.pt(), weight); registry.fill(HIST("hEtaPart"), particle.eta(), weight); @@ -882,7 +882,7 @@ struct JetHadronRecoil { void processMCPWeightedWithMatchedTracks(aod::JetMcCollision const& collision, soa::Filtered> const& jets, soa::Filtered const& particles, - soa::Filtered const& tracks) + soa::Filtered const& tracks) { if (std::abs(collision.posZ()) > vertexZCut) { return; From 2a95823c42c282f24719c5a2f1bf5a584666c3ce Mon Sep 17 00:00:00 2001 From: dajones2 Date: Mon, 6 Oct 2025 18:28:45 +0100 Subject: [PATCH 3/4] Fixing bugs --- PWGJE/Tasks/jetHadronRecoil.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 8cadc53417a..52410076e76 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -527,6 +527,22 @@ struct JetHadronRecoil { registry.fill(HIST("hPtPartPtHard"), particle.pt(), particle.pt() / pTHat, weight); } + if (nTT > 0) { + trigNumber = rand->Integer(nTT); + phiTT = phiTTAr[trigNumber]; + ptTT = ptTTAr[trigNumber]; + if (isSigCol) { + registry.fill(HIST("hNtrig"), 1.5, weight); + registry.fill(HIST("hSigEventTriggers"), nTT, weight); + registry.fill(HIST("hSignalTriggersPtHard"), ptTT / pTHat, weight); + } + if (!isSigCol) { + registry.fill(HIST("hNtrig"), 0.5, weight); + registry.fill(HIST("hRefEventTriggers"), nTT, weight); + registry.fill(HIST("hReferenceTriggersPtHard"), ptTT / pTHat, weight); + } + } + for (const auto& jet : jets) { if (jet.pt() > leadingJetPt) { leadingJetPt = jet.pt(); From fbeaecc26bf14ba2f12811d5dc5eeac30e8073bf Mon Sep 17 00:00:00 2001 From: dajones2 Date: Tue, 7 Oct 2025 16:27:30 +0100 Subject: [PATCH 4/4] Selection on track pt --- PWGJE/Tasks/jetHadronRecoil.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 52410076e76..1d42f47562c 100644 --- a/PWGJE/Tasks/jetHadronRecoil.cxx +++ b/PWGJE/Tasks/jetHadronRecoil.cxx @@ -508,13 +508,13 @@ struct JetHadronRecoil { if ((pdgParticle->Charge() == 0.0) || (!particle.isPhysicalPrimary())) { continue; } - if (isSigCol && particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin) { + if (isSigCol && particle.pt() < ptTTsigMax && particle.pt() > ptTTsigMin && track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; registry.fill(HIST("hSignalTriggers"), particle.pt(), weight); } - if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin) { + if (!isSigCol && particle.pt() < ptTTrefMax && particle.pt() > ptTTrefMin && track.pt() < ptTTrefMax && track.pt() > ptTTrefMin) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++;