From d5e3dac9252642075274fb9ebebc04cd6451c7ef Mon Sep 17 00:00:00 2001 From: jimun_lee Date: Mon, 2 Nov 2026 22:55:10 +0900 Subject: [PATCH 1/3] Changed pT axis binning --- PWGLF/Tasks/Resonances/kstarInJets.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Resonances/kstarInJets.cxx b/PWGLF/Tasks/Resonances/kstarInJets.cxx index d62d47cd5dc..c99e054fb95 100644 --- a/PWGLF/Tasks/Resonances/kstarInJets.cxx +++ b/PWGLF/Tasks/Resonances/kstarInJets.cxx @@ -161,7 +161,7 @@ struct kstarInJets { const AxisSpec axisEta{30, -1.5, 1.5, "#eta"}; const AxisSpec axisPhi{200, -1, 7, "#phi"}; const AxisSpec axisPt{100, 0, 100, "#it{p}_{T}"}; // Jet pT - const AxisSpec ptAxis = {100, 0, 100.0}; // Particle pT + const AxisSpec ptAxis = {1000, 0, 100}; // Particle pT const AxisSpec pidAxis = {120, -6, 6}; const AxisSpec minvAxis = {cfgMinvNBins, cfgMinvMin, cfgMinvMax}; const AxisSpec axisDCAz{binsDCAz, "DCA_{z}"}; @@ -1629,6 +1629,7 @@ struct kstarInJets { */ if (cfgJetMCHistos) { + histos.fill(HIST("nEvents_Gen"), 3.5); histos.fill(HIST("hRec_pT_Kstar"), particle.pt()); // SL: numerator and eff: denominator } } // loop over particles From 46098cf22da64fd61be4ac0f84e0566322fb949b Mon Sep 17 00:00:00 2001 From: jimun_lee Date: Tue, 24 Nov 2026 15:53:54 +0900 Subject: [PATCH 2/3] Added processPrior and processRecInJets and organized the code as a function --- PWGLF/Tasks/Resonances/kstarInJets.cxx | 1527 +++++++++--------------- 1 file changed, 543 insertions(+), 984 deletions(-) diff --git a/PWGLF/Tasks/Resonances/kstarInJets.cxx b/PWGLF/Tasks/Resonances/kstarInJets.cxx index c99e054fb95..8796764cf70 100644 --- a/PWGLF/Tasks/Resonances/kstarInJets.cxx +++ b/PWGLF/Tasks/Resonances/kstarInJets.cxx @@ -101,7 +101,7 @@ struct kstarInJets { Configurable cfgTrackTPCPID{"cfgTrackTPCPID", true, "Enables TPC PID"}; Configurable cfgTrackTOFPID{"cfgTrackTOFPID", true, "Enables TOF PID"}; Configurable cfgTrackSquarePIDCut{"cfgTrackSqurePIDCut", true, "Enables PID cut shape square switch"}; - Configurable cfgTrackCirclePIDCut{"cfgTrackCirclePIDCut", true, "Enables PID cut shape circle switch"}; + Configurable cfgTrackCirclePIDCut{"cfgTrackCirclePIDCut", false, "Enables PID cut shape circle switch"}; Configurable cfgTrackCircleValue{"cfgTrackCircleValue", 2, "Enables TOF TPC PID circle cut value"}; Configurable cfgTrackTOFHard{"cfgTrackTOFHard", false, "Enables TOF Hard"}; Configurable cfgTrackTPCPIDnSig{"cfgTrackTPCPIDnSig", 4.0, "nTPC PID sigma"}; @@ -109,7 +109,7 @@ struct kstarInJets { // MCGen Configurable cfgForceGenReco{"cfgForceGenReco", false, "Only consider events which are reconstructed (neglect event-loss)"}; - Configurable cfgReqMcEffPID{"cfgReqMcEffPID", false, "Request McEfficiency PID"}; + Configurable cfgReqMcEffPID{"cfgReqMcEffPID", true, "Request McEfficiency PID"}; // Pair Configurable cfgMinvNBins{"cfgMinvNBins", 300, "Number of bins for Minv axis"}; @@ -122,12 +122,12 @@ struct kstarInJets { Configurable cfgEventCutQA{"cfgEventCutsQA", false, "Enable Event QA Hists"}; Configurable cfgTrackCutQA{"cfgTrackCutQA", false, "Enable Track QA Hists"}; Configurable cfgJetQAHistos{"cfgJetQAHistos", false, "Enable Jet QA Histos"}; - - Configurable cfgMCHistos{"cfgMCHistos", false, "Enable MC Histos"}; - Configurable cfgJetHistos{"cfgJetHistos", false, "Enable Jet Histos"}; + Configurable cfgJetInvHistos{"cfgJetInvHistos", false, "Enable Jet Inv Histos"}; Configurable cfgJetMCHistos{"cfgJetMCHistos", false, "Enable Jet MC Histos"}; Configurable cfgJetdRHistos{"cfgJetdRHistos", false, "Enable Jet dR QA Histos"}; Configurable cfgMatchedGenHistos{"cfgMatchedGenHistos", false, "Enable Matched Gen Histos"}; + Configurable cfgPriorHistos{"cfgPriorHistos", false, "Enable Prior Gen and Rec Histos"}; + Configurable cfgFullClosureTest{"cfgFullClosureTest", false, "Enable Prior Gen for full closure"}; Configurable cfgCutonTrig{"cfgCutonTrig", false, "Enable Jet Cut on Trig"}; @@ -141,13 +141,11 @@ struct kstarInJets { Configurable cfgJetdR{"cfgJetdR", 0.4, "Set Jet radius parameter"}; Configurable cfgJetMaxEta{"cfgJetMaxEta", 0.9, "Set Jet Max Eta"}; - Configurable cfgSingleJet{"cfgSingleJet", false, "Enforces strict phi-jet correspondance"}; - Configurable cfgReqJets{"cfgReqJets", false, "False: MB, True: Inside Jets"}; + Configurable cfgReqJets{"cfgReqJets", false, "False: MB, True: In Jets"}; Configurable cfgRealTriggerMasks{"cfgRealTriggerMasks", "", "possible JE Trigger masks: fJetChLowPt,fJetChHighPt,fTrackLowPt,fTrackHighPt,fJetD0ChLowPt,fJetD0ChHighPt,fJetLcChLowPt,fJetLcChHighPt,fEMCALReadout,fJetFullHighPt,fJetFullLowPt,fJetNeutralHighPt,fJetNeutralLowPt,fGammaVeryHighPtEMCAL,fGammaVeryHighPtDCAL,fGammaHighPtEMCAL,fGammaHighPtDCAL,fGammaLowPtEMCAL,fGammaLowPtDCAL,fGammaVeryLowPtEMCAL,fGammaVeryLowPtDCAL"}; Configurable cfgTriggerMasksTest1{"cfgTriggerMasksTest1", "", "possible JE Trigger masks Test1"}; Configurable cfgTriggerMasksTest2{"cfgTriggerMasksTest2", "", "possible JE Trigger masks Test2"}; Configurable cfgTriggerMasksTest3{"cfgTriggerMasksTest3", "", "possible JE Trigger masks Test3"}; - Configurable cfgForceTrueINELgt{"cfgForceTrueINELgt", true, "Check generated event with True INELgt0"}; std::vector eventSelectionBits; std::vector RealTriggerMaskBits; @@ -158,15 +156,12 @@ struct kstarInJets { void init(o2::framework::InitContext&) { // HISTOGRAMS - const AxisSpec axisEta{30, -1.5, 1.5, "#eta"}; - const AxisSpec axisPhi{200, -1, 7, "#phi"}; const AxisSpec axisPt{100, 0, 100, "#it{p}_{T}"}; // Jet pT const AxisSpec ptAxis = {1000, 0, 100}; // Particle pT const AxisSpec pidAxis = {120, -6, 6}; const AxisSpec minvAxis = {cfgMinvNBins, cfgMinvMin, cfgMinvMax}; const AxisSpec axisDCAz{binsDCAz, "DCA_{z}"}; const AxisSpec axisDCAxy{binsDCAxy, "DCA_{XY}"}; - const AxisSpec dRAxis = {100, 0, 100}; if (cfgEventCutQA) { histos.add("hEvent_Cut", "Number of event after cuts", kTH1D, {{13, -0.5, 12.5}}); @@ -174,22 +169,6 @@ struct kstarInJets { histos.add("hPosZ_AC", "hPosZ_AC", kTH1F, {{300, -15.0, 15.0}}); histos.add("hcentFT0C_BC", "centFT0C_BC", kTH1F, {{110, 0.0, 110.0}}); histos.add("hcentFT0C_AC", "centFT0C_AC", kTH1F, {{110, 0.0, 110.0}}); - - std::shared_ptr hCutFlow = histos.get(HIST("hEvent_Cut")); - std::vector eventCutLabels = { - "All Events", - "sel8", - Form("|Vz| < %.1f", cfgEventVtxCut.value), - "kIsGoodZvtxFT0vsPV", - "kNoSameBunchPileup", - "kNoTimeFrameBorder", - "kNoITSROFrameBorder", - "kNoCollInTimeRangeStandard", - "kIsGoodITSLayersAll", - "All passed events"}; - for (size_t i = 0; i < eventCutLabels.size(); ++i) { - hCutFlow->GetXaxis()->SetBinLabel(i + 1, eventCutLabels[i].c_str()); - } } if (cfgTrackCutQA) { histos.add("hDCArToPv_BC", "DCArToPv_BC", kTH1F, {axisDCAxy}); @@ -238,7 +217,6 @@ struct kstarInJets { histos.add("nGoodJets", "The number of good jets", kTH1F, {{6, -0.5, 5.5}}); histos.add("nJetsPerEvent", "The number of jet per event", kTH1F, {{6, -0.5, 5.5}}); - histos.add("jetTrackEta", "Jet Track Eta", kTH1F, {{100, -1.0, 1.0}}); histos.add("jetTrackPhi", "Jet Track Phi", kTH1F, {{80, -1.0, 7.0}}); } @@ -247,39 +225,24 @@ struct kstarInJets { histos.add("mcpjet_eta", "MC particle-level Jet Eta", kTH1F, {{100, -1.0, 1.0}}); histos.add("mcpjet_phi", "MC particle-level Jet Phi", kTH1F, {{80, -1.0, 7.0}}); - histos.add("Gen_KstarPt_All_BR", "Generated K*0 All pT (GeV/c)", kTH1F, {{2000, 0., 100.}}); histos.add("Gen_Kstar_BR", "Generated K*0 BR", kTH1F, {minvAxis}); histos.add("Gen_KstarPt_BR", "Generated K*0 pT (GeV/c)", kTH1F, {{2000, 0., 100.}}); + histos.add("dR_kstar_pion", "dR between kstar and pion", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); + histos.add("dR_kstar_kaon", "dR between kstar and kaon", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); histos.add("dR_taggedjet_kaon", "dR between tagged jet and kaon wo pT cut", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); histos.add("dR_taggedjet_pion", "dR between tagged jet and pion wo pT cut", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); histos.add("dR_taggedjet_all", "dR between tagged jet and kpi", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); histos.add("dR_taggedjet_all_6_8", "dR between tagged jet and kpi 6 < jet pT < 8", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); - histos.add("dR_taggedjet_all_8_12", "dR between tagged jet and kpi 8 < jet pT < 12", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); - - histos.add("dR_taggedjet_0_8", "dR between tagged jet and kpi 0 < jet pT < 8", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); - - histos.add("dR_kstar_pion", "dR between kstar and pion", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); - histos.add("dR_kstar_kaon", "dR between kstar and kaon", {HistType::kTH2F, {{100, 0., 3.0}, {150, 0., 30.}}}); - histos.add("Kstar_pT_INJet_6_8", "K*0 pT Inside 6-8 Jet", kTH1F, {{1000, 0., 50.}}); - histos.add("Kstar_pT_INJet_8_10", "K*0 pT Inside 8-10 Jet", kTH1F, {{1000, 0., 50.}}); - histos.add("Kstar_pT_INJet_10_12", "K*0 pT Inside 10-12 Jet", kTH1F, {{1000, 0., 50.}}); - histos.add("Kstar_pT_INJet_8_12", "K*0 pT Inside 8-12 Jet", kTH1F, {{1000, 0., 50.}}); + histos.add("Kstar_pT_INJet_6_8", "K*0 pT Inside 6-8 Jet", kTH1F, {{500, 0., 50.}}); + histos.add("Kstar_pT_INJet_8_10", "K*0 pT Inside 8-10 Jet", kTH1F, {{500, 0., 50.}}); + histos.add("Kstar_pT_INJet_10_12", "K*0 pT Inside 10-12 Jet", kTH1F, {{500, 0., 50.}}); - histos.add("JetpT_8to", "Jet pT 8 to", kTH1F, {{2000, 0., 100.}}); histos.add("recoveredJetpT_6_8to8", "Recovered Jet pT 6-8 --> 8", kTH1F, {{2000, 0., 100.}}); histos.add("Kstar_pT_6_8to8_IN_recoveredJet", "K*0 pT In recovered Jet pT 6-8 --> 8", kTH1F, {{1000, 0., 50.}}); histos.add("Kstar_pT_6_8to8_10_IN_recoveredJet", "K*0 pT In recovered Jet pT 6-8 --> 8-10", kTH1F, {{1000, 0., 50.}}); - histos.add("missed_kpi_INJets_6_8", "missed kpi In Jets with 6 < jetPt < 8", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_8_10", "missed kpi In Jets with 8 < jetPt < 10", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_10_12", "missed kpi In Jets with 10 < jetPt < 12", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_12_15", "missed kpi In Jets with 12 < jetPt < 15", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_15_25", "missed kpi In Jets with 15 < jetPt < 25", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_25_infinite", "missed kpi In Jets with 25 < jetPt < infinite", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("missed_kpi_INJets_8_infinite", "missed kpi In Jets with 8 < jetPt < infinite", {HistType::kTH2F, {{120, 0.0, 1.2}, {100, 0., 20.}}}); - histos.add("JetMigration", "bin to bin migration", {HistType::kTH2F, {{150, 0.0, 15.0, "True jet pT (GeV/c)"}, {150, 0., 15., "Recovered jet pT (GeV/c)"}}}); } @@ -290,45 +253,48 @@ struct kstarInJets { histos.add("hUSS_PiK", "hUSS_PiK", kTHnSparseF, {cfgCentAxis, ptAxis, minvAxis}); histos.add("hLSS_PiK", "hLSS_PiK", kTHnSparseF, {cfgCentAxis, ptAxis, minvAxis}); - if (cfgMCHistos) { - histos.add("nEvents_Gen", "nEvents_Gen", kTH1F, {{7, 0.0, 7.0}}); - histos.add("hUSS_TrueRec", "hUSS_TrueRec", kTHnSparseF, {cfgCentAxis, ptAxis, minvAxis}); - histos.add("hGen_pT_Kstar", "Gen_pT_Kstar (GeV/c)", kTH1F, {{800, 0., 40.}}); - histos.add("hRec_pT_Kstar", "Rec_pT_Kstar", kTHnSparseF, {cfgCentAxis, ptAxis}); - } - if (cfgJetHistos) { - histos.add("hUSS_KPi_INSIDE", "hUSS_KPi_INSIDE", kTHnSparseF, {cfgCentAxis, dRAxis, ptAxis, minvAxis}); - histos.add("hUSS_PiK_INSIDE", "hUSS_PiK_INSIDE", kTHnSparseF, {cfgCentAxis, dRAxis, ptAxis, minvAxis}); - histos.add("hLSS_KPi_INSIDE", "hLSS_KPi_INSIDE", kTHnSparseF, {cfgCentAxis, dRAxis, ptAxis, minvAxis}); - histos.add("hLSS_PiK_INSIDE", "hLSS_PiK_INSIDE", kTHnSparseF, {cfgCentAxis, dRAxis, ptAxis, minvAxis}); + if (cfgJetInvHistos) { + histos.add("hUSS_KPi_INSIDE", "hUSS_KPi_INSIDE", kTHnSparseF, {cfgCentAxis, axisPt, ptAxis, minvAxis}); + histos.add("hUSS_PiK_INSIDE", "hUSS_PiK_INSIDE", kTHnSparseF, {cfgCentAxis, axisPt, ptAxis, minvAxis}); + histos.add("hLSS_KPi_INSIDE", "hLSS_KPi_INSIDE", kTHnSparseF, {cfgCentAxis, axisPt, ptAxis, minvAxis}); + histos.add("hLSS_PiK_INSIDE", "hLSS_PiK_INSIDE", kTHnSparseF, {cfgCentAxis, axisPt, ptAxis, minvAxis}); } if (cfgJetMCHistos) { histos.add("nEvents_Gen", "nEvents_Gen", kTH1F, {{7, 0.0, 7.0}}); - histos.add("hUSS_TrueRec", "hUSS_TrueRec", kTHnSparseF, {cfgCentAxis, ptAxis, minvAxis}); - histos.add("hUSS_TrueRec_INSIDE", "hUSS_TrueRec_INSIDE", kTHnSparseF, {cfgCentAxis, dRAxis, ptAxis, minvAxis}); + histos.add("hKstar_VtxEvt", "Kstar pT AC Vtx only (GeV/c)", kTH1F, {{800, 0., 40.}}); + histos.add("hKstar_Gen", "Kstar pT AC good Event (GeV/c)", kTH1F, {{800, 0., 40.}}); + + histos.add("Gen_daughter", "Gen_daughter", kTH1F, {{1000, -500., 500}}); + histos.add("Gen_mother", "Gen_mother", kTH1F, {{1000, -500., 500}}); - histos.add("hGen_pT_Kstar", "Gen_pT_Kstar (GeV/c)", kTH1F, {{800, 0., 40.}}); - histos.add("hRec_pT_Kstar", "Rec_pT_Kstar (GeV/c)", kTH1F, {{800, 0., 40.}}); + histos.add("nEvents_Rec", "nEvents_Rec", kTH1F, {{7, 0.0, 7.0}}); histos.add("hEffRec_pT", "EffRec_pT (GeV/c)", kTH1F, {{1600, 0., 80.}}); - } + histos.add("lResonance_Rec_Inv", "lResonance_Rec_Inv", kTH1F, {minvAxis}); + } if (cfgMatchedGenHistos) { histos.add("nEvents_MCGen_MATCHED", "nEvents_MCGen_MATCHED", kTH1F, {{7, 0.0, 7.0}}); histos.add("matchedJets_pT", "#it{p}_{T,jet part}; #it{p}_{T,jet det}", {HistType::kTH2F, {{100, 0., 20.}, {400, -20., 20.0}}}); histos.add("matchedJets_eta", "#eta_{jet part}; #eta_{jet det}", {HistType::kTH2F, {{100, -1.0, 1.0}, {400, -20.0, 20.0}}}); histos.add("matchedJets_phi", "#phi_{jet part}; #phi_{jet det}", {HistType::kTH2F, {{80, -1.0, 7.}, {400, -20.0, 20.}}}); - histos.add("NoMatchedJets_pT", "Gen. No Matched detector-level Jet", kTHnSparseD, {axisPt}); + histos.add("GeneratedJets_pT", "GeneratedJets_pT", kTH1F, {axisPt}); + histos.add("NoMatchedJets_pT", "Gen. No Matched detector-level Jet", kTH1F, {axisPt}); + histos.add("MatchedJets_pT", "Gen. Matched detector-level Jet", kTH1F, {axisPt}); + histos.add("RespGen_Matched_rand0", "Gen. Response Matrix Matched 0", kTHnSparseD, {ptAxis, axisPt, ptAxis, axisPt}); histos.add("RespGen_Matched_rand1", "Gen. Response Matrix Matched 1", kTHnSparseD, {ptAxis, axisPt, ptAxis, axisPt}); - // ALL Jets - histos.add("nEvents_MCGen_MATCHED_allJet", "nEvents_MCGen_MATCHED_allJet", kTH1F, {{7, 0.0, 7.0}}); - histos.add("NoMatchedJets_pT_allJet", "Gen. No Matched detector-level ALL Jet", kTHnSparseD, {axisPt}); - histos.add("RespGen_MatchedJet_TEST_allJet", "Gen. Response Matrix Matched ALL Jet Test", kTHnSparseD, {axisPt, axisPt}); - histos.add("RespGen_Matrix_Matched_allJet", "Gen. Response Matrix Matched ALL Jet", kTHnSparseD, {ptAxis, axisPt, ptAxis, axisPt}); + histos.add("NoMatched", "NoMatched", kTHnSparseD, {ptAxis, axisPt}); + histos.add("Matched", "Matched", kTHnSparseD, {ptAxis, axisPt}); + } + + if (cfgPriorHistos) { + histos.add("nEvents_Prior", "nEvents_Prior", kTH1F, {{7, 0.0, 7.0}}); + histos.add("Prior", "Prior", kTHnSparseD, {ptAxis, axisPt}); - histos.add("RespGen_MatchedJet_TEST_rand0_allJet", "Gen. Response Matrix Matched ALL Jet TEST", kTHnSparseD, {axisPt, axisPt}); + histos.add("nEvents_PriorRec", "nEvents_PriorRec", kTH1F, {{7, 0.0, 7.0}}); + histos.add("Prior_Rec", "Prior_Rec", kTHnSparseD, {ptAxis, axisPt}); } // Jet @@ -339,25 +305,17 @@ struct kstarInJets { triggerMaskBitsTest3 = jetderiveddatautilities::initialiseTriggerMaskBits(cfgTriggerMasksTest3); } // end of init - //=============== - //| LF Analysis - //=============== - using EventCandidates = soa::Join; //, aod::CentFT0Ms, aod::CentFT0As - using EventCandidatesTrue = aod::McCollisions; using TrackCandidates = soa::Join; using TrackCandidatesMC = soa::Join; + using JetTrackCandidatesMC = soa::Join; - //================= - //|| Jet Analysis - //================= + Preslice tracksPerRecoCollision = aod::jtrack::collisionId; Filter JEPosZFilter = nabs(aod::jcollision::posZ) < cfgEventVtxCut; Filter JEMCPosZFilter = nabs(aod::jmccollision::posZ) < cfgEventVtxCut; Filter JetCuts = aod::jet::pt > cfgJetpT&& aod::jet::r == nround(cfgJetR.node() * 100.0f); - using JetTrackCandidatesMC = soa::Join; - double massKa = o2::constants::physics::MassKPlus; double massPi = o2::constants::physics::MassPiMinus; @@ -441,11 +399,6 @@ struct kstarInJets { } // pion pid Selection } // fill QA - // enum class objectType { Inclusive, - // Jets, - // RecoParticle, - // JetsRecoParticle }; - enum class objectType { Inclusive, Jets }; template @@ -470,7 +423,7 @@ struct kstarInJets { break; case objectType::Jets: - if (cfgJetHistos) { + if (cfgJetInvHistos) { if (conjugate < 0) { if (!flip) { histos.fill(HIST("hUSS_KPi_INSIDE"), centrality, jetpt, lReso.Pt(), lReso.M()); @@ -491,68 +444,15 @@ struct kstarInJets { } // fillMinv //====================================================================== - template - std::pair eventSelection(const EventType& event, const bool QA) + template + bool hasINELgt0(Table const& objects) { - if (cfgEventCutQA && QA) { - fillQA(false, event, 1); - histos.fill(HIST("hEvent_Cut"), 0); - } - - if (!event.sel8()) { - return {false, 1}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 1); - } - if (std::abs(event.posZ()) > cfgEventVtxCut) { - return {false, 2}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 2); - } - if (!event.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV)) { - return {false, 3}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 3); - } - if (!event.selection_bit(aod::evsel::kNoSameBunchPileup)) { - return {false, 4}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 4); - } - if (!event.selection_bit(aod::evsel::kNoTimeFrameBorder)) { - return {false, 5}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 5); - } - if (!event.selection_bit(aod::evsel::kNoITSROFrameBorder)) { - return {false, 6}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 6); - } - if (!event.selection_bit(aod::evsel::kNoCollInTimeRangeStandard)) { - return {false, 7}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 7); - } - if (!event.selection_bit(aod::evsel::kIsGoodITSLayersAll)) { - return {false, 8}; - } - if (cfgEventCutQA && QA) { - histos.fill(HIST("hEvent_Cut"), 8); - } - - if (cfgEventCutQA && QA) { - fillQA(true, event, 1); - histos.fill(HIST("hEvent_Cut"), 9); + for (const auto& obj : objects) { + if (std::abs(obj.eta()) < cfgEventMaxEta && obj.pt() > 0.0) { + return true; + } } - return {true, 10}; + return false; }; template @@ -560,17 +460,21 @@ struct kstarInJets { { if (cfgEventCutQA && QA) { fillQA(false, event, 1); + histos.fill(HIST("hEvent_Cut"), 0); } if (!jetderiveddatautilities::selectCollision(event, eventSelectionBits)) { // sel8 return {false, 1}; } + if (cfgEventCutQA && QA) { + histos.fill(HIST("hEvent_Cut"), 1); + } if (std::abs(event.posZ()) > cfgEventVtxCut) { return {false, 2}; } - if (cfgEventCutQA && QA) { fillQA(true, event, 1); + histos.fill(HIST("hEvent_Cut"), 2); } return {true, 8}; }; @@ -714,7 +618,6 @@ struct kstarInJets { } } } // TPCPID cut - } // end of square cut if (cfgTrackCirclePIDCut) { @@ -745,6 +648,33 @@ struct kstarInJets { return false; } + double getdR(double Eta1, double Phi1, double Eta2, double Phi2) + { + const double dphi = TVector2::Phi_mpi_pi(Phi1 - Phi2); + const double deta = Eta1 - Eta2; + return TMath::Sqrt(dphi * dphi + deta * deta); + } + + template + double DistinguishJets(const JetType& jets, ROOT::Math::PxPyPzMVector& lResonance) + { + if (cDebugLevel > 0) { + LOG(info) << "Found multiple jets to the same K*0."; + } + + double bestR = 0; + double bestJetpT = 0; + for (auto const& jet : jets) { + + const double dR = getdR(jet.eta(), jet.phi(), lResonance.Eta(), lResonance.Phi()); + if (dR < cfgJetR && (bestR == 0 || dR < bestR)) { + bestR = dR; + bestJetpT = jet.pt(); + } + } // jet + return bestJetpT; + } + template ROOT::Math::PxPyPzMVector minvReconstruction(const TracksType& trk1, const TracksType& trk2, const bool QA, const bool flip) { @@ -754,7 +684,7 @@ struct kstarInJets { if (!trackPIDKaon(trk1, QA) || !trackPIDPion(trk2, QA)) { return {}; } - if (trk1.globalIndex() >= trk2.globalIndex()) { + if (trk1.globalIndex() == trk2.globalIndex()) { return {}; } @@ -775,173 +705,107 @@ struct kstarInJets { return {lResonance}; } // minvReconstruction - template - ROOT::Math::PxPyPzMVector TrueReconstruction(const TracksType& trk1, const TracksType& trk2) + template + bool KPidaughters(ParticleType const& mcParticle) { - double conjugate = trk1.sign() * trk2.sign(); - if (conjugate > 0) { - return {}; - } - - auto particle1 = trk1.mcParticle(); - auto particle2 = trk2.mcParticle(); - - if (!particle1.has_mothers() || !particle2.has_mothers()) { - return {}; - } - if (std::abs(particle1.eta()) > cfgTrackMaxEta || std::abs(particle2.eta()) > cfgTrackMaxEta) { - return {}; - } - - std::vector mothers1{}; - std::vector mothers1PDG{}; - for (auto& particle1_mom : particle1.template mothers_as()) { - mothers1.push_back(particle1_mom.globalIndex()); - mothers1PDG.push_back(particle1_mom.pdgCode()); - } - - std::vector mothers2{}; - std::vector mothers2PDG{}; - for (auto& particle2_mom : particle2.template mothers_as()) { - mothers2.push_back(particle2_mom.globalIndex()); - mothers2PDG.push_back(particle2_mom.pdgCode()); - } - - if (std::abs(mothers1PDG[0]) != Kstar0PDG) { - return {}; // mother not K*0 - } - if (std::abs(mothers2PDG[0]) != Kstar0PDG) { - return {}; // mothers not K*0 - } - if (mothers1[0] != mothers2[0]) { - return {}; // Kaon and pion not from the same K*0 - } - if (std::abs(particle1.pdgCode()) != PionPDG && std::abs(particle1.pdgCode()) != KaonPDG) { + if (std::abs(mcParticle.eta()) > cfgTrackMaxEta) { return {}; } - if (std::abs(particle2.pdgCode()) != PionPDG && std::abs(particle2.pdgCode()) != KaonPDG) { + if (std::abs(mcParticle.pdgCode()) != Kstar0PDG) { return {}; } - - double track1_mass = 0; - double track2_mass = 0; - if (std::abs(particle1.pdgCode()) == PionPDG) { - track1_mass = massPi; - } else { - track1_mass = massKa; - } - - if (std::abs(particle2.pdgCode()) == PionPDG) { - track2_mass = massPi; - } else { - track2_mass = massKa; - } - - if (track1_mass == track2_mass) { + if (!mcParticle.has_daughters()) { return {}; } - ROOT::Math::PxPyPzMVector lTrueDaughter1, lTrueDaughter2, lTrueReso; - lTrueDaughter1 = ROOT::Math::PxPyPzMVector(particle1.px(), particle1.py(), particle1.pz(), track1_mass); - lTrueDaughter2 = ROOT::Math::PxPyPzMVector(particle2.px(), particle2.py(), particle2.pz(), track2_mass); - lTrueReso = lTrueDaughter1 + lTrueDaughter2; - - if (lTrueReso.M() < 0) { - return {}; - } - if (std::abs(lTrueReso.Eta()) > cfgTrackMaxEta) { - return {}; - } + int nKaon = 0; + int nPion = 0; - return {lTrueReso}; - } // TrueReconstruction + for (const auto& daughter : mcParticle.template daughters_as()) { + if (std::abs(daughter.eta()) > cfgTrackMaxEta) { + continue; + } + if (std::abs(daughter.pdgCode()) == KaonPDG) { + ++nKaon; + } else if (std::abs(daughter.pdgCode()) == PionPDG) { + ++nPion; + } + } // daughter loop + return nKaon == 1 && nPion == 1; + }; - template - void TrackSlicing(const CollisionType& collision, const TracksType& tracks, const bool QA) + using RecoCandidate = std::pair; + template + std::vector recoResonance(TracksType const& tracks) { - auto centrality = collision.centFT0C(); - for (const auto& [trk1, trk2] : combinations(o2::soa::CombinationsUpperIndexPolicy(tracks, tracks))) { - for (bool flip : {false, true}) { - auto lReso = minvReconstruction(trk1, trk2, QA, flip); - if (lReso.M() < 0) { - continue; - } - - fillMinv(objectType::Inclusive, trk1, trk2, lReso, centrality, -1.0, flip); - } // flip - } // for - } // TrackSlicing + std::vector results; + for (auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(tracks, tracks))) { + auto trk1 = track1.template track_as(); + auto trk2 = track2.template track_as(); - template - void TrackSlicingMC(const CollisionType& collision, const TracksType& tracks, const bool QA) - { - auto centrality = collision.centFT0C(); - for (const auto& [trk1, trk2] : combinations(o2::soa::CombinationsUpperIndexPolicy(tracks, tracks))) { if (!trk1.has_mcParticle() || !trk2.has_mcParticle()) { continue; } + if (!trackSelection(trk1, true) || !trackSelection(trk2, false)) { + continue; + } + if (!trackPIDKaon(trk1, true) || !trackPIDPion(trk2, true)) { + continue; + } + if (trk1.globalIndex() == trk2.globalIndex()) { + continue; + } - for (bool flip : {false, true}) { - auto lReso = minvReconstruction(trk1, trk2, QA, flip); - if (lReso.M() < 0) { - continue; - } - fillMinv(objectType::Inclusive, trk1, trk2, lReso, centrality, -1.0, flip); - } // flip + auto particle1 = trk1.mcParticle(); + auto particle2 = trk2.mcParticle(); - //============================ - //| True Reconstruction - //============================ - auto lTrueReso = TrueReconstruction(trk1, trk2); - if (cfgMCHistos) { - histos.fill(HIST("hUSS_TrueRec"), centrality, lTrueReso.Pt(), lTrueReso.M()); + if (!particle1.has_mothers() || !particle2.has_mothers()) { + continue; + } + if (std::abs(particle1.pdgCode()) != KaonPDG) { + continue; + } + if (std::abs(particle2.pdgCode()) != PionPDG) { + continue; } - } // tracks - } // TrackSlicingMC - - template - double DistinguishJets(const JetType& jets, ROOT::Math::PxPyPzMVector& lResonance) - { - if (cDebugLevel > 0) { - LOG(info) << "Found multiple jets to the same phi."; - } + std::vector mothers1{}; + std::vector mothers1PDG{}; + for (auto& particle1_mom : particle1.template mothers_as()) { + mothers1.push_back(particle1_mom.globalIndex()); + mothers1PDG.push_back(particle1_mom.pdgCode()); + } - double bestR = 0; - double bestJetpT = 0; - for (auto const& jet : jets) { - double phidiff = TVector2::Phi_mpi_pi(jet.phi() - lResonance.Phi()); - double etadiff = jet.eta() - lResonance.Eta(); - double R = TMath::Sqrt((phidiff * phidiff) + (etadiff * etadiff)); - if (R < cfgJetR && (bestR == 0 || R < bestR)) { - bestR = R; - bestJetpT = jet.pt(); + std::vector mothers2{}; + std::vector mothers2PDG{}; + for (auto& particle2_mom : particle2.template mothers_as()) { + mothers2.push_back(particle2_mom.globalIndex()); + mothers2PDG.push_back(particle2_mom.pdgCode()); } - } // jet - return bestJetpT; - } - template - double DistinguishJetsMC(const Jet_pt& jet_pt, const Jet_phi& jet_phi, const Jet_eta& jet_eta, const Resonance& lResonance) - { - if (cDebugLevel > 0) { - LOG(info) << "Multiple jets fit to the same K*0. Time to find the best K*0-jet"; - } + if (mothers1[0] != mothers2[0]) { + continue; // Kaon and pion not from the same K*0 + } + if (std::abs(mothers1PDG[0]) != Kstar0PDG) { + continue; + } + if (std::abs(mothers2PDG[0]) != Kstar0PDG) { + continue; + } - double best_R = 0; - double best_jetpt = 0; - for (std::vector::size_type i = 0; i < jet_pt.size(); i++) { - double phidiff = TVector2::Phi_mpi_pi(jet_phi[i] - lResonance.Phi()); - double etadiff = jet_eta[i] - lResonance.Eta(); - double R = TMath::Sqrt((phidiff * phidiff) + (etadiff * etadiff)); + ROOT::Math::PxPyPzMVector lDaughter1, lDaughter2, lResonance; + lDaughter1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massKa); + lDaughter2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPi); + lResonance = lDaughter1 + lDaughter2; - if (R < cfgJetR && (best_R == 0 || R < best_R)) { - best_R = R; - best_jetpt = jet_pt[i]; + if (std::abs(lResonance.Eta()) > cfgTrackMaxEta) { + continue; } - } // jet loop - return best_jetpt; - } + results.emplace_back(mothers1[0], lResonance); + + } // tracks loop + return results; + }; template void JetTrackSlicing(aod::JetCollision const& collision, TracksType const& jetTracks, const JetType& chargedjets, const bool QA) @@ -950,16 +814,15 @@ struct kstarInJets { //| Inclusive //============= auto centrality = collision.centFT0C(); - for (const auto& [track1, track2] : combinations(o2::soa::CombinationsUpperIndexPolicy(jetTracks, jetTracks))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(jetTracks, jetTracks))) { auto trk1 = track1.template track_as(); auto trk2 = track2.template track_as(); for (bool flip : {false, true}) { auto lResonance = minvReconstruction(trk1, trk2, QA, flip); - if (lResonance.M() < 0) { + if (lResonance.M() <= 0) { continue; } - fillMinv(objectType::Inclusive, trk1, trk2, lResonance, centrality, -1.0, flip); //======== @@ -984,10 +847,8 @@ struct kstarInJets { histos.fill(HIST("nGoodJets"), goodjets); } - if (!cfgSingleJet) { - if (goodjets > 1) { - jetpt = DistinguishJets(chargedjets, lResonance); - } + if (goodjets > 1) { + jetpt = DistinguishJets(chargedjets, lResonance); } if (jetFlag) { @@ -1004,7 +865,7 @@ struct kstarInJets { //| MB: Track Reconstruction //============================ auto centrality = collision.centFT0C(); - for (const auto& [track1, track2] : combinations(o2::soa::CombinationsUpperIndexPolicy(jetTracks, jetTracks))) { + for (const auto& [track1, track2] : combinations(o2::soa::CombinationsFullIndexPolicy(jetTracks, jetTracks))) { auto trk1 = track1.template track_as(); auto trk2 = track2.template track_as(); @@ -1014,7 +875,7 @@ struct kstarInJets { for (bool flip : {false, true}) { auto lResonance = minvReconstruction(trk1, trk2, QA, flip); - if (lResonance.M() < 0) { + if (lResonance.M() <= 0) { continue; } fillMinv(objectType::Inclusive, trk1, trk2, lResonance, centrality, -1.0, flip); @@ -1026,29 +887,26 @@ struct kstarInJets { int goodjets = 0; double jetpt = 0; for (auto const& jet : mcdjets) { - double phidiff = TVector2::Phi_mpi_pi(jet.phi() - lResonance.Phi()); - double etadiff = jet.eta() - lResonance.Eta(); - double R = TMath::Sqrt((etadiff * etadiff) + (phidiff * phidiff)); - if (R < cfgJetR) { + const double dR = getdR(jet.eta(), jet.phi(), lResonance.Eta(), lResonance.Phi()); + + if (dR < cfgJetR) { jetFlag = true; jetpt = jet.pt(); goodjets++; } - } + } // mcdjets if (cfgJetQAHistos) { histos.fill(HIST("nGoodJets"), goodjets); } - if (!cfgSingleJet) { - if (goodjets > 1) { - jetpt = DistinguishJets(mcdjets, lResonance); - } + + if (goodjets > 1) { + jetpt = DistinguishJets(mcdjets, lResonance); } if (jetFlag) { fillMinv(objectType::Jets, trk1, trk2, lResonance, centrality, jetpt, flip); - } // jetFlag + } } // filp - } // Tracks loop } // JetTrackSlicingMC @@ -1069,23 +927,14 @@ struct kstarInJets { LOG(info) << "Processed Jet Data Events: " << nJetEvents; } } - histos.fill(HIST("nEvents"), 0.5); // Raw event - bool INELgt0 = false; - for (auto& jetTrack : jetTracks) { - if (std::abs(jetTrack.eta()) < cfgEventMaxEta) { - INELgt0 = true; - break; - } - } - if (!INELgt0) { + if (!hasINELgt0(jetTracks)) { return; } histos.fill(HIST("nEvents"), 1.5); // INEL>0 event auto [goodEv, code] = JetEventSelection(collision, true); - // auto [goodEv, code] = eventSelection(collision, true); if (!goodEv) { return; } @@ -1178,6 +1027,7 @@ struct kstarInJets { } // jetTrack loop JetTrackSlicing(collision, jetTracks, chargedjets, true); + } // ProcessDataJets PROCESS_SWITCH(kstarInJets, processDataJets, "process Data Jets", false); @@ -1186,7 +1036,11 @@ struct kstarInJets { //| JET MC STUFF //| //======================================================= - void processMCJets(o2::aod::JetCollision const& collision, JetTrackCandidatesMC const& jetTracks, soa::Filtered const& mcdjets, TrackCandidatesMC const&, aod::McParticles const&, aod::JetParticles const&) + + void processMCJets(o2::aod::JetCollision const& collision, + JetTrackCandidatesMC const& jetTracks, TrackCandidatesMC const&, + soa::Filtered const& mcdjets, + aod::McParticles const&, aod::JetParticles const&) { static int nJetMCEvents = 0; if (cDebugLevel > 0) { @@ -1195,16 +1049,12 @@ struct kstarInJets { LOG(info) << "Processed Jet MC Events: " << nJetMCEvents; } } + if (!cfgJetMCHistos) { + return; + } histos.fill(HIST("nEvents"), 0.5); // Gen event - bool INELgt0 = false; - for (auto& jetTrack : jetTracks) { - if (std::abs(jetTrack.eta()) < cfgEventMaxEta) { - INELgt0 = true; - break; - } - } // jetTrack loop - if (!INELgt0) { + if (!hasINELgt0(jetTracks)) { return; } histos.fill(HIST("nEvents"), 1.5); // INEL>0 event @@ -1226,7 +1076,6 @@ struct kstarInJets { if (std::abs(mcdjet.eta()) > cfgJetMaxEta - cfgJetdR) { continue; } - nJets++; if (cfgJetQAHistos) { histos.fill(HIST("JetpT"), mcdjet.pt()); @@ -1249,394 +1098,130 @@ struct kstarInJets { } } histos.fill(HIST("nEvents"), 3.5); // Jet event - JetTrackSlicingMC(collision, jetTracks, mcdjets, true); + } // process loop + PROCESS_SWITCH(kstarInJets, processMCJets, "process MC Jets", false); - // Instead of using "JetTrackSlicingMC", Once we have to test showing the distribution each condition + //======================== + //| + //| GENERATED STUFF + //| + //======================== + void processGen(o2::aod::JetMcCollision const& collision, + soa::SmallGroups> const& recocolls, + aod::JetParticles const& mcParticles, aod::McParticles const&) + { + static int nprocessGenEvents = 0; + if (cDebugLevel > 0) { + ++nprocessGenEvents; + if (nprocessGenEvents % 10000 == 0) { + LOG(info) << "Processed MC (GEN) Events: " << nprocessGenEvents; + } + } + if (!cfgJetMCHistos) { + return; + } + histos.fill(HIST("nEvents_Gen"), 0.5); - for (auto& [track1, track2] : combinations(o2::soa::CombinationsUpperIndexPolicy(jetTracks, jetTracks))) { - auto trk1 = track1.template track_as(); - auto trk2 = track2.template track_as(); + //======================= + //| Event & Signal loss + //======================= + if (!hasINELgt0(mcParticles)) { + return; + } + histos.fill(HIST("nEvents_Gen"), 1.5); // EL: denominator - // Each section, test pT. which section we lost the entries - ROOT::Math::PxPyPzMVector lDecayDaughter1, lDecayDaughter2, lResonance; - lDecayDaughter1 = ROOT::Math::PxPyPzMVector(trk1.px(), trk1.py(), trk1.pz(), massKa); - lDecayDaughter2 = ROOT::Math::PxPyPzMVector(trk2.px(), trk2.py(), trk2.pz(), massPi); - lResonance = lDecayDaughter1 + lDecayDaughter2; + if (std::abs(collision.posZ()) > cfgEventVtxCut) { + return; + } - if (!trk1.has_mcParticle() || !trk2.has_mcParticle()) { + // Find Gen K*0 + for (const auto& mcParticle : mcParticles) { + + if (std::abs(mcParticle.pdgCode()) != Kstar0PDG) { continue; } - if (!trackSelection(trk1, true) || !trackSelection(trk2, false)) { + if (std::abs(mcParticle.eta()) > cfgTrackMaxEta) { continue; } - if (cfgReqMcEffPID) { // false, true - if (!trackPIDKaon(trk1, true) || !trackPIDPion(trk2, true)) { - continue; - } - } - - auto particle1 = trk1.mcParticle(); - auto particle2 = trk2.mcParticle(); - if (!particle1.has_mothers() || !particle2.has_mothers()) { - continue; - } - - std::vector mothers1{}; - std::vector mothers1PDG{}; - for (auto& particle1_mom : particle1.template mothers_as()) { - mothers1.push_back(particle1_mom.globalIndex()); - mothers1PDG.push_back(particle1_mom.pdgCode()); - } - - std::vector mothers2{}; - std::vector mothers2PDG{}; - for (auto& particle2_mom : particle2.template mothers_as()) { - mothers2.push_back(particle2_mom.globalIndex()); - mothers2PDG.push_back(particle2_mom.pdgCode()); - } - - if (mothers1[0] != mothers2[0]) { - continue; // Kaon and pion not from the same K*0 - } - if (std::abs(particle1.pdgCode()) != KaonPDG) { - continue; - } - if (std::abs(particle2.pdgCode()) != PionPDG) { - continue; - } - - if (std::abs(mothers1PDG[0]) != Kstar0PDG) { - continue; // mother not K*0 - } - if (std::abs(mothers2PDG[0]) != Kstar0PDG) { - continue; // mothers not K*0 - } - if (cfgJetMCHistos) { - histos.fill(HIST("hEffRec_pT"), lResonance.Pt()); - } - - } // track loop - - } // process loop - PROCESS_SWITCH(kstarInJets, processMCJets, "process MC Jets", false); - - //======================================================= - //| - //| DATA STUFF (SE) - //| - //======================================================= - void processDataSameEvent(EventCandidates::iterator const& collision, TrackCandidates const& tracks) - { - static int nEvents = 0; - if (cDebugLevel > 0) { - nEvents++; - if ((nEvents + 1) % 10000 == 0) { - LOG(info) << "Processed Data Events: " << nEvents; - } - } - histos.fill(HIST("nEvents"), 0.5); - - bool INELgt0 = false; - for (const auto& track : tracks) { - if (std::abs(track.eta()) < cfgEventMaxEta) { - INELgt0 = true; - break; - } - } - if (!INELgt0) { - return; - } - histos.fill(HIST("nEvents"), 1.5); + histos.fill(HIST("hKstar_VtxEvt"), mcParticle.pt()); // SL: denominator - auto [goodEv, code] = eventSelection(collision, true); - if (!goodEv) { - return; - } - histos.fill(HIST("nEvents"), 2.5); - - // for trackQA plot - for (const auto& track : tracks) { - if (!trackSelection(track, true)) { - continue; - } - } - - TrackSlicing(collision, tracks, true); - } // processSameEvents - PROCESS_SWITCH(kstarInJets, processDataSameEvent, "process Data Same Event", false); - - //======================================================= - //| - //| MC STUFF (SE) - //| - //========================================================= - void processSameEventMC(EventCandidates::iterator const& collision, TrackCandidatesMC const& tracks, aod::McParticles const&) - { - static int nEventsMC = 0; - if (cDebugLevel > 0) { - nEventsMC++; - if ((nEventsMC + 1) % 10000 == 0) { - double histmem = histos.getSize(); - LOG(info) << histmem; - LOG(info) << "process_SameEvent_MC: " << nEventsMC; - } - } - histos.fill(HIST("nEvents"), 0.5); - - bool INELgt0 = false; - for (const auto& track : tracks) { - if (std::abs(track.eta()) < cfgEventMaxEta) { - INELgt0 = true; - break; - } - } - if (!INELgt0) { - return; - } - histos.fill(HIST("nEvents"), 1.5); - - auto [goodEv, code] = eventSelection(collision, true); // sel8 & vtx - if (!goodEv) { - return; - } - histos.fill(HIST("nEvents"), 2.5); - - // for trackQA plot - for (const auto& track : tracks) { - if (!trackSelection(track, true)) { - continue; - } - } - - TrackSlicingMC(collision, tracks, true); - } // processSameEvents_MC - PROCESS_SWITCH(kstarInJets, processSameEventMC, "process Same Event MC", false); - - //====================================== - //| - //| GENERATED STUFF - //| - //====================================== - void processGen(EventCandidatesTrue::iterator const& collision, soa::SmallGroups> const& recocolls, aod::McParticles const& mcParticles) - { - static int nEventsGen = 0; - if (cDebugLevel > 0) { - ++nEventsGen; - if (nEventsGen % 10000 == 0) { - LOG(info) << "Processed MC (GEN) Events: " << nEventsGen; - } - } - if (cfgMCHistos) { - histos.fill(HIST("nEvents_Gen"), 0.5); // Gen events - } - //======================= - //| Event & Signal loss - //======================= - bool INELgt0 = false; - for (auto& particle : mcParticles) { - if (std::abs(particle.eta()) > cfgEventMaxEta) { - continue; - } - if (particle.pt() <= 0.0) { - continue; - } - INELgt0 = true; - break; - } - if (cfgForceTrueINELgt) { - if (!INELgt0) { - return; - } - } - if (cfgMCHistos) { - histos.fill(HIST("nEvents_Gen"), 1.5); // INEL>0 Gen events & EL: denominator - } - if (std::abs(collision.posZ()) > cfgEventVtxCut) { - return; - } - - for (auto& particle : mcParticles) { - if (std::abs(particle.pdgCode()) != Kstar0PDG) { - continue; - } - if (std::abs(particle.eta()) > cfgTrackMaxEta) { - continue; - } - - if (cfgMCHistos) { - histos.fill(HIST("hGen_pT_Kstar"), particle.pt()); // SL: denominator - } - } // Gen colls - - if (recocolls.size() <= 0) { // not reconstructed - if (cfgForceGenReco) { - return; - } - } + } // mcParticles in GenEvents //================= //| Efficiency //================= - double centrality = -1; - bool hasGoodEv = false; + if (recocolls.size() <= 0) { // not reconstructed + return; + } + for (auto& recocoll : recocolls) { // poorly reconstructed - auto [goodEv, code] = eventSelection(recocoll, true); - if (recocoll.posZ() > cfgEventVtxCut) { + auto goodEv = jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits); + if (std::abs(recocoll.posZ()) > cfgEventVtxCut) { goodEv = false; } if (!goodEv) { - continue; + return; } + } // reco.coll + histos.fill(HIST("nEvents_Gen"), 2.5); // EL: numerator - hasGoodEv = true; - centrality = recocoll.centFT0C(); - break; - } // recocolls - if (!hasGoodEv) { - return; - } - if (cfgMCHistos) { - histos.fill(HIST("nEvents_Gen"), 2.5); // EL: numerator - } - for (auto& particle : mcParticles) { - if (std::abs(particle.pdgCode()) != Kstar0PDG) { - continue; // Not K*0 - } - if (std::abs(particle.eta()) > cfgTrackMaxEta) { - continue; - } - if (particle.pt() < cfgTrackMinPt) { + // Find Gen K*0 + for (const auto& mcParticle : mcParticles) { + if (!KPidaughters(mcParticle)) { continue; } + histos.fill(HIST("hKstar_Gen"), mcParticle.pt()); // SL: numerator and eff: denominator + histos.fill(HIST("Gen_mother"), mcParticle.pdgCode()); - if (cfgMCHistos) { - histos.fill(HIST("hRec_pT_Kstar"), centrality, particle.pt()); // SL: numerator // eff: denominator - } - } // loop over particles - } // processGen - PROCESS_SWITCH(kstarInJets, processGen, "process Generated Particles", false); + } // mcParticles of BR + } // end of process + PROCESS_SWITCH(kstarInJets, processGen, "Process Generated Particles", false); - //============================================== + //======================== //| - //| GENERATED STUFF (INCLUSIVE & JETS) + //| Rec. STUFF //| - //============================================== - void processGenJets(o2::aod::JetMcCollision const& collision, soa::SmallGroups> const& recocolls, aod::JetParticles const& mcParticles) + //======================== + void processRec(o2::aod::JetCollision const& collision, + JetTrackCandidatesMC const& tracks, TrackCandidatesMC const&, + aod::JetParticles const&, aod::McParticles const&) { - static int nprocessGenEvents = 0; + static int nprocessRecEvents = 0; if (cDebugLevel > 0) { - ++nprocessGenEvents; - if (nprocessGenEvents % 10000 == 0) { - LOG(info) << "Processed MC (GEN) Events: " << nprocessGenEvents; + ++nprocessRecEvents; + if (nprocessRecEvents % 10000 == 0) { + LOG(info) << "Processed MC (REC) Events: " << nprocessRecEvents; } } - if (cfgJetMCHistos) { - histos.fill(HIST("nEvents_Gen"), 0.5); - } - //======================= - //| Event & Signal loss - //======================= - bool INELgt0 = false; - for (auto& particle : mcParticles) { - if (std::abs(particle.eta()) > cfgEventMaxEta) { - continue; - } - if (particle.pt() <= 0.0) { - continue; - } - INELgt0 = true; - break; - } - if (cfgForceTrueINELgt) { - if (!INELgt0) { - return; - } - } - if (cfgJetMCHistos) { - histos.fill(HIST("nEvents_Gen"), 1.5); // EL: denominator - } - if (std::abs(collision.posZ()) > cfgEventVtxCut) { + if (!cfgJetMCHistos) { return; } + histos.fill(HIST("nEvents_Rec"), 0.5); - for (auto& particle : mcParticles) { - if (std::abs(particle.pdgCode()) != Kstar0PDG) { - continue; - } - if (std::abs(particle.eta()) > cfgTrackMaxEta) { - continue; - } - - if (cfgJetMCHistos) { - histos.fill(HIST("hGen_pT_Kstar"), particle.pt()); // SL: denominator - } - } // Unreco. - - if (recocolls.size() <= 0) { // not reconstructed + if (!hasINELgt0(tracks)) { return; } - //================= - //| Efficiency - //================= - for (auto& recocoll : recocolls) { // poorly reconstructed - auto goodEv = jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits); - if (goodEv) { - goodEv = jetderiveddatautilities::selectTrigger(recocoll, RealTriggerMaskBits); - } - if (std::abs(recocoll.posZ()) > cfgEventVtxCut) { - goodEv = false; - } + histos.fill(HIST("nEvents_Rec"), 1.5); - if (!goodEv) { - return; - } - } // reco.coll - if (cfgJetMCHistos) { - histos.fill(HIST("nEvents_Gen"), 2.5); // EL: numerator - } + auto [goodEv, code] = JetEventSelection(collision, true); + if (!goodEv) + return; + histos.fill(HIST("nEvents_Rec"), 2.5); - for (auto& particle : mcParticles) { - if (std::abs(particle.pdgCode()) != Kstar0PDG) { - continue; - } - if (std::abs(particle.eta()) > cfgTrackMaxEta) { - continue; - } - if (particle.pt() < cfgTrackMinPt) { - continue; - } + for (const auto& candidate : recoResonance(tracks)) { + const auto& lResonance = candidate.second; - /* // Not Yet - if (cfg_Force_BR) { - bool baddecay = false; - for (auto& phidaughter : particle.daughters_as()) { - if (std::abs(phidaughter.pdgCode()) != 321) { - baddecay = true; - break; - } - if (cfg_Force_Kaon_Acceptence) { - if (std::abs(phidaughter.eta()) > cfg_Track_MaxEta) { - baddecay = true; - break; - } - } - } // loop over daughters - - if (baddecay) - continue; - } // enforce BR restriction - */ - - if (cfgJetMCHistos) { - histos.fill(HIST("nEvents_Gen"), 3.5); - histos.fill(HIST("hRec_pT_Kstar"), particle.pt()); // SL: numerator and eff: denominator - } - } // loop over particles - } // end of process - PROCESS_SWITCH(kstarInJets, processGenJets, "Process Generated Particles Inclusive&Jets", false); + histos.fill(HIST("hEffRec_pT"), lResonance.Pt()); + histos.fill(HIST("lResonance_Rec_Inv"), lResonance.M()); + + } // recoResonances + } // processRec + PROCESS_SWITCH(kstarInJets, processRec, "Process Reconstructed Particles", false); - void processJetQA(o2::aod::JetMcCollision const& collision, soa::Filtered const& mcpjets, aod::JetParticles const& mcParticles, aod::McParticles const&) + void processJetBias(o2::aod::JetMcCollision const& collision, + soa::Filtered const& mcpjets, + aod::JetParticles const& mcParticles, aod::McParticles const&) { static int ndRtest = 0; if (cDebugLevel > 0) { @@ -1645,19 +1230,11 @@ struct kstarInJets { LOG(info) << "Processed dR test: " << ndRtest; } } + if (!cfgJetdRHistos) { + return; + } - bool INELgt0 = false; - for (auto& mcpjet : mcpjets) { - if (std::abs(mcpjet.eta()) > cfgEventMaxEta) { - continue; - } - if (mcpjet.pt() <= 0.0) { - continue; - } - INELgt0 = true; - break; - } // Selection event through mcpjet loop - if (!INELgt0) { + if (!hasINELgt0(mcpjets)) { return; } if (std::abs(collision.posZ()) > cfgEventVtxCut) { @@ -1666,63 +1243,27 @@ struct kstarInJets { histos.fill(HIST("nEvents"), 0.5); for (auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.eta()) > cfgTrackMaxEta) { - continue; - } - if (!mcParticle.has_daughters()) { - continue; - } - if (std::abs(mcParticle.pdgCode()) != Kstar0PDG) { - continue; - } - - if (cfgJetdRHistos) { - histos.fill(HIST("Gen_KstarPt_All_BR"), mcParticle.pt()); - } - // 4vector: K*0 - ROOT::Math::PxPyPzEVector lResonance = ROOT::Math::PxPyPzEVector(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); - bool skip = false; - int daughter_kaon = 0; - int daughter_pion = 0; - for (auto& daughter : mcParticle.daughters_as()) { - if (std::abs(daughter.pdgCode()) == KaonPDG) { - ++daughter_kaon; - } else if (std::abs(daughter.pdgCode()) == PionPDG) { - ++daughter_pion; - } - } - if (daughter_kaon != 1 || daughter_pion != 1) { - skip = true; - } - if (skip) { + if (!KPidaughters(mcParticle)) { continue; } - - if (cfgJetdRHistos) { - histos.fill(HIST("Gen_Kstar_BR"), lResonance.M()); - histos.fill(HIST("Gen_KstarPt_BR"), mcParticle.pt()); - } + histos.fill(HIST("Gen_KstarPt_BR"), mcParticle.pt()); //================== // Distinguish Jets double bestR = 999; ROOT::Math::PxPyPzEVector bestJet; + ROOT::Math::PxPyPzEVector lResonance = ROOT::Math::PxPyPzEVector(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); for (auto& mcpjet : mcpjets) { if (mcpjet.pt() < cfgJetpT) { continue; } + histos.fill(HIST("mcpjet_eta"), mcpjet.eta()); + histos.fill(HIST("mcpjet_phi"), mcpjet.phi()); + histos.fill(HIST("mcpjet_pt"), mcpjet.pt()); - if (cfgJetdRHistos) { - histos.fill(HIST("mcpjet_eta"), mcpjet.eta()); - histos.fill(HIST("mcpjet_phi"), mcpjet.phi()); - histos.fill(HIST("mcpjet_pt"), mcpjet.pt()); - } - - double dphi = TVector2::Phi_mpi_pi(mcpjet.phi() - lResonance.Phi()); - double deta = mcpjet.eta() - lResonance.Eta(); - double dR = TMath::Sqrt((dphi * dphi) + (deta * deta)); + const double dR = getdR(mcpjet.eta(), mcpjet.phi(), lResonance.Eta(), lResonance.Phi()); if (dR < bestR) { bestR = dR; bestJet = ROOT::Math::PxPyPzEVector(mcpjet.px(), mcpjet.py(), mcpjet.pz(), mcpjet.energy()); @@ -1738,6 +1279,7 @@ struct kstarInJets { double dR_pion = 0; double dR_k_kstar = 0; double dR_pi_kstar = 0; + bool isKaonInJet = false; bool isPionInJet = false; ROOT::Math::PxPyPzEVector Daughter, missing_daughter; @@ -1746,16 +1288,10 @@ struct kstarInJets { Daughter = ROOT::Math::PxPyPzEVector(daughter.px(), daughter.py(), daughter.pz(), daughter.energy()); if (std::abs(daughter.pdgCode()) == KaonPDG) { - //=============== - // K*0 and kaon - double dphi_k_kstar = TVector2::Phi_mpi_pi(lResonance.Phi() - Daughter.Phi()); - double deta_k_kstar = lResonance.Eta() - Daughter.Eta(); - dR_k_kstar = TMath::Sqrt((dphi_k_kstar * dphi_k_kstar) + (deta_k_kstar * deta_k_kstar)); - // Jet and kaon - double dphi_kaon = TVector2::Phi_mpi_pi(bestJet.Phi() - Daughter.Phi()); - double deta_kaon = bestJet.Eta() - Daughter.Eta(); - dR_kaon = TMath::Sqrt((dphi_kaon * dphi_kaon) + (deta_kaon * deta_kaon)); + // K*0 and kaon + dR_k_kstar = getdR(lResonance.Eta(), lResonance.Phi(), daughter.eta(), daughter.phi()); + dR_kaon = getdR(bestJet.Eta(), bestJet.Phi(), daughter.eta(), daughter.phi()); if (dR_kaon <= cfgJetdR) { isKaonInJet = true; @@ -1763,16 +1299,10 @@ struct kstarInJets { missing_daughter += Daughter; } } else if (std::abs(daughter.pdgCode()) == PionPDG) { - //=============== - // K*0 and pion - double dphi_pi_kstar = TVector2::Phi_mpi_pi(lResonance.Phi() - Daughter.Phi()); - double deta_pi_kstar = lResonance.Eta() - Daughter.Eta(); - dR_pi_kstar = TMath::Sqrt((dphi_pi_kstar * dphi_pi_kstar) + (deta_pi_kstar * deta_pi_kstar)); - // Jet and pion - double dphi_pion = TVector2::Phi_mpi_pi(bestJet.Phi() - Daughter.Phi()); - double deta_pion = bestJet.Eta() - Daughter.Eta(); - dR_pion = TMath::Sqrt((dphi_pion * dphi_pion) + (deta_pion * deta_pion)); + // K*0 and pion + dR_pi_kstar = getdR(lResonance.Eta(), lResonance.Phi(), daughter.eta(), daughter.phi()); + dR_pion = getdR(bestJet.Eta(), bestJet.Phi(), daughter.eta(), daughter.phi()); if (dR_pion <= cfgJetdR) { isPionInJet = true; @@ -1782,80 +1312,47 @@ struct kstarInJets { } } // daughter - if (cfgJetdRHistos) { - histos.fill(HIST("dR_kstar_kaon"), dR_k_kstar, lResonance.Pt()); - histos.fill(HIST("dR_kstar_pion"), dR_pi_kstar, lResonance.Pt()); + histos.fill(HIST("dR_kstar_kaon"), dR_k_kstar, lResonance.Pt()); + histos.fill(HIST("dR_kstar_pion"), dR_pi_kstar, lResonance.Pt()); - if (bestR < cfgJetdR) { - histos.fill(HIST("dR_taggedjet_all"), dR_kaon, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_all"), dR_pion, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_kaon"), dR_kaon, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_pion"), dR_pion, lResonance.Pt()); + if (bestR < cfgJetdR) { + histos.fill(HIST("dR_taggedjet_all"), dR_kaon, lResonance.Pt()); + histos.fill(HIST("dR_taggedjet_all"), dR_pion, lResonance.Pt()); + histos.fill(HIST("dR_taggedjet_kaon"), dR_kaon, lResonance.Pt()); + histos.fill(HIST("dR_taggedjet_pion"), dR_pion, lResonance.Pt()); - if (bestJet.Pt() < 8.0) { - histos.fill(HIST("dR_taggedjet_0_8"), dR_kaon, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_0_8"), dR_pion, lResonance.Pt()); - } + if (bestJet.Pt() > 6.0 && bestJet.Pt() < 8.0) { + histos.fill(HIST("dR_taggedjet_all_6_8"), dR_kaon, lResonance.Pt()); + histos.fill(HIST("dR_taggedjet_all_6_8"), dR_pion, lResonance.Pt()); + histos.fill(HIST("Kstar_pT_INJet_6_8"), lResonance.Pt()); + } + if (bestJet.Pt() > 8.0 && bestJet.Pt() < 10.0) { + histos.fill(HIST("Kstar_pT_INJet_8_10"), lResonance.Pt()); + } + if (bestJet.Pt() > 10.0 && bestJet.Pt() < 12.0) { + histos.fill(HIST("Kstar_pT_INJet_10_12"), lResonance.Pt()); + } + + // Daughters out of jets + if (!isKaonInJet || !isPionInJet) { + ROOT::Math::PxPyPzEVector recoveredJet = bestJet + missing_daughter; if (bestJet.Pt() > 6.0 && bestJet.Pt() < 8.0) { - histos.fill(HIST("dR_taggedjet_all_6_8"), dR_kaon, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_all_6_8"), dR_pion, lResonance.Pt()); - histos.fill(HIST("Kstar_pT_INJet_6_8"), lResonance.Pt()); - } - if (bestJet.Pt() > 8.0) { - histos.fill(HIST("JetpT_8to"), bestJet.Pt()); - } - if (bestJet.Pt() > 8.0 && bestJet.Pt() < 10.0) { - histos.fill(HIST("Kstar_pT_INJet_8_10"), lResonance.Pt()); - } - if (bestJet.Pt() > 10.0 && bestJet.Pt() < 12.0) { - histos.fill(HIST("Kstar_pT_INJet_10_12"), lResonance.Pt()); - } - if (bestJet.Pt() > 8.0 && bestJet.Pt() < 12.0) { - histos.fill(HIST("dR_taggedjet_all_8_12"), dR_kaon, lResonance.Pt()); - histos.fill(HIST("dR_taggedjet_all_8_12"), dR_pion, lResonance.Pt()); - histos.fill(HIST("Kstar_pT_INJet_8_12"), lResonance.Pt()); - } - // Daughters out of jets - if (!isKaonInJet || !isPionInJet) { - ROOT::Math::PxPyPzEVector recoveredJet = bestJet + missing_daughter; - if (bestJet.Pt() > 6.0 && bestJet.Pt() < 8.0) { - histos.fill(HIST("missed_kpi_INJets_6_8"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); - - if (recoveredJet.Pt() > 8.0) { - histos.fill(HIST("recoveredJetpT_6_8to8"), recoveredJet.Pt()); - histos.fill(HIST("Kstar_pT_6_8to8_IN_recoveredJet"), lResonance.Pt()); - } - if (recoveredJet.Pt() > 8.0 && recoveredJet.Pt() < 10.0) { - histos.fill(HIST("Kstar_pT_6_8to8_10_IN_recoveredJet"), lResonance.Pt()); - } - } // 6 < bestJetpT < 8 GeV/c - if (bestJet.Pt() > 8.0 && bestJet.Pt() < 10.0) { - histos.fill(HIST("missed_kpi_INJets_8_10"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); - } - if (bestJet.Pt() > 10.0 && bestJet.Pt() < 12.0) { - histos.fill(HIST("missed_kpi_INJets_10_12"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); - } - if (bestJet.Pt() > 12.0 && bestJet.Pt() < 15.0) { - histos.fill(HIST("missed_kpi_INJets_12_15"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); - } - if (bestJet.Pt() > 15.0 && bestJet.Pt() < 25.0) { - histos.fill(HIST("missed_kpi_INJets_15_25"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); - } - if (bestJet.Pt() > 25.0) { - histos.fill(HIST("missed_kpi_INJets_25_infinite"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); + if (recoveredJet.Pt() > 8.0) { + histos.fill(HIST("recoveredJetpT_6_8to8"), recoveredJet.Pt()); + histos.fill(HIST("Kstar_pT_6_8to8_IN_recoveredJet"), lResonance.Pt()); } - if (bestJet.Pt() > 8.0) { - histos.fill(HIST("missed_kpi_INJets_8_infinite"), (bestJet.Pt() - missing_daughter.Pt()) / bestJet.Pt(), lResonance.Pt()); + if (recoveredJet.Pt() > 8.0 && recoveredJet.Pt() < 10.0) { + histos.fill(HIST("Kstar_pT_6_8to8_10_IN_recoveredJet"), lResonance.Pt()); } - histos.fill(HIST("JetMigration"), bestJet.Pt(), recoveredJet.Pt()); - } // Daughters out of jet - } // K*0 InJet - } // cfgJetdRHistos + } + histos.fill(HIST("JetMigration"), bestJet.Pt(), recoveredJet.Pt()); + } // Daughters out of jet + } // K*0 InJet } // mcParticles }; - PROCESS_SWITCH(kstarInJets, processJetQA, "Process dR of K*0 Inclusive and Inside jet", false); + PROCESS_SWITCH(kstarInJets, processJetBias, "Process dR of K*0 Inclusive and Inside jet", false); //======================== // @@ -1866,248 +1363,310 @@ struct kstarInJets { using JetMCDTable = soa::Filtered>; using JetMCPTable = soa::Filtered>; - void processMatchedJet(aod::JetMcCollision const& collision, - soa::SmallGroups> const& recocolls, - JetMCPTable const& mcpjets, JetMCDTable const&, - JetTrackCandidatesMC const& tracks, TrackCandidatesMC const&, - aod::JetParticles const& mcParticles, aod::McParticles const&) + void processMatched(aod::JetMcCollision const& collision, + soa::SmallGroups> const& recocolls, + JetMCPTable const& mcpjets, JetMCDTable const&, + JetTrackCandidatesMC const& tracks, TrackCandidatesMC const&, + aod::JetParticles const& mcParticles, aod::McParticles const&) { - static int nMatched = 0; + static int nProcessMatched = 0; if (cDebugLevel > 0) { - ++nMatched; - if (nMatched % 10000 == 0) { - LOG(info) << "Processed Matched test: " << nMatched; + ++nProcessMatched; + if (nProcessMatched % 10000 == 0) { + LOG(info) << "Processed Matched: " << nProcessMatched; } } - - if (cfgMatchedGenHistos) { - histos.fill(HIST("nEvents_MCGen_MATCHED"), 0.5); + if (!cfgMatchedGenHistos) { + return; } + histos.fill(HIST("nEvents_MCGen_MATCHED"), 0.5); + if (std::fabs(collision.posZ()) > cfgEventVtxCut) { return; } - if (recocolls.size() <= 0) { return; } - for (auto& recocoll : recocolls) { - if (!jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits)) { + for (auto& recocoll : recocolls) { // poorly reconstructed + auto goodEv = jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits); + if (std::abs(recocoll.posZ()) > cfgEventVtxCut) { + goodEv = false; + } + if (!goodEv) { return; } - } + } // reco.coll - bool INELgt0 = false; - for (const auto& mcParticle : mcParticles) { - if (std::abs(mcParticle.eta()) < cfgEventMaxEta) { - INELgt0 = true; - break; - } - } // mcParticles - if (!INELgt0) { + if (!hasINELgt0(mcpjets)) { return; } - if (cfgMatchedGenHistos) { - histos.fill(HIST("nEvents_MCGen_MATCHED"), 1.5); - } + histos.fill(HIST("nEvents_MCGen_MATCHED"), 1.5); // 1. Gen jet --> Reco jet - std::vector mcd_pt{}; std::vector mcd_phi{}; std::vector mcd_eta{}; - std::vector mcp_pt{}; std::vector mcp_phi{}; std::vector mcp_eta{}; + std::vector NOMATCHED_mcp_pt{}; + std::vector NOMATCHED_mcp_phi{}; + std::vector NOMATCHED_mcp_eta{}; bool hasJets = false; for (const auto& mcpjet : mcpjets) { - if (!mcpjet.has_matchedJetGeo()) { + histos.fill(HIST("GeneratedJets_pT"), mcpjet.pt()); - if (cfgMatchedGenHistos) { - histos.fill(HIST("NoMatchedJets_pT"), mcpjet.pt()); - } - continue; - } - - for (const auto& mcdjet : mcpjet.template matchedJetGeo_as()) { - if (!mcdjet.has_matchedJetGeo()) { - continue; - } - hasJets = true; - - // QA - // double dPhi = TVector2::Phi_mpi_pi(mcdjet.phi() - mcpjet.phi()); - // double dEta = mcdjet.eta() - mcpjet.eta(); - // double dR = std::sqrt((dPhi * dPhi) + (dEta * dEta)); + int nMatches = 0; + if (mcpjet.has_matchedJetGeo()) { + for (const auto& mcdjet : mcpjet.template matchedJetGeo_as()) { + if (!mcdjet.has_matchedJetGeo()) { + continue; + } + ++nMatches; + hasJets = true; - if (cfgMatchedGenHistos) { histos.fill(HIST("matchedJets_pT"), mcpjet.pt(), mcdjet.pt() - mcpjet.pt()); histos.fill(HIST("matchedJets_phi"), mcpjet.phi(), mcdjet.phi() - mcpjet.phi()); histos.fill(HIST("matchedJets_eta"), mcpjet.eta(), mcdjet.eta() - mcpjet.eta()); - } - mcd_pt.push_back(mcdjet.pt()); - mcd_phi.push_back(mcdjet.phi()); - mcd_eta.push_back(mcdjet.eta()); + mcd_pt.push_back(mcdjet.pt()); + mcd_phi.push_back(mcdjet.phi()); + mcd_eta.push_back(mcdjet.eta()); - mcp_pt.push_back(mcpjet.pt()); - mcp_phi.push_back(mcpjet.phi()); - mcp_eta.push_back(mcpjet.eta()); + mcp_pt.push_back(mcpjet.pt()); + mcp_phi.push_back(mcpjet.phi()); + mcp_eta.push_back(mcpjet.eta()); + } // mcd matching + } // mcp matching - } // mcdjet - } // mcpjet + if (nMatches > 0) { + histos.fill(HIST("MatchedJets_pT"), mcpjet.pt()); + } else { + histos.fill(HIST("NoMatchedJets_pT"), mcpjet.pt()); - if (hasJets) { - if (cfgMatchedGenHistos) { - histos.fill(HIST("nEvents_MCGen_MATCHED"), 2.5); + NOMATCHED_mcp_pt.push_back(mcpjet.pt()); + NOMATCHED_mcp_phi.push_back(mcpjet.phi()); + NOMATCHED_mcp_eta.push_back(mcpjet.eta()); } + } // mcpjets loop + + if (hasJets) { + histos.fill(HIST("nEvents_MCGen_MATCHED"), 2.5); } - // 2. Find Gen K*0 + // Filtered the meaningful tracks from recocoll - // True K*0 + std::vector recoCandidates; + for (const auto& recocoll : recocolls) { + const auto collisionTracks = tracks.sliceBy(tracksPerRecoCollision, recocoll.globalIndex()); + const auto candidates = recoResonance(collisionTracks); + + recoCandidates.insert(recoCandidates.end(), candidates.begin(), candidates.end()); + } + + // Gen K*0 loop for (const auto& mcParticle : mcParticles) { - if (std::fabs(mcParticle.eta()) > cfgTrackMaxEta) { + if (!KPidaughters(mcParticle)) { continue; } - if (std::fabs(mcParticle.pdgCode()) != Kstar0PDG) { + + double best_dR = cfgJetdR; + //============== + // Matched Jet + //============== + auto bestMatched_index = mcp_pt.size(); + for (std::vector::size_type i = 0; i < mcp_pt.size(); ++i) { + if (mcp_pt[i] < cfgJetpT) { + continue; + } + const double dR = getdR(mcp_eta[i], mcp_phi[i], mcParticle.eta(), mcParticle.phi()); + if (dR < best_dR) { + best_dR = dR; + bestMatched_index = i; + } + } // mcpjet loop + + //=============== + // NoMatched Jet + //=============== + auto bestNoMatched_index = NOMATCHED_mcp_pt.size(); + for (std::vector::size_type i = 0; i < NOMATCHED_mcp_pt.size(); ++i) { + if (NOMATCHED_mcp_pt[i] < cfgJetpT) { + continue; + } + const double dR = getdR(NOMATCHED_mcp_eta[i], NOMATCHED_mcp_phi[i], mcParticle.eta(), mcParticle.phi()); + if (dR < best_dR) { + best_dR = dR; + bestNoMatched_index = i; + } + } // NOMATCHED mcpjet loop + + if (bestNoMatched_index != NOMATCHED_mcp_pt.size()) { + histos.fill(HIST("NoMatched"), mcParticle.pt(), NOMATCHED_mcp_pt[bestNoMatched_index]); continue; } - if (!mcParticle.has_daughters()) { + + if (bestMatched_index == mcp_pt.size()) { continue; } - // K*0 --> Kpi - int nKaon = 0; - int nPion = 0; + const auto i_jet = bestMatched_index; + const double jetpt_mcp = mcp_pt[i_jet]; - int kaonIndex = -1; - int pionIndex = -1; + histos.fill(HIST("Matched"), mcParticle.pt(), jetpt_mcp); - double kaonPx = 0; - double kaonPy = 0; - double kaonPz = 0; - - double pionPx = 0; - double pionPy = 0; - double pionPz = 0; - - // Truth K*0 --> Keep the KPi Index - for (const auto& daughter : mcParticle.daughters_as()) { - - if (std::abs(daughter.pdgCode()) == KaonPDG) { - ++nKaon; - kaonIndex = daughter.globalIndex(); - } else if (std::abs(daughter.pdgCode()) == PionPDG) { - ++nPion; - pionIndex = daughter.globalIndex(); + const auto gen_Index = mcParticle.globalIndex(); + for (const auto& [motherIndex, lResonance] : recoCandidates) { + if (motherIndex != gen_Index) { + continue; } - } - if (nKaon != 1 || nPion != 1) { - continue; - } - //======================= - // Track KPi --> Reco K*0 + // Matched Rec. K*0 --> Matching detector-level jet - bool kaon_daughter = false; - bool pion_daughter = false; + const double dR = getdR(mcd_eta[i_jet], mcd_phi[i_jet], lResonance.Eta(), lResonance.Phi()); + const bool recoJetFlag = dR < cfgJetdR; - for (const auto& track : tracks) { - auto trk = track.track_as(); - - if (!trk.has_mcParticle()) { - continue; - } - if (!trackSelection(trk, true)) { + if (!recoJetFlag) { continue; } - if (std::fabs(trk.eta()) > cfgTrackMaxEta) { - continue; - } - if (!trackPIDKaon(trk, false) || !trackPIDPion(trk, false)) { - continue; + const double jetpt_mcd = mcd_pt[i_jet]; + + unsigned int seed = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); + int dice = rand_r(&seed) % 2; + + if (dice > 0) { + // Train + histos.fill(HIST("RespGen_Matched_rand0"), lResonance.Pt(), jetpt_mcd, mcParticle.pt(), jetpt_mcp); + } else { + // Test + histos.fill(HIST("RespGen_Matched_rand1"), lResonance.Pt(), jetpt_mcd, mcParticle.pt(), jetpt_mcp); } + break; + } // recoCandidates loop + } // mcParticles + }; // processmatchedJet + PROCESS_SWITCH(kstarInJets, processMatched, "Process Matched K*0 jets", false); - auto particle1 = trk.mcParticle(); - auto particle2 = trk.mcParticle(); + void processPrior(aod::JetMcCollision const& collision, + soa::SmallGroups> const& recocolls, + JetMCPTable const& mcpjets, + aod::JetParticles const& mcParticles, aod::McParticles const&) + { + static int nPrior = 0; + if (cDebugLevel > 0) { + ++nPrior; + if (nPrior % 10000 == 0) { + LOG(info) << "Processed Prior: " << nPrior; + } + } + if (!cfgPriorHistos) { + return; + } + histos.fill(HIST("nEvents_Prior"), 0.5); - if (particle1.globalIndex() == kaonIndex) { - kaonPx = trk.px(); - kaonPy = trk.py(); - kaonPz = trk.pz(); - kaon_daughter = true; + if (std::fabs(collision.posZ()) > cfgEventVtxCut) { + return; + } + if (!hasINELgt0(mcParticles)) { + return; + } + + if (!cfgFullClosureTest) { + if (recocolls.size() <= 0) { + return; + } + for (auto& recocoll : recocolls) { + if (std::abs(recocoll.posZ()) > cfgEventVtxCut) { + return; } - if (particle2.globalIndex() == pionIndex) { - pionPx = trk.px(); - pionPy = trk.py(); - pionPz = trk.pz(); - pion_daughter = true; + if (!jetderiveddatautilities::selectCollision(recocoll, eventSelectionBits)) { + return; } - } // track + } + } // Full Closure Test + histos.fill(HIST("nEvents_Prior"), 1.5); - if (!kaon_daughter || !pion_daughter) { + for (const auto& mcParticle : mcParticles) { + if (!KPidaughters(mcParticle)) { continue; } - // 3. Prepare Gen and Rec K*0 - - ROOT::Math::PxPyPzEVector lResonance = ROOT::Math::PxPyPzEVector(mcParticle.px(), mcParticle.py(), mcParticle.pz(), mcParticle.e()); - ROOT::Math::PxPyPzMVector lDecayKaon_Rec = ROOT::Math::PxPyPzMVector(kaonPx, kaonPy, kaonPz, massKa); - ROOT::Math::PxPyPzMVector lDecayPion_Rec = ROOT::Math::PxPyPzMVector(pionPx, pionPy, pionPz, massPi); - ROOT::Math::PxPyPzMVector lResonance_Rec = lDecayKaon_Rec + lDecayPion_Rec; + double best_dR = cfgJetdR; + ROOT::Math::PxPyPzEVector bestJet; - // 4. Calculate dR between jet and K*0 + for (const auto& mcpjet : mcpjets) { + if (mcpjet.pt() < cfgJetpT) { + continue; + } - int goodjets = 0; - bool jetFlag = false; - double jetpt_mcp = 0; - double jetpt_mcd = 0; + double dR = getdR(mcpjet.eta(), mcpjet.phi(), mcParticle.eta(), mcParticle.phi()); + if (dR < best_dR) { + best_dR = dR; + bestJet = ROOT::Math::PxPyPzEVector(mcpjet.px(), mcpjet.py(), mcpjet.pz(), mcpjet.energy()); + } // bestJet + } // mcpjets loop - for (std::vector::size_type i = 0; i < mcp_pt.size(); i++) { - double dphi = TVector2::Phi_mpi_pi(mcp_phi[i] - lResonance.Phi()); - double deta = mcp_eta[i] - lResonance.Eta(); - double dR = TMath::Sqrt((deta * deta) + (dphi * dphi)); + if (best_dR < cfgJetdR) { + histos.fill(HIST("Prior"), mcParticle.pt(), bestJet.Pt()); + } + } // mcParticles loop + }; + PROCESS_SWITCH(kstarInJets, processPrior, "Process Prior K*0 jets", false); - if (dR < cfgJetdR) { - jetFlag = true; - jetpt_mcp = mcp_pt[i]; - jetpt_mcd = mcd_pt[i]; + void processRecInJet(aod::JetCollision const& collision, + JetMCDTable const& mcdjets, + JetTrackCandidatesMC const& tracks, TrackCandidatesMC const&, + aod::JetParticles const& mcParticles, aod::McParticles const&) + { + static int nRec = 0; + if (cDebugLevel > 0) { + ++nRec; + if (nRec % 10000 == 0) { + LOG(info) << "Processed Rec In Jet: " << nRec; + } + } + if (!cfgPriorHistos) { + return; + } + histos.fill(HIST("nEvents_PriorRec"), 0.5); - goodjets++; - } - } // mcp jet + if (std::fabs(collision.posZ()) > cfgEventVtxCut) { + return; + } + if (!hasINELgt0(mcParticles)) { + return; + } + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + histos.fill(HIST("nEvents_PriorRec"), 1.5); - if (cfgSingleJet) { - if (goodjets > 1) { - jetpt_mcp = DistinguishJetsMC(mcp_pt, mcp_phi, mcp_eta, lResonance); - jetpt_mcd = DistinguishJetsMC(mcd_pt, mcd_phi, mcd_eta, lResonance_Rec); - } - } + for (const auto& candidate : recoResonance(tracks)) { + const auto& lResonance = candidate.second; - if (!jetFlag) { - continue; - } + double best_dR = cfgJetdR; + ROOT::Math::PxPyPzEVector bestJet; - if (cfgMatchedGenHistos) { - unsigned int seed = static_cast(std::chrono::system_clock::now().time_since_epoch().count()); - int dice = rand_r(&seed) % 2; + for (const auto& mcdjet : mcdjets) { + if (mcdjet.pt() < cfgJetpT) { + continue; + } - // for checking - if (dice > 0) { - // Train - histos.fill(HIST("RespGen_Matched_rand0"), lResonance_Rec.Pt(), jetpt_mcd, lResonance.Pt(), jetpt_mcp); - } else { - // Test - histos.fill(HIST("RespGen_Matched_rand1"), lResonance_Rec.Pt(), jetpt_mcd, lResonance.Pt(), jetpt_mcp); + double dR = getdR(mcdjet.eta(), mcdjet.phi(), lResonance.eta(), lResonance.phi()); + if (dR < best_dR) { + best_dR = dR; + bestJet = ROOT::Math::PxPyPzEVector(mcdjet.px(), mcdjet.py(), mcdjet.pz(), mcdjet.energy()); } + } // mcdjets loop - } // cfgMatchedGenHistos + if (best_dR < cfgJetdR) { + histos.fill(HIST("Prior_Rec"), lResonance.pt(), bestJet.Pt()); + } - } // mcParticles - }; // processJetUnfolding - PROCESS_SWITCH(kstarInJets, processMatchedJet, "Process Unfolding of K*0 jets", false); + } // tracks loop + }; + PROCESS_SWITCH(kstarInJets, processRecInJet, "Process Rec K*0 In Jets", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From 534c95a8328bf08b786567a50a389f05dc06e67d Mon Sep 17 00:00:00 2001 From: jimun_lee Date: Tue, 24 Nov 2026 20:02:15 +0900 Subject: [PATCH 3/3] modified few include --- PWGLF/Tasks/Resonances/kstarInJets.cxx | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/PWGLF/Tasks/Resonances/kstarInJets.cxx b/PWGLF/Tasks/Resonances/kstarInJets.cxx index 8796764cf70..1954906625c 100644 --- a/PWGLF/Tasks/Resonances/kstarInJets.cxx +++ b/PWGLF/Tasks/Resonances/kstarInJets.cxx @@ -16,10 +16,10 @@ #include "PWGJE/DataModel/Jet.h" #include "PWGJE/DataModel/JetReducedData.h" -#include "Common/CCDB/EventSelectionParams.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/Multiplicity.h" +// #include "Common/CCDB/EventSelectionParams.h" +// #include "Common/DataModel/Centrality.h" +// #include "Common/DataModel/EventSelection.h" +// #include "Common/DataModel/Multiplicity.h" #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -38,16 +38,15 @@ #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include -#include +// #include #include -#include +// #include #include #include #include -#include +// #include #include -#include #include #include #include