diff --git a/PWGJE/Tasks/jetHadronRecoil.cxx b/PWGJE/Tasks/jetHadronRecoil.cxx index 34af8f17272..b0705f7c8d2 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); @@ -179,9 +179,11 @@ struct JetHadronRecoil { registry.add("hDeltaRpTReference", "jet p_{T} vs #DeltaR;p_{T,jet};#DeltaR", {HistType::kTH2F, {{500, -100, 400}, dRAxis}}, doSumw); registry.add("hDeltaRpTDPhiReference", "jet p_{T} vs #DeltaR vs #Delta#phi;p_{T,jet};#Delta#phi;#DeltaR", {HistType::kTH3F, {{500, -100, 400}, {100, 0, o2::constants::math::TwoPI}, dRAxis}}, doSumw); 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); + registry.add("hPtTrackMatched", "Track p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}, doSumw); + registry.add("hPtTrackMatchedToCollisions", "Track p_{T};p_{T};entries", {HistType::kTH1F, {{200, 0, 200}}}, 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); @@ -262,7 +264,149 @@ struct JetHadronRecoil { registry.fill(HIST("hTrack3D"), track.pt(), track.eta(), track.phi(), weight); registry.fill(HIST("hPtTrackPtHard"), track.pt() / pTHat, track.pt(), 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("hRhoSignal"), rho, 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("hRhoReference"), rhoReference, weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hRhoReferenceShift"), rho + shift, shift, weight); + } + registry.fill(HIST("hReferenceTriggersPtHard"), ptTT / pTHat, weight); + } + } + for (const auto& jet : jets) { + if (jet.pt() > leadingJetPt) { + leadingJetPt = jet.pt(); + } + if (jet.pt() > pTHatMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + for (const auto& constituent : jet.template tracks_as()) { + if (constituent.pt() > leadingPT) { + leadingPT = constituent.pt(); + } + registry.fill(HIST("hConstituents3D"), constituent.pt(), constituent.eta(), constituent.phi()); + } + if (leadingPT > maxLeadingTrackPt) { + continue; + } + registry.fill(HIST("hJetPt"), jet.pt() - (rho * jet.area()), weight); + registry.fill(HIST("hJetEta"), jet.eta(), weight); + registry.fill(HIST("hJetPhi"), jet.phi(), weight); + registry.fill(HIST("hJet3D"), jet.pt() - (rho * jet.area()), jet.eta(), jet.phi(), weight); + + if (nTT > 0) { + float dphi = RecoDecay::constrainAngle(jet.phi() - phiTT); + double dR = getWTAaxisDifference(jet, tracks); + if (isSigCol) { + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTSignal"), jet.pt() - (rho * jet.area()), dR, weight); + registry.fill(HIST("hDeltaRSignal"), dR, weight); + } + registry.fill(HIST("hDeltaRpTDPhiSignal"), jet.pt() - (rho * jet.area()), dphi, dR, weight); + registry.fill(HIST("hSignalPtDPhi"), dphi, jet.pt() - (rho * jet.area()), weight); + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hSignalPt"), jet.pt() - (rho * jet.area()), weight); + registry.fill(HIST("hSignalPtHard"), jet.pt() - (rho * jet.area()), ptTT / pTHat, weight); + } + } + if (!isSigCol) { + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hDeltaRpTReference"), jet.pt() - (rhoReference * jet.area()), dR, weight); + registry.fill(HIST("hDeltaRReference"), dR, weight); + } + registry.fill(HIST("hDeltaRpTDPhiReference"), jet.pt() - (rhoReference * jet.area()), dphi, dR, weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hDeltaRpTDPhiReferenceShifts"), jet.pt() - ((rho + shift) * jet.area()), dphi, dR, shift, weight); + } + registry.fill(HIST("hReferencePtDPhi"), dphi, jet.pt() - (rhoReference * jet.area()), weight); + for (double shift = 0.0; shift <= 2.0; shift += 0.1) { + registry.fill(HIST("hReferencePtDPhiShifts"), dphi, jet.pt() - ((rho + shift) * jet.area()), shift, weight); + } + if (std::abs(dphi - o2::constants::math::PI) < 0.6) { + registry.fill(HIST("hReferencePt"), jet.pt() - (rhoReference * jet.area()), weight); + registry.fill(HIST("hReferencePtHard"), jet.pt() - (rhoReference * jet.area()), ptTT / pTHat, weight); + } + } + } + } + registry.fill(HIST("hTracksvsJets"), leadingTrackPt, leadingJetPt, pTHat, weight); + } + template + void fillHistogramsMCD(T const& jets, U const& tracks, P const&, float weight = 1.0, float rho = 0.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 leadingPT = 0; + double leadingTrackPt = 0; + double leadingJetPt = 0; + float rhoReference = rho + rhoReferenceShift; + + float dice = rand->Rndm(); + if (dice < fracSig) + isSigCol = true; + else + isSigCol = false; + + for (const auto& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + if (track.pt() > leadingTrackPt) { + leadingTrackPt = track.pt(); + } + if (track.pt() > pTHatTrackMaxMCD * pTHat) { + if (outlierRejectEvent) { + return; + } else { + continue; + } + } + if (isSigCol && track.pt() < ptTTsigMax && track.pt() > ptTTsigMin) { + phiTTAr.push_back(track.phi()); + ptTTAr.push_back(track.pt()); + registry.fill(HIST("hSignalTriggers"), track.pt(), weight); + nTT++; + } + if (!isSigCol && track.pt() < ptTTrefMax && track.pt() > ptTTrefMin) { + phiTTAr.push_back(track.phi()); + ptTTAr.push_back(track.pt()); + registry.fill(HIST("hReferenceTriggers"), track.pt(), weight); + nTT++; + } + registry.fill(HIST("hPtTrack"), track.pt(), weight); + registry.fill(HIST("hEtaTrack"), track.eta(), weight); + registry.fill(HIST("hPhiTrack"), track.phi(), weight); + registry.fill(HIST("hTrack3D"), track.pt(), track.eta(), track.phi(), weight); + registry.fill(HIST("hPtTrackPtHard"), track.pt() / pTHat, track.pt(), weight); + if (track.has_mcParticle()) { + registry.fill(HIST("hPtTrackMatched"), track.pt(), weight); + auto particle = track.template mcParticle_as

(); + if (track.collisionId() == particle.mcCollisionId()) { + registry.fill(HIST("hPtTrackMatchedToCollisions"), track.pt(), weight); + } + } + } if (nTT > 0) { trigNumber = rand->Integer(nTT); phiTT = phiTTAr[trigNumber]; @@ -386,11 +530,139 @@ struct JetHadronRecoil { 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) { phiTTAr.push_back(particle.phi()); ptTTAr.push_back(particle.pt()); nTT++; + registry.fill(HIST("hReferenceTriggers"), particle.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); + } + + 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(); + } + 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 fillMCPHistogramsWithMatchedTracks(T const& jets, U const& particles, 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 && 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 && track.pt() < ptTTrefMax && track.pt() > ptTTrefMin) { + phiTTAr.push_back(particle.phi()); + ptTTAr.push_back(particle.pt()); + nTT++; + registry.fill(HIST("hReferenceTriggers"), particle.pt(), weight); } registry.fill(HIST("hPtPart"), particle.pt(), weight); registry.fill(HIST("hEtaPart"), particle.eta(), weight); @@ -534,10 +806,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()); + } } } @@ -625,7 +906,8 @@ struct JetHadronRecoil { void processMCD(soa::Filtered>::iterator const& collision, aod::JMcCollisions const&, soa::Filtered> const& jets, - soa::Filtered const& tracks) + soa::Filtered const& tracks, + soa::Filtered const& particles) { if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; @@ -643,14 +925,15 @@ struct JetHadronRecoil { return; } registry.fill(HIST("hZvtxSelected"), collision.posZ()); - fillHistograms(jets, tracks, 1.0, 0.0, collision.mcCollision().ptHard()); + fillHistogramsMCD(jets, tracks, particles, 1.0, 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCD, "process MC detector level", false); void processMCDWithRhoSubtraction(soa::Filtered>::iterator const& collision, aod::JMcCollisions const&, soa::Filtered> const& jets, - soa::Filtered const& tracks) + soa::Filtered const& tracks, + soa::Filtered const& particles) { if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; @@ -668,14 +951,15 @@ struct JetHadronRecoil { return; } registry.fill(HIST("hZvtxSelected"), collision.posZ()); - fillHistograms(jets, tracks, 1.0, collision.rho(), collision.mcCollision().ptHard()); + fillHistogramsMCD(jets, tracks, particles, 1.0, collision.rho(), collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCDWithRhoSubtraction, "process MC detector level with rho subtraction", false); void processMCDWeighted(soa::Filtered>::iterator const& collision, aod::JMcCollisions const&, soa::Filtered> const& jets, - soa::Filtered const& tracks) + soa::Filtered const& tracks, + soa::Filtered const& particles) { if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; @@ -693,14 +977,15 @@ struct JetHadronRecoil { return; } registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight()); - fillHistograms(jets, tracks, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard()); + fillHistogramsMCD(jets, tracks, particles, collision.mcCollision().weight(), 0.0, collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCDWeighted, "process MC detector level with event weights", false); void processMCDWeightedWithRhoSubtraction(soa::Filtered>::iterator const& collision, aod::JMcCollisions const&, soa::Filtered> const& jets, - soa::Filtered const& tracks) + soa::Filtered const& tracks, + soa::Filtered const& particles) { if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { return; @@ -718,7 +1003,7 @@ struct JetHadronRecoil { return; } registry.fill(HIST("hZvtxSelected"), collision.posZ(), collision.mcCollision().weight()); - fillHistograms(jets, tracks, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard()); + fillHistogramsMCD(jets, tracks, particles, collision.mcCollision().weight(), collision.rho(), collision.mcCollision().ptHard()); } PROCESS_SWITCH(JetHadronRecoil, processMCDWeightedWithRhoSubtraction, "process MC detector level with event weights and rho subtraction", false); @@ -758,6 +1043,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,