@@ -328,7 +328,8 @@ struct nucleiInJets {
328328 jetHist.add (" jet/h2JetPtVsBkgRho" , " jet_{p_{T}} vs background #rho; jet_{p_{T}} (GeV/c); #rho (GeV/c/area)" , kTH2F , {PtJetAxis, {100 , 0 , 20 }});
329329 jetHist.add (" jet/h1BkgRho" , " Background #rho; #rho (GeV/c/area); Entries" , kTH1F , {{100 , 0 , 20 }});
330330 jetHist.add (" jet/h1JetEvents" , " NumbeOfJetEvents" , kTH1F , {{1 , 0 , 1 }});
331- jetHist.add (" jetBkgSub/h1JetEvents" , " Number of jet events with leading p_{T}^{jet,bkg sub} above cfgjetPtBkgSubMin" , kTH1F , {{1 , 0 , 1 }});
331+ jetHist.add (" jetBkgSub/h1JetEventsBeforeRhoSelection" , " Number of jet events with leading p_{T}^{jet,bkg sub} above cfgjetPtBkgSubMin before rho selection" , kTH1F , {{1 , 0 , 1 }});
332+ jetHist.add (" jetBkgSub/h1JetEvents" , " Number of jet events with leading p_{T}^{jet,bkg sub} above cfgjetPtBkgSubMin and rho > 0" , kTH1F , {{1 , 0 , 1 }});
332333 jetHist.add (" jetBkgSub/h1BkgRhoLeadingJetPtBkgSubAboveCut" , " Background #rho for events with leading p_{T}^{jet,bkg sub} above cfgjetPtBkgSubMin; #rho (GeV/#it{c}/area); Entries" , kTH1F , {{100 , 0 , 20 }});
333334 jetHist.add (" jet/h1JetEta" , " jet_{#eta}" , kTH1F , {{100 , -1.0 , 1.0 }});
334335 jetHist.add (" jet/h1JetPhi" , " jet_{#phi}" , kTH1F , {{80 , -1.0 , 7 .}});
@@ -1807,7 +1808,7 @@ struct nucleiInJets {
18071808 jetHist.fill (HIST (" jetBkgSub/h1LeadingJetPtBkgSub" ), leadingJetPtBkgSub);
18081809 jetHist.fill (HIST (" jetBkgSub/h2LeadingJetPtBkgSubVsVertexZ" ), leadingJetPtBkgSub, collision.posZ ());
18091810 }
1810- if (leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
1811+ if (backgroundRho > 0 && leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
18111812 jetHist.fill (HIST (" jetBkgSub/vertexZ" ), collision.posZ ());
18121813 jetHist.fill (HIST (" jetBkgSub/h1BkgRhoLeadingJetPtBkgSubAboveCut" ), backgroundRho);
18131814 jetHist.fill (HIST (" hNEvents" ), 8.5 );
@@ -1818,7 +1819,10 @@ struct nucleiInJets {
18181819 return ;
18191820 jetHist.fill (HIST (" jet/h1JetEvents" ), 0.5 );
18201821 if (leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
1821- jetHist.fill (HIST (" jetBkgSub/h1JetEvents" ), 0.5 );
1822+ jetHist.fill (HIST (" jetBkgSub/h1JetEventsBeforeRhoSelection" ), 0.5 );
1823+ if (backgroundRho > 0 ) {
1824+ jetHist.fill (HIST (" jetBkgSub/h1JetEvents" ), 0.5 );
1825+ }
18221826 }
18231827 for (const auto & track : tracks) {
18241828 auto trk = track.track_as <TrackCandidates>();
@@ -1909,7 +1913,7 @@ struct nucleiInJets {
19091913 jetHist.fill (HIST (" jetBkgSub/h1LeadingJetPtBkgSub" ), leadingJetPtBkgSub);
19101914 jetHist.fill (HIST (" jetBkgSub/h2LeadingJetPtBkgSubVsVertexZ" ), leadingJetPtBkgSub, collision.posZ ());
19111915 }
1912- if (leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
1916+ if (backgroundRho > 0 && leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
19131917 jetHist.fill (HIST (" jetBkgSub/vertexZ" ), collision.posZ ());
19141918 jetHist.fill (HIST (" jetBkgSub/h1BkgRhoLeadingJetPtBkgSubAboveCut" ), backgroundRho);
19151919 jetHist.fill (HIST (" hNEvents" ), 8.5 );
@@ -1920,7 +1924,10 @@ struct nucleiInJets {
19201924 return ;
19211925 jetHist.fill (HIST (" jet/h1JetEvents" ), 0.5 );
19221926 if (leadingJetPtBkgSub > cfgjetPtBkgSubMin) {
1923- jetHist.fill (HIST (" jetBkgSub/h1JetEvents" ), 0.5 );
1927+ jetHist.fill (HIST (" jetBkgSub/h1JetEventsBeforeRhoSelection" ), 0.5 );
1928+ if (backgroundRho > 0 ) {
1929+ jetHist.fill (HIST (" jetBkgSub/h1JetEvents" ), 0.5 );
1930+ }
19241931 }
19251932 for (auto & track : tracks) {
19261933 auto trk = track.track_as <TrackCandidatesLfPid>();
@@ -2366,6 +2373,13 @@ struct nucleiInJets {
23662373 if (!jetderiveddatautilities::selectCollision (collision, jetderiveddatautilities::initialiseEventSelectionBits (" sel8" )))
23672374 return ;
23682375
2376+ if (selNoSameBunchPileup && !jetderiveddatautilities::selectCollision (collision, jetderiveddatautilities::initialiseEventSelectionBits (" NoSameBunchPileup" )))
2377+ return ;
2378+ if (selIsGoodZvtxFT0vsPV && !jetderiveddatautilities::selectCollision (collision, jetderiveddatautilities::initialiseEventSelectionBits (" IsGoodZvtxFT0vsPV" )))
2379+ return ;
2380+ if (useOccupancy && !isOccupancyAccepted (collision))
2381+ return ;
2382+
23692383 jetHist.fill (HIST (" recmatched/vertexZ" ), collision.posZ ());
23702384
23712385 // Event-wise random splitting for closure test: decide once per event
@@ -2376,6 +2390,22 @@ struct nucleiInJets {
23762390 jetHist.fill (HIST (" jet/h1BkgRho" ), backgroundRho);
23772391 }
23782392
2393+ // Select the accepted detector-level leading jet before considering matches.
2394+ int64_t leadingDetJetId = -1 ;
2395+ float leadingDetJetPt = -1 .f ;
2396+ if (isWithLeadingJet) {
2397+ for (const auto & mcdjet : mcdjets) {
2398+ if (isConeAxisAccepted (mcdjet.eta ()) && mcdjet.pt () > leadingDetJetPt) {
2399+ leadingDetJetPt = mcdjet.pt ();
2400+ leadingDetJetId = mcdjet.globalIndex ();
2401+ }
2402+ }
2403+ if (leadingDetJetId < 0 ) {
2404+ return ;
2405+ }
2406+ }
2407+
2408+ std::vector<int64_t > mcdJetIds{};
23792409 std::vector<double > mcdJetPt{};
23802410 std::vector<double > mcdJetPhi{};
23812411 std::vector<double > mcdJetEta{};
@@ -2396,7 +2426,7 @@ struct nucleiInJets {
23962426 continue ;
23972427
23982428 const float mcdJetPtForResponse = usebkgSubractionMC ? mcdjet.pt () - backgroundRho * jetArea : mcdjet.pt ();
2399- if (mcdJetPtForResponse < cfgjetPtBkgSubMinMC) {
2429+ if (mcdJetPtForResponse <= cfgjetPtBkgSubMinMC) {
24002430 continue ;
24012431 }
24022432 const double jetAxisEtaForEff = isWithLeadingJet ? (useLeadingJetDetLevelValue ? mcdjet.eta () : mcpjet.eta ()) : mcdjet.eta ();
@@ -2409,6 +2439,7 @@ struct nucleiInJets {
24092439 jetHist.fill (HIST (" recmatched/qa/h2JetConeEtaPhiAfterAcceptance" ), jetAxisEtaForEff, jetAxisPhiForEff);
24102440 jetHist.fill (HIST (" recmatched/qa/h2PerpConeEtaPhiAfterAcceptance" ), jetAxisEtaForEff, perpConePhiJet[0 ]);
24112441 jetHist.fill (HIST (" recmatched/qa/h2PerpConeEtaPhiAfterAcceptance" ), jetAxisEtaForEff, perpConePhiJet[1 ]);
2442+ mcdJetIds.push_back (mcdjet.globalIndex ());
24122443 mcdJetPt.push_back (mcdJetPtForResponse);
24132444 mcdJetPhi.push_back (mcdjet.phi ());
24142445 mcdJetEta.push_back (mcdjet.eta ());
@@ -2436,6 +2467,13 @@ struct nucleiInJets {
24362467 } else {
24372468 LOGP (fatal, " Error: Index {} is out of range for vectors!" , indexJet);
24382469 }
2470+ if (isWithLeadingJet) {
2471+ const auto leadingMatch = std::find (mcdJetIds.begin (), mcdJetIds.end (), leadingDetJetId);
2472+ if (leadingMatch == mcdJetIds.end ()) {
2473+ return ; // Do not replace an unmatched or rejected leading jet with a subleading jet.
2474+ }
2475+ indexJet = std::distance (mcdJetIds.begin (), leadingMatch);
2476+ }
24392477 if (useMcC) {
24402478 if (useDataLikeHist)
24412479 jetHist.fill (HIST (" recmatched/h2ResponseMatrixLeadingJet" ), mcdJetPt.at (indexJet), mcpJetPt.at (indexJet));
0 commit comments