diff --git a/PWGJE/Tasks/jetHFAngularity.cxx b/PWGJE/Tasks/jetHFAngularity.cxx index 4850f1819fc..974786bc343 100644 --- a/PWGJE/Tasks/jetHFAngularity.cxx +++ b/PWGJE/Tasks/jetHFAngularity.cxx @@ -8,11 +8,14 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -// Measure heavy flavour angularity(D0 & Lambda_c) + +/// \file jetHFAngularity.cxx +/// \brief Measure heavy flavour angularity(D0 & Lambda_c) /// \author Rajdeep Nandi /// \author Preeti Dhankher +#include "PWGHF/Core/DecayChannels.h" #include "PWGJE/Core/JetCandidateUtilities.h" #include "PWGJE/Core/JetDerivedDataUtilities.h" #include "PWGJE/Core/JetUtilities.h" @@ -35,9 +38,15 @@ #include #include +#include + +#include + #include #include #include +#include +#include #include #include @@ -47,38 +56,93 @@ using namespace o2::framework::expressions; namespace { -constexpr int kOriginMcPrompt = 1; // MC origin flag: prompt -constexpr int kOriginMcNonPrompt = 2; // MC origin flag: non-prompt -constexpr int8_t kCandSelFlagD0 = 0; +constexpr int OriginMcPrompt = 1; // RecoDecay::OriginType::Prompt +constexpr int OriginMcNonPrompt = 2; // RecoDecay::OriginType::NonPrompt +constexpr int NOrigins = 2; // prompt, non-prompt (index 0, 1 of the per-origin objects) + +constexpr int CandSelBitD0 = 0; +constexpr int CandSelBitD0bar = 1; + +constexpr int ChanD0ToPiK = static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiK); +constexpr int ChanD0ToPiKPi0 = static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToPiKPi0); +constexpr int ChanD0ToKK = static_cast(o2::hf_decay::hf_cand_2prong::DecayChannelMain::D0ToKK); + +/// correlated-background channels: 2 = K pi pi0, 3 = pi pi, 4 = pi pi pi0, 5 = K K +inline bool isCorrBkgChannel(int absFlag) +{ + return absFlag >= ChanD0ToPiKPi0 && absFlag <= ChanD0ToKK; +} + +struct McCandClass { + bool isTrueSignal = false; // D0 -> K pi, selected with the correct K/pi mass hypothesis + bool isReflection = false; // D0 -> K pi, selected with the swapped mass hypothesis + bool isCorrBkg = false; // other D0 decay channels, either hypothesis + int channel = 0; // |flagMcMatchRec| +}; + +template +McCandClass classifyMcCandidate(CAND const& cand) +{ + McCandClass c; + const int flag = cand.flagMcMatchRec(); + c.channel = std::abs(flag); + if (c.channel == ChanD0ToPiK) { + int hypothesis = 0; // +1: row selected as D0, -1: row selected as D0bar + const int sel = cand.candidateSelFlag(); + if ((sel & BIT(CandSelBitD0)) != 0) { + hypothesis = 1; + } else if ((sel & BIT(CandSelBitD0bar)) != 0) { + hypothesis = -1; + } + // reflection: true species differs from the hypothesis used for this row + c.isReflection = (hypothesis != 0) && ((flag > 0) != (hypothesis > 0)); + c.isTrueSignal = !c.isReflection; + } else if (isCorrBkgChannel(c.channel)) { + c.isCorrBkg = true; + } + return c; +} + +/// Returns 1 (input = pseudo-data sample) for a fraction 'fraction` of MC collisions, else 0 ("correction" sample). +inline int closureSample(int64_t mcCollisionIndex, float fraction) +{ + if (fraction <= 0.f) { + return 0; + } + uint64_t h = static_cast(mcCollisionIndex) * 0x9E3779B97F4A7C15ULL; + h ^= (h >> 29); + h *= 0xBF58476D1CE4E5B9ULL; + h ^= (h >> 32); + return (static_cast(h % 100000ULL) < fraction * 100000.f) ? 1 : 0; +} } // namespace namespace o2::aod { - -// Jet-side columns (shared by all three tables) +// Jet-side columns (shared by all tables) DECLARE_SOA_COLUMN(JetHfDist, jetHfDist, float); DECLARE_SOA_COLUMN(JetPt, jetPt, float); DECLARE_SOA_COLUMN(JetEta, jetEta, float); DECLARE_SOA_COLUMN(JetPhi, jetPhi, float); DECLARE_SOA_COLUMN(JetNConst, jetNConst, int); -DECLARE_SOA_COLUMN(JetAng, jetAng, float); -DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); +DECLARE_SOA_COLUMN(JetLambda, jetLambda, float); DECLARE_SOA_COLUMN(JetMass, jetMass, float); -// D0-candidate columns (shared by all three tables) +// D0-candidate columns DECLARE_SOA_COLUMN(HfZParallel, hfZParallel, float); DECLARE_SOA_COLUMN(HfPt, hfPt, float); DECLARE_SOA_COLUMN(HfEta, hfEta, float); DECLARE_SOA_COLUMN(HfPhi, hfPhi, float); DECLARE_SOA_COLUMN(HfMass, hfMass, float); DECLARE_SOA_COLUMN(HfY, hfY, float); +DECLARE_SOA_COLUMN(HfSelFlag, hfSelFlag, int8_t); -// ML scores (one entry per BDT class) — DATA & MCD only +// ML scores (one entry per BDT class), -1 if the model has fewer classes DECLARE_SOA_COLUMN(HfMlScore0, hfMlScore0, float); DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); -// MC-truth columns — MCD & MCP only +// MC-truth columns DECLARE_SOA_COLUMN(HfFlagMcMatch, hfFlagMcMatch, int8_t); DECLARE_SOA_COLUMN(HfOriginMc, hfOriginMc, int8_t); @@ -90,93 +154,38 @@ DECLARE_SOA_COLUMN(JetMatchedEta, jetMatchedEta, float); DECLARE_SOA_COLUMN(JetMatchedPhi, jetMatchedPhi, float); DECLARE_SOA_COLUMN(JetMatchedDR, jetMatchedDR, float); DECLARE_SOA_COLUMN(JetMatchedD0Pt, jetMatchedD0Pt, float); +DECLARE_SOA_COLUMN(JetMatchedLambda, jetMatchedLambda, float); +DECLARE_SOA_COLUMN(ClosureSample, closureSample, int8_t); DECLARE_SOA_TABLE(D0JetObjTable, "AOD", "D0JETOBJTABLE", - JetHfDist, - JetPt, - JetEta, - JetPhi, - JetNConst, - JetAng, - JetGirth, - JetMass, - HfZParallel, - HfPt, - HfEta, - HfPhi, - HfMass, - HfY, - HfMlScore0, - HfMlScore1, - HfMlScore2); + JetHfDist, JetPt, JetEta, JetPhi, JetNConst, + JetLambda, JetMass, + HfZParallel, HfPt, HfEta, HfPhi, HfMass, HfY, HfSelFlag, + HfMlScore0, HfMlScore1, HfMlScore2); DECLARE_SOA_TABLE(D0JetMCDObjTable, "AOD", "D0JETMCDOBJ", - JetHfDist, - JetPt, - JetEta, - JetPhi, - JetNConst, - JetAng, - JetGirth, - JetMass, - HfZParallel, - HfPt, - HfEta, - HfPhi, - HfMass, - HfY, - HfMlScore0, - HfMlScore1, - HfMlScore2, - HfFlagMcMatch, - HfOriginMc); + JetHfDist, JetPt, JetEta, JetPhi, JetNConst, + JetLambda, JetMass, + HfZParallel, HfPt, HfEta, HfPhi, HfMass, HfY, HfSelFlag, + HfMlScore0, HfMlScore1, HfMlScore2, + HfFlagMcMatch, HfOriginMc); DECLARE_SOA_TABLE(D0JetMCPObjTable, "AOD", "D0JETMCPOBJ", - JetHfDist, - JetPt, - JetEta, - JetPhi, - JetNConst, - JetAng, - JetGirth, - JetMass, - HfZParallel, - HfPt, - HfEta, - HfPhi, - HfY, - HfFlagMcMatch, - HfOriginMc); + JetHfDist, JetPt, JetEta, JetPhi, JetNConst, + JetLambda, JetMass, + HfZParallel, HfPt, HfEta, HfPhi, HfY, + HfFlagMcMatch, HfOriginMc); DECLARE_SOA_TABLE(D0JetMCDObjMatchedTable, "AOD", "D0JMCDOBJMATCH", - JetHfDist, - JetPt, - JetEta, - JetPhi, - JetNConst, - JetAng, - JetGirth, - JetMass, - HfZParallel, - HfPt, - HfEta, - HfPhi, - HfMass, - HfY, - HfMlScore0, - HfMlScore1, - HfMlScore2, - HfFlagMcMatch, - HfOriginMc, - JetMatchGeoStatus, - JetMatchCandStatus, - JetMatchClean, - JetMatchedPt, - JetMatchedEta, - JetMatchedPhi, - JetMatchedDR, - JetMatchedD0Pt); - + JetHfDist, JetPt, JetEta, JetPhi, JetNConst, + JetLambda, JetMass, + HfZParallel, HfPt, HfEta, HfPhi, HfMass, HfY, HfSelFlag, + HfMlScore0, HfMlScore1, HfMlScore2, + HfFlagMcMatch, HfOriginMc, + JetMatchGeoStatus, JetMatchCandStatus, JetMatchClean, + JetMatchedPt, JetMatchedEta, JetMatchedPhi, JetMatchedDR, JetMatchedD0Pt, + JetMatchedLambda, + ClosureSample); } // namespace o2::aod consteval float getValFromBin(int bin) @@ -184,19 +193,21 @@ consteval float getValFromBin(int bin) return static_cast(bin) - 0.5f; } -/// Collision-counter bins +/// Collision-counter bins (data) enum BinCollCntr { AllCollisions = 1, - Sel8ZCut = 2 + SelectedCollisions = 2, + CollisionsWithD0Jet = 3, + RejectedCollisions = 4 }; /// Jet-counter bins enum BinJetCntr { - ChargedJets = 1, - D0TaggedJets = 2 + D0JetsInFiducialRange = 1, + D0JetsWithSelectedCandidate = 2 }; -/// MC-efficiency collision-counter bins (jet-matching based efficiency) +/// MC collision-counter bins enum BinMCColCntr { AllMCCollisions = 1, SelectedMCCollisions = 2, @@ -204,7 +215,7 @@ enum BinMCColCntr { SelectedAssociatedRecoCollisions = 4 }; -/// MC-efficiency jet-counter bins (jet-matching based efficiency) +/// MC jet-counter bins enum BinMCJetCntr { DetectorLevelJetInMCCollision = 1, ParticleLevelJetInMCCollision = 2, @@ -214,535 +225,457 @@ enum BinMCJetCntr { struct JetHFAngularityTask { - // DATA - using D0CandidatesData = aod::CandidatesD0Data; - - using D0DataJets = soa::Join; - - // MC-DETECTOR LEVEL(MCD) + using D0DataJets = soa::Join; using D0CandidatesMCD = aod::CandidatesD0MCD; - - using D0MCDJets = soa::Join; - + using D0MCDJets = soa::Join; using D0MCDJetsMatched = soa::Join; - // MC PARTICLE LEVEL (MCP) - using D0CandidatesMCP = aod::CandidatesD0MCP; - - using D0MCPJets = soa::Join; - + using D0MCPJets = soa::Join; using D0MCPJetsMatched = soa::Join; - // Configurables + // ---------------------------------------------------------------- configurables + // Event selection + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range (cm), same as jet finder"}; + Configurable eventSelections{"eventSelections", "sel8", "Event selection string, same as jet finder"}; + Configurable skipMBGapEvents{"skipMBGapEvents", false, "Skip MB-gap events (same as jet finder skipMBGapEvents)"}; + Configurable applyRCTSelections{"applyRCTSelections", true, "Apply RCT selection (same as jet finder applyRCTSelections)"}; + Configurable trackSelections{"trackSelections", "globalTracks", "Track selection string (track QA only)"}; - Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range (cm)"}; - Configurable jetPtMin{"jetPtMin", 5.0f, "Minimum jet pT (GeV/c)"}; + // Jets + Configurable jetPtMin{"jetPtMin", 5.0f, "Minimum jet pT (GeV/c). Use 0 in MC so the response covers migrations from below the analysis range"}; Configurable jetR{"jetR", 0.4f, "Jet resolution parameter R"}; - Configurable eventSelections{"eventSelections", "sel8", - "Event selection string"}; - Configurable trackSelections{"trackSelections", "globalTracks", - "Track selection string"}; - Configurable rejectReflections{"rejectReflections", true, - "Exclude reflections from response matrices and efficiency numerators"}; - // Shared axes - ConfigurableAxis binsMassD0{"binsMassD0", {500, 1.6f, 2.1f}, "m_{D^{0}} (GeV/#it{c}^{2})"}; - ConfigurableAxis binsPtD0{"binsPtD0", {200, 0.f, 100.f}, "#it{p}_{T,D^{0}} (GeV/#it{c})"}; - ConfigurableAxis binsZParallel{"binsZParallel", {200, 0.f, 2.f}, "z_{||}"}; - ConfigurableAxis binsDeltaR{"binsDeltaR", {200, 0.f, 1.f}, "#DeltaR"}; - ConfigurableAxis binsLambda11{"binsLambda11", {50, 0.f, 1.f}, "#lambda_{1}^{1}"}; - ConfigurableAxis binsLambda12{"binsLambda12", {50, 0.f, 1.f}, "#lambda_{2}^{1}"}; - - // Jet pT: data sparse vs. MC / response - ConfigurableAxis binsPtJetData{"binsPtJetData", {200, 0.f, 100.f}, "#it{p}_{T,jet} (GeV/#it{c})"}; - ConfigurableAxis binsPtJetMC{"binsPtJetMC", {40, 0.f, 200.f}, "#it{p}_{T,jet} (GeV/#it{c})"}; - - // Response-matrix axes - ConfigurableAxis binsPtD0Resp{"binsPtD0Resp", {50, 0.f, 50.f}, "#it{p}_{T,D^{0}} (GeV/#it{c})"}; - ConfigurableAxis binsLambda11Resp{"binsLambda11Resp", {50, 0.f, 1.f}, "#lambda_{1}^{1}"}; - ConfigurableAxis binsLambda12Resp{"binsLambda12Resp", {50, 0.f, 1.f}, "#lambda_{2}^{1}"}; + // Observables + Configurable alpha{"alpha", 1.f, "Angularity exponent alpha of DeltaR/R (one value per run; e.g. 1, 1.5, 2, 3)"}; + Configurable kappa{"kappa", 1.f, "Angularity exponent kappa of the momentum fraction z (one value per run; 1 = IRC safe)"}; + Configurable lambdaMax{"lambdaMax", 1.f, "Upper edge of the lambda axis (1 for kappa = 1; adjust e.g. 0.8/0.6/0.5 for alpha = 1.5/2/3)"}; + Configurable nBinsLambda{"nBinsLambda", 100, "Number of lambda bins in the data / pseudo-data sparses"}; + Configurable nBinsLambdaResp{"nBinsLambdaResp", 50, "Number of lambda bins in response / efficiency objects, mass-template and legacy sparses"}; + + // Optional BDT cut on top of the HF selector (for the BDT systematic). Off by default. + Configurable applyMlCut{"applyMlCut", false, "Apply an additional pT-dependent cut on ML score 0 (background)"}; + Configurable> mlCutPtEdges{"mlCutPtEdges", std::vector{1., 2., 3., 4., 5., 6., 7., 8., 10., 12., 16., 24., 36., 50.}, "pT_D0 bin edges of the ML cut"}; + Configurable> mlCutBkgMax{"mlCutBkgMax", std::vector{0.02, 0.02, 0.02, 0.05, 0.06, 0.08, 0.08, 0.1, 0.1, 0.2, 0.25, 0.3, 0.4}, "Max ML background score per pT_D0 bin (n_edges - 1 values)"}; + + // MC + Configurable rejectReflections{"rejectReflections", true, "Exclude reflections from response matrices and efficiency numerators"}; + Configurable useMcWeights{"useMcWeights", false, "Weight MC entries with mcCollision.weight() (pT-hard weighted productions)"}; + Configurable closureInputFraction{"closureInputFraction", 0.2f, "Fraction of MC collisions flagged as closure 'input' (sample axis = 1)"}; + Configurable matchingMode{"matchingMode", 0, "MCD-MCP jet matching for response/efficiency: 0 = clean (geo AND HF point to the same MCP jet, analysis note), 1 = HF (candidate) matching only"}; + + Configurable fillLegacyOutputs{"fillLegacyOutputs", true, "Also fill the histograms of the previous task version"}; + Configurable fillTables{"fillTables", true, "Fill the per-candidate output tables"}; + + // Axes + ConfigurableAxis binsMassD0{"binsMassD0", {200, 1.6f, 2.2f}, "m_{K#pi} (GeV/#it{c}^{2})"}; + ConfigurableAxis binsPtD0{"binsPtD0", {100, 0.f, 50.f}, "#it{p}_{T,D^{0}} (GeV/#it{c})"}; + ConfigurableAxis binsZParallel{"binsZParallel", {100, 0.f, 1.f}, "z_{||}"}; + ConfigurableAxis binsDeltaR{"binsDeltaR", {50, 0.f, 0.5f}, "#DeltaR"}; + ConfigurableAxis binsPtJetData{"binsPtJetData", {60, 0.f, 60.f}, "#it{p}_{T,jet} (GeV/#it{c})"}; + ConfigurableAxis binsPtJetMC{"binsPtJetMC", {60, 0.f, 60.f}, "#it{p}_{T,jet} (GeV/#it{c})"}; + ConfigurableAxis binsPtD0Resp{"binsPtD0Resp", {VARIABLE_WIDTH, 1., 2., 3., 4., 5., 6., 7., 8., 10., 12., 16., 24., 36., 50.}, "#it{p}_{T,D^{0}} (GeV/#it{c})"}; + ConfigurableAxis binsPtJetResp{"binsPtJetResp", {VARIABLE_WIDTH, 0., 3., 5., 7., 10., 15., 20., 30., 50., 80.}, "#it{p}_{T,jet} (GeV/#it{c})"}; Produces objJetTable; Produces objJetMCDTable; Produces objJetMCPTable; - Produces objJetMCDMatchedTable; std::vector eventSelectionBits; int trackSelection = -1; + float massD0Pdg = -1.f; + int jetRBin = 40; + + std::shared_ptr hMassPtLambda; // data + std::shared_ptr hMassPtLambdaMC; // MC pseudo-data (closure) + std::array, NOrigins> hResponse; + std::array, NOrigins> hGen; + std::array, NOrigins> hGenMatched; + std::array, NOrigins> hDetTrue; + std::array, NOrigins> hDetMatched; + std::shared_ptr hGenD0Jet; // MCP particle level - float massD0MCP = -1.f; - - // Slices for the jet-matching based MC efficiency calculation - - // Reconstructed collisions associated to a given JetMcCollision PresliceUnsorted collisionsPerMCCollisionPreslice = aod::jmccollisionlb::mcCollisionId; - - // D0-tagged (matched) MCD jets per reconstructed collision Preslice d0MCDJetsPerCollisionPreslice = aod::jet::collisionId; - - // D0-tagged (matched) MCP jets per MC collision Preslice d0MCPJetsPerMCCollisionPreslice = aod::jet::mcCollisionId; - // Filters - Filter jetCutsPt = aod::jet::pt > jetPtMin; Filter jetCutsR = aod::jet::r == nround(jetR.node() * 100.0f); - Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - - // Histograms - HistogramRegistry registry{"registry", { + HistogramRegistry registry{"registry"}; - // DATA + // ================================================================ helpers - // ----- Collision QA ----- - {"h_collisions", "Event status;status;entries", {HistType::kTH1F, {{4, 0., 4.}}}}, + struct JetObservables { + float lambda = -1.f; + float mass = 0.f; + int nConst = 0; + }; - // ----- Track QA ----- - {"h_track_pt", ";#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_track_eta", ";#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_track_phi", ";#varphi_{track};entries", {HistType::kTH1F, {{80, -1., 7.}}}}, + struct D0InJet { + float zParallel = -1.f; + float deltaR = -1.f; + }; - // ----- Jet QA ----- - {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{4, 0., 4.}}}}, - - {"h_jet_pt", ";#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta", ";#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_jet_phi", ";#phi_{jet};entries", {HistType::kTH1F, {{80, -1., 7.}}}}, - - // ----- D0 candidate properties ----- - {"h_d0_mass", ";m_{K#pi} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{300, 1.7, 2.0}}}}, - {"h_d0_pt", ";#it{p}_{T,D^{0}} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 100.}}}}, - {"h_d0_eta", ";#eta_{D^{0}};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_d0_phi", ";#phi_{D^{0}};entries", {HistType::kTH1F, {{100, -1., 7.}}}}, - {"h_d0_y", ";y_{D^{0}};entries", {HistType::kTH1F, {{100, -2., 2.}}}}, - - // ----- D0-in-jet observables ----- - {"h_d0_jet_projection", ";z_{||}^{D^{0},jet};entries", {HistType::kTH1F, {{200, 0., 2.}}}}, - - {"h_d0_jet_distance", ";#DeltaR_{D^{0},jet};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - - // ----- Jet substructure (D0-tagged jets only) ----- - {"h_d0_jet_lambda11", ";#lambda_{1}^{1} (angularity);entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - - {"h_d0_jet_lambda12", ";#lambda_{2}^{1} (girth);entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - - {"h_d0_jet_mass", ";m_{jet} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - - // ----- Jet constituent multiplicity & ML scores - {"h_jet_nconst", ";N_{const};entries", {HistType::kTH1F, {{100, -0.5, 99.5}}}}, - {"h_d0_mlscore0", ";ML score 0 (bkg);entries", {HistType::kTH1F, {{100, 0., 1.}}}}, - {"h_d0_mlscore1", ";ML score 1 (prompt);entries", {HistType::kTH1F, {{100, 0., 1.}}}}, - {"h_d0_mlscore2", ";ML score 2 (non-prompt);entries", {HistType::kTH1F, {{100, 0., 1.}}}}, - - // hSparse_d0 is booked in init() (configurable axes) - - // MC DETECTOR LEVEL (MCD) - - {"h_collisions_mcd", "MCD event status;status;entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - - {"h_jet_counter_mcd", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_jet_pt_mcd", ";#it{p}_{T,jet}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta_mcd", ";#eta_{jet}^{det};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_jet_phi_mcd", ";#phi_{jet}^{det};entries", {HistType::kTH1F, {{80, -1., 7.}}}}, - - {"h_d0_mass_mcd", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{300, 1.7, 2.0}}}}, - {"h_d0_pt_mcd", ";#it{p}_{T,D^{0}}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 100.}}}}, - {"h_d0_eta_mcd", ";#eta_{D^{0}}^{det};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_d0_phi_mcd", ";#phi_{D^{0}}^{det};entries", {HistType::kTH1F, {{100, -1., 7.}}}}, - {"h_d0_y_mcd", ";y_{D^{0}}^{det};entries", {HistType::kTH1F, {{100, -2., 2.}}}}, - - {"h_d0_jet_projection_mcd", ";z_{||}^{D^{0},jet,det};entries", {HistType::kTH1F, {{200, 0., 2.}}}}, - {"h_d0_jet_distance_mcd", ";#DeltaR_{D^{0},jet}^{det};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - - {"h_d0_jet_lambda11_mcd", ";#lambda_{1}^{1,det};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - {"h_d0_jet_lambda12_mcd", ";#lambda_{2}^{1,det};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - {"h_d0_jet_mass_mcd", ";m_{jet}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - - {"h_d0_origin_mcd", ";origin (0=none,1=prompt,2=non-prompt);entries", {HistType::kTH1F, {{3, 0., 3.}}}}, - - // hSparse_d0_mcd, hSparse_d0_mcd_calib, hSparse_d0_mcd_reflection are booked in init() - - {"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}}}}, - - // MC PARTICLE LEVEL (MCP) - - {"h_collisions_mcp", "MCP event status;status;entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - - {"h_jet_counter_mcp", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_jet_pt_mcp", ";#it{p}_{T,jet}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta_mcp", ";#eta_{jet}^{part};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_jet_phi_mcp", ";#phi_{jet}^{part};entries", {HistType::kTH1F, {{80, -1., 7.}}}}, - - {"h_d0_pt_mcp", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 100.}}}}, - {"h_d0_eta_mcp", ";#eta_{D^{0}}^{part};entries", {HistType::kTH1F, {{100, -1., 1.}}}}, - {"h_d0_phi_mcp", ";#phi_{D^{0}}^{part};entries", {HistType::kTH1F, {{100, -1., 7.}}}}, - {"h_d0_y_mcp", ";y_{D^{0}}^{part};entries", {HistType::kTH1F, {{100, -2., 2.}}}}, - - {"h_d0_jet_projection_mcp", ";z_{||}^{D^{0},jet,part};entries", {HistType::kTH1F, {{200, 0., 2.}}}}, - {"h_d0_jet_distance_mcp", ";#DeltaR_{D^{0},jet}^{part};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - - {"h_d0_jet_lambda11_mcp", ";#lambda_{1}^{1,part};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - {"h_d0_jet_lambda12_mcp", ";#lambda_{2}^{1,part};entries", {HistType::kTH1F, {{200, 0., 1.}}}}, - {"h_d0_jet_mass_mcp", ";m_{jet}^{part} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - - {"h_d0_origin_mcp", ";origin (0=none,1=prompt,2=non-prompt);entries", {HistType::kTH1F, {{3, 0., 3.}}}}, - - // JET-TO-JET MATCHING (MCD <-> MCP) - - {"h_jet_matching_geo_status_mcd", ";status (0=unmatched,1=matched);entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_jet_matching_cand_status_mcd", ";status (0=unmatched,1=matched);entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_jet_matching_clean_mcd", ";status (0=not clean,1=clean);entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - - {"h_jet_matching_geocand_disagree_mcd", ";geo & cand agree? (0=no,1=yes);entries", {HistType::kTH1F, {{2, 0., 2.}}}}, - - {"h_jet_matching_dr_mcd", ";#DeltaR(jet^{det},jet^{part});entries", {HistType::kTH1F, {{100, 0., 0.5}}}}, - - {"h_jet_matching_ngeo_mcd", ";number of geo-matched candidates;entries", {HistType::kTH1F, {{6, 0., 6.}}}}, - - {"h_jet_matching_ncand_mcd", ";number of cand-matched candidates;entries", {HistType::kTH1F, {{6, 0., 6.}}}}, + template + static float computeLambda(JET const& jet, TRACKS const& tracks, CANDIDATES const& candidates, float expAlpha, float expKappa) + { + if (jet.pt() <= 0.f) { + return -1.f; + } + double sum = 0.; + for (auto const& trk : tracks) { + sum += std::pow(trk.pt(), expKappa) * std::pow(jetutilities::deltaR(jet, trk), expAlpha); + } + for (auto const& cand : candidates) { + sum += std::pow(cand.pt(), expKappa) * std::pow(jetutilities::deltaR(jet, cand), expAlpha); + } + const double jetRadius = jet.r() / 100.; // stored as R x 100 + const double denom = std::pow(jet.pt(), expKappa) * std::pow(jetRadius, expAlpha); + return denom > 0. ? static_cast(sum / denom) : -1.f; + } - {"h_jet_matching_dr_mcd_allcand", ";#DeltaR(jet^{det},jet^{part}) (all geo candidates);entries", {HistType::kTH1F, {{100, 0., 0.5}}}}, + template + float computeJetMass(TRACKS const& tracks, CANDIDATES const& candidates) const + { + std::array momTotal{0., 0., 0.}; + double energyTot = 0.; + for (auto const& trk : tracks) { + momTotal[0] += trk.px(); + momTotal[1] += trk.py(); + momTotal[2] += trk.pz(); + energyTot += RecoDecay::p(trk.px(), trk.py(), trk.pz()); + } + for (auto const& cand : candidates) { + momTotal[0] += cand.px(); + momTotal[1] += cand.py(); + momTotal[2] += cand.pz(); + energyTot += RecoDecay::e(cand.px(), cand.py(), cand.pz(), static_cast(massD0Pdg)); + } + const double mass2 = RecoDecay::m2(momTotal, energyTot); + return (mass2 > 0.) ? static_cast(std::sqrt(mass2)) : 0.f; + } - {"h_jet_pt_response_matrix_allcand", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,jet}^{part} (GeV/#it{c}) (all geo candidates)", {HistType::kTH2F, {{200, 0., 200.}, {200, 0., 200.}}}}, + template + JetObservables jetObservables(JET const& jet, TRACKS const& tracks, CANDIDATES const& candidates) const + { + JetObservables obs; + obs.lambda = computeLambda(jet, tracks, candidates, alpha.value, kappa.value); + obs.mass = computeJetMass(tracks, candidates); + obs.nConst = static_cast(tracks.size()) + static_cast(candidates.size()); + return obs; + } - // Detector-level vs matched particle-level jet pT - // Response matrices (h_jet_pt_response_matrix[_pr/_np], h_response_*) are booked in init() + template + static D0InJet d0JetKinematics(JET const& jet, CAND const& cand) + { + const std::array jetMom{jet.px(), jet.py(), jet.pz()}; + const std::array d0Mom{cand.px(), cand.py(), cand.pz()}; + D0InJet k; + k.zParallel = static_cast(RecoDecay::dotProd(d0Mom, jetMom) / RecoDecay::mag2(jetMom)); + k.deltaR = jetutilities::deltaR(jet, cand); + return k; + } - {"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.}}}}, - {"h_kineff_gen_den_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.}}}}, + template + static float mlScore(CAND const& cand, size_t i) + { + const auto scores = cand.mlScores(); + return (scores.size() > i) ? scores[i] : -1.f; + } - {"h_kineff_det_num_pr", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, - {"h_kineff_det_den_pr", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, - {"h_kineff_det_num_np", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, - {"h_kineff_det_den_np", ";#it{p}_{T,jet}^{det} (GeV/#it{c});#it{p}_{T,D^{0}}^{det} (GeV/#it{c})", {HistType::kTH2F, {{40, 0., 200.}, {50, 0., 50.}}}}, + /// optional pT-dependent cut on the background score (BDT systematic) + template + bool passMlCut(CAND const& cand) const + { + if (!applyMlCut.value) { + return true; + } + const auto& edges = mlCutPtEdges.value; + const auto& cuts = mlCutBkgMax.value; + const float pt = cand.pt(); + for (size_t i = 0; i + 1 < edges.size() && i < cuts.size(); ++i) { + if (pt >= edges[i] && pt < edges[i + 1]) { + const float bkg = mlScore(cand, 0); + return bkg >= 0.f && bkg < cuts[i]; + } + } + return false; + } - {"h_eff_run2_num_pr", ";#it{p}_{T,D^{0}}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_eff_run2_num_np", ";#it{p}_{T,D^{0}}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_eff_run2_den_pr", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_eff_run2_den_np", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, + template + bool selectRecoCollision(COLL const& collision) const + { + if (std::abs(collision.posZ()) >= vertexZCut.value) { + return false; + } + return jetderiveddatautilities::selectCollision(collision, eventSelectionBits, skipMBGapEvents.value, applyRCTSelections.value); + } - // MC EFFICIENCY (jet-to-jet matching based) + template + bool selectMcCollision(MCCOLL const& mcCollision) const + { + if (std::abs(mcCollision.posZ()) >= vertexZCut.value) { + return false; + } + if (skipMBGapEvents.value && mcCollision.getSubGeneratorId() == jetderiveddatautilities::JCollisionSubGeneratorId::mbGap) { + return false; + } + return true; + } - {"MC_CollisionCounter", "N_{collisions};", {HistType::kTH1F, {{4, 0., 4.}}}}, - {"MC_JetCounter", "N_{jet};", {HistType::kTH1F, {{4, 0., 4.}}}}, + template + float mcWeight(MCCOLL const& mcCollision) const + { + return useMcWeights.value ? mcCollision.weight() : 1.f; + } - // hSparse_d0_mcd_eff and hSparse_d0_mcp_eff are booked in init() + static int originIndex(int origin) + { + if (origin == OriginMcPrompt) { + return 0; + } + if (origin == OriginMcNonPrompt) { + return 1; + } + return -1; + } - }}; + template + void fillMcQa(CAND const& cand) + { + const int flag = cand.flagMcMatchRec(); + const int sel = cand.candidateSelFlag(); + registry.fill(HIST("h_d0_flag_mcd"), static_cast(flag)); + registry.fill(HIST("h_d0_selflag"), static_cast(sel)); + // mass of true D0 -> K pi rows per (sign of flag, selection bit): + // 1: flag>0 & D0 hyp (signal) 2: flag>0 & D0bar hyp (reflection) + // 3: flag<0 & D0 hyp (reflection) 4: flag<0 & D0bar hyp (signal) + // 5: both bits 6: no bit + if (std::abs(flag) == ChanD0ToPiK) { + const bool bit0 = (sel & BIT(CandSelBitD0)) != 0; + const bool bit1 = (sel & BIT(CandSelBitD0bar)) != 0; + float category = 6.f; + if (bit0 && bit1) { + category = 5.f; + } else if (bit0) { + category = (flag > 0) ? 1.f : 3.f; + } else if (bit1) { + category = (flag > 0) ? 2.f : 4.f; + } + registry.fill(HIST("h_d0_mass_hypothesis_check"), cand.m(), category); + } + } - // init() + // ================================================================ init void init(InitContext const&) { eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(eventSelections.value); trackSelection = jetderiveddatautilities::initialiseTrackSelection(trackSelections.value); + massD0Pdg = jetcandidateutilities::getTablePDGMass(); + jetRBin = static_cast(std::lround(static_cast(jetR) * 100.0f)); + if (alpha.value <= 0.f || kappa.value <= 0.f || lambdaMax.value <= 0.f) { + LOGF(fatal, "alpha, kappa and lambdaMax must be > 0, got %g, %g, %g", static_cast(alpha), static_cast(kappa), static_cast(lambdaMax)); + } + LOGF(info, "angularity lambda_alpha^kappa with alpha = %g, kappa = %g, lambda axis [0, %g]", static_cast(alpha), static_cast(kappa), static_cast(lambdaMax)); + if (matchingMode != 0 && matchingMode != 1) { + LOGF(fatal, "matchingMode must be 0 (clean: geo AND HF) or 1 (HF only), got %d", static_cast(matchingMode)); + } + if (applyMlCut && mlCutBkgMax.value.size() + 1 != mlCutPtEdges.value.size()) { + LOGF(fatal, "mlCutBkgMax needs exactly (mlCutPtEdges - 1) entries"); + } - massD0MCP = jetcandidateutilities::getTablePDGMass(); - - // Histograms with configurable axes - // ---- Configurable axes ---- - const AxisSpec axMass{binsMassD0, "m_{D^{0}} (GeV/#it{c}^{2})"}; + const AxisSpec axMass{binsMassD0, "m_{K#pi} (GeV/#it{c}^{2})"}; const AxisSpec axPtD0{binsPtD0, "#it{p}_{T,D^{0}} (GeV/#it{c})"}; const AxisSpec axZ{binsZParallel, "z_{||}"}; const AxisSpec axDR{binsDeltaR, "#DeltaR"}; - const AxisSpec axL11{binsLambda11, "#lambda_{1}^{1}"}; - const AxisSpec axL12{binsLambda12, "#lambda_{2}^{1}"}; + const std::string alphaStr = fmt::format("{:g}", static_cast(alpha)); + const std::string kappaStr = fmt::format("{:g}", static_cast(kappa)); + const std::string lamLabel = fmt::format("#lambda_{{{}}}^{{{}}}", alphaStr, kappaStr); + const AxisSpec axLam{nBinsLambda.value, 0.f, lambdaMax.value, lamLabel}; // data / pseudo-data sparses + const AxisSpec axLamT{nBinsLambdaResp.value, 0.f, lambdaMax.value, lamLabel}; const AxisSpec axPtJetData{binsPtJetData, "#it{p}_{T,jet} (GeV/#it{c})"}; const AxisSpec axPtJetDet{binsPtJetMC, "#it{p}_{T,jet}^{det} (GeV/#it{c})"}; const AxisSpec axPtJetPart{binsPtJetMC, "#it{p}_{T,jet}^{part} (GeV/#it{c})"}; - const AxisSpec axPtD0Det{binsPtD0Resp, "#it{p}_{T,D^{0}}^{det} (GeV/#it{c})"}; const AxisSpec axPtD0Part{binsPtD0Resp, "#it{p}_{T,D^{0}}^{part} (GeV/#it{c})"}; - const AxisSpec axL11Det{binsLambda11Resp, "#lambda_{1}^{1,det}"}; - const AxisSpec axL11Part{binsLambda11Resp, "#lambda_{1}^{1,part}"}; - const AxisSpec axL12Det{binsLambda12Resp, "#lambda_{2}^{1,det}"}; - const AxisSpec axL12Part{binsLambda12Resp, "#lambda_{2}^{1,part}"}; - - // ---- Fixed categorical axes (not configurable) ---- + const AxisSpec axPtJetRespDet{binsPtJetResp, "#it{p}_{T,jet}^{det} (GeV/#it{c})"}; + const AxisSpec axPtJetRespPart{binsPtJetResp, "#it{p}_{T,jet}^{part} (GeV/#it{c})"}; + const AxisSpec axLamDet{nBinsLambdaResp.value, 0.f, lambdaMax.value, fmt::format("#lambda_{{{}}}^{{{},det}}", alphaStr, kappaStr)}; + const AxisSpec axLamPart{nBinsLambdaResp.value, 0.f, lambdaMax.value, fmt::format("#lambda_{{{}}}^{{{},part}}", alphaStr, kappaStr)}; const AxisSpec axOrigin{3, -0.5, 2.5, "Origin(D^{0})"}; const AxisSpec axMatch{2, -0.5, 1.5, "Matching status"}; const AxisSpec axRefl{2, -0.5, 1.5, "IsReflection"}; + const AxisSpec axSample{2, -0.5, 1.5, "closure sample (0 = correction, 1 = input)"}; + const AxisSpec axChannelCorr{4, 1.5, 5.5, "|flagMcMatch| (correlated bkg channel)"}; + const AxisSpec axChannelGen{5, 0.5, 5.5, "|flagMcMatchGen| (D^{0} decay channel)"}; + const AxisSpec axHypCat{6, 0.5, 6.5, "category"}; + + // ---------------- QA (all levels) + registry.add("h_collisions", "Event status;;entries", {HistType::kTH1F, {{4, 0., 4.}}}); + registry.add("h_track_pt", ";#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); + registry.add("h_track_eta", ";#eta_{track};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_track_phi", ";#varphi_{track};entries", {HistType::kTH1F, {{80, -1., 7.}}}); + registry.add("h_jet_counter", ";;counts", {HistType::kTH1F, {{2, 0., 2.}}}); + registry.add("h_jet_pt", ";#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); + registry.add("h_jet_eta", ";#eta_{jet};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_jet_phi", ";#phi_{jet};entries", {HistType::kTH1F, {{80, -1., 7.}}}); + registry.add("h_d0_mass", ";m_{K#pi} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axMass}}); + registry.add("h_d0_pt", ";#it{p}_{T,D^{0}} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 100.}}}); + registry.add("h_d0_eta", ";#eta_{D^{0}};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_d0_phi", ";#phi_{D^{0}};entries", {HistType::kTH1F, {{100, -1., 7.}}}); + registry.add("h_d0_y", ";y_{D^{0}};entries", {HistType::kTH1F, {{100, -2., 2.}}}); + registry.add("h_d0_jet_projection", ";z_{||}^{D^{0},jet};entries", {HistType::kTH1F, {{100, 0., 1.}}}); + registry.add("h_d0_jet_distance", ";#DeltaR_{D^{0},jet};entries", {HistType::kTH1F, {{100, 0., 0.5}}}); + registry.add("h_d0_jet_lambda", (";" + lamLabel + ";entries").c_str(), {HistType::kTH1F, {{200, 0., lambdaMax.value}}}); + registry.add("h_d0_jet_mass", ";m_{jet} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}); + registry.add("h_jet_nconst", ";N_{const};entries", {HistType::kTH1F, {{100, -0.5, 99.5}}}); + registry.add("h_d0_mlscore0", ";ML score 0 (bkg);entries", {HistType::kTH1F, {{100, 0., 1.}}}); + registry.add("h_d0_mlscore1", ";ML score 1 (prompt);entries", {HistType::kTH1F, {{100, 0., 1.}}}); + registry.add("h_d0_mlscore2", ";ML score 2 (non-prompt);entries", {HistType::kTH1F, {{100, 0., 1.}}}); - // ---- DATA ---- - registry.add("hSparse_d0", "hSparse_d0", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetData, axZ, axDR, axL11, axL12}); - - // ---- MCD ---- - registry.add("hSparse_d0_mcd", "hSparse_d0_mcd", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetDet, axZ, axDR, axL11, axL12}); - registry.add("hSparse_d0_mcd_calib", "hSparse_d0_mcd_calib", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axL11, axL12}); - registry.add("hSparse_d0_mcd_reflection", "hSparse_d0_mcd_reflection", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axL11, axL12}); - - // ---- Jet pT response (detector level vs. matched particle level) ---- - registry.add("h_jet_pt_response_matrix", "", HistType::kTH2F, {axPtJetDet, axPtJetPart}); - registry.add("h_jet_pt_response_matrix_pr", "prompt", HistType::kTH2F, {axPtJetDet, axPtJetPart}); - registry.add("h_jet_pt_response_matrix_np", "non-prompt", HistType::kTH2F, {axPtJetDet, axPtJetPart}); - - // ---- D0 pT response. Axes: pT_jet^det, pT_D0^det, pT_jet^part, pT_D0^part ---- - registry.add("h_response_d0pt_pr", "", HistType::kTHnSparseF, - {axPtJetDet, axPtD0Det, axPtJetPart, axPtD0Part}); - registry.add("h_response_d0pt_np", "", HistType::kTHnSparseF, - {axPtJetDet, axPtD0Det, axPtJetPart, axPtD0Part}); - - // ---- Angularity / girth response matrices ---- - registry.add("h_response_angularity_pr", "", HistType::kTHnSparseF, - {axPtJetDet, axL11Det, axPtJetPart, axL11Part}); - registry.add("h_response_angularity_np", "", HistType::kTHnSparseF, - {axPtJetDet, axL11Det, axPtJetPart, axL11Part}); - registry.add("h_response_girth_pr", "", HistType::kTHnSparseF, - {axPtJetDet, axL12Det, axPtJetPart, axL12Part}); - registry.add("h_response_girth_np", "", HistType::kTHnSparseF, - {axPtJetDet, axL12Det, axPtJetPart, axL12Part}); - - // ---- Particle-level efficiency, consistent with the response matrices ---- - registry.add("h_eff_num_d0pt_pr", "", HistType::kTH2F, {axPtJetPart, axPtD0Part}); - registry.add("h_eff_num_d0pt_np", "", HistType::kTH2F, {axPtJetPart, axPtD0Part}); - registry.add("h_eff_den_d0pt_pr", "", HistType::kTH2F, {axPtJetPart, axPtD0Part}); - registry.add("h_eff_den_d0pt_np", "", HistType::kTH2F, {axPtJetPart, axPtD0Part}); - - registry.add("h_eff_num_angularity_pr", "", HistType::kTH2F, {axPtJetPart, axL11Part}); - registry.add("h_eff_num_angularity_np", "", HistType::kTH2F, {axPtJetPart, axL11Part}); - registry.add("h_eff_den_angularity_pr", "", HistType::kTH2F, {axPtJetPart, axL11Part}); - registry.add("h_eff_den_angularity_np", "", HistType::kTH2F, {axPtJetPart, axL11Part}); - - registry.add("h_eff_num_girth_pr", "", HistType::kTH2F, {axPtJetPart, axL12Part}); - registry.add("h_eff_num_girth_np", "", HistType::kTH2F, {axPtJetPart, axL12Part}); - registry.add("h_eff_den_girth_pr", "", HistType::kTH2F, {axPtJetPart, axL12Part}); - registry.add("h_eff_den_girth_np", "", HistType::kTH2F, {axPtJetPart, axL12Part}); - - // ---- Efficiency sparses ---- - registry.add("hSparse_d0_mcd_eff", "hSparse_d0_mcd_eff", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axMatch, axL11, axL12, axRefl}); - registry.add("hSparse_d0_mcp_eff", "hSparse_d0_mcp_eff", HistType::kTHnSparseF, - {axPtD0, axPtJetPart, axZ, axOrigin, axMatch, axL11, axL12}); - - // ---- Efficiency sparses, candidate-match version (match axis = candidate-match flag) ---- - registry.add("hSparse_d0_mcd_eff_cand", "hSparse_d0_mcd_eff_cand", HistType::kTHnSparseF, - {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axMatch, axL11, axL12, axRefl}); - registry.add("hSparse_d0_mcp_eff_cand", "hSparse_d0_mcp_eff_cand", HistType::kTHnSparseF, - {axPtD0, axPtJetPart, axZ, axOrigin, axMatch, axL11, axL12}); - - // Bin labels - - // ---- DATA bin labels ---- auto hColl = registry.get(HIST("h_collisions")); hColl->GetXaxis()->SetBinLabel(AllCollisions, "all"); - hColl->GetXaxis()->SetBinLabel(Sel8ZCut, "sel8 + |z| cut"); - hColl->GetXaxis()->SetBinLabel(3, "has D0 jet"); - hColl->GetXaxis()->SetBinLabel(4, "rejected"); - + hColl->GetXaxis()->SetBinLabel(SelectedCollisions, "selected (ev. sel + RCT + |z|)"); + hColl->GetXaxis()->SetBinLabel(CollisionsWithD0Jet, "has D0 jet"); + hColl->GetXaxis()->SetBinLabel(RejectedCollisions, "rejected"); auto hJet = registry.get(HIST("h_jet_counter")); - hJet->GetXaxis()->SetBinLabel(ChargedJets, "All charged jets"); - hJet->GetXaxis()->SetBinLabel(D0TaggedJets, "D0-tagged jets"); - - // ---- MCD bin labels ---- - auto hCollMCD = registry.get(HIST("h_collisions_mcd")); - hCollMCD->GetXaxis()->SetBinLabel(1, "selected collisions"); - hCollMCD->GetXaxis()->SetBinLabel(2, "has D0 jet"); - - auto hJetMCD = registry.get(HIST("h_jet_counter_mcd")); - hJetMCD->GetXaxis()->SetBinLabel(ChargedJets, "All charged jets"); - hJetMCD->GetXaxis()->SetBinLabel(D0TaggedJets, "D0-tagged jets"); - - auto hOriginMCD = registry.get(HIST("h_d0_origin_mcd")); - hOriginMCD->GetXaxis()->SetBinLabel(1, "none/bkg"); - hOriginMCD->GetXaxis()->SetBinLabel(2, "prompt"); - hOriginMCD->GetXaxis()->SetBinLabel(3, "non-prompt"); - - // ---- MCP bin labels ---- - auto hCollMCP = registry.get(HIST("h_collisions_mcp")); - hCollMCP->GetXaxis()->SetBinLabel(1, "all MC collisions"); - hCollMCP->GetXaxis()->SetBinLabel(2, "has D0 jet"); - - auto hJetMCP = registry.get(HIST("h_jet_counter_mcp")); - hJetMCP->GetXaxis()->SetBinLabel(ChargedJets, "All charged jets"); - hJetMCP->GetXaxis()->SetBinLabel(D0TaggedJets, "D0-tagged jets"); - - auto hOriginMCP = registry.get(HIST("h_d0_origin_mcp")); - hOriginMCP->GetXaxis()->SetBinLabel(1, "none/bkg"); - hOriginMCP->GetXaxis()->SetBinLabel(2, "prompt"); - hOriginMCP->GetXaxis()->SetBinLabel(3, "non-prompt"); - - // ---- Jet-matching bin labels ---- - auto hMatchGeoMCD = registry.get(HIST("h_jet_matching_geo_status_mcd")); - hMatchGeoMCD->GetXaxis()->SetBinLabel(1, "unmatched"); - hMatchGeoMCD->GetXaxis()->SetBinLabel(2, "matched"); - - auto hMatchCandMCD = registry.get(HIST("h_jet_matching_cand_status_mcd")); - hMatchCandMCD->GetXaxis()->SetBinLabel(1, "unmatched"); - hMatchCandMCD->GetXaxis()->SetBinLabel(2, "matched"); - - auto hMatchCleanMCD = registry.get(HIST("h_jet_matching_clean_mcd")); - hMatchCleanMCD->GetXaxis()->SetBinLabel(1, "not clean"); - hMatchCleanMCD->GetXaxis()->SetBinLabel(2, "clean"); - - auto hGeoCandDisagreeMCD = registry.get(HIST("h_jet_matching_geocand_disagree_mcd")); - hGeoCandDisagreeMCD->GetXaxis()->SetBinLabel(1, "disagree"); - hGeoCandDisagreeMCD->GetXaxis()->SetBinLabel(2, "agree"); - - // ---- MC efficiency (jet-to-jet matching based) bin labels ---- - auto mcCollisionCounter = registry.get(HIST("MC_CollisionCounter")); - mcCollisionCounter->GetXaxis()->SetBinLabel(BinMCColCntr::AllMCCollisions, "All MC collisions"); - mcCollisionCounter->GetXaxis()->SetBinLabel(BinMCColCntr::SelectedMCCollisions, "Selected MC collisions"); - mcCollisionCounter->GetXaxis()->SetBinLabel(BinMCColCntr::AssociatedRecoCollisions, "MC-Associated reco collisions"); - mcCollisionCounter->GetXaxis()->SetBinLabel(BinMCColCntr::SelectedAssociatedRecoCollisions, "Selected MC-Associated reco collisions"); - - auto jetCounter = registry.get(HIST("MC_JetCounter")); - jetCounter->GetXaxis()->SetBinLabel(BinMCJetCntr::DetectorLevelJetInMCCollision, "Detector-level D0 jets"); - jetCounter->GetXaxis()->SetBinLabel(BinMCJetCntr::ParticleLevelJetInMCCollision, "Particle-level D0 jets"); - jetCounter->GetXaxis()->SetBinLabel(BinMCJetCntr::DetectorLevelJetWithMatchedCandidate, "Detector jets matched to particle"); - jetCounter->GetXaxis()->SetBinLabel(BinMCJetCntr::ParticleLevelJetWithMatchedCandidate, "Particle jets matched to detector"); - - auto hSparseMCDEff = registry.get(HIST("hSparse_d0_mcd_eff")); - hSparseMCDEff->GetAxis(4)->SetBinLabel(1, "none/bkg"); - hSparseMCDEff->GetAxis(4)->SetBinLabel(2, "prompt"); - hSparseMCDEff->GetAxis(4)->SetBinLabel(3, "non-prompt"); - hSparseMCDEff->GetAxis(5)->SetBinLabel(1, "Unmatched"); - hSparseMCDEff->GetAxis(5)->SetBinLabel(2, "Matched"); - hSparseMCDEff->GetAxis(8)->SetBinLabel(1, "Not reflection"); - hSparseMCDEff->GetAxis(8)->SetBinLabel(2, "Reflection"); - - auto hSparseMCPEff = registry.get(HIST("hSparse_d0_mcp_eff")); - hSparseMCPEff->GetAxis(3)->SetBinLabel(1, "none/bkg"); - hSparseMCPEff->GetAxis(3)->SetBinLabel(2, "prompt"); - hSparseMCPEff->GetAxis(3)->SetBinLabel(3, "non-prompt"); - hSparseMCPEff->GetAxis(4)->SetBinLabel(1, "Unmatched"); - hSparseMCPEff->GetAxis(4)->SetBinLabel(2, "Matched"); - - // ---- Candidate-match efficiency sparse bin labels ---- - auto hSparseMCDEffCand = registry.get(HIST("hSparse_d0_mcd_eff_cand")); - hSparseMCDEffCand->GetAxis(4)->SetBinLabel(1, "none/bkg"); - hSparseMCDEffCand->GetAxis(4)->SetBinLabel(2, "prompt"); - hSparseMCDEffCand->GetAxis(4)->SetBinLabel(3, "non-prompt"); - hSparseMCDEffCand->GetAxis(5)->SetBinLabel(1, "Unmatched (cand)"); - hSparseMCDEffCand->GetAxis(5)->SetBinLabel(2, "Matched (cand)"); - hSparseMCDEffCand->GetAxis(8)->SetBinLabel(1, "Not reflection"); - hSparseMCDEffCand->GetAxis(8)->SetBinLabel(2, "Reflection"); - - auto hSparseMCPEffCand = registry.get(HIST("hSparse_d0_mcp_eff_cand")); - hSparseMCPEffCand->GetAxis(3)->SetBinLabel(1, "none/bkg"); - hSparseMCPEffCand->GetAxis(3)->SetBinLabel(2, "prompt"); - hSparseMCPEffCand->GetAxis(3)->SetBinLabel(3, "non-prompt"); - hSparseMCPEffCand->GetAxis(4)->SetBinLabel(1, "Unmatched (cand)"); - hSparseMCPEffCand->GetAxis(4)->SetBinLabel(2, "Matched (cand)"); - - // ---- Reflection sparse bin labels ---- - auto hSparseMCDRefl = registry.get(HIST("hSparse_d0_mcd_reflection")); - hSparseMCDRefl->GetAxis(4)->SetBinLabel(1, "none/bkg"); - hSparseMCDRefl->GetAxis(4)->SetBinLabel(2, "prompt"); - hSparseMCDRefl->GetAxis(4)->SetBinLabel(3, "non-prompt"); - } - - // Helper: reflection identification (MCD only) + hJet->GetXaxis()->SetBinLabel(D0JetsInFiducialRange, "D0 jets (pT, R)"); + hJet->GetXaxis()->SetBinLabel(D0JetsWithSelectedCandidate, "D0 jets with selected cand."); - template - bool isReflectedCandidate(CAND const& cand) - { - const int8_t flagMcMatchRec = cand.flagMcMatchRec(); - if (flagMcMatchRec == 0) { - return false; // not truth-matched -> background, not a reflection - } - const bool trueIsD0 = flagMcMatchRec > 0; // sign encodes true species - const bool thisRowIsD0Hypothesis = (cand.candidateSelFlag() == kCandSelFlagD0); // which hypothesis this row uses - return thisRowIsD0Hypothesis != trueIsD0; - } - - // Helper: angularity - - template - float computeLambda(JET const& jet, TRACKS const& tracks, CANDIDATES const& candidates, - float alpha, float kappa) - { - if (jet.pt() <= 0.f) { - return -1.f; + const std::string title = fmt::format("alpha = {}, kappa = {}", alphaStr, kappaStr); + if (doprocessDataChargedSubstructure) { + hMassPtLambda = registry.add("ang/hMassPtLambda_a0", title.c_str(), HistType::kTHnSparseF, + {axMass, axPtD0, axPtJetData, axLam}); } - - float sum = 0.f; - for (auto const& trk : tracks) { - const float dr = jetutilities::deltaR(jet, trk); - sum += std::pow(trk.pt(), kappa) * std::pow(dr, alpha); + if (doprocessMCDChargedSubstructureMatched) { + hMassPtLambdaMC = registry.add("ang/hMassPtLambdaMC_a0", title.c_str(), HistType::kTHnSparseF, + {axMass, axPtD0, axPtJetData, axLam, axSample}); + const std::array originTag{"pr", "np"}; + for (int o = 0; o < NOrigins; ++o) { + const std::string sfx = "a0_" + originTag[o]; + + hResponse[o] = registry.add(("ang/hResponse_" + sfx).c_str(), title.c_str(), HistType::kTHnSparseF, + {axPtJetRespDet, axLamDet, axPtD0Det, axPtJetRespPart, axLamPart, axPtD0Part, axSample}); + hGen[o] = registry.add(("ang/hGen_" + sfx).c_str(), title.c_str(), HistType::kTHnSparseF, + {axPtJetRespPart, axLamPart, axPtD0Part, axSample}); + hGenMatched[o] = registry.add(("ang/hGenMatched_" + sfx).c_str(), title.c_str(), HistType::kTHnSparseF, + {axPtJetRespPart, axLamPart, axPtD0Part, axSample}); + hDetTrue[o] = registry.add(("ang/hDetTrue_" + sfx).c_str(), title.c_str(), HistType::kTHnSparseF, + {axPtJetRespDet, axLamDet, axPtD0Det, axSample}); + hDetMatched[o] = registry.add(("ang/hDetMatched_" + sfx).c_str(), title.c_str(), HistType::kTHnSparseF, + {axPtJetRespDet, axLamDet, axPtD0Det, axSample}); + } } - for (auto const& cand : candidates) { - const float dr = jetutilities::deltaR(jet, cand); - sum += std::pow(cand.pt(), kappa) * std::pow(dr, alpha); + if (doprocessMCPChargedSubstructure) { + hGenD0Jet = registry.add("ang/hGenD0Jet_a0", title.c_str(), HistType::kTHnSparseF, + {axPtD0Part, axPtJetRespPart, axLamPart, axOrigin}); } - const float jetRadius = jet.r() / 100.f; // stored as R×100 in the table - const float denom = std::pow(jet.pt(), kappa) * std::pow(jetRadius, alpha); - if (denom <= 0.f) { - return -1.f; + if (doprocessDataChargedSubstructure && fillLegacyOutputs) { + registry.add("hSparse_d0", "hSparse_d0", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetData, axZ, axDR, axLamT}); } - return sum / denom; - } - - // Helper: jet invariant mass - template - float computeJetMass(TRACKS const& tracks, - CANDIDATES const& candidates, - double candMass = -1.) - { - std::array momTotal{0., 0., 0.}; - double energyTot = 0.; + // ---------------- MC detector level (templates, QA) + if (doprocessMCDChargedSubstructure || doprocessMCDChargedSubstructureMatched) { + registry.add("h_d0_mass_mcd", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axMass}}); + registry.add("h_d0_mass_mcd_signal", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axMass}}); + registry.add("h_d0_mass_mcd_reflection", ";m_{K#pi}^{det} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {axMass}}); + registry.add("h_d0_origin_mcd", ";origin;entries", {HistType::kTH1F, {{3, 0., 3.}}}); + registry.add("h_d0_flag_mcd", ";flagMcMatchRec;entries", HistType::kTH1F, {{11, -5.5, 5.5}}); + registry.add("h_d0_selflag", ";candidateSelFlag;entries", HistType::kTH1F, {{5, -0.5, 4.5}}); + registry.add("h_d0_mass_hypothesis_check", ";m_{K#pi} (GeV/#it{c}^{2});category", HistType::kTH2F, {axMass, axHypCat}); + registry.add("hSparse_d0_mcd", "hSparse_d0_mcd", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetDet, axZ, axDR, axLamT}); + registry.add("hSparse_d0_mcd_calib", "hSparse_d0_mcd_calib", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axLamT}); + registry.add("hSparse_d0_mcd_reflection", "hSparse_d0_mcd_reflection", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axLamT}); + registry.add("hSparse_d0_mcd_corrbkg", "hSparse_d0_mcd_corrbkg", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetDet, axZ, axChannelCorr, axOrigin, axLamT}); + registry.add("h_d0_mass_mcd_corrbkg", ";m_{K#pi}^{det} (GeV/#it{c}^{2});channel", HistType::kTH2F, {axMass, axChannelCorr}); + auto hCorr = registry.get(HIST("hSparse_d0_mcd_corrbkg")); + hCorr->GetAxis(4)->SetBinLabel(1, "K#pi#pi^{0}"); + hCorr->GetAxis(4)->SetBinLabel(2, "#pi#pi"); + hCorr->GetAxis(4)->SetBinLabel(3, "#pi#pi#pi^{0}"); + hCorr->GetAxis(4)->SetBinLabel(4, "KK"); + } - for (auto const& trk : tracks) { - momTotal[0] += trk.px(); - momTotal[1] += trk.py(); - momTotal[2] += trk.pz(); - energyTot += RecoDecay::p(trk.px(), trk.py(), trk.pz()); // massless approximation for ordinary tracks + // ---------------- MC particle level / matched + if (doprocessMCPChargedSubstructure || doprocessMCDChargedSubstructureMatched) { + registry.add("MC_CollisionCounter", "N_{collisions};", {HistType::kTH1F, {{4, 0., 4.}}}); + registry.add("MC_JetCounter", "N_{jet};", {HistType::kTH1F, {{4, 0., 4.}}}); + registry.add("h_d0_flag_mcp", ";flagMcMatchGen;entries", HistType::kTH1F, {{11, -5.5, 5.5}}); + registry.add("hSparse_d0_mcp_channel", "hSparse_d0_mcp_channel", HistType::kTHnSparseF, {axPtD0, axPtJetPart, axZ, axChannelGen, axOrigin, axLamT}); + auto c = registry.get(HIST("MC_CollisionCounter")); + c->GetXaxis()->SetBinLabel(AllMCCollisions, "All MC collisions"); + c->GetXaxis()->SetBinLabel(SelectedMCCollisions, "Selected MC collisions"); + c->GetXaxis()->SetBinLabel(AssociatedRecoCollisions, "Associated reco collisions"); + c->GetXaxis()->SetBinLabel(SelectedAssociatedRecoCollisions, "Selected associated reco collisions"); + auto j = registry.get(HIST("MC_JetCounter")); + j->GetXaxis()->SetBinLabel(DetectorLevelJetInMCCollision, "Detector-level D0 jets"); + j->GetXaxis()->SetBinLabel(ParticleLevelJetInMCCollision, "Particle-level D0 jets"); + j->GetXaxis()->SetBinLabel(DetectorLevelJetWithMatchedCandidate, "Det. jets matched (matchingMode)"); + j->GetXaxis()->SetBinLabel(ParticleLevelJetWithMatchedCandidate, "Part. jets matched (matchingMode)"); + auto hChan = registry.get(HIST("hSparse_d0_mcp_channel")); + hChan->GetAxis(3)->SetBinLabel(1, "K#pi (signal)"); + hChan->GetAxis(3)->SetBinLabel(2, "K#pi#pi^{0}"); + hChan->GetAxis(3)->SetBinLabel(3, "#pi#pi"); + hChan->GetAxis(3)->SetBinLabel(4, "#pi#pi#pi^{0}"); + hChan->GetAxis(3)->SetBinLabel(5, "KK"); } - for (auto const& cand : candidates) { - double m = 0; - if (candMass > 0.) { - m = candMass; - } else if constexpr (requires { cand.m(); }) { - m = cand.m(); // DATA / MCD: reconstructed invariant mass - } else { - m = 0.; + if (doprocessMCDChargedSubstructureMatched) { + registry.add("h_jet_matching_geo_status_mcd", ";status (0=unmatched,1=matched);entries", {HistType::kTH1F, {{2, 0., 2.}}}); + registry.add("h_jet_matching_cand_status_mcd", ";status (0=unmatched,1=matched);entries", {HistType::kTH1F, {{2, 0., 2.}}}); + registry.add("h_jet_matching_clean_mcd", ";status (0=not clean,1=clean);entries", {HistType::kTH1F, {{2, 0., 2.}}}); + registry.add("h_jet_matching_dr_mcd", ";#DeltaR(jet^{det},jet^{part});entries", {HistType::kTH1F, {{100, 0., 0.5}}}); + registry.add("h_jet_matching_ngeo_mcd", ";number of geo-matched jets;entries", {HistType::kTH1F, {{6, 0., 6.}}}); + registry.add("h_jet_matching_ncand_mcd", ";number of cand-matched jets;entries", {HistType::kTH1F, {{6, 0., 6.}}}); + registry.add("h_closure_sample", ";closure sample;MC collisions", {HistType::kTH1F, {{2, -0.5, 1.5}}}); + + registry.add("h_eff_run2_num_pr", ";#it{p}_{T,D^{0}}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}); + registry.add("h_eff_run2_num_np", ";#it{p}_{T,D^{0}}^{det} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}); + registry.add("h_eff_run2_den_pr", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}); + registry.add("h_eff_run2_den_np", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 50.}}}); + + if (fillLegacyOutputs) { + registry.add("h_jet_pt_response_matrix", "", HistType::kTH2F, {axPtJetDet, axPtJetPart}); + registry.add("h_jet_pt_response_matrix_pr", "prompt", HistType::kTH2F, {axPtJetDet, axPtJetPart}); + registry.add("h_jet_pt_response_matrix_np", "non-prompt", HistType::kTH2F, {axPtJetDet, axPtJetPart}); + registry.add("h_response_d0pt_pr", "", HistType::kTHnSparseF, {axPtJetDet, axPtD0Det, axPtJetPart, axPtD0Part}); + registry.add("h_response_d0pt_np", "", HistType::kTHnSparseF, {axPtJetDet, axPtD0Det, axPtJetPart, axPtD0Part}); + registry.add("h_response_angularity_pr", "", HistType::kTHnSparseF, {axPtJetDet, axLamDet, axPtJetPart, axLamPart}); + registry.add("h_response_angularity_np", "", HistType::kTHnSparseF, {axPtJetDet, axLamDet, axPtJetPart, axLamPart}); + registry.add("hSparse_d0_mcd_eff", "hSparse_d0_mcd_eff", HistType::kTHnSparseF, {axMass, axPtD0, axPtJetDet, axZ, axOrigin, axMatch, axLamT, axRefl}); + registry.add("hSparse_d0_mcp_eff", "hSparse_d0_mcp_eff", HistType::kTHnSparseF, {axPtD0, axPtJetPart, axZ, axOrigin, axMatch, axLamT}); } - - momTotal[0] += cand.px(); - momTotal[1] += cand.py(); - momTotal[2] += cand.pz(); - energyTot += RecoDecay::e(cand.px(), cand.py(), cand.pz(), m); } - const double mass2 = RecoDecay::m2(momTotal, energyTot); - return (mass2 > 0.) ? static_cast(std::sqrt(mass2)) : 0.f; + if (doprocessMCPChargedSubstructure) { + registry.add("h_jet_pt_mcp", ";#it{p}_{T,jet}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}); + registry.add("h_jet_eta_mcp", ";#eta_{jet}^{part};entries", {HistType::kTH1F, {{100, -1., 1.}}}); + registry.add("h_d0_pt_mcp", ";#it{p}_{T,D^{0}}^{part} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 100.}}}); + registry.add("h_d0_y_mcp", ";y_{D^{0}}^{part};entries", {HistType::kTH1F, {{100, -2., 2.}}}); + registry.add("h_d0_origin_mcp", ";origin;entries", {HistType::kTH1F, {{3, 0., 3.}}}); + } } - // Process: collision QA (DATA) + // ================================================================ data - void processCollisions(aod::JetCollision const& collision, - aod::JetTracks const& tracks) + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) { registry.fill(HIST("h_collisions"), getValFromBin(AllCollisions)); - - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - registry.fill(HIST("h_collisions"), 3.5f); // rejected + if (!selectRecoCollision(collision)) { + registry.fill(HIST("h_collisions"), getValFromBin(RejectedCollisions)); return; } - registry.fill(HIST("h_collisions"), getValFromBin(Sel8ZCut)); - + registry.fill(HIST("h_collisions"), getValFromBin(SelectedCollisions)); // N_ev for the feed-down normalisation for (auto const& track : tracks) { if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { continue; @@ -752,336 +685,221 @@ struct JetHFAngularityTask { registry.fill(HIST("h_track_phi"), track.phi()); } } + PROCESS_SWITCH(JetHFAngularityTask, processCollisions, "DATA: event counter (N_ev) and track QA", true); - PROCESS_SWITCH(JetHFAngularityTask, processCollisions, - "Collision and track QA", true); - - // Process: DATA jet analysis - - void processDataChargedSubstructure( - aod::JetCollision const& collision, - soa::Filtered const& jets, - D0CandidatesData const& /*candidates*/, - aod::JetTracks const&) + void processDataChargedSubstructure(aod::JetCollision const& collision, + soa::Filtered const& jets, + D0CandidatesData const&, + aod::JetTracks const&) { - // ---- Event selection ---- - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + if (!selectRecoCollision(collision)) { return; } - bool collisionHasD0Jet = false; - for (const auto& jet : jets) { - - registry.fill(HIST("h_jet_counter"), getValFromBin(ChargedJets)); + registry.fill(HIST("h_jet_counter"), getValFromBin(D0JetsInFiducialRange)); registry.fill(HIST("h_jet_pt"), jet.pt()); registry.fill(HIST("h_jet_eta"), jet.eta()); registry.fill(HIST("h_jet_phi"), jet.phi()); - // ---- Jet-level quantities ---- - auto jetTracks = jet.template tracks_as(); auto jetCandidates = jet.template candidates_as(); + const auto obs = jetObservables(jet, jetTracks, jetCandidates); - const int nConst = static_cast(jetTracks.size()) + static_cast(jetCandidates.size()); - const float angularity = computeLambda(jet, jetTracks, jetCandidates, 1.f, 1.f); // λ_1^1 - const float girth = computeLambda(jet, jetTracks, jetCandidates, 2.f, 1.f); // λ_2^1 - const float mjet = computeJetMass(jetTracks, jetCandidates); - - const std::array jetMom{jet.px(), jet.py(), jet.pz()}; - - bool hasD0 = false; - - // ---- D0 candidate loop ---- - for (const auto& d0Candidate : jetCandidates) { - - hasD0 = true; - - const std::array d0Mom{d0Candidate.px(), d0Candidate.py(), d0Candidate.pz()}; - - // Longitudinal momentum fraction: z_|| = (p_D0 . p_jet) / |p_jet|^2 - const float zParallel = RecoDecay::dotProd(d0Mom, jetMom) / RecoDecay::mag2(jetMom); - // Angular separation between D0 and jet axis - const float axisDistance = jetutilities::deltaR(jet, d0Candidate); - - // ---- Histograms ---- - registry.fill(HIST("h_d0_mass"), d0Candidate.m()); - registry.fill(HIST("h_d0_pt"), d0Candidate.pt()); - registry.fill(HIST("h_d0_eta"), d0Candidate.eta()); - registry.fill(HIST("h_d0_phi"), d0Candidate.phi()); - registry.fill(HIST("h_d0_y"), d0Candidate.y()); - registry.fill(HIST("h_d0_jet_projection"), zParallel); - registry.fill(HIST("h_d0_jet_distance"), axisDistance); - - registry.fill(HIST("h_jet_nconst"), nConst); - registry.fill(HIST("h_d0_mlscore0"), d0Candidate.mlScores()[0]); - registry.fill(HIST("h_d0_mlscore1"), d0Candidate.mlScores()[1]); - registry.fill(HIST("h_d0_mlscore2"), d0Candidate.mlScores()[2]); - - registry.fill(HIST("hSparse_d0"), - d0Candidate.m(), d0Candidate.pt(), - jet.pt(), zParallel, axisDistance, - angularity, girth); - - objJetTable(axisDistance, - jet.pt(), - jet.eta(), - jet.phi(), - nConst, - angularity, - girth, - mjet, - zParallel, - d0Candidate.pt(), - d0Candidate.eta(), - d0Candidate.phi(), - d0Candidate.m(), - d0Candidate.y(), - d0Candidate.mlScores()[0], - d0Candidate.mlScores()[1], - d0Candidate.mlScores()[2]); - - } // end D0 loop - - if (hasD0) { - registry.fill(HIST("h_jet_counter"), getValFromBin(D0TaggedJets)); - registry.fill(HIST("h_d0_jet_lambda11"), angularity); - registry.fill(HIST("h_d0_jet_lambda12"), girth); - registry.fill(HIST("h_d0_jet_mass"), mjet); + bool hasSelectedD0 = false; + for (const auto& cand : jetCandidates) { + if (!passMlCut(cand)) { + continue; + } + hasSelectedD0 = true; + const auto kin = d0JetKinematics(jet, cand); + + registry.fill(HIST("h_d0_mass"), cand.m()); + registry.fill(HIST("h_d0_pt"), cand.pt()); + registry.fill(HIST("h_d0_eta"), cand.eta()); + registry.fill(HIST("h_d0_phi"), cand.phi()); + registry.fill(HIST("h_d0_y"), cand.y()); + registry.fill(HIST("h_d0_jet_projection"), kin.zParallel); + registry.fill(HIST("h_d0_jet_distance"), kin.deltaR); + registry.fill(HIST("h_jet_nconst"), obs.nConst); + registry.fill(HIST("h_d0_mlscore0"), mlScore(cand, 0)); + registry.fill(HIST("h_d0_mlscore1"), mlScore(cand, 1)); + registry.fill(HIST("h_d0_mlscore2"), mlScore(cand, 2)); + + hMassPtLambda->Fill(cand.m(), cand.pt(), jet.pt(), obs.lambda); + if (fillLegacyOutputs) { + registry.fill(HIST("hSparse_d0"), cand.m(), cand.pt(), jet.pt(), kin.zParallel, kin.deltaR, obs.lambda); + } + if (fillTables) { + objJetTable(kin.deltaR, jet.pt(), jet.eta(), jet.phi(), obs.nConst, + obs.lambda, obs.mass, + kin.zParallel, cand.pt(), cand.eta(), cand.phi(), cand.m(), cand.y(), + static_cast(cand.candidateSelFlag()), + mlScore(cand, 0), mlScore(cand, 1), mlScore(cand, 2)); + } + } + if (hasSelectedD0) { + registry.fill(HIST("h_jet_counter"), getValFromBin(D0JetsWithSelectedCandidate)); + registry.fill(HIST("h_d0_jet_lambda"), obs.lambda); + registry.fill(HIST("h_d0_jet_mass"), obs.mass); collisionHasD0Jet = true; } - - } // end jet loop - + } if (collisionHasD0Jet) { - registry.fill(HIST("h_collisions"), 2.5f); // has D0 jet + registry.fill(HIST("h_collisions"), getValFromBin(CollisionsWithD0Jet)); } } + PROCESS_SWITCH(JetHFAngularityTask, processDataChargedSubstructure, "DATA: D0-tagged charged-jet angularities", true); - PROCESS_SWITCH(JetHFAngularityTask, processDataChargedSubstructure, - "DATA: D0-tagged charged jet substructure", true); - - // Process: MC DETECTOR-LEVEL (MCD) + // ================================================================ MC detector level (QA only) - void processMCDChargedSubstructure( - aod::JetCollision const& collision, - soa::Filtered const& mcdjets, - D0CandidatesMCD const& /*candidates*/, - aod::JetTracks const&) + void processMCDChargedSubstructure(aod::JetCollision const& collision, + soa::Filtered const& mcdjets, + D0CandidatesMCD const&, + aod::JetTracks const&) { - // ---- Event selection (same sel8 + |z| ) ---- - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + if (!selectRecoCollision(collision)) { return; } - - registry.fill(HIST("h_collisions_mcd"), 0.5f); // selected collisions - - bool collisionHasD0Jet = false; - for (const auto& jet : mcdjets) { - - registry.fill(HIST("h_jet_counter_mcd"), getValFromBin(ChargedJets)); - registry.fill(HIST("h_jet_pt_mcd"), jet.pt()); - registry.fill(HIST("h_jet_eta_mcd"), jet.eta()); - registry.fill(HIST("h_jet_phi_mcd"), jet.phi()); - - // ---- Jet-level quantities (detector level) ---- auto jetTracks = jet.template tracks_as(); auto jetCandidates = jet.template candidates_as(); - - const int nConst = static_cast(jetTracks.size()) + static_cast(jetCandidates.size()); - const float angularity = computeLambda(jet, jetTracks, jetCandidates, 1.f, 1.f); // λ_1^1 - const float girth = computeLambda(jet, jetTracks, jetCandidates, 2.f, 1.f); // λ_2^1 - const float mjet = computeJetMass(jetTracks, jetCandidates); - - const std::array jetMom{jet.px(), jet.py(), jet.pz()}; - - bool hasD0 = false; - - // D0 candidate loop (with MC truth-matching info) - for (const auto& d0Candidate : jetCandidates) { - - hasD0 = true; - - const std::array d0Mom{d0Candidate.px(), d0Candidate.py(), d0Candidate.pz()}; - - const float zParallel = RecoDecay::dotProd(d0Mom, jetMom) / RecoDecay::mag2(jetMom); - const float axisDistance = jetutilities::deltaR(jet, d0Candidate); - - const int8_t flagMcMatch = d0Candidate.flagMcMatchRec(); - const int8_t originMc = d0Candidate.originMcRec(); // 0 none, 1 prompt, 2 non-prompt - - // ---- Reflection identification ---- - const bool isReflection = isReflectedCandidate(d0Candidate); - const bool isTrueSignal = (flagMcMatch != 0) && !isReflection; - - if (isReflection) { - registry.fill(HIST("h_d0_mass_mcd_reflection"), d0Candidate.m()); - registry.fill(HIST("hSparse_d0_mcd_reflection"), - d0Candidate.m(), d0Candidate.pt(), jet.pt(), zParallel, originMc, - angularity, girth); - } else if (isTrueSignal) { - registry.fill(HIST("h_d0_mass_mcd_signal"), d0Candidate.m()); - registry.fill(HIST("hSparse_d0_mcd_calib"), - d0Candidate.m(), d0Candidate.pt(), jet.pt(), zParallel, originMc, - angularity, girth); + const auto obs = jetObservables(jet, jetTracks, jetCandidates); + for (const auto& cand : jetCandidates) { + if (!passMlCut(cand)) { + continue; } - - // ---- Histograms ---- - registry.fill(HIST("h_d0_mass_mcd"), d0Candidate.m()); - registry.fill(HIST("h_d0_pt_mcd"), d0Candidate.pt()); - registry.fill(HIST("h_d0_eta_mcd"), d0Candidate.eta()); - registry.fill(HIST("h_d0_phi_mcd"), d0Candidate.phi()); - registry.fill(HIST("h_d0_y_mcd"), d0Candidate.y()); - registry.fill(HIST("h_d0_jet_projection_mcd"), zParallel); - registry.fill(HIST("h_d0_jet_distance_mcd"), axisDistance); - registry.fill(HIST("h_d0_origin_mcd"), static_cast(originMc)); - registry.fill(HIST("hSparse_d0_mcd"), - d0Candidate.m(), d0Candidate.pt(), - jet.pt(), zParallel, axisDistance, - angularity, girth); - - if (originMc == kOriginMcPrompt) { - registry.fill(HIST("h_eff_run2_num_pr"), d0Candidate.pt()); - } else if (originMc == kOriginMcNonPrompt) { - registry.fill(HIST("h_eff_run2_num_np"), d0Candidate.pt()); + const auto kin = d0JetKinematics(jet, cand); + fillMcQa(cand); + registry.fill(HIST("h_d0_mass_mcd"), cand.m()); + registry.fill(HIST("h_d0_origin_mcd"), static_cast(cand.originMcRec())); + registry.fill(HIST("hSparse_d0_mcd"), cand.m(), cand.pt(), jet.pt(), kin.zParallel, kin.deltaR, obs.lambda); + if (fillTables) { + objJetMCDTable(kin.deltaR, jet.pt(), jet.eta(), jet.phi(), obs.nConst, + obs.lambda, obs.mass, + kin.zParallel, cand.pt(), cand.eta(), cand.phi(), cand.m(), cand.y(), + static_cast(cand.candidateSelFlag()), + mlScore(cand, 0), mlScore(cand, 1), mlScore(cand, 2), + static_cast(cand.flagMcMatchRec()), static_cast(cand.originMcRec())); } - - objJetMCDTable(axisDistance, - jet.pt(), - jet.eta(), - jet.phi(), - nConst, - angularity, - girth, - mjet, - zParallel, - d0Candidate.pt(), - d0Candidate.eta(), - d0Candidate.phi(), - d0Candidate.m(), - d0Candidate.y(), - d0Candidate.mlScores()[0], - d0Candidate.mlScores()[1], - d0Candidate.mlScores()[2], - flagMcMatch, - originMc); - - } // end D0 loop - - if (hasD0) { - registry.fill(HIST("h_jet_counter_mcd"), getValFromBin(D0TaggedJets)); - registry.fill(HIST("h_d0_jet_lambda11_mcd"), angularity); - registry.fill(HIST("h_d0_jet_lambda12_mcd"), girth); - registry.fill(HIST("h_d0_jet_mass_mcd"), mjet); - collisionHasD0Jet = true; } - - } // end jet loop - - if (collisionHasD0Jet) { - registry.fill(HIST("h_collisions_mcd"), 1.5f); // has D0 jet } } + PROCESS_SWITCH(JetHFAngularityTask, processMCDChargedSubstructure, "MC DET LEVEL QA (no efficiency objects)", false); - PROCESS_SWITCH(JetHFAngularityTask, processMCDChargedSubstructure, - "MC DETECTOR LEVEL: D0-tagged charged jet substructure", false); + // ================================================================ MC particle level - // Process: MC PARTICLE-LEVEL (MCP) - - void processMCPChargedSubstructure( - aod::JetMcCollision const& /*mcCollision*/, - soa::Filtered const& mcpjets, - D0CandidatesMCP const& /*candidates*/, - aod::JetParticles const&) + void processMCPChargedSubstructure(aod::JetMcCollision const& mcCollision, + soa::Filtered const& mcpjets, + D0CandidatesMCP const&, + aod::JetParticles const&) { - - registry.fill(HIST("h_collisions_mcp"), 0.5f); // all MC collisions - - bool collisionHasD0Jet = false; + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(AllMCCollisions)); + if (!selectMcCollision(mcCollision)) { + return; + } + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(SelectedMCCollisions)); // N_ev,gen for sigma/N_ev scaling + const float w = mcWeight(mcCollision); for (const auto& jet : mcpjets) { + registry.fill(HIST("MC_JetCounter"), getValFromBin(ParticleLevelJetInMCCollision)); + registry.fill(HIST("h_jet_pt_mcp"), jet.pt(), w); + registry.fill(HIST("h_jet_eta_mcp"), jet.eta(), w); - registry.fill(HIST("h_jet_counter_mcp"), getValFromBin(ChargedJets)); - registry.fill(HIST("h_jet_pt_mcp"), jet.pt()); - registry.fill(HIST("h_jet_eta_mcp"), jet.eta()); - registry.fill(HIST("h_jet_phi_mcp"), jet.phi()); - - // Jet-level quantities (particle / generator level) auto jetParticles = jet.template tracks_as(); auto jetCandidates = jet.template candidates_as(); + const auto obs = jetObservables(jet, jetParticles, jetCandidates); + + for (const auto& d0 : jetCandidates) { + const auto kin = d0JetKinematics(jet, d0); + const int flag = d0.flagMcMatchGen(); + const int absFlag = std::abs(flag); + const int origin = d0.originMcGen(); + registry.fill(HIST("h_d0_pt_mcp"), d0.pt(), w); + registry.fill(HIST("h_d0_y_mcp"), d0.y(), w); + registry.fill(HIST("h_d0_origin_mcp"), static_cast(origin), w); + registry.fill(HIST("h_d0_flag_mcp"), static_cast(flag), w); + if (absFlag >= ChanD0ToPiK && absFlag <= ChanD0ToKK) { + registry.fill(HIST("hSparse_d0_mcp_channel"), d0.pt(), jet.pt(), kin.zParallel, static_cast(absFlag), + static_cast(origin), obs.lambda, w); + } - const int nConst = static_cast(jetParticles.size()) + static_cast(jetCandidates.size()); - const float angularity = computeLambda(jet, jetParticles, jetCandidates, 1.f, 1.f); // λ_1^1 - const float girth = computeLambda(jet, jetParticles, jetCandidates, 2.f, 1.f); // λ_2^1 - const float mjet = computeJetMass(jetParticles, jetCandidates, massD0MCP); - - const std::array jetMom{jet.px(), jet.py(), jet.pz()}; - - bool hasD0 = false; - - // Generated D0 loop (with MC truth-matching info) - for (const auto& d0Particle : jetCandidates) { - - hasD0 = true; - - const std::array d0Mom{d0Particle.px(), d0Particle.py(), d0Particle.pz()}; - - const float zParallel = RecoDecay::dotProd(d0Mom, jetMom) / RecoDecay::mag2(jetMom); - const float axisDistance = jetutilities::deltaR(jet, d0Particle); - - const int8_t flagMcMatch = d0Particle.flagMcMatchGen(); - const int8_t originMc = d0Particle.originMcGen(); // 0 none, 1 prompt, 2 non-prompt - - // ---- Histograms ---- - registry.fill(HIST("h_d0_pt_mcp"), d0Particle.pt()); - registry.fill(HIST("h_d0_eta_mcp"), d0Particle.eta()); - registry.fill(HIST("h_d0_phi_mcp"), d0Particle.phi()); - registry.fill(HIST("h_d0_y_mcp"), d0Particle.y()); - registry.fill(HIST("h_d0_jet_projection_mcp"), zParallel); - registry.fill(HIST("h_d0_jet_distance_mcp"), axisDistance); - registry.fill(HIST("h_d0_origin_mcp"), static_cast(originMc)); - - if (originMc == kOriginMcPrompt) { - registry.fill(HIST("h_eff_run2_den_pr"), d0Particle.pt()); - } else if (originMc == kOriginMcNonPrompt) { - registry.fill(HIST("h_eff_run2_den_np"), d0Particle.pt()); + if (isCorrBkgChannel(absFlag)) { + continue; + } + const std::array x{d0.pt(), jet.pt(), obs.lambda, static_cast(origin)}; + hGenD0Jet->Fill(x.data(), w); + if (fillTables) { + objJetMCPTable(kin.deltaR, jet.pt(), jet.eta(), jet.phi(), obs.nConst, + obs.lambda, obs.mass, + kin.zParallel, d0.pt(), d0.eta(), d0.phi(), d0.y(), + static_cast(flag), static_cast(origin)); } - objJetMCPTable(axisDistance, - jet.pt(), - jet.eta(), - jet.phi(), - nConst, - angularity, - girth, - mjet, - zParallel, - d0Particle.pt(), - d0Particle.eta(), - d0Particle.phi(), - d0Particle.y(), - flagMcMatch, - originMc); - - } // end D0 loop - - if (hasD0) { - registry.fill(HIST("h_jet_counter_mcp"), getValFromBin(D0TaggedJets)); - registry.fill(HIST("h_d0_jet_lambda11_mcp"), angularity); - registry.fill(HIST("h_d0_jet_lambda12_mcp"), girth); - registry.fill(HIST("h_d0_jet_mass_mcp"), mjet); - collisionHasD0Jet = true; } - - } // end jet loop - - if (collisionHasD0Jet) { - registry.fill(HIST("h_collisions_mcp"), 1.5f); // has D0 jet } } - - PROCESS_SWITCH(JetHFAngularityTask, processMCPChargedSubstructure, - "MC PARTICLE LEVEL: D0-tagged charged jet substructure", false); + PROCESS_SWITCH(JetHFAngularityTask, processMCPChargedSubstructure, "MC PART LEVEL (POWHEG feed-down input)", false); + + // ================================================================ MC matched: templates, response, efficiency + + struct MatchInfo { + bool geo = false; + bool cand = false; + bool clean = false; + bool used = false; + int nGeo = 0; + int nCand = 0; + float pt = -1.f; + float eta = -999.f; + float phi = -999.f; + float dR = -1.f; + float d0Pt = -1.f; + float lambda = -1.f; + }; + + template + MatchInfo findMatch(MCDJET const& mcdjet) + { + MatchInfo m; + int geoIndex = -1; + if (mcdjet.has_matchedJetGeo()) { + for (const auto& mcpjet : mcdjet.template matchedJetGeo_as()) { + if (m.nGeo++ == 0) { + geoIndex = mcpjet.globalIndex(); + m.geo = true; + } + } + } + int candIndex = -1; + if (mcdjet.has_matchedJetCand()) { + for (const auto& mcpjet : mcdjet.template matchedJetCand_as()) { + if (m.nCand++ == 0) { + candIndex = mcpjet.globalIndex(); + m.cand = true; + } + } + } + m.clean = m.geo && m.cand && (geoIndex == candIndex); + m.used = (matchingMode == 1) ? m.cand : m.clean; + if (!m.used) { + return m; + } + for (const auto& mcpjet : mcdjet.template matchedJetCand_as()) { + m.pt = mcpjet.pt(); + m.eta = mcpjet.eta(); + m.phi = mcpjet.phi(); + m.dR = jetutilities::deltaR(mcdjet, mcpjet); + auto parts = mcpjet.template tracks_as(); + auto cands = mcpjet.template candidates_as(); + const auto obs = jetObservables(mcpjet, parts, cands); + m.lambda = obs.lambda; + if (cands.size() > 0) { + m.d0Pt = mcpjet.template candidates_first_as().pt(); + } + break; // first candidate match (== first geo match) + } + return m; + } void processMCDChargedSubstructureMatched(aod::JetMcCollisions const& mccollisions, aod::JetCollisionsMCD const& collisions, @@ -1092,353 +910,199 @@ struct JetHFAngularityTask { aod::JetTracks const&, aod::JetParticles const&) { - - const int jetRBin = static_cast(std::lround(static_cast(jetR) * 100.0f)); - for (const auto& mccollision : mccollisions) { - - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::AllMCCollisions)); - - if (std::abs(mccollision.posZ()) > vertexZCut) { + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(AllMCCollisions)); + if (!selectMcCollision(mccollision)) { continue; } - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::SelectedMCCollisions)); - - // const float mcWeight = mccollision.weight(); + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(SelectedMCCollisions)); + const float w = mcWeight(mccollision); + const int sample = closureSample(mccollision.globalIndex(), closureInputFraction); + registry.fill(HIST("h_closure_sample"), sample); + // ------------------------------------------------------------ detector level const auto collisionsPerMCCollision = collisions.sliceBy(collisionsPerMCCollisionPreslice, mccollision.globalIndex()); for (const auto& collision : collisionsPerMCCollision) { - - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::AssociatedRecoCollisions)); - - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || - !(std::abs(collision.posZ()) < vertexZCut)) { + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(AssociatedRecoCollisions)); + if (!selectRecoCollision(collision)) { continue; } - registry.fill(HIST("MC_CollisionCounter"), getValFromBin(BinMCColCntr::SelectedAssociatedRecoCollisions)); + registry.fill(HIST("MC_CollisionCounter"), getValFromBin(SelectedAssociatedRecoCollisions)); - const auto d0mcdJetsPerCollision = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); - for (const auto& mcdjet : d0mcdJetsPerCollision) { + const auto jetsThisColl = mcdjets.sliceBy(d0MCDJetsPerCollisionPreslice, collision.globalIndex()); + for (const auto& mcdjet : jetsThisColl) { if (mcdjet.pt() <= jetPtMin || mcdjet.r() != jetRBin) { continue; } - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetInMCCollision)); + registry.fill(HIST("MC_JetCounter"), getValFromBin(DetectorLevelJetInMCCollision)); + registry.fill(HIST("h_jet_eta"), mcdjet.eta()); auto jetTracks = mcdjet.template tracks_as(); auto jetCandidates = mcdjet.template candidates_as(); + const auto obs = jetObservables(mcdjet, jetTracks, jetCandidates); + const auto match = findMatch(mcdjet); + + registry.fill(HIST("h_jet_matching_ngeo_mcd"), match.nGeo); + registry.fill(HIST("h_jet_matching_ncand_mcd"), match.nCand); + registry.fill(HIST("h_jet_matching_geo_status_mcd"), match.geo ? 1.5f : 0.5f); + registry.fill(HIST("h_jet_matching_cand_status_mcd"), match.cand ? 1.5f : 0.5f); + registry.fill(HIST("h_jet_matching_clean_mcd"), match.clean ? 1.5f : 0.5f); + if (match.used) { + registry.fill(HIST("h_jet_matching_dr_mcd"), match.dR); + registry.fill(HIST("MC_JetCounter"), getValFromBin(DetectorLevelJetWithMatchedCandidate)); + } - 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); - registry.fill(HIST("h_jet_pt_response_matrix_allcand"), mcdjet.pt(), mcpjet.pt()); - - 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.empty()) { - auto matchedMcpD0 = mcpjet.template candidates_first_as(); - matchedD0Pt = matchedMcpD0.pt(); - } - } + for (const auto& cand : jetCandidates) { + if (!passMlCut(cand)) { + continue; } - } - registry.fill(HIST("h_jet_matching_ngeo_mcd"), nGeoMatches); - - 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(); - } + const auto kin = d0JetKinematics(mcdjet, cand); + const int origin = cand.originMcRec(); + const auto mcClass = classifyMcCandidate(cand); + fillMcQa(cand); + registry.fill(HIST("h_d0_y"), cand.y()); + registry.fill(HIST("h_d0_mass_mcd"), cand.m(), w); + registry.fill(HIST("h_d0_origin_mcd"), static_cast(origin), w); + + // pseudo-data for the full-chain closure: every candidate, like in data + const std::array xMc{cand.m(), cand.pt(), mcdjet.pt(), obs.lambda, static_cast(sample)}; + hMassPtLambdaMC->Fill(xMc.data(), w); + + // mass templates + if (mcClass.isReflection) { + registry.fill(HIST("h_d0_mass_mcd_reflection"), cand.m(), w); + registry.fill(HIST("hSparse_d0_mcd_reflection"), cand.m(), cand.pt(), mcdjet.pt(), kin.zParallel, origin, obs.lambda, w); + } else if (mcClass.isTrueSignal) { + registry.fill(HIST("h_d0_mass_mcd_signal"), cand.m(), w); + registry.fill(HIST("hSparse_d0_mcd_calib"), cand.m(), cand.pt(), mcdjet.pt(), kin.zParallel, origin, obs.lambda, w); + } else if (mcClass.isCorrBkg) { + registry.fill(HIST("h_d0_mass_mcd_corrbkg"), cand.m(), static_cast(mcClass.channel), w); + registry.fill(HIST("hSparse_d0_mcd_corrbkg"), cand.m(), cand.pt(), mcdjet.pt(), kin.zParallel, + static_cast(mcClass.channel), static_cast(origin), obs.lambda, w); } - } - registry.fill(HIST("h_jet_matching_ncand_mcd"), nCandMatches); - - // "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); - registry.fill(HIST("h_jet_matching_cand_status_mcd"), isCandMatched ? 1.5f : 0.5f); - registry.fill(HIST("h_jet_matching_clean_mcd"), isCleanMatched ? 1.5f : 0.5f); - - if (isGeoMatched) { - const bool agree = isCandMatched && (geoMatchedGlobalIndex == candMatchedGlobalIndex); - registry.fill(HIST("h_jet_matching_geocand_disagree_mcd"), agree ? 1.5f : 0.5f); - } - - if (isCleanMatched) { - // registry.fill(HIST("h_jet_pt_response_matrix"), mcdjet.pt(), matchedPt); - registry.fill(HIST("h_jet_matching_dr_mcd"), matchedDR); - } - - const auto geoStatus = static_cast(isGeoMatched); - const auto candStatus = static_cast(isCandMatched); - const auto cleanStatus = static_cast(isCleanMatched); - - const int isCleanMatchedMCD = isCleanMatched ? 1 : 0; - - if (isCleanMatched) { - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::DetectorLevelJetWithMatchedCandidate)); - } - - 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()); - 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()); - registry.fill(HIST("hSparse_d0_mcd_calib"), - mcdD0cand.m(), mcdD0cand.pt(), mcdjet.pt(), zParallelMCD, originMcd, - angularity, girth); + if (fillLegacyOutputs && !mcClass.isCorrBkg) { + registry.fill(HIST("hSparse_d0_mcd_eff"), cand.m(), cand.pt(), mcdjet.pt(), kin.zParallel, origin, + match.clean ? 1 : 0, obs.lambda, mcClass.isReflection ? 1 : 0, w); } - registry.fill(HIST("hSparse_d0_mcd_eff"), - mcdD0cand.m(), - mcdD0cand.pt(), - mcdjet.pt(), - zParallelMCD, - originMcd, - isCleanMatchedMCD, - angularity, - girth, - isReflectionFlag); - - // Same entry, but the match axis carries the candidate-match flag - registry.fill(HIST("hSparse_d0_mcd_eff_cand"), - mcdD0cand.m(), - mcdD0cand.pt(), - mcdjet.pt(), - zParallelMCD, - originMcd, - static_cast(isCandMatched), - angularity, - girth, - isReflectionFlag); - - // Reflection rows are a second copy of the same true D0: skip them (switchable). - const bool skipReflection = rejectReflections && isReflection; - - if (!skipReflection) { - 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()); - } - } 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()); - } - } + // true D0 -> K pi with origin: efficiency numerators and response + const bool skip = !(mcClass.isTrueSignal || mcClass.isReflection) || (rejectReflections && mcClass.isReflection); + const int o = originIndex(origin); + if (skip || o < 0) { + continue; } - - if (isCleanMatched && !skipReflection) { - registry.fill(HIST("h_jet_pt_response_matrix"), mcdjet.pt(), matchedPt); - - // The matched particle-level jet must lie in the range covered by the denominator. - const bool matchedInDenominatorRange = (matchedPt > jetPtMin); - - if (originMcd == kOriginMcPrompt) { - registry.fill(HIST("h_jet_pt_response_matrix_pr"), mcdjet.pt(), matchedPt); - registry.fill(HIST("h_response_angularity_pr"), mcdjet.pt(), angularity, matchedPt, matchedAngularity); - registry.fill(HIST("h_response_girth_pr"), mcdjet.pt(), girth, matchedPt, matchedGirth); - registry.fill(HIST("h_response_d0pt_pr"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt); - if (matchedInDenominatorRange) { - registry.fill(HIST("h_eff_num_d0pt_pr"), matchedPt, matchedD0Pt); - registry.fill(HIST("h_eff_num_angularity_pr"), matchedPt, matchedAngularity); - registry.fill(HIST("h_eff_num_girth_pr"), matchedPt, matchedGirth); - } - } else if (originMcd == kOriginMcNonPrompt) { - registry.fill(HIST("h_jet_pt_response_matrix_np"), mcdjet.pt(), matchedPt); - registry.fill(HIST("h_response_angularity_np"), mcdjet.pt(), angularity, matchedPt, matchedAngularity); - registry.fill(HIST("h_response_girth_np"), mcdjet.pt(), girth, matchedPt, matchedGirth); - registry.fill(HIST("h_response_d0pt_np"), mcdjet.pt(), mcdD0cand.pt(), matchedPt, matchedD0Pt); - if (matchedInDenominatorRange) { - registry.fill(HIST("h_eff_num_d0pt_np"), matchedPt, matchedD0Pt); - registry.fill(HIST("h_eff_num_angularity_np"), matchedPt, matchedAngularity); - registry.fill(HIST("h_eff_num_girth_np"), matchedPt, matchedGirth); - } + if (o == 0) { + registry.fill(HIST("h_eff_run2_num_pr"), cand.pt(), w); + } else { + registry.fill(HIST("h_eff_run2_num_np"), cand.pt(), w); + } + const std::array xd{mcdjet.pt(), obs.lambda, cand.pt(), static_cast(sample)}; + hDetTrue[o]->Fill(xd.data(), w); + if (!match.used) { + continue; + } + const std::array xg{match.pt, match.lambda, match.d0Pt, static_cast(sample)}; + const std::array xr{mcdjet.pt(), obs.lambda, cand.pt(), match.pt, match.lambda, match.d0Pt, static_cast(sample)}; + hDetMatched[o]->Fill(xd.data(), w); + hGenMatched[o]->Fill(xg.data(), w); + hResponse[o]->Fill(xr.data(), w); + if (fillLegacyOutputs) { + registry.fill(HIST("h_jet_pt_response_matrix"), mcdjet.pt(), match.pt, w); + if (o == 0) { + registry.fill(HIST("h_jet_pt_response_matrix_pr"), mcdjet.pt(), match.pt, w); + registry.fill(HIST("h_response_angularity_pr"), mcdjet.pt(), obs.lambda, match.pt, match.lambda, w); + registry.fill(HIST("h_response_d0pt_pr"), mcdjet.pt(), cand.pt(), match.pt, match.d0Pt, w); + } else { + registry.fill(HIST("h_jet_pt_response_matrix_np"), mcdjet.pt(), match.pt, w); + registry.fill(HIST("h_response_angularity_np"), mcdjet.pt(), obs.lambda, match.pt, match.lambda, w); + registry.fill(HIST("h_response_d0pt_np"), mcdjet.pt(), cand.pt(), match.pt, match.d0Pt, w); } } + if (fillTables) { + objJetMCDMatchedTable(kin.deltaR, mcdjet.pt(), mcdjet.eta(), mcdjet.phi(), obs.nConst, + obs.lambda, obs.mass, + kin.zParallel, cand.pt(), cand.eta(), cand.phi(), cand.m(), cand.y(), + static_cast(cand.candidateSelFlag()), + mlScore(cand, 0), mlScore(cand, 1), mlScore(cand, 2), + static_cast(cand.flagMcMatchRec()), static_cast(origin), + static_cast(match.geo), static_cast(match.cand), static_cast(match.clean), + match.pt, match.eta, match.phi, match.dR, match.d0Pt, + match.lambda, + static_cast(sample)); + } + } // candidates + } // MCD jets + } // reco collisions - 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) { - + // ------------------------------------------------------------ particle level + const auto mcpJetsThisColl = mcpjets.sliceBy(d0MCPJetsPerMCCollisionPreslice, mccollision.globalIndex()); + for (const auto& mcpjet : mcpJetsThisColl) { if (mcpjet.pt() <= jetPtMin || mcpjet.r() != jetRBin) { continue; } + registry.fill(HIST("MC_JetCounter"), getValFromBin(ParticleLevelJetInMCCollision)); + auto parts = mcpjet.template tracks_as(); + auto cands = mcpjet.template candidates_as(); + if (cands.size() == 0) { + continue; + } + const auto obs = jetObservables(mcpjet, parts, cands); + const auto d0 = mcpjet.template candidates_first_as(); + const auto kin = d0JetKinematics(mcpjet, d0); + const int flag = d0.flagMcMatchGen(); + const int absFlag = std::abs(flag); + const int origin = d0.originMcGen(); + + registry.fill(HIST("h_d0_flag_mcp"), static_cast(flag), w); + if (absFlag >= ChanD0ToPiK && absFlag <= ChanD0ToKK) { + registry.fill(HIST("hSparse_d0_mcp_channel"), d0.pt(), mcpjet.pt(), kin.zParallel, static_cast(absFlag), + static_cast(origin), obs.lambda, w); + } + if (absFlag != ChanD0ToPiK) { + continue; // only D0 -> K pi enters the efficiency denominators + } - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetInMCCollision)); - - bool mcpIsCleanMatched = false; + bool cleanMatched = 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 geoTarget = -1; + for (const auto& j : mcpjet.template matchedJetGeo_as()) { + geoTarget = j.globalIndex(); + break; } - int mcpCandTarget = -1; - for (const auto& mcdjetCand : mcpjet.template matchedJetCand_as()) { - mcpCandTarget = mcdjetCand.globalIndex(); + int candTarget = -1; + for (const auto& j : mcpjet.template matchedJetCand_as()) { + candTarget = j.globalIndex(); break; } - mcpIsCleanMatched = (mcpGeoTarget == mcpCandTarget) && (mcpGeoTarget != -1); + cleanMatched = (geoTarget != -1) && (geoTarget == candTarget); } - const int isCleanMatchedMCP = mcpIsCleanMatched ? 1 : 0; - - if (mcpIsCleanMatched) { - registry.fill(HIST("MC_JetCounter"), getValFromBin(BinMCJetCntr::ParticleLevelJetWithMatchedCandidate)); + if (matchingMode == 1) { + cleanMatched = mcpjet.has_matchedJetCand(); // HF matching only } - // ---- First generated D0 of the jet only: one entry per MCP jet ---- - auto mcpD0cand = mcpjet.template candidates_first_as(); - - const int originMcp = mcpD0cand.originMcGen(); // 0 none/bkg, 1 prompt, 2 non-prompt - - 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 - - const int isCandMatchedMCP = mcpjet.has_matchedJetCand() ? 1 : 0; - const bool mcpIsGeoMatched = mcpjet.has_matchedJetGeo(); - - // clean-match version - registry.fill(HIST("hSparse_d0_mcp_eff"), - mcpD0cand.pt(), - mcpjet.pt(), - zParallelMCP, - originMcp, - isCleanMatchedMCP, - angularityMCP, - girthMCP); - - // candidate-match version - registry.fill(HIST("hSparse_d0_mcp_eff_cand"), - mcpD0cand.pt(), - mcpjet.pt(), - zParallelMCP, - originMcp, - isCandMatchedMCP, - angularityMCP, - girthMCP); - - if (originMcp == kOriginMcPrompt) { - registry.fill(HIST("h_eff_den_d0pt_pr"), mcpjet.pt(), mcpD0cand.pt()); - registry.fill(HIST("h_eff_den_angularity_pr"), mcpjet.pt(), angularityMCP); - registry.fill(HIST("h_eff_den_girth_pr"), mcpjet.pt(), girthMCP); - } else if (originMcp == kOriginMcNonPrompt) { - registry.fill(HIST("h_eff_den_d0pt_np"), mcpjet.pt(), mcpD0cand.pt()); - registry.fill(HIST("h_eff_den_angularity_np"), mcpjet.pt(), angularityMCP); - registry.fill(HIST("h_eff_den_girth_np"), mcpjet.pt(), girthMCP); + if (cleanMatched) { + registry.fill(HIST("MC_JetCounter"), getValFromBin(ParticleLevelJetWithMatchedCandidate)); } - 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()); - } + if (fillLegacyOutputs) { + registry.fill(HIST("hSparse_d0_mcp_eff"), d0.pt(), mcpjet.pt(), kin.zParallel, origin, cleanMatched ? 1 : 0, + obs.lambda, w); } - } // end MCP jet loop - } // end MC collision loop + const int o = originIndex(origin); + if (o < 0) { + continue; + } + if (o == 0) { + registry.fill(HIST("h_eff_run2_den_pr"), d0.pt(), w); + } else { + registry.fill(HIST("h_eff_run2_den_np"), d0.pt(), w); + } + const std::array xg{mcpjet.pt(), obs.lambda, d0.pt(), static_cast(sample)}; + hGen[o]->Fill(xg.data(), w); + } // MCP jets + } // MC collisions } - PROCESS_SWITCH(JetHFAngularityTask, processMCDChargedSubstructureMatched, - "MC: unified efficiency + jet matching + response matrix + reflection (needs jet-matching workflow)", false); + "MC: templates + 6D responses + efficiencies + closure split (needs jet-matching-mc-d0-ch)", false); }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)