Skip to content

Commit d80d859

Browse files
[PWGJE] add jet migration and event-normalization corrections (#18016)
Co-authored-by: Arvind Khuntia <arvind.khuntia@cern.ch>
1 parent 6037ae9 commit d80d859

1 file changed

Lines changed: 177 additions & 1 deletion

File tree

‎PWGJE/Tasks/nucleiInJets.cxx‎

Lines changed: 177 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,17 @@ struct nucleiInJets {
815815
jetHist.add<TH2>("eff/recmatched/mcC/gen/perpCone/pt/PtParticleType", "Pt (gen, mcC, perp cone) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
816816
jetHist.add<TH2>("eff/recmatched/mcCSpectra/gen/perpCone/pt/PtParticleType", "Pt (gen, mcCSpectra, perp cone) vs particletype", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
817817

818+
jetHist.add<TH1>("jetSelCorr/genSel/hLeadingJetPt", "particle-level leading jet selected for jet-selection correction; #it{p}_{T,lead}^{gen} (GeV/#it{c}); Entries", HistType::kTH1F, {{100, 0., 100.}});
819+
jetHist.add<TH1>("jetSelCorr/recoSel/hLeadingJetPtBkgSub", "matched detector-level leading jet selected for jet-selection correction; #it{p}_{T,lead}^{reco,corr} (GeV/#it{c}); Entries", HistType::kTH1F, {{120, -20., 100.}});
820+
jetHist.add<TH2>("jetSelCorr/recoSel/hMatchedLeadingJetPt", "selected matched leading jet; #it{p}_{T,lead}^{reco,corr} (GeV/#it{c}); #it{p}_{T,lead}^{gen} (GeV/#it{c})", HistType::kTH2F, {{120, -20., 100.}, {100, 0., 100.}});
821+
jetHist.add<TH1>("jetSelCorr/eventNorm/hEventCounts", "event count for leading-jet event-normalization correction; event selection; Entries", HistType::kTH1D, {{2, 0., 2.}});
822+
jetHist.get<TH1>(HIST("jetSelCorr/eventNorm/hEventCounts"))->GetXaxis()->SetBinLabel(1, "gen lead #it{p}_{T} > cut");
823+
jetHist.get<TH1>(HIST("jetSelCorr/eventNorm/hEventCounts"))->GetXaxis()->SetBinLabel(2, "reco lead #it{p}_{T}^{corr} > cut");
824+
jetHist.add<TH2>("jetSelCorr/genSel/jetCone/pt/PtParticleType", "generated primaries in particle-level leading-jet cone; #it{p}_{T}^{gen} (GeV/#it{c}); particle type", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
825+
jetHist.add<TH2>("jetSelCorr/genSel/perpCone/pt/PtParticleType", "generated primaries in particle-level perpendicular cone; #it{p}_{T}^{gen} (GeV/#it{c}); particle type", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
826+
jetHist.add<TH2>("jetSelCorr/recoSel/jetCone/pt/PtParticleType", "generated primaries in matched reco-selected leading-jet cone; #it{p}_{T}^{gen} (GeV/#it{c}); particle type", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
827+
jetHist.add<TH2>("jetSelCorr/recoSel/perpCone/pt/PtParticleType", "generated primaries in matched reco-selected perpendicular cone; #it{p}_{T}^{gen} (GeV/#it{c}); particle type", HistType::kTH2D, {{PtAxis}, {14, -7, 7}});
828+
818829
jetHist.add<TH2>("feeddown/antiProton/jetCone/PtOrigin", "reconstructed #bar{p} origin in jet cone; #it{p}_{T}^{rec} (GeV/#it{c}); origin", HistType::kTH2D, {{PtAxis}, {ParticleOriginAxis}});
819830
jetHist.add<TH2>("feeddown/antiProton/jetCone/PtOriginTPC", "reconstructed #bar{p} origin in jet cone, TPC PID; #it{p}_{T}^{rec} (GeV/#it{c}); origin", HistType::kTH2D, {{PtAxis}, {ParticleOriginAxis}});
820831
jetHist.add<TH2>("feeddown/antiProton/jetCone/PtOriginTOF", "reconstructed #bar{p} origin in jet cone, TOF matched; #it{p}_{T}^{rec} (GeV/#it{c}); origin", HistType::kTH2D, {{PtAxis}, {ParticleOriginAxis}});
@@ -2291,13 +2302,17 @@ struct nucleiInJets {
22912302
jetHist.fill(HIST("mcdJet/eventStat"), 2.5);
22922303

22932304
int nJets = 0;
2305+
int nAcceptedJets = 0;
22942306
std::vector<float> leadingJetWithPtEtaPhi(3, -999.f);
22952307
float leadingJetPt = -1.0f;
22962308
for (auto& mcdjet : mcdjets) {
22972309
jetHist.fill(HIST("mcdJet/hJetPt"), mcdjet.pt());
22982310
jetHist.fill(HIST("mcdJet/hJetEta"), mcdjet.eta());
22992311
jetHist.fill(HIST("mcdJet/hJetPhi"), mcdjet.phi());
2300-
if (mcdjet.pt() > leadingJetPt) {
2312+
if (isConeAxisAccepted(mcdjet.eta())) {
2313+
nAcceptedJets++;
2314+
}
2315+
if (isConeAxisAccepted(mcdjet.eta()) && mcdjet.pt() > leadingJetPt) {
23012316
leadingJetPt = mcdjet.pt();
23022317
leadingJetWithPtEtaPhi[0] = mcdjet.pt();
23032318
leadingJetWithPtEtaPhi[1] = mcdjet.eta();
@@ -2309,6 +2324,8 @@ struct nucleiInJets {
23092324
jetHist.fill(HIST("mcdJet/nJetsPerEvent"), nJets);
23102325
if (isWithJetEvents && nJets == 0)
23112326
return;
2327+
if (isWithJetEvents && nAcceptedJets == 0)
2328+
return;
23122329
for (const auto& track : tracks) {
23132330
auto fullTrack = track.track_as<TrackCandidatesMC>();
23142331
if (!isTrackSelected(fullTrack))
@@ -2339,6 +2356,9 @@ struct nucleiInJets {
23392356
jetFlagPerpCone = true;
23402357
} else if (!isWithLeadingJet) {
23412358
for (const auto& mcdjet : mcdjets) {
2359+
if (!isConeAxisAccepted(mcdjet.eta())) {
2360+
continue;
2361+
}
23422362
double delPhi = TVector2::Phi_mpi_pi(mcdjet.phi() - track.phi());
23432363
double delEta = mcdjet.eta() - track.eta();
23442364
double R = RecoDecay::sqrtSumOfSquares(delEta, delPhi);
@@ -2357,6 +2377,73 @@ struct nucleiInJets {
23572377
}
23582378

23592379
Preslice<soa::Join<aod::JMcParticles, aod::JMcParticlePIs>> perMCCol = aod::jmcparticle::mcCollisionId;
2380+
2381+
template <typename CollType>
2382+
bool isRecoCollisionSelectedForJetSelectionCorrection(const CollType& collision)
2383+
{
2384+
if (std::abs(collision.posZ()) > cfgMaxZVertex) {
2385+
return false;
2386+
}
2387+
if (!jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("sel8"))) {
2388+
return false;
2389+
}
2390+
if (selNoSameBunchPileup && !jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("NoSameBunchPileup"))) {
2391+
return false;
2392+
}
2393+
if (selIsGoodZvtxFT0vsPV && !jetderiveddatautilities::selectCollision(collision, jetderiveddatautilities::initialiseEventSelectionBits("IsGoodZvtxFT0vsPV"))) {
2394+
return false;
2395+
}
2396+
if (useOccupancy && !isOccupancyAccepted(collision)) {
2397+
return false;
2398+
}
2399+
return true;
2400+
}
2401+
2402+
template <bool RecoSelected, typename ParticlesType>
2403+
void fillJetSelectionCorrectionParticles(const ParticlesType& mcParticles, double jetEta, double jetPhi)
2404+
{
2405+
const auto perpConePhiJet = getPerpendicuarPhi(jetPhi);
2406+
for (const auto& mcParticle : mcParticles) {
2407+
if (!mcParticle.isPhysicalPrimary()) {
2408+
continue;
2409+
}
2410+
if (std::fabs(mcParticle.eta()) > cfgtrkMaxEta) {
2411+
continue;
2412+
}
2413+
if (useRapidityCutForPID && !isRapiditySelectedForPID(mcParticle.y())) {
2414+
continue;
2415+
}
2416+
2417+
const auto particleType = mapPDGToValue(mcParticle.pdgCode());
2418+
if (particleType == 0) {
2419+
continue;
2420+
}
2421+
2422+
const double delEta = jetEta - mcParticle.eta();
2423+
const double delPhi = TVector2::Phi_mpi_pi(jetPhi - mcParticle.phi());
2424+
const double rJet = RecoDecay::sqrtSumOfSquares(delEta, delPhi);
2425+
if (rJet < cfgjetR) {
2426+
if constexpr (RecoSelected) {
2427+
jetHist.fill(HIST("jetSelCorr/recoSel/jetCone/pt/PtParticleType"), mcParticle.pt(), particleType);
2428+
} else {
2429+
jetHist.fill(HIST("jetSelCorr/genSel/jetCone/pt/PtParticleType"), mcParticle.pt(), particleType);
2430+
}
2431+
}
2432+
2433+
const double delPhiPerpCone1 = TVector2::Phi_mpi_pi(perpConePhiJet[0] - mcParticle.phi());
2434+
const double delPhiPerpCone2 = TVector2::Phi_mpi_pi(perpConePhiJet[1] - mcParticle.phi());
2435+
const double rPerpCone1 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone1);
2436+
const double rPerpCone2 = RecoDecay::sqrtSumOfSquares(delEta, delPhiPerpCone2);
2437+
if (rPerpCone1 < cfgjetR || rPerpCone2 < cfgjetR) {
2438+
if constexpr (RecoSelected) {
2439+
jetHist.fill(HIST("jetSelCorr/recoSel/perpCone/pt/PtParticleType"), mcParticle.pt(), particleType);
2440+
} else {
2441+
jetHist.fill(HIST("jetSelCorr/genSel/perpCone/pt/PtParticleType"), mcParticle.pt(), particleType);
2442+
}
2443+
}
2444+
}
2445+
}
2446+
23602447
void processRecMatched(JetCollWithLabel const& collision, JetMCDetTable const& mcdjets,
23612448
soa::Join<aod::JetTracks, aod::JTrackPIs, aod::JMcTrackLbs> const& tracks,
23622449
JetMCPartTable const&, TrackCandidatesMC const&, aod::JetParticles const& particleTracks, aod::JMcCollisions const&)
@@ -2687,6 +2774,94 @@ struct nucleiInJets {
26872774
} // process
26882775

26892776
int nprocessSimJEEvents = 0;
2777+
void processJetSelectionCorrection(aod::JetMcCollision const& collision,
2778+
soa::SmallGroups<soa::Join<aod::JetCollisionsMCD, aod::BkgChargedRhos>> const& recocolls,
2779+
JetMCDetTable const&, JetMCPartTable const& mcpjets, aod::JetParticles const& mcParticles)
2780+
{
2781+
if (std::abs(collision.posZ()) > cfgMaxZVertex) {
2782+
return;
2783+
}
2784+
2785+
bool hasGenLeadingJet = false;
2786+
double genLeadingJetPt = -999.;
2787+
double genLeadingJetEta = -999.;
2788+
double genLeadingJetPhi = -999.;
2789+
2790+
for (const auto& mcpjet : mcpjets) {
2791+
if (!isConeAxisAccepted(mcpjet.eta())) {
2792+
continue;
2793+
}
2794+
if (mcpjet.pt() > genLeadingJetPt) {
2795+
hasGenLeadingJet = true;
2796+
genLeadingJetPt = mcpjet.pt();
2797+
genLeadingJetEta = mcpjet.eta();
2798+
genLeadingJetPhi = mcpjet.phi();
2799+
}
2800+
}
2801+
2802+
if (hasGenLeadingJet && genLeadingJetPt > cfgjetPtBkgSubMinMC) {
2803+
jetHist.fill(HIST("jetSelCorr/eventNorm/hEventCounts"), 0.5);
2804+
jetHist.fill(HIST("jetSelCorr/genSel/hLeadingJetPt"), genLeadingJetPt);
2805+
fillJetSelectionCorrectionParticles<false>(mcParticles, genLeadingJetEta, genLeadingJetPhi);
2806+
}
2807+
2808+
bool hasRecoSelectedLeadingJet = false;
2809+
double recoSelectedLeadingJetPt = -999.;
2810+
double recoSelectedMatchedGenJetPt = -999.;
2811+
double recoSelectedMatchedGenJetEta = -999.;
2812+
double recoSelectedMatchedGenJetPhi = -999.;
2813+
2814+
for (const auto& mcpjet : mcpjets) {
2815+
if (!mcpjet.has_matchedJetGeo()) {
2816+
continue;
2817+
}
2818+
if (!isConeAxisAccepted(mcpjet.eta())) {
2819+
continue;
2820+
}
2821+
for (const auto& mcdjet : mcpjet.template matchedJetGeo_as<JetMCDetTable>()) {
2822+
if (!isConeAxisAccepted(mcdjet.eta())) {
2823+
continue;
2824+
}
2825+
double selectedRecoCollisionRho = -1.;
2826+
bool hasSelectedRecoCollision = false;
2827+
for (const auto& recocoll : recocolls) {
2828+
if (mcdjet.collisionId() != recocoll.globalIndex()) {
2829+
continue;
2830+
}
2831+
if (!isRecoCollisionSelectedForJetSelectionCorrection(recocoll)) {
2832+
continue;
2833+
}
2834+
selectedRecoCollisionRho = recocoll.rho();
2835+
hasSelectedRecoCollision = true;
2836+
break;
2837+
}
2838+
if (!hasSelectedRecoCollision) {
2839+
continue;
2840+
}
2841+
2842+
const double jetArea = M_PI * cfgjetR * cfgjetR;
2843+
const double mcdJetPtBkgSub = usebkgSubractionMC ? mcdjet.pt() - selectedRecoCollisionRho * jetArea : mcdjet.pt();
2844+
if (mcdJetPtBkgSub <= cfgjetPtBkgSubMinMC) {
2845+
continue;
2846+
}
2847+
if (mcdJetPtBkgSub > recoSelectedLeadingJetPt) {
2848+
hasRecoSelectedLeadingJet = true;
2849+
recoSelectedLeadingJetPt = mcdJetPtBkgSub;
2850+
recoSelectedMatchedGenJetPt = mcpjet.pt();
2851+
recoSelectedMatchedGenJetEta = mcpjet.eta();
2852+
recoSelectedMatchedGenJetPhi = mcpjet.phi();
2853+
}
2854+
}
2855+
}
2856+
2857+
if (hasRecoSelectedLeadingJet) {
2858+
jetHist.fill(HIST("jetSelCorr/eventNorm/hEventCounts"), 1.5);
2859+
jetHist.fill(HIST("jetSelCorr/recoSel/hLeadingJetPtBkgSub"), recoSelectedLeadingJetPt);
2860+
jetHist.fill(HIST("jetSelCorr/recoSel/hMatchedLeadingJetPt"), recoSelectedLeadingJetPt, recoSelectedMatchedGenJetPt);
2861+
fillJetSelectionCorrectionParticles<true>(mcParticles, recoSelectedMatchedGenJetEta, recoSelectedMatchedGenJetPhi);
2862+
}
2863+
}
2864+
26902865
void processGenMatched(aod::JetMcCollision const& collision,
26912866
soa::SmallGroups<soa::Join<aod::JMcCollisionLbs, aod::JetCollisions>> const& recocolls,
26922867
JetMCDetTable const&, JetMCPartTable const& mcpjets, aod::JetParticles const& mcParticles)
@@ -3096,6 +3271,7 @@ struct nucleiInJets {
30963271
PROCESS_SWITCH(nucleiInJets, processMCRec, "nuclei in Jets for detectorlevel Jets", false);
30973272
PROCESS_SWITCH(nucleiInJets, processMCGen, "nuclei in Jets MC particlelevel Jets", false);
30983273
PROCESS_SWITCH(nucleiInJets, processRecMatched, "nuclei in Jets rec matched", false);
3274+
PROCESS_SWITCH(nucleiInJets, processJetSelectionCorrection, "nuclei in Jets jet-selection migration correction", false);
30993275
PROCESS_SWITCH(nucleiInJets, processGenMatched, "nuclei in Jets gen matched", false);
31003276
PROCESS_SWITCH(nucleiInJets, processEventSignalLoss, "Event and signal loss analysis (inclusive)", false);
31013277
};

0 commit comments

Comments
 (0)