diff --git a/PWGJE/Tasks/jetHFAngularity.cxx b/PWGJE/Tasks/jetHFAngularity.cxx index 9ad90432255..dac9b5e1bfc 100644 --- a/PWGJE/Tasks/jetHFAngularity.cxx +++ b/PWGJE/Tasks/jetHFAngularity.cxx @@ -356,15 +356,13 @@ struct JetHFAngularityTask { {"h_d0_origin_mcd", ";origin (0=none,1=prompt,2=non-prompt);entries", {HistType::kTH1F, {{3, 0., 3.}}}}, {"hSparse_d0_mcd", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};#DeltaR^{det};#lambda_{1}^{1,det};#lambda_{2}^{1,det}", {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {200, 0., 1.}, {50, 0., 1.}, {50, 0., 1.}}}}, - - {"hSparse_d0_mcd_calib", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};Origin(D^{0});#lambda_{1}^{1,det};#lambda_{2}^{1,det}", - {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {50, 0., 1.}, {50, 0., 1.}}}}, + + {"hSparse_d0_mcd_calib", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};Origin(D^{0});#lambda_{1}^{1,det};#lambda_{2}^{1,det}", {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {50, 0., 1.}, {50, 0., 1.}}}}, {"h_d0_mass_mcd_signal", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{300, 1.7, 2.0}}}}, {"h_d0_mass_mcd_reflection", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{300, 1.7, 2.0}}}}, - {"hSparse_d0_mcd_reflection", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};Origin(D^{0});#lambda_{1}^{1,det};#lambda_{2}^{1,det}", - {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {50, 0., 1.}, {50, 0., 1.}}}}, + {"hSparse_d0_mcd_reflection", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};Origin(D^{0});#lambda_{1}^{1,det};#lambda_{2}^{1,det}", {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {50, 0., 1.}, {50, 0., 1.}}}}, // MC PARTICLE LEVEL (MCP) @@ -416,7 +414,7 @@ struct JetHFAngularityTask { // Axes: pT_jet^det, pT_D0^det, pT_jet^part, pT_D0^part {"h_response_d0pt_pr", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,D^{0}}^{part} (GeV/#it{c})", {HistType::kTHnSparseF, {{40, 0., 200.}, {50, 0., 50.}, {40, 0., 200.}, {50, 0., 50.}}}}, {"h_response_d0pt_np", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,D^{0}}^{part} (GeV/#it{c})", {HistType::kTHnSparseF, {{40, 0., 200.}, {50, 0., 50.}, {40, 0., 200.}, {50, 0., 50.}}}}, - + {"h_kineff_gen_num_pr", ";#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,D^{0}}^{part} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, {"h_kineff_gen_den_pr", ";#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,D^{0}}^{part} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, {"h_kineff_gen_num_np", ";#it{p}_{T,jet}^{part} (GeV/#it{c});#it{p}_{T,D^{0}}^{part} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, @@ -444,9 +442,9 @@ struct JetHFAngularityTask { {"MC_JetCounter", "N_{jet};", {HistType::kTH1F, {{4, 0., 4.}}}}, {"hSparse_d0_mcd_eff", ";m_{D^{0}}^{det};#it{p}_{T,D^{0}}^{det};#it{p}_{T,jet}^{det};z_{||}^{det};Origin(D^{0});Matching status;#lambda_{1}^{1,det};#lambda_{2}^{1,det};IsReflection", {HistType::kTHnSparseF, {{300, 1.7, 2.0}, {200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {2, -0.5, 1.5}, {50, 0., 1.}, {50, 0., 1.}, {2, -0.5, 1.5}}}}, - + {"hSparse_d0_mcp_eff", ";#it{p}_{T,D^{0}}^{part};#it{p}_{T,jet}^{part};z_{||}^{part};Origin(D^{0});Matching status;#lambda_{1}^{1,part};#lambda_{2}^{1,part}", {HistType::kTHnSparseF, {{200, 0., 100.}, {200, 0., 100.}, {200, 0., 2.}, {3, -0.5, 2.5}, {2, -0.5, 1.5}, {50, 0., 1.}, {50, 0., 1.}}}}, - + }}; // init() @@ -559,7 +557,7 @@ struct JetHFAngularityTask { if (flagMcMatchRec == 0) { return false; // not truth-matched -> background, not a reflection } - const bool trueIsD0 = flagMcMatchRec > 0; // sign encodes true species + const bool trueIsD0 = flagMcMatchRec > 0; // sign encodes true species const bool thisRowIsD0Hypothesis = (cand.candidateSelFlag() == kCandSelFlagD0); // which hypothesis this row uses return thisRowIsD0Hypothesis != trueIsD0; } @@ -846,7 +844,6 @@ struct JetHFAngularityTask { registry.fill(HIST("h_eff_run2_num_np"), d0Candidate.pt()); } - objJetMCDTable(axisDistance, jet.pt(), jet.eta(), @@ -984,306 +981,306 @@ struct JetHFAngularityTask { "MC PARTICLE LEVEL: D0-tagged charged jet substructure", false); void processMCDChargedSubstructureMatched(aod::JetMcCollisions const& mccollisions, - aod::JetCollisionsMCD const& collisions, - D0MCDJetsMatched const& mcdjets, // now Filtered: jetCutsPt/jetCutsR applied automatically - D0MCPJetsMatched const& mcpjets, // MUST stay bare -- accessor target type - D0CandidatesMCD const&, - D0CandidatesMCP const&, - aod::JetTracks const&, - aod::JetParticles const&) + aod::JetCollisionsMCD const& collisions, + D0MCDJetsMatched const& mcdjets, // now Filtered: jetCutsPt/jetCutsR applied automatically + D0MCPJetsMatched const& mcpjets, // MUST stay bare -- accessor target type + D0CandidatesMCD const&, + D0CandidatesMCP const&, + aod::JetTracks const&, + aod::JetParticles const&) { - - const int jetRBin = static_cast(std::lround(static_cast(jetR) * 100.0f)); - for (const auto& mccollision : mccollisions) { + const int jetRBin = static_cast(std::lround(static_cast(jetR) * 100.0f)); - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::All)); + for (const auto& mccollision : mccollisions) { - if (std::abs(mccollision.posZ()) > vertexZCut) { - continue; - } - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::ZCut)); + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::All)); - const float mcWeight = mccollision.weight(); + if (std::abs(mccollision.posZ()) > vertexZCut) { + continue; + } + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::ZCut)); - const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex()); - for (const auto& collision : collisionsPerMCCollision) { + const float mcWeight = mccollision.weight(); - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::Matched)); + const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex()); + for (const auto& collision : collisionsPerMCCollision) { - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || - !(std::abs(collision.posZ()) < vertexZCut)) { - continue; - } - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::MatchedSel8ZCut)); + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::Matched)); - const auto d0mcdJetsPerCollision = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); - for (const auto& mcdjet : d0mcdJetsPerCollision) { - if (!(mcdjet.pt() > jetPtMin && mcdjet.r() == jetRBin)) { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || + !(std::abs(collision.posZ()) < vertexZCut)) { continue; - } - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetInMCCollision)); - - auto jetTracks = mcdjet.template tracks_as(); - auto jetCandidates = mcdjet.template candidates_as(); - - const int nConst = static_cast(jetTracks.size()) + static_cast(jetCandidates.size()); - const float angularity = computeLambda(mcdjet, jetTracks, jetCandidates, 1.f, 1.f); // λ_1^1 - const float girth = computeLambda(mcdjet, jetTracks, jetCandidates, 2.f, 1.f); // λ_2^1 - const float mjet = computeJetMass(jetTracks, jetCandidates); - - const std::array jetMomMCD{mcdjet.px(), mcdjet.py(), mcdjet.pz()}; - - bool isGeoMatched = false; - float matchedPt = -1.f; - float matchedEta = -999.f; - float matchedPhi = -999.f; - float matchedDR = -1.f; - float matchedAngularity = -1.f; - float matchedGirth = -1.f; - float matchedD0Pt = -1.f; // NEW - int geoMatchedGlobalIndex = -1; - int nGeoMatches = 0; - - if (mcdjet.has_matchedJetGeo()) { - for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { - ++nGeoMatches; - - const float dR = jetutilities::deltaR(mcdjet, mcpjet); - registry.fill(HIST("h_jet_matching_dr_mcd_allcand"), dR, mcWeight); - registry.fill(HIST("h_jet_pt_response_matrix_allcand"), mcdjet.pt(), mcpjet.pt(), mcWeight); - - if (!isGeoMatched) { - isGeoMatched = true; - matchedPt = mcpjet.pt(); - matchedEta = mcpjet.eta(); - matchedPhi = mcpjet.phi(); - matchedDR = dR; - geoMatchedGlobalIndex = mcpjet.globalIndex(); - - auto mcpjetParticles = mcpjet.template tracks_as(); - auto mcpjetCandidates = mcpjet.template candidates_as(); - matchedAngularity = computeLambda(mcpjet, mcpjetParticles, mcpjetCandidates, 1.f, 1.f); // λ_1^1 - matchedGirth = computeLambda(mcpjet, mcpjetParticles, mcpjetCandidates, 2.f, 1.f); // λ_2^1 - if (mcpjetCandidates.size() > 0) { - auto matchedMcpD0 = mcpjet.template candidates_first_as(); - matchedD0Pt = matchedMcpD0.pt(); + } + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::MatchedSel8ZCut)); + + const auto d0mcdJetsPerCollision = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); + for (const auto& mcdjet : d0mcdJetsPerCollision) { + if (!(mcdjet.pt() > jetPtMin && mcdjet.r() == jetRBin)) { + continue; + } + registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetInMCCollision)); + + auto jetTracks = mcdjet.template tracks_as(); + auto jetCandidates = mcdjet.template candidates_as(); + + const int nConst = static_cast(jetTracks.size()) + static_cast(jetCandidates.size()); + const float angularity = computeLambda(mcdjet, jetTracks, jetCandidates, 1.f, 1.f); // λ_1^1 + const float girth = computeLambda(mcdjet, jetTracks, jetCandidates, 2.f, 1.f); // λ_2^1 + const float mjet = computeJetMass(jetTracks, jetCandidates); + + const std::array jetMomMCD{mcdjet.px(), mcdjet.py(), mcdjet.pz()}; + + bool isGeoMatched = false; + float matchedPt = -1.f; + float matchedEta = -999.f; + float matchedPhi = -999.f; + float matchedDR = -1.f; + float matchedAngularity = -1.f; + float matchedGirth = -1.f; + float matchedD0Pt = -1.f; // NEW + int geoMatchedGlobalIndex = -1; + int nGeoMatches = 0; + + if (mcdjet.has_matchedJetGeo()) { + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + ++nGeoMatches; + + const float dR = jetutilities::deltaR(mcdjet, mcpjet); + registry.fill(HIST("h_jet_matching_dr_mcd_allcand"), dR, mcWeight); + registry.fill(HIST("h_jet_pt_response_matrix_allcand"), mcdjet.pt(), mcpjet.pt(), mcWeight); + + if (!isGeoMatched) { + isGeoMatched = true; + matchedPt = mcpjet.pt(); + matchedEta = mcpjet.eta(); + matchedPhi = mcpjet.phi(); + matchedDR = dR; + geoMatchedGlobalIndex = mcpjet.globalIndex(); + + auto mcpjetParticles = mcpjet.template tracks_as(); + auto mcpjetCandidates = mcpjet.template candidates_as(); + matchedAngularity = computeLambda(mcpjet, mcpjetParticles, mcpjetCandidates, 1.f, 1.f); // λ_1^1 + matchedGirth = computeLambda(mcpjet, mcpjetParticles, mcpjetCandidates, 2.f, 1.f); // λ_2^1 + if (mcpjetCandidates.size() > 0) { + auto matchedMcpD0 = mcpjet.template candidates_first_as(); + matchedD0Pt = matchedMcpD0.pt(); + } } } } - } - registry.fill(HIST("h_jet_matching_ngeo_mcd"), nGeoMatches, mcWeight); - - bool isCandMatched = false; - int candMatchedGlobalIndex = -1; - int nCandMatches = 0; - - if (mcdjet.has_matchedJetCand()) { - for (const auto& mcpjet : mcdjet.template matchedJetCand_as()) { - ++nCandMatches; - if (!isCandMatched) { - isCandMatched = true; - candMatchedGlobalIndex = mcpjet.globalIndex(); + registry.fill(HIST("h_jet_matching_ngeo_mcd"), nGeoMatches, mcWeight); + + bool isCandMatched = false; + int candMatchedGlobalIndex = -1; + int nCandMatches = 0; + + if (mcdjet.has_matchedJetCand()) { + for (const auto& mcpjet : mcdjet.template matchedJetCand_as()) { + ++nCandMatches; + if (!isCandMatched) { + isCandMatched = true; + candMatchedGlobalIndex = mcpjet.globalIndex(); + } } } - } - registry.fill(HIST("h_jet_matching_ncand_mcd"), nCandMatches, mcWeight); + registry.fill(HIST("h_jet_matching_ncand_mcd"), nCandMatches, mcWeight); - // "Clean" match: both criteria fire AND agree on the same target jet. - const bool isCleanMatched = isGeoMatched && isCandMatched && - (geoMatchedGlobalIndex == candMatchedGlobalIndex); + // "Clean" match: both criteria fire AND agree on the same target jet. + const bool isCleanMatched = isGeoMatched && isCandMatched && + (geoMatchedGlobalIndex == candMatchedGlobalIndex); - registry.fill(HIST("h_jet_matching_geo_status_mcd"), isGeoMatched ? 1.5f : 0.5f, mcWeight); - registry.fill(HIST("h_jet_matching_cand_status_mcd"), isCandMatched ? 1.5f : 0.5f, mcWeight); - registry.fill(HIST("h_jet_matching_clean_mcd"), isCleanMatched ? 1.5f : 0.5f, mcWeight); + registry.fill(HIST("h_jet_matching_geo_status_mcd"), isGeoMatched ? 1.5f : 0.5f, mcWeight); + registry.fill(HIST("h_jet_matching_cand_status_mcd"), isCandMatched ? 1.5f : 0.5f, mcWeight); + registry.fill(HIST("h_jet_matching_clean_mcd"), isCleanMatched ? 1.5f : 0.5f, mcWeight); - if (isGeoMatched) { - const bool agree = isCandMatched && (geoMatchedGlobalIndex == candMatchedGlobalIndex); - registry.fill(HIST("h_jet_matching_geocand_disagree_mcd"), agree ? 1.5f : 0.5f, mcWeight); - } - - if (isCleanMatched) { - registry.fill(HIST("h_jet_pt_response_matrix"), mcdjet.pt(), matchedPt, mcWeight); - registry.fill(HIST("h_jet_matching_dr_mcd"), matchedDR, mcWeight); - } + if (isGeoMatched) { + const bool agree = isCandMatched && (geoMatchedGlobalIndex == candMatchedGlobalIndex); + registry.fill(HIST("h_jet_matching_geocand_disagree_mcd"), agree ? 1.5f : 0.5f, mcWeight); + } - const int8_t geoStatus = static_cast(isGeoMatched); - const int8_t candStatus = static_cast(isCandMatched); - const int8_t cleanStatus = static_cast(isCleanMatched); + if (isCleanMatched) { + registry.fill(HIST("h_jet_pt_response_matrix"), mcdjet.pt(), matchedPt, mcWeight); + registry.fill(HIST("h_jet_matching_dr_mcd"), matchedDR, mcWeight); + } - const int isCleanMatchedMCD = isCleanMatched ? 1 : 0; + const int8_t geoStatus = static_cast(isGeoMatched); + const int8_t candStatus = static_cast(isCandMatched); + const int8_t cleanStatus = static_cast(isCleanMatched); - if (isCleanMatched) { - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetWithMatchedCandidate)); - } + const int isCleanMatchedMCD = isCleanMatched ? 1 : 0; - for (const auto& mcdD0cand : jetCandidates) { - - const std::array candMomMCD{mcdD0cand.px(), mcdD0cand.py(), mcdD0cand.pz()}; - const float zParallelMCD = RecoDecay::dotProd(candMomMCD, jetMomMCD) / RecoDecay::mag2(jetMomMCD); - const float axisDistance = jetutilities::deltaR(mcdjet, mcdD0cand); - - const int8_t flagMcMatch = mcdD0cand.flagMcMatchRec(); - const int originMcd = mcdD0cand.originMcRec(); // 0 none/bkg, 1 prompt, 2 non-prompt - - // Reflection identification: candidateSelFlag() hypothesis vs. true species - const bool isReflection = isReflectedCandidate(mcdD0cand); - const int isReflectionFlag = isReflection ? 1 : 0; - const bool isTrueSignal = (flagMcMatch != 0) && !isReflection; - - if (isReflection) { - registry.fill(HIST("h_d0_mass_mcd_reflection"), mcdD0cand.m(), mcWeight); - registry.fill(HIST("hSparse_d0_mcd_reflection"), - mcdD0cand.m(), mcdD0cand.pt(), mcdjet.pt(), zParallelMCD, originMcd, - angularity, girth); - } else if (isTrueSignal) { - registry.fill(HIST("h_d0_mass_mcd_signal"), mcdD0cand.m(), mcWeight); - registry.fill(HIST("hSparse_d0_mcd_calib"), - mcdD0cand.m(), mcdD0cand.pt(), mcdjet.pt(), zParallelMCD, originMcd, - angularity, girth); + if (isCleanMatched) { + registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetWithMatchedCandidate)); } - registry.fill(HIST("hSparse_d0_mcd_eff"), - mcdD0cand.m(), - mcdD0cand.pt(), - mcdjet.pt(), - zParallelMCD, - originMcd, - isCleanMatchedMCD, - angularity, - girth, - isReflectionFlag); - - if (originMcd == kOriginMcPrompt) { - registry.fill(HIST("h_eff_run2_num_pr"), mcdD0cand.pt()); - registry.fill(HIST("h_kineff_det_den_pr"), mcdjet.pt(), mcdD0cand.pt()); - if (isGeoMatched) { - registry.fill(HIST("h_kineff_det_num_pr"), mcdjet.pt(), mcdD0cand.pt()); + for (const auto& mcdD0cand : jetCandidates) { + + const std::array candMomMCD{mcdD0cand.px(), mcdD0cand.py(), mcdD0cand.pz()}; + const float zParallelMCD = RecoDecay::dotProd(candMomMCD, jetMomMCD) / RecoDecay::mag2(jetMomMCD); + const float axisDistance = jetutilities::deltaR(mcdjet, mcdD0cand); + + const int8_t flagMcMatch = mcdD0cand.flagMcMatchRec(); + const int originMcd = mcdD0cand.originMcRec(); // 0 none/bkg, 1 prompt, 2 non-prompt + + // Reflection identification: candidateSelFlag() hypothesis vs. true species + const bool isReflection = isReflectedCandidate(mcdD0cand); + const int isReflectionFlag = isReflection ? 1 : 0; + const bool isTrueSignal = (flagMcMatch != 0) && !isReflection; + + if (isReflection) { + registry.fill(HIST("h_d0_mass_mcd_reflection"), mcdD0cand.m(), mcWeight); + registry.fill(HIST("hSparse_d0_mcd_reflection"), + mcdD0cand.m(), mcdD0cand.pt(), mcdjet.pt(), zParallelMCD, originMcd, + angularity, girth); + } else if (isTrueSignal) { + registry.fill(HIST("h_d0_mass_mcd_signal"), mcdD0cand.m(), mcWeight); + registry.fill(HIST("hSparse_d0_mcd_calib"), + mcdD0cand.m(), mcdD0cand.pt(), mcdjet.pt(), zParallelMCD, originMcd, + angularity, girth); } - } else if (originMcd == kOriginMcNonPrompt) { - registry.fill(HIST("h_eff_run2_num_np"), mcdD0cand.pt()); - registry.fill(HIST("h_kineff_det_den_np"), mcdjet.pt(), mcdD0cand.pt()); - if (isGeoMatched) { - registry.fill(HIST("h_kineff_det_num_np"), mcdjet.pt(), mcdD0cand.pt()); - } - } - if (isCleanMatched) { + registry.fill(HIST("hSparse_d0_mcd_eff"), + mcdD0cand.m(), + mcdD0cand.pt(), + mcdjet.pt(), + zParallelMCD, + originMcd, + isCleanMatchedMCD, + angularity, + girth, + isReflectionFlag); + if (originMcd == kOriginMcPrompt) { - registry.fill(HIST("h_jet_pt_response_matrix_pr"), mcdjet.pt(), matchedPt, mcWeight); - registry.fill(HIST("h_response_angularity_pr"), mcdjet.pt(), angularity, matchedPt, matchedAngularity, mcWeight); - registry.fill(HIST("h_response_girth_pr"), mcdjet.pt(), girth, matchedPt, matchedGirth, mcWeight); - registry.fill(HIST("h_response_d0pt_pr"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt, mcWeight); + registry.fill(HIST("h_eff_run2_num_pr"), mcdD0cand.pt()); + registry.fill(HIST("h_kineff_det_den_pr"), mcdjet.pt(), mcdD0cand.pt()); + if (isGeoMatched) { + registry.fill(HIST("h_kineff_det_num_pr"), mcdjet.pt(), mcdD0cand.pt()); + } } else if (originMcd == kOriginMcNonPrompt) { - registry.fill(HIST("h_jet_pt_response_matrix_np"), mcdjet.pt(), matchedPt, mcWeight); - registry.fill(HIST("h_response_angularity_np"), mcdjet.pt(), angularity, matchedPt, matchedAngularity, mcWeight); - registry.fill(HIST("h_response_girth_np"), mcdjet.pt(), girth, matchedPt, matchedGirth, mcWeight); - registry.fill(HIST("h_response_d0pt_np"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt, mcWeight); + registry.fill(HIST("h_eff_run2_num_np"), mcdD0cand.pt()); + registry.fill(HIST("h_kineff_det_den_np"), mcdjet.pt(), mcdD0cand.pt()); + if (isGeoMatched) { + registry.fill(HIST("h_kineff_det_num_np"), mcdjet.pt(), mcdD0cand.pt()); + } } - } - objJetMCDMatchedTable(axisDistance, - mcdjet.pt(), - mcdjet.eta(), - mcdjet.phi(), - nConst, - angularity, - girth, - mjet, - zParallelMCD, - mcdD0cand.pt(), - mcdD0cand.eta(), - mcdD0cand.phi(), - mcdD0cand.m(), - mcdD0cand.y(), - mcdD0cand.mlScores()[0], - mcdD0cand.mlScores()[1], - mcdD0cand.mlScores()[2], - flagMcMatch, - originMcd, - geoStatus, - candStatus, - cleanStatus, - matchedPt, - matchedEta, - matchedPhi, - matchedDR, - matchedD0Pt); - } // end D0 candidate loop - } // end MCD jet loop - } // end reconstructed-collision loop - - const auto d0mcpJetsPerMCCollision = mcpjets.sliceBy(d0MCPJetsPerMCCollisionPreslice, mccollision.globalIndex()); - for (const auto& mcpjet : d0mcpJetsPerMCCollision) { - - if (!(mcpjet.pt() > jetPtMin && mcpjet.r() == jetRBin)) { - continue; - } + if (isCleanMatched) { + if (originMcd == kOriginMcPrompt) { + registry.fill(HIST("h_jet_pt_response_matrix_pr"), mcdjet.pt(), matchedPt, mcWeight); + registry.fill(HIST("h_response_angularity_pr"), mcdjet.pt(), angularity, matchedPt, matchedAngularity, mcWeight); + registry.fill(HIST("h_response_girth_pr"), mcdjet.pt(), girth, matchedPt, matchedGirth, mcWeight); + registry.fill(HIST("h_response_d0pt_pr"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt, mcWeight); + } else if (originMcd == kOriginMcNonPrompt) { + registry.fill(HIST("h_jet_pt_response_matrix_np"), mcdjet.pt(), matchedPt, mcWeight); + registry.fill(HIST("h_response_angularity_np"), mcdjet.pt(), angularity, matchedPt, matchedAngularity, mcWeight); + registry.fill(HIST("h_response_girth_np"), mcdjet.pt(), girth, matchedPt, matchedGirth, mcWeight); + registry.fill(HIST("h_response_d0pt_np"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt, mcWeight); + } + } - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetInMCCollision)); + objJetMCDMatchedTable(axisDistance, + mcdjet.pt(), + mcdjet.eta(), + mcdjet.phi(), + nConst, + angularity, + girth, + mjet, + zParallelMCD, + mcdD0cand.pt(), + mcdD0cand.eta(), + mcdD0cand.phi(), + mcdD0cand.m(), + mcdD0cand.y(), + mcdD0cand.mlScores()[0], + mcdD0cand.mlScores()[1], + mcdD0cand.mlScores()[2], + flagMcMatch, + originMcd, + geoStatus, + candStatus, + cleanStatus, + matchedPt, + matchedEta, + matchedPhi, + matchedDR, + matchedD0Pt); + } // end D0 candidate loop + } // end MCD jet loop + } // end reconstructed-collision loop + + const auto d0mcpJetsPerMCCollision = mcpjets.sliceBy(d0MCPJetsPerMCCollisionPreslice, mccollision.globalIndex()); + for (const auto& mcpjet : d0mcpJetsPerMCCollision) { + + if (!(mcpjet.pt() > jetPtMin && mcpjet.r() == jetRBin)) { + continue; + } - auto mcpD0cand = mcpjet.template candidates_first_as(); + registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetInMCCollision)); - const int originMcp = mcpD0cand.originMcGen(); // 0 none/bkg, 1 prompt, 2 non-prompt + auto mcpD0cand = mcpjet.template candidates_first_as(); - bool mcpIsCleanMatched = false; - if (mcpjet.has_matchedJetGeo() && mcpjet.has_matchedJetCand()) { - int mcpGeoTarget = -1; - for (const auto& mcdjetGeo : mcpjet.template matchedJetGeo_as()) { - mcpGeoTarget = mcdjetGeo.globalIndex(); - break; // first geo match, mirrors the MCD-side "first match wins" convention - } - int mcpCandTarget = -1; - for (const auto& mcdjetCand : mcpjet.template matchedJetCand_as()) { - mcpCandTarget = mcdjetCand.globalIndex(); - break; + const int originMcp = mcpD0cand.originMcGen(); // 0 none/bkg, 1 prompt, 2 non-prompt + + bool mcpIsCleanMatched = false; + if (mcpjet.has_matchedJetGeo() && mcpjet.has_matchedJetCand()) { + int mcpGeoTarget = -1; + for (const auto& mcdjetGeo : mcpjet.template matchedJetGeo_as()) { + mcpGeoTarget = mcdjetGeo.globalIndex(); + break; // first geo match, mirrors the MCD-side "first match wins" convention + } + int mcpCandTarget = -1; + for (const auto& mcdjetCand : mcpjet.template matchedJetCand_as()) { + mcpCandTarget = mcdjetCand.globalIndex(); + break; + } + mcpIsCleanMatched = (mcpGeoTarget == mcpCandTarget) && (mcpGeoTarget != -1); } - mcpIsCleanMatched = (mcpGeoTarget == mcpCandTarget) && (mcpGeoTarget != -1); - } - const int isCleanMatchedMCP = mcpIsCleanMatched ? 1 : 0; + const int isCleanMatchedMCP = mcpIsCleanMatched ? 1 : 0; - if (mcpIsCleanMatched) { - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetWithMatchedCandidate)); - } + if (mcpIsCleanMatched) { + registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetWithMatchedCandidate)); + } - const std::array jetMomMCP{mcpjet.px(), mcpjet.py(), mcpjet.pz()}; - const std::array candMomMCP{mcpD0cand.px(), mcpD0cand.py(), mcpD0cand.pz()}; - const float zParallelMCP = RecoDecay::dotProd(candMomMCP, jetMomMCP) / RecoDecay::mag2(jetMomMCP); - - auto mcpJetParticles = mcpjet.template tracks_as(); - auto mcpJetCandidates = mcpjet.template candidates_as(); - const float angularityMCP = computeLambda(mcpjet, mcpJetParticles, mcpJetCandidates, 1.f, 1.f); // λ_1^1 - const float girthMCP = computeLambda(mcpjet, mcpJetParticles, mcpJetCandidates, 2.f, 1.f); // λ_2^1 - - registry.fill(HIST("hSparse_d0_mcp_eff"), - mcpD0cand.pt(), - mcpjet.pt(), - zParallelMCP, - originMcp, - isCleanMatchedMCP, - angularityMCP, - girthMCP); - - const bool mcpIsGeoMatched = mcpjet.has_matchedJetGeo(); - if (originMcp == kOriginMcPrompt) { - registry.fill(HIST("h_eff_run2_den_pr"), mcpD0cand.pt()); - registry.fill(HIST("h_kineff_gen_den_pr"), mcpjet.pt(), mcpD0cand.pt()); - if (mcpIsGeoMatched) { - registry.fill(HIST("h_kineff_gen_num_pr"), mcpjet.pt(), mcpD0cand.pt()); - } - } else if (originMcp == kOriginMcNonPrompt) { - registry.fill(HIST("h_eff_run2_den_np"), mcpD0cand.pt()); - registry.fill(HIST("h_kineff_gen_den_np"), mcpjet.pt(), mcpD0cand.pt()); - if (mcpIsGeoMatched) { - registry.fill(HIST("h_kineff_gen_num_np"), mcpjet.pt(), mcpD0cand.pt()); - } - } - } // end MCP jet loop - } // end MC collision loop -} + const std::array jetMomMCP{mcpjet.px(), mcpjet.py(), mcpjet.pz()}; + const std::array candMomMCP{mcpD0cand.px(), mcpD0cand.py(), mcpD0cand.pz()}; + const float zParallelMCP = RecoDecay::dotProd(candMomMCP, jetMomMCP) / RecoDecay::mag2(jetMomMCP); + + auto mcpJetParticles = mcpjet.template tracks_as(); + auto mcpJetCandidates = mcpjet.template candidates_as(); + const float angularityMCP = computeLambda(mcpjet, mcpJetParticles, mcpJetCandidates, 1.f, 1.f); // λ_1^1 + const float girthMCP = computeLambda(mcpjet, mcpJetParticles, mcpJetCandidates, 2.f, 1.f); // λ_2^1 + + registry.fill(HIST("hSparse_d0_mcp_eff"), + mcpD0cand.pt(), + mcpjet.pt(), + zParallelMCP, + originMcp, + isCleanMatchedMCP, + angularityMCP, + girthMCP); + + const bool mcpIsGeoMatched = mcpjet.has_matchedJetGeo(); + if (originMcp == kOriginMcPrompt) { + registry.fill(HIST("h_eff_run2_den_pr"), mcpD0cand.pt()); + registry.fill(HIST("h_kineff_gen_den_pr"), mcpjet.pt(), mcpD0cand.pt()); + if (mcpIsGeoMatched) { + registry.fill(HIST("h_kineff_gen_num_pr"), mcpjet.pt(), mcpD0cand.pt()); + } + } else if (originMcp == kOriginMcNonPrompt) { + registry.fill(HIST("h_eff_run2_den_np"), mcpD0cand.pt()); + registry.fill(HIST("h_kineff_gen_den_np"), mcpjet.pt(), mcpD0cand.pt()); + if (mcpIsGeoMatched) { + registry.fill(HIST("h_kineff_gen_num_np"), mcpjet.pt(), mcpD0cand.pt()); + } + } + } // end MCP jet loop + } // end MC collision loop + } -PROCESS_SWITCH(JetHFAngularityTask, processMCDChargedSubstructureMatched, - "MC: unified efficiency + jet matching + response matrix + reflection (needs jet-matching workflow)", false); + PROCESS_SWITCH(JetHFAngularityTask, processMCDChargedSubstructureMatched, + "MC: unified efficiency + jet matching + response matrix + reflection (needs jet-matching workflow)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)