From 95672e72545d49894c64376c4f0d7edded676c7f Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Tue, 3 Mar 2026 16:27:47 -0300 Subject: [PATCH 01/15] [PWGJE] Add angularity --- PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx | 319 ------------------- 1 file changed, 319 deletions(-) delete mode 100644 PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx diff --git a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx deleted file mode 100644 index 629ba2f75f3..00000000000 --- a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// 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. - -// Jet substructure and spectrum task for D_s mesons -// -// This task is used to reconstruct and analyse jets containing charged D_s -// mesons -// -/// \author Monalisa Melo -// - -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetReducedData.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -namespace o2::aod -{ -namespace jet_distance -{ -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(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(HfMlScore0, hfMlScore0, float); -DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); -DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); - -// extra -DECLARE_SOA_COLUMN(JetMass, jetMass, float); -DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); -DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 -DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 -} // namespace jet_distance - -DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", - jet_distance::JetHfDist, - jet_distance::JetPt, - jet_distance::JetEta, - jet_distance::JetPhi, - jet_distance::JetNConst, - jet_distance::HfPt, - jet_distance::HfEta, - jet_distance::HfPhi, - jet_distance::HfMass, - jet_distance::HfY, - jet_distance::HfMlScore0, - jet_distance::HfMlScore1, - jet_distance::HfMlScore2, - jet_distance::JetMass, - jet_distance::JetGirth, - jet_distance::JetThrust, - jet_distance::JetLambda11); -} // namespace o2::aod - -struct JetDsSpecSubs { - HistogramRegistry registry{ - "registry", - { - {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, - {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_counter", ";# of D_{S} jets;", {HistType::kTH1F, {{6, 0., 3.0}}}}, - {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, - {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, - {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, - {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, - {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, - {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, - {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, - {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, - {"h_ds_jet_lambda_extra", ";#lambda_{#alpha}^{#kappa};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h2_dsjet_pt_lambda_extra", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{#alpha}^{#kappa}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - }}; - - Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; - Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; - Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; - - Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; - Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - - // extra angularity knob - Configurable kappa{"kappa", 1.0f, "angularity kappa"}; - Configurable alpha{"alpha", 1.0f, "angularity alpha"}; - - bool doExtraAngularity = false; - - std::vector eventSelectionBits; - int trackSelection = -1; - - Produces distJetTable; - - template - float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) - { - if (jet.pt() <= 0.f) { - return -1.f; - } - float sum = 0.f; - for (auto const& trk : tracks) { - const float dr = jetutilities::deltaR(jet, trk); - sum += std::pow(trk.pt(), k) * std::pow(dr, a); - } - const float R = jet.r() / 100.f; - const float denom = std::pow(jet.pt(), k) * std::pow(R, a); - if (denom <= 0.f) { - return -1.f; - } - return sum / denom; - } - - template - float computeJetMassFromTracksMass(TRACKS const& tracks) - { - double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; - - for (auto const& trk : tracks) { - const double pt = trk.pt(); - const double phi = trk.phi(); - const double eta = trk.eta(); - - const double px = pt * std::cos(phi); - const double py = pt * std::sin(phi); - const double pz = pt * std::sinh(eta); - const double p = std::sqrt(px * px + py * py + pz * pz); - - sumPx += px; - sumPy += py; - sumPz += pz; - sumE += p; // massless - } - - const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); - return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; - } - - void init(o2::framework::InitContext&) - { - eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - - const bool is11 = (std::abs(kappa.value - 1.f) < 1e-6f) && (std::abs(alpha.value - 1.f) < 1e-6f); - const bool is12 = (std::abs(kappa.value - 1.f) < 1e-6f) && (std::abs(alpha.value - 2.f) < 1e-6f); - doExtraAngularity = !(is11 || is12); - } - - Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); - Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - - void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) - { - registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - registry.fill(HIST("h_collisions"), 1.5); - - for (auto const& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); - - void processDataCharged(soa::Filtered::iterator const& collision, - soa::Filtered const& jets) - { - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - for (auto& jet : jets) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); - - void processDataChargedSubstructure(aod::JetCollision const& collision, - soa::Join const& jets, - aod::CandidatesDsData const&, - aod::JetTracks const&) - { - registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || - !(std::abs(collision.posZ()) < vertexZCut)) { - return; - } - registry.fill(HIST("h_collision_counter"), 3.0); - - for (const auto& jet : jets) { - registry.fill(HIST("h_jet_counter"), 0.5); - - TVector3 jetVector(jet.px(), jet.py(), jet.pz()); - - for (const auto& dsCandidate : jet.candidates_as()) { - TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); - - const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); - const double axisDistance = jetutilities::deltaR(jet, dsCandidate); - - registry.fill(HIST("h_ds_jet_projection"), zParallel); - registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); - registry.fill(HIST("h_ds_jet_distance"), axisDistance); - registry.fill(HIST("h_ds_jet_pt"), jet.pt()); - registry.fill(HIST("h_ds_jet_eta"), jet.eta()); - registry.fill(HIST("h_ds_jet_phi"), jet.phi()); - registry.fill(HIST("h_ds_mass"), dsCandidate.m()); - registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); - registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); - - auto jetTracks = jet.tracks_as(); - - const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); - const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); // thrust = λ_2^1 - const float mjet = computeJetMassFromTracksMass(jetTracks); - - const float R = jet.r() / 100.f; - const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; - - if (lambda11 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda11"), lambda11); - registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); - } - if (lambda12 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda12"), lambda12); - registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); - } - registry.fill(HIST("h_ds_jet_mass"), mjet); - registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); - - if (girth >= 0.f) { - registry.fill(HIST("h_ds_jet_girth"), girth); - registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); - } - - if (doExtraAngularity) { - const float lambdaExtra = computeLambda(jet, jetTracks, alpha.value, kappa.value); - if (lambdaExtra >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda_extra"), lambdaExtra); - registry.fill(HIST("h2_dsjet_pt_lambda_extra"), jet.pt(), lambdaExtra); - } - } - - auto scores = dsCandidate.mlScores(); - const float s0 = (scores.size() > 0) ? scores[0] : -999.f; - const float s1 = (scores.size() > 1) ? scores[1] : -999.f; - const float s2 = (scores.size() > 2) ? scores[2] : -999.f; - - distJetTable(static_cast(axisDistance), - jet.pt(), jet.eta(), jet.phi(), - static_cast(jetTracks.size()), - dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), - dsCandidate.m(), dsCandidate.y(), - s0, s1, s2, - mjet, girth, lambda12, lambda11); - - break; // only first Ds per jet - } - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); -}; - -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-ds-spectrum-subs"})}; } From 432286810b65a9c8ed81b606c8594674b0f03ce4 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Sun, 5 Apr 2026 23:54:24 -0300 Subject: [PATCH 02/15] [PWGJE] Fix O2 linter: task name and file name --- PWGJE/Tasks/jetDsSpecSubs.cxx | 345 ++++++++++++++++++++++++++++++++++ 1 file changed, 345 insertions(+) create mode 100644 PWGJE/Tasks/jetDsSpecSubs.cxx diff --git a/PWGJE/Tasks/jetDsSpecSubs.cxx b/PWGJE/Tasks/jetDsSpecSubs.cxx new file mode 100644 index 00000000000..b19eaee33f7 --- /dev/null +++ b/PWGJE/Tasks/jetDsSpecSubs.cxx @@ -0,0 +1,345 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +// Jet substructure and spectrum task for D_s mesons +// +// This task is used to reconstruct and analyse jets containing charged D_s +// mesons +// +/// \author Monalisa Melo , Universidade de São Paulo +// + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include + +#include "TVector3.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace jet_distance +{ +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(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(HfMlScore0, hfMlScore0, float); +DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); +DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); + +// extra +DECLARE_SOA_COLUMN(JetMass, jetMass, float); +DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); +DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 +DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 +} // namespace jet_distance + +DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", + jet_distance::JetHfDist, + jet_distance::JetPt, + jet_distance::JetEta, + jet_distance::JetPhi, + jet_distance::JetNConst, + jet_distance::HfPt, + jet_distance::HfEta, + jet_distance::HfPhi, + jet_distance::HfMass, + jet_distance::HfY, + jet_distance::HfMlScore0, + jet_distance::HfMlScore1, + jet_distance::HfMlScore2, + jet_distance::JetMass, + jet_distance::JetGirth, + jet_distance::JetThrust, + jet_distance::JetLambda11); +} // namespace o2::aod + +struct JetDsSpecSubs { + HistogramRegistry registry{ + "registry", + { + {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, + {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, + {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, + {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, + {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, + {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, + {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"hSparse_ds", ";m_{D_{S}};p_{T,D_{S}};z^{D_{S},jet}_{||};#DeltaR_{D_{S},jet}", {HistType::kTHnSparseF, {{60, 1.7, 2.1}, {60, 0., 100.}, {60, 0., 2.}, {60, 0., 1.0}}}}, + {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, + {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, + {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, + {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, + {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, + }}; + + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + std::vector eventSelectionBits; + int trackSelection = -1; + + Produces distJetTable; + + template + float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) + { + if (jet.pt() <= 0.f) { + return -1.f; + } + float sum = 0.f; + for (auto const& trk : tracks) { + const float dr = jetutilities::deltaR(jet, trk); + sum += std::pow(trk.pt(), k) * std::pow(dr, a); + } + const float R = jet.r() / 100.f; + const float denom = std::pow(jet.pt(), k) * std::pow(R, a); + if (denom <= 0.f) { + return -1.f; + } + return sum / denom; + } + + template + float computeJetMassFromTracksMass(TRACKS const& tracks) + { + double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; + + for (auto const& trk : tracks) { + const double pt = trk.pt(); + const double phi = trk.phi(); + const double eta = trk.eta(); + + const double px = pt * std::cos(phi); + const double py = pt * std::sin(phi); + const double pz = pt * std::sinh(eta); + const double p = std::sqrt(px * px + py * py + pz * pz); + + sumPx += px; + sumPy += py; + sumPz += pz; + sumE += p; // massless + } + + const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); + return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; + } + + void init(o2::framework::InitContext&) + { + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + + auto h = registry.get(HIST("h_jet_counter")); + h->GetXaxis()->SetBinLabel(1, "All jets"); + h->GetXaxis()->SetBinLabel(2, "Ds-tagged jets"); + } + + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; + + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) + { + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_collisions"), 1.5); + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt()); + registry.fill(HIST("h_track_eta"), track.eta()); + registry.fill(HIST("h_track_phi"), track.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); + + void processDataCharged(soa::Filtered::iterator const& collision, + soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + for (const auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); + + void processDataChargedSubstructure(aod::JetCollision const& collision, + soa::Join const& jets, + aod::CandidatesDsData const&, + aod::JetTracks const&) + { + registry.fill(HIST("h_collision_counter"), 2.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || + !(std::abs(collision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("h_collision_counter"), 3.0); + + for (const auto& jet : jets) { + + registry.fill(HIST("h_jet_counter"), 0.5); + + bool hasDs = false; + + TVector3 jetVector(jet.px(), jet.py(), jet.pz()); + + // Compute jet-level quantities once (independent of Ds candidates) + auto jetTracks = jet.tracks_as(); + + const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); + const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); + const float mjet = computeJetMassFromTracksMass(jetTracks); + + const float R = jet.r() / 100.f; + const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; + + // Loop over Ds candidates (particle level) + for (const auto& dsCandidate : jet.candidates_as()) { + + hasDs = true; + + TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); + + // zParallel defined as longitudinal momentum fraction along the jet axis + const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); + const double axisDistance = jetutilities::deltaR(jet, dsCandidate); + + // --- Ds-level observables --- + registry.fill(HIST("h_ds_jet_projection"), zParallel); + registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); + registry.fill(HIST("h_ds_jet_distance"), axisDistance); + + registry.fill(HIST("h_ds_mass"), dsCandidate.m()); + registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); + registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); + + const float mass = dsCandidate.m(); + const float pt = dsCandidate.pt(); + const float z = zParallel; + const float dR = axisDistance; + + // Main THnSparse: invariant mass, pT, z, and ΔR + registry.fill(HIST("hSparse_ds"), mass, pt, z, dR); + + // --- output table --- + auto scores = dsCandidate.mlScores(); + constexpr int kScore0 = 0; + constexpr int kScore1 = 1; + constexpr int kScore2 = 2; + + const float s0 = (scores.size() > kScore0) ? scores[kScore0] : -999.f; + const float s1 = (scores.size() > kScore1) ? scores[kScore1] : -999.f; + const float s2 = (scores.size() > kScore2) ? scores[kScore2] : -999.f; + + distJetTable(static_cast(axisDistance), + jet.pt(), jet.eta(), jet.phi(), + static_cast(jetTracks.size()), + dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), + dsCandidate.m(), dsCandidate.y(), + s0, s1, s2, + mjet, girth, lambda12, lambda11); + } + + // Jet-level quantities (filled once per jet containing at least one Ds) + if (hasDs) { + + registry.fill(HIST("h_jet_counter"), 1.5); + + // Jet properties + registry.fill(HIST("h_ds_jet_pt"), jet.pt()); + registry.fill(HIST("h_ds_jet_eta"), jet.eta()); + registry.fill(HIST("h_ds_jet_phi"), jet.phi()); + + // Jet substructure observables + if (lambda11 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda11"), lambda11); + registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); + } + + if (lambda12 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda12"), lambda12); + registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); + } + + registry.fill(HIST("h_ds_jet_mass"), mjet); + registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); + + if (girth >= 0.f) { + registry.fill(HIST("h_ds_jet_girth"), girth); + registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); + } + } + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} \ No newline at end of file From 35ba6cf1c417644fb0747d0d42fd46707ab291a2 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Sun, 5 Apr 2026 23:56:49 -0300 Subject: [PATCH 03/15] [PWGJE] Fix O2 linter: task name and file name --- PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx | 345 +++++++++++++++++++ 1 file changed, 345 insertions(+) create mode 100644 PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx diff --git a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx new file mode 100644 index 00000000000..3b464b17061 --- /dev/null +++ b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx @@ -0,0 +1,345 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +// Jet substructure and spectrum task for D_s mesons +// +// This task is used to reconstruct and analyse jets containing charged D_s +// mesons +// +/// \author Monalisa Melo , Universidade de São Paulo +// + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include + +#include "TVector3.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace jet_distance +{ +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(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(HfMlScore0, hfMlScore0, float); +DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); +DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); + +// extra +DECLARE_SOA_COLUMN(JetMass, jetMass, float); +DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); +DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 +DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 +} // namespace jet_distance + +DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", + jet_distance::JetHfDist, + jet_distance::JetPt, + jet_distance::JetEta, + jet_distance::JetPhi, + jet_distance::JetNConst, + jet_distance::HfPt, + jet_distance::HfEta, + jet_distance::HfPhi, + jet_distance::HfMass, + jet_distance::HfY, + jet_distance::HfMlScore0, + jet_distance::HfMlScore1, + jet_distance::HfMlScore2, + jet_distance::JetMass, + jet_distance::JetGirth, + jet_distance::JetThrust, + jet_distance::JetLambda11); +} // namespace o2::aod + +struct JetDsSpecSubs { + HistogramRegistry registry{ + "registry", + { + {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, + {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, + {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, + {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, + {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, + {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, + {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"hSparse_ds", ";m_{D_{S}};p_{T,D_{S}};z^{D_{S},jet}_{||};#DeltaR_{D_{S},jet}", {HistType::kTHnSparseF, {{60, 1.7, 2.1}, {60, 0., 100.}, {60, 0., 2.}, {60, 0., 1.0}}}}, + {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, + {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, + {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, + {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, + {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, + }}; + + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + std::vector eventSelectionBits; + int trackSelection = -1; + + Produces distJetTable; + + template + float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) + { + if (jet.pt() <= 0.f) { + return -1.f; + } + float sum = 0.f; + for (auto const& trk : tracks) { + const float dr = jetutilities::deltaR(jet, trk); + sum += std::pow(trk.pt(), k) * std::pow(dr, a); + } + const float R = jet.r() / 100.f; + const float denom = std::pow(jet.pt(), k) * std::pow(R, a); + if (denom <= 0.f) { + return -1.f; + } + return sum / denom; + } + + template + float computeJetMassFromTracksMass(TRACKS const& tracks) + { + double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; + + for (auto const& trk : tracks) { + const double pt = trk.pt(); + const double phi = trk.phi(); + const double eta = trk.eta(); + + const double px = pt * std::cos(phi); + const double py = pt * std::sin(phi); + const double pz = pt * std::sinh(eta); + const double p = std::sqrt(px * px + py * py + pz * pz); + + sumPx += px; + sumPy += py; + sumPz += pz; + sumE += p; // massless + } + + const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); + return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; + } + + void init(o2::framework::InitContext&) + { + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + + auto h = registry.get(HIST("h_jet_counter")); + h->GetXaxis()->SetBinLabel(1, "All jets"); + h->GetXaxis()->SetBinLabel(2, "Ds-tagged jets"); + } + + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; + + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) + { + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_collisions"), 1.5); + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt()); + registry.fill(HIST("h_track_eta"), track.eta()); + registry.fill(HIST("h_track_phi"), track.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); + + void processDataCharged(soa::Filtered::iterator const& collision, + soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + for (const auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); + + void processDataChargedSubstructure(aod::JetCollision const& collision, + soa::Join const& jets, + aod::CandidatesDsData const&, + aod::JetTracks const&) + { + registry.fill(HIST("h_collision_counter"), 2.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || + !(std::abs(collision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("h_collision_counter"), 3.0); + + for (const auto& jet : jets) { + + registry.fill(HIST("h_jet_counter"), 0.5); + + bool hasDs = false; + + TVector3 jetVector(jet.px(), jet.py(), jet.pz()); + + // Compute jet-level quantities once (independent of Ds candidates) + auto jetTracks = jet.tracks_as(); + + const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); + const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); + const float mjet = computeJetMassFromTracksMass(jetTracks); + + const float R = jet.r() / 100.f; + const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; + + // Loop over Ds candidates (particle level) + for (const auto& dsCandidate : jet.candidates_as()) { + + hasDs = true; + + TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); + + // zParallel defined as longitudinal momentum fraction along the jet axis + const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); + const double axisDistance = jetutilities::deltaR(jet, dsCandidate); + + // --- Ds-level observables --- + registry.fill(HIST("h_ds_jet_projection"), zParallel); + registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); + registry.fill(HIST("h_ds_jet_distance"), axisDistance); + + registry.fill(HIST("h_ds_mass"), dsCandidate.m()); + registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); + registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); + + const float mass = dsCandidate.m(); + const float pt = dsCandidate.pt(); + const float z = zParallel; + const float dR = axisDistance; + + // Main THnSparse: invariant mass, pT, z, and ΔR + registry.fill(HIST("hSparse_ds"), mass, pt, z, dR); + + // --- output table --- + auto scores = dsCandidate.mlScores(); + constexpr int kScore0 = 0; + constexpr int kScore1 = 1; + constexpr int kScore2 = 2; + + const float s0 = (scores.size() > kScore0) ? scores[kScore0] : -999.f; + const float s1 = (scores.size() > kScore1) ? scores[kScore1] : -999.f; + const float s2 = (scores.size() > kScore2) ? scores[kScore2] : -999.f; + + distJetTable(static_cast(axisDistance), + jet.pt(), jet.eta(), jet.phi(), + static_cast(jetTracks.size()), + dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), + dsCandidate.m(), dsCandidate.y(), + s0, s1, s2, + mjet, girth, lambda12, lambda11); + } + + // Jet-level quantities (filled once per jet containing at least one Ds) + if (hasDs) { + + registry.fill(HIST("h_jet_counter"), 1.5); + + // Jet properties + registry.fill(HIST("h_ds_jet_pt"), jet.pt()); + registry.fill(HIST("h_ds_jet_eta"), jet.eta()); + registry.fill(HIST("h_ds_jet_phi"), jet.phi()); + + // Jet substructure observables + if (lambda11 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda11"), lambda11); + registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); + } + + if (lambda12 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda12"), lambda12); + registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); + } + + registry.fill(HIST("h_ds_jet_mass"), mjet); + registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); + + if (girth >= 0.f) { + registry.fill(HIST("h_ds_jet_girth"), girth); + registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); + } + } + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc)}; +} From 8e4ee162ab7c3b8795471053d02e236ba9d3a83a Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:00:20 -0300 Subject: [PATCH 04/15] [PWGJE] Fix O2 linter: task name and file name --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 0275a7a66ed..569076f8f53 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -396,7 +396,7 @@ if(FastJet_FOUND) PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-ds-spectrum-subs - SOURCES jetDsSpectrumAndSubstructure.cxx + SOURCES jetDsSpecSubs.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-d0-ang-substructure From 75deeff2a9ffbbf7a7b67b933475c97b4ab5e520 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:06:30 -0300 Subject: [PATCH 05/15] [PWGJE] Remove old file and keep renamed task --- PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx | 345 ------------------- 1 file changed, 345 deletions(-) delete mode 100644 PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx diff --git a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx deleted file mode 100644 index 3b464b17061..00000000000 --- a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// 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. - -// Jet substructure and spectrum task for D_s mesons -// -// This task is used to reconstruct and analyse jets containing charged D_s -// mesons -// -/// \author Monalisa Melo , Universidade de São Paulo -// - -#include "PWGHF/Core/DecayChannels.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/JetSubtraction.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include -#include -#include -#include -#include -#include -#include - -#include "TVector3.h" - -#include -#include -#include - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -namespace o2::aod -{ -namespace jet_distance -{ -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(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(HfMlScore0, hfMlScore0, float); -DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); -DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); - -// extra -DECLARE_SOA_COLUMN(JetMass, jetMass, float); -DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); -DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 -DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 -} // namespace jet_distance - -DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", - jet_distance::JetHfDist, - jet_distance::JetPt, - jet_distance::JetEta, - jet_distance::JetPhi, - jet_distance::JetNConst, - jet_distance::HfPt, - jet_distance::HfEta, - jet_distance::HfPhi, - jet_distance::HfMass, - jet_distance::HfY, - jet_distance::HfMlScore0, - jet_distance::HfMlScore1, - jet_distance::HfMlScore2, - jet_distance::JetMass, - jet_distance::JetGirth, - jet_distance::JetThrust, - jet_distance::JetLambda11); -} // namespace o2::aod - -struct JetDsSpecSubs { - HistogramRegistry registry{ - "registry", - { - {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, - {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, - {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, - {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, - {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, - {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"hSparse_ds", ";m_{D_{S}};p_{T,D_{S}};z^{D_{S},jet}_{||};#DeltaR_{D_{S},jet}", {HistType::kTHnSparseF, {{60, 1.7, 2.1}, {60, 0., 100.}, {60, 0., 2.}, {60, 0., 1.0}}}}, - {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, - {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, - {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, - {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, - }}; - - Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; - Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; - Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; - - Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; - Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - - std::vector eventSelectionBits; - int trackSelection = -1; - - Produces distJetTable; - - template - float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) - { - if (jet.pt() <= 0.f) { - return -1.f; - } - float sum = 0.f; - for (auto const& trk : tracks) { - const float dr = jetutilities::deltaR(jet, trk); - sum += std::pow(trk.pt(), k) * std::pow(dr, a); - } - const float R = jet.r() / 100.f; - const float denom = std::pow(jet.pt(), k) * std::pow(R, a); - if (denom <= 0.f) { - return -1.f; - } - return sum / denom; - } - - template - float computeJetMassFromTracksMass(TRACKS const& tracks) - { - double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; - - for (auto const& trk : tracks) { - const double pt = trk.pt(); - const double phi = trk.phi(); - const double eta = trk.eta(); - - const double px = pt * std::cos(phi); - const double py = pt * std::sin(phi); - const double pz = pt * std::sinh(eta); - const double p = std::sqrt(px * px + py * py + pz * pz); - - sumPx += px; - sumPy += py; - sumPz += pz; - sumE += p; // massless - } - - const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); - return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; - } - - void init(o2::framework::InitContext&) - { - eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - - auto h = registry.get(HIST("h_jet_counter")); - h->GetXaxis()->SetBinLabel(1, "All jets"); - h->GetXaxis()->SetBinLabel(2, "Ds-tagged jets"); - } - - Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); - Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - - void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) - { - registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - - registry.fill(HIST("h_collisions"), 1.5); - - for (auto const& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); - - void processDataCharged(soa::Filtered::iterator const& collision, - soa::Filtered const& jets) - { - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - for (const auto& jet : jets) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); - - void processDataChargedSubstructure(aod::JetCollision const& collision, - soa::Join const& jets, - aod::CandidatesDsData const&, - aod::JetTracks const&) - { - registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || - !(std::abs(collision.posZ()) < vertexZCut)) { - return; - } - registry.fill(HIST("h_collision_counter"), 3.0); - - for (const auto& jet : jets) { - - registry.fill(HIST("h_jet_counter"), 0.5); - - bool hasDs = false; - - TVector3 jetVector(jet.px(), jet.py(), jet.pz()); - - // Compute jet-level quantities once (independent of Ds candidates) - auto jetTracks = jet.tracks_as(); - - const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); - const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); - const float mjet = computeJetMassFromTracksMass(jetTracks); - - const float R = jet.r() / 100.f; - const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; - - // Loop over Ds candidates (particle level) - for (const auto& dsCandidate : jet.candidates_as()) { - - hasDs = true; - - TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); - - // zParallel defined as longitudinal momentum fraction along the jet axis - const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); - const double axisDistance = jetutilities::deltaR(jet, dsCandidate); - - // --- Ds-level observables --- - registry.fill(HIST("h_ds_jet_projection"), zParallel); - registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); - registry.fill(HIST("h_ds_jet_distance"), axisDistance); - - registry.fill(HIST("h_ds_mass"), dsCandidate.m()); - registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); - registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); - - const float mass = dsCandidate.m(); - const float pt = dsCandidate.pt(); - const float z = zParallel; - const float dR = axisDistance; - - // Main THnSparse: invariant mass, pT, z, and ΔR - registry.fill(HIST("hSparse_ds"), mass, pt, z, dR); - - // --- output table --- - auto scores = dsCandidate.mlScores(); - constexpr int kScore0 = 0; - constexpr int kScore1 = 1; - constexpr int kScore2 = 2; - - const float s0 = (scores.size() > kScore0) ? scores[kScore0] : -999.f; - const float s1 = (scores.size() > kScore1) ? scores[kScore1] : -999.f; - const float s2 = (scores.size() > kScore2) ? scores[kScore2] : -999.f; - - distJetTable(static_cast(axisDistance), - jet.pt(), jet.eta(), jet.phi(), - static_cast(jetTracks.size()), - dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), - dsCandidate.m(), dsCandidate.y(), - s0, s1, s2, - mjet, girth, lambda12, lambda11); - } - - // Jet-level quantities (filled once per jet containing at least one Ds) - if (hasDs) { - - registry.fill(HIST("h_jet_counter"), 1.5); - - // Jet properties - registry.fill(HIST("h_ds_jet_pt"), jet.pt()); - registry.fill(HIST("h_ds_jet_eta"), jet.eta()); - registry.fill(HIST("h_ds_jet_phi"), jet.phi()); - - // Jet substructure observables - if (lambda11 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda11"), lambda11); - registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); - } - - if (lambda12 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda12"), lambda12); - registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); - } - - registry.fill(HIST("h_ds_jet_mass"), mjet); - registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); - - if (girth >= 0.f) { - registry.fill(HIST("h_ds_jet_girth"), girth); - registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); - } - } - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); -}; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} From d8ea8c8487b13805b7eca72fc12748265622dcb1 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:13:51 -0300 Subject: [PATCH 06/15] [PWGJE] Restore CMakeLists to upstream version --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 569076f8f53..0275a7a66ed 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -396,7 +396,7 @@ if(FastJet_FOUND) PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-ds-spectrum-subs - SOURCES jetDsSpecSubs.cxx + SOURCES jetDsSpectrumAndSubstructure.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-d0-ang-substructure From e8873ca61e4865a864e1e8e1df2f1188359a3395 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:17:16 -0300 Subject: [PATCH 07/15] [PWGJE] Add newline at end of file --- PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx | 345 +++++++++++++++++++ 1 file changed, 345 insertions(+) create mode 100644 PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx diff --git a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx new file mode 100644 index 00000000000..40f2efb4be2 --- /dev/null +++ b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx @@ -0,0 +1,345 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// 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. + +// Jet substructure and spectrum task for D_s mesons +// +// This task is used to reconstruct and analyse jets containing charged D_s +// mesons +// +/// \author Monalisa Melo , Universidade de São Paulo +// + +#include "PWGHF/Core/DecayChannels.h" +#include "PWGJE/Core/JetDerivedDataUtilities.h" +#include "PWGJE/Core/JetUtilities.h" +#include "PWGJE/DataModel/Jet.h" +#include "PWGJE/DataModel/JetReducedData.h" +#include "PWGJE/DataModel/JetSubtraction.h" + +#include "Common/Core/RecoDecay.h" +#include "Common/DataModel/TrackSelectionTables.h" + +#include "Framework/ASoA.h" +#include "Framework/AnalysisDataModel.h" +#include "Framework/HistogramRegistry.h" +#include +#include +#include +#include +#include +#include +#include + +#include "TVector3.h" + +#include +#include +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; + +namespace o2::aod +{ +namespace jet_distance +{ +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(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(HfMlScore0, hfMlScore0, float); +DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); +DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); + +// extra +DECLARE_SOA_COLUMN(JetMass, jetMass, float); +DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); +DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 +DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 +} // namespace jet_distance + +DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", + jet_distance::JetHfDist, + jet_distance::JetPt, + jet_distance::JetEta, + jet_distance::JetPhi, + jet_distance::JetNConst, + jet_distance::HfPt, + jet_distance::HfEta, + jet_distance::HfPhi, + jet_distance::HfMass, + jet_distance::HfY, + jet_distance::HfMlScore0, + jet_distance::HfMlScore1, + jet_distance::HfMlScore2, + jet_distance::JetMass, + jet_distance::JetGirth, + jet_distance::JetThrust, + jet_distance::JetLambda11); +} // namespace o2::aod + +struct JetDsSpecSubs { + HistogramRegistry registry{ + "registry", + { + {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, + {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, + {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, + {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, + {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, + {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, + {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, + {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, + {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, + {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"hSparse_ds", ";m_{D_{S}};p_{T,D_{S}};z^{D_{S},jet}_{||};#DeltaR_{D_{S},jet}", {HistType::kTHnSparseF, {{60, 1.7, 2.1}, {60, 0., 100.}, {60, 0., 2.}, {60, 0., 1.0}}}}, + {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, + {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, + {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, + {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, + {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, + {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, + {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, + {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, + {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, + }}; + + Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; + Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; + Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; + + Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; + Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; + + std::vector eventSelectionBits; + int trackSelection = -1; + + Produces distJetTable; + + template + float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) + { + if (jet.pt() <= 0.f) { + return -1.f; + } + float sum = 0.f; + for (auto const& trk : tracks) { + const float dr = jetutilities::deltaR(jet, trk); + sum += std::pow(trk.pt(), k) * std::pow(dr, a); + } + const float R = jet.r() / 100.f; + const float denom = std::pow(jet.pt(), k) * std::pow(R, a); + if (denom <= 0.f) { + return -1.f; + } + return sum / denom; + } + + template + float computeJetMassFromTracksMass(TRACKS const& tracks) + { + double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; + + for (auto const& trk : tracks) { + const double pt = trk.pt(); + const double phi = trk.phi(); + const double eta = trk.eta(); + + const double px = pt * std::cos(phi); + const double py = pt * std::sin(phi); + const double pz = pt * std::sinh(eta); + const double p = std::sqrt(px * px + py * py + pz * pz); + + sumPx += px; + sumPy += py; + sumPz += pz; + sumE += p; // massless + } + + const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); + return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; + } + + void init(o2::framework::InitContext&) + { + eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); + trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); + + auto h = registry.get(HIST("h_jet_counter")); + h->GetXaxis()->SetBinLabel(1, "All jets"); + h->GetXaxis()->SetBinLabel(2, "Ds-tagged jets"); + } + + Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); + Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; + + void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) + { + registry.fill(HIST("h_collisions"), 0.5); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + + registry.fill(HIST("h_collisions"), 1.5); + + for (auto const& track : tracks) { + if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { + continue; + } + registry.fill(HIST("h_track_pt"), track.pt()); + registry.fill(HIST("h_track_eta"), track.eta()); + registry.fill(HIST("h_track_phi"), track.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); + + void processDataCharged(soa::Filtered::iterator const& collision, + soa::Filtered const& jets) + { + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { + return; + } + for (const auto& jet : jets) { + registry.fill(HIST("h_jet_pt"), jet.pt()); + registry.fill(HIST("h_jet_eta"), jet.eta()); + registry.fill(HIST("h_jet_phi"), jet.phi()); + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); + + void processDataChargedSubstructure(aod::JetCollision const& collision, + soa::Join const& jets, + aod::CandidatesDsData const&, + aod::JetTracks const&) + { + registry.fill(HIST("h_collision_counter"), 2.0); + if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || + !(std::abs(collision.posZ()) < vertexZCut)) { + return; + } + registry.fill(HIST("h_collision_counter"), 3.0); + + for (const auto& jet : jets) { + + registry.fill(HIST("h_jet_counter"), 0.5); + + bool hasDs = false; + + TVector3 jetVector(jet.px(), jet.py(), jet.pz()); + + // Compute jet-level quantities once (independent of Ds candidates) + auto jetTracks = jet.tracks_as(); + + const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); + const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); + const float mjet = computeJetMassFromTracksMass(jetTracks); + + const float R = jet.r() / 100.f; + const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; + + // Loop over Ds candidates (particle level) + for (const auto& dsCandidate : jet.candidates_as()) { + + hasDs = true; + + TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); + + // zParallel defined as longitudinal momentum fraction along the jet axis + const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); + const double axisDistance = jetutilities::deltaR(jet, dsCandidate); + + // --- Ds-level observables --- + registry.fill(HIST("h_ds_jet_projection"), zParallel); + registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); + registry.fill(HIST("h_ds_jet_distance"), axisDistance); + + registry.fill(HIST("h_ds_mass"), dsCandidate.m()); + registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); + registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); + + const float mass = dsCandidate.m(); + const float pt = dsCandidate.pt(); + const float z = zParallel; + const float dR = axisDistance; + + // Main THnSparse: invariant mass, pT, z, and ΔR + registry.fill(HIST("hSparse_ds"), mass, pt, z, dR); + + // --- output table --- + auto scores = dsCandidate.mlScores(); + constexpr int kScore0 = 0; + constexpr int kScore1 = 1; + constexpr int kScore2 = 2; + + const float s0 = (scores.size() > kScore0) ? scores[kScore0] : -999.f; + const float s1 = (scores.size() > kScore1) ? scores[kScore1] : -999.f; + const float s2 = (scores.size() > kScore2) ? scores[kScore2] : -999.f; + + distJetTable(static_cast(axisDistance), + jet.pt(), jet.eta(), jet.phi(), + static_cast(jetTracks.size()), + dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), + dsCandidate.m(), dsCandidate.y(), + s0, s1, s2, + mjet, girth, lambda12, lambda11); + } + + // Jet-level quantities (filled once per jet containing at least one Ds) + if (hasDs) { + + registry.fill(HIST("h_jet_counter"), 1.5); + + // Jet properties + registry.fill(HIST("h_ds_jet_pt"), jet.pt()); + registry.fill(HIST("h_ds_jet_eta"), jet.eta()); + registry.fill(HIST("h_ds_jet_phi"), jet.phi()); + + // Jet substructure observables + if (lambda11 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda11"), lambda11); + registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); + } + + if (lambda12 >= 0.f) { + registry.fill(HIST("h_ds_jet_lambda12"), lambda12); + registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); + } + + registry.fill(HIST("h_ds_jet_mass"), mjet); + registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); + + if (girth >= 0.f) { + registry.fill(HIST("h_ds_jet_girth"), girth); + registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); + } + } + } + } + PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); +}; +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) +{ + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-ds-spectrum-subs"})}; +} From c9ff6315613ee1435e9e6fae47fdc52c94907df7 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:19:49 -0300 Subject: [PATCH 08/15] [PWGJE] Remove old task file --- PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx | 345 ------------------- 1 file changed, 345 deletions(-) delete mode 100644 PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx diff --git a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx b/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx deleted file mode 100644 index 40f2efb4be2..00000000000 --- a/PWGJE/Tasks/jetDsSpectrumAndSubstructure.cxx +++ /dev/null @@ -1,345 +0,0 @@ -// Copyright 2019-2020 CERN and copyright holders of ALICE O2. -// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. -// All rights not expressly granted are reserved. -// -// This software is distributed under the terms of the GNU General Public -// License v3 (GPL Version 3), copied verbatim in the file "COPYING". -// -// 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. - -// Jet substructure and spectrum task for D_s mesons -// -// This task is used to reconstruct and analyse jets containing charged D_s -// mesons -// -/// \author Monalisa Melo , Universidade de São Paulo -// - -#include "PWGHF/Core/DecayChannels.h" -#include "PWGJE/Core/JetDerivedDataUtilities.h" -#include "PWGJE/Core/JetUtilities.h" -#include "PWGJE/DataModel/Jet.h" -#include "PWGJE/DataModel/JetReducedData.h" -#include "PWGJE/DataModel/JetSubtraction.h" - -#include "Common/Core/RecoDecay.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "Framework/ASoA.h" -#include "Framework/AnalysisDataModel.h" -#include "Framework/HistogramRegistry.h" -#include -#include -#include -#include -#include -#include -#include - -#include "TVector3.h" - -#include -#include -#include - -using namespace o2; -using namespace o2::framework; -using namespace o2::framework::expressions; - -namespace o2::aod -{ -namespace jet_distance -{ -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(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(HfMlScore0, hfMlScore0, float); -DECLARE_SOA_COLUMN(HfMlScore1, hfMlScore1, float); -DECLARE_SOA_COLUMN(HfMlScore2, hfMlScore2, float); - -// extra -DECLARE_SOA_COLUMN(JetMass, jetMass, float); -DECLARE_SOA_COLUMN(JetGirth, jetGirth, float); -DECLARE_SOA_COLUMN(JetThrust, jetThrust, float); // lambda_2^1 -DECLARE_SOA_COLUMN(JetLambda11, jetLambda11, float); // lambda_1^1 -} // namespace jet_distance - -DECLARE_SOA_TABLE(JetDistanceTable, "AOD", "JETDISTTABLE", - jet_distance::JetHfDist, - jet_distance::JetPt, - jet_distance::JetEta, - jet_distance::JetPhi, - jet_distance::JetNConst, - jet_distance::HfPt, - jet_distance::HfEta, - jet_distance::HfPhi, - jet_distance::HfMass, - jet_distance::HfY, - jet_distance::HfMlScore0, - jet_distance::HfMlScore1, - jet_distance::HfMlScore2, - jet_distance::JetMass, - jet_distance::JetGirth, - jet_distance::JetThrust, - jet_distance::JetLambda11); -} // namespace o2::aod - -struct JetDsSpecSubs { - HistogramRegistry registry{ - "registry", - { - {"h_collisions", "event status;event status;entries", {HistType::kTH1F, {{4, 0.0, 4.0}}}}, - {"h_track_pt", "track pT;#it{p}_{T,track} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_track_eta", "track #eta;#eta_{track};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_track_phi", "track #varphi;#varphi_{track};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_jet_pt", "jet pT;#it{p}_{T,jet} (GeV/#it{c});entries", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_eta", "jet #eta;#eta_{jet};entries", {HistType::kTH1F, {{100, -1.0, 1.0}}}}, - {"h_jet_phi", "jet #phi;#phi_{jet};entries", {HistType::kTH1F, {{80, -1.0, 7.}}}}, - {"h_collision_counter", "# of collisions;", {HistType::kTH1F, {{200, 0., 200.}}}}, - {"h_jet_counter", ";type;counts", {HistType::kTH1F, {{2, 0., 2.}}}}, - {"h_ds_jet_projection", ";z^{D_{S},jet}_{||};dN/dz^{D_{S},jet}_{||}", {HistType::kTH1F, {{1000, 0., 2.}}}}, - {"h_ds_jet_distance_vs_projection", ";#DeltaR_{D_{S},jet};z^{D_{S},jet}_{||}", {HistType::kTH2F, {{1000, 0., 1.}, {1000, 0., 2.}}}}, - {"h_ds_jet_distance", ";#DeltaR_{D_{S},jet};dN/d(#DeltaR)", {HistType::kTH1F, {{1000, 0., 1.}}}}, - {"h_ds_jet_pt", ";p_{T,D_{S} jet};dN/dp_{T,D_{S} jet}", {HistType::kTH1F, {{1000, 0., 100.}}}}, - {"h_ds_jet_eta", ";#eta_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_jet_phi", ";#phi_{D_{S} jet};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"hSparse_ds", ";m_{D_{S}};p_{T,D_{S}};z^{D_{S},jet}_{||};#DeltaR_{D_{S},jet}", {HistType::kTHnSparseF, {{60, 1.7, 2.1}, {60, 0., 100.}, {60, 0., 2.}, {60, 0., 1.0}}}}, - {"h_ds_mass", ";m_{D_{S}} (GeV/c^{2});entries", {HistType::kTH1F, {{1000, 0., 6.}}}}, - {"h_ds_eta", ";#eta_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 1.}}}}, - {"h_ds_phi", ";#phi_{D_{S}};entries", {HistType::kTH1F, {{250, -1., 7.}}}}, - {"h_ds_jet_mass", ";m_{jet}^{ch} (GeV/#it{c}^{2});entries", {HistType::kTH1F, {{200, 0., 50.}}}}, - {"h_ds_jet_lambda11", ";#lambda_{1}^{1};entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_lambda12", ";#lambda_{2}^{1} (thrust);entries", {HistType::kTH1F, {{200, 0., 1.0}}}}, - {"h_ds_jet_girth", ";g (#equiv #lambda_{1}^{1}R);entries", {HistType::kTH1F, {{200, 0., 0.5}}}}, - {"h2_dsjet_pt_lambda11", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{1}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_lambda12", ";#it{p}_{T,jet} (GeV/#it{c});#lambda_{2}^{1}", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 1.0}}}}, - {"h2_dsjet_pt_mass", ";#it{p}_{T,jet} (GeV/#it{c});m_{jet}^{ch} (GeV/#it{c}^{2})", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 50.0}}}}, - {"h2_dsjet_pt_girth", ";#it{p}_{T,jet} (GeV/#it{c});g", {HistType::kTH2F, {{100, 0., 100.}, {200, 0., 0.5}}}}, - }}; - - Configurable vertexZCut{"vertexZCut", 10.0f, "Accepted z-vertex range"}; - Configurable jetPtMin{"jetPtMin", 5.0, "minimum jet pT cut"}; - Configurable jetR{"jetR", 0.4, "jet resolution parameter"}; - - Configurable eventSelections{"eventSelections", "sel8", "choose event selection"}; - Configurable trackSelections{"trackSelections", "globalTracks", "set track selections"}; - - std::vector eventSelectionBits; - int trackSelection = -1; - - Produces distJetTable; - - template - float computeLambda(JET const& jet, TRACKS const& tracks, float a, float k) - { - if (jet.pt() <= 0.f) { - return -1.f; - } - float sum = 0.f; - for (auto const& trk : tracks) { - const float dr = jetutilities::deltaR(jet, trk); - sum += std::pow(trk.pt(), k) * std::pow(dr, a); - } - const float R = jet.r() / 100.f; - const float denom = std::pow(jet.pt(), k) * std::pow(R, a); - if (denom <= 0.f) { - return -1.f; - } - return sum / denom; - } - - template - float computeJetMassFromTracksMass(TRACKS const& tracks) - { - double sumPx = 0.0, sumPy = 0.0, sumPz = 0.0, sumE = 0.0; - - for (auto const& trk : tracks) { - const double pt = trk.pt(); - const double phi = trk.phi(); - const double eta = trk.eta(); - - const double px = pt * std::cos(phi); - const double py = pt * std::sin(phi); - const double pz = pt * std::sinh(eta); - const double p = std::sqrt(px * px + py * py + pz * pz); - - sumPx += px; - sumPy += py; - sumPz += pz; - sumE += p; // massless - } - - const double m2 = sumE * sumE - (sumPx * sumPx + sumPy * sumPy + sumPz * sumPz); - return (m2 > 0.0) ? static_cast(std::sqrt(m2)) : 0.f; - } - - void init(o2::framework::InitContext&) - { - eventSelectionBits = jetderiveddatautilities::initialiseEventSelectionBits(static_cast(eventSelections)); - trackSelection = jetderiveddatautilities::initialiseTrackSelection(static_cast(trackSelections)); - - auto h = registry.get(HIST("h_jet_counter")); - h->GetXaxis()->SetBinLabel(1, "All jets"); - h->GetXaxis()->SetBinLabel(2, "Ds-tagged jets"); - } - - Filter jetCuts = aod::jet::pt > jetPtMin&& aod::jet::r == nround(jetR.node() * 100.0f); - Filter collisionFilter = nabs(aod::jcollision::posZ) < vertexZCut; - - void processCollisions(aod::JetCollision const& collision, aod::JetTracks const& tracks) - { - registry.fill(HIST("h_collisions"), 0.5); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - - registry.fill(HIST("h_collisions"), 1.5); - - for (auto const& track : tracks) { - if (!jetderiveddatautilities::selectTrack(track, trackSelection)) { - continue; - } - registry.fill(HIST("h_track_pt"), track.pt()); - registry.fill(HIST("h_track_eta"), track.eta()); - registry.fill(HIST("h_track_phi"), track.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processCollisions, "process JE collisions", false); - - void processDataCharged(soa::Filtered::iterator const& collision, - soa::Filtered const& jets) - { - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits)) { - return; - } - for (const auto& jet : jets) { - registry.fill(HIST("h_jet_pt"), jet.pt()); - registry.fill(HIST("h_jet_eta"), jet.eta()); - registry.fill(HIST("h_jet_phi"), jet.phi()); - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataCharged, "charged jets in data", false); - - void processDataChargedSubstructure(aod::JetCollision const& collision, - soa::Join const& jets, - aod::CandidatesDsData const&, - aod::JetTracks const&) - { - registry.fill(HIST("h_collision_counter"), 2.0); - if (!jetderiveddatautilities::selectCollision(collision, eventSelectionBits) || - !(std::abs(collision.posZ()) < vertexZCut)) { - return; - } - registry.fill(HIST("h_collision_counter"), 3.0); - - for (const auto& jet : jets) { - - registry.fill(HIST("h_jet_counter"), 0.5); - - bool hasDs = false; - - TVector3 jetVector(jet.px(), jet.py(), jet.pz()); - - // Compute jet-level quantities once (independent of Ds candidates) - auto jetTracks = jet.tracks_as(); - - const float lambda11 = computeLambda(jet, jetTracks, 1.f, 1.f); - const float lambda12 = computeLambda(jet, jetTracks, 2.f, 1.f); - const float mjet = computeJetMassFromTracksMass(jetTracks); - - const float R = jet.r() / 100.f; - const float girth = (lambda11 >= 0.f) ? (lambda11 * R) : -1.f; - - // Loop over Ds candidates (particle level) - for (const auto& dsCandidate : jet.candidates_as()) { - - hasDs = true; - - TVector3 dsVector(dsCandidate.px(), dsCandidate.py(), dsCandidate.pz()); - - // zParallel defined as longitudinal momentum fraction along the jet axis - const double zParallel = (jetVector * dsVector) / (jetVector * jetVector); - const double axisDistance = jetutilities::deltaR(jet, dsCandidate); - - // --- Ds-level observables --- - registry.fill(HIST("h_ds_jet_projection"), zParallel); - registry.fill(HIST("h_ds_jet_distance_vs_projection"), axisDistance, zParallel); - registry.fill(HIST("h_ds_jet_distance"), axisDistance); - - registry.fill(HIST("h_ds_mass"), dsCandidate.m()); - registry.fill(HIST("h_ds_eta"), dsCandidate.eta()); - registry.fill(HIST("h_ds_phi"), dsCandidate.phi()); - - const float mass = dsCandidate.m(); - const float pt = dsCandidate.pt(); - const float z = zParallel; - const float dR = axisDistance; - - // Main THnSparse: invariant mass, pT, z, and ΔR - registry.fill(HIST("hSparse_ds"), mass, pt, z, dR); - - // --- output table --- - auto scores = dsCandidate.mlScores(); - constexpr int kScore0 = 0; - constexpr int kScore1 = 1; - constexpr int kScore2 = 2; - - const float s0 = (scores.size() > kScore0) ? scores[kScore0] : -999.f; - const float s1 = (scores.size() > kScore1) ? scores[kScore1] : -999.f; - const float s2 = (scores.size() > kScore2) ? scores[kScore2] : -999.f; - - distJetTable(static_cast(axisDistance), - jet.pt(), jet.eta(), jet.phi(), - static_cast(jetTracks.size()), - dsCandidate.pt(), dsCandidate.eta(), dsCandidate.phi(), - dsCandidate.m(), dsCandidate.y(), - s0, s1, s2, - mjet, girth, lambda12, lambda11); - } - - // Jet-level quantities (filled once per jet containing at least one Ds) - if (hasDs) { - - registry.fill(HIST("h_jet_counter"), 1.5); - - // Jet properties - registry.fill(HIST("h_ds_jet_pt"), jet.pt()); - registry.fill(HIST("h_ds_jet_eta"), jet.eta()); - registry.fill(HIST("h_ds_jet_phi"), jet.phi()); - - // Jet substructure observables - if (lambda11 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda11"), lambda11); - registry.fill(HIST("h2_dsjet_pt_lambda11"), jet.pt(), lambda11); - } - - if (lambda12 >= 0.f) { - registry.fill(HIST("h_ds_jet_lambda12"), lambda12); - registry.fill(HIST("h2_dsjet_pt_lambda12"), jet.pt(), lambda12); - } - - registry.fill(HIST("h_ds_jet_mass"), mjet); - registry.fill(HIST("h2_dsjet_pt_mass"), jet.pt(), mjet); - - if (girth >= 0.f) { - registry.fill(HIST("h_ds_jet_girth"), girth); - registry.fill(HIST("h2_dsjet_pt_girth"), jet.pt(), girth); - } - } - } - } - PROCESS_SWITCH(JetDsSpecSubs, processDataChargedSubstructure, "charged HF jet substructure", false); -}; -WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) -{ - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-ds-spectrum-subs"})}; -} From dd21f064dcd526e7d09136bd0ddd723c55da0794 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:21:17 -0300 Subject: [PATCH 09/15] [PWGJE] Finalize task rename and fix linter issues --- PWGJE/Tasks/jetDsSpecSubs.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGJE/Tasks/jetDsSpecSubs.cxx b/PWGJE/Tasks/jetDsSpecSubs.cxx index b19eaee33f7..40f2efb4be2 100644 --- a/PWGJE/Tasks/jetDsSpecSubs.cxx +++ b/PWGJE/Tasks/jetDsSpecSubs.cxx @@ -341,5 +341,5 @@ struct JetDsSpecSubs { }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc)}; -} \ No newline at end of file + return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-ds-spectrum-subs"})}; +} From c4b6556dccb2b16f36b25849b21b57aab1eacb3b Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:23:55 -0300 Subject: [PATCH 10/15] [PWGJE] Finalize task rename and fix linter issues --- PWGJE/Tasks/jetDsSpecSubs.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/jetDsSpecSubs.cxx b/PWGJE/Tasks/jetDsSpecSubs.cxx index 40f2efb4be2..3b464b17061 100644 --- a/PWGJE/Tasks/jetDsSpecSubs.cxx +++ b/PWGJE/Tasks/jetDsSpecSubs.cxx @@ -341,5 +341,5 @@ struct JetDsSpecSubs { }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) { - return WorkflowSpec{adaptAnalysisTask(cfgc, TaskName{"jet-ds-spectrum-subs"})}; + return WorkflowSpec{adaptAnalysisTask(cfgc)}; } From 03261af5ee287a4db904b78b303ed2fa6bbb7fdf Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:33:00 -0300 Subject: [PATCH 11/15] [PWGJE] Fix CMake after task rename --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 0275a7a66ed..569076f8f53 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -396,7 +396,7 @@ if(FastJet_FOUND) PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-ds-spectrum-subs - SOURCES jetDsSpectrumAndSubstructure.cxx + SOURCES jetDsSpecSubs.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-d0-ang-substructure From 1d843825266f114da485e62695e236a1e93f2757 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:38:08 -0300 Subject: [PATCH 12/15] [PWGJE] restore CMake --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 569076f8f53..0275a7a66ed 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -396,7 +396,7 @@ if(FastJet_FOUND) PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-ds-spectrum-subs - SOURCES jetDsSpecSubs.cxx + SOURCES jetDsSpectrumAndSubstructure.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-d0-ang-substructure From 00cca65535447381d9ff946c96d583fba430c78b Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 00:52:13 -0300 Subject: [PATCH 13/15] trigger CI From a96e2769decc6d31475a81c15524eb4f98459dbf Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 13:28:39 -0300 Subject: [PATCH 14/15] [PWGJE] Rename Ds jet analysis task --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 0275a7a66ed..64d99e49d08 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -396,7 +396,7 @@ if(FastJet_FOUND) PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-ds-spectrum-subs - SOURCES jetDsSpectrumAndSubstructure.cxx + SOURCES jetDsSpecSubs.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) o2physics_add_dpl_workflow(jet-d0-ang-substructure From b778244d406537f32bdbe42ba9f6e900bb4b7160 Mon Sep 17 00:00:00 2001 From: Monalisa Melo Date: Mon, 6 Apr 2026 13:43:23 -0300 Subject: [PATCH 15/15] [PWGJE] Fix CMakeLists --- PWGJE/Tasks/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGJE/Tasks/CMakeLists.txt b/PWGJE/Tasks/CMakeLists.txt index 64d99e49d08..a1b103a528c 100644 --- a/PWGJE/Tasks/CMakeLists.txt +++ b/PWGJE/Tasks/CMakeLists.txt @@ -395,7 +395,7 @@ if(FastJet_FOUND) SOURCES substructureDebug.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis) - o2physics_add_dpl_workflow(jet-ds-spectrum-subs + o2physics_add_dpl_workflow(jet-ds-spec-subs SOURCES jetDsSpecSubs.cxx PUBLIC_LINK_LIBRARIES O2::Framework O2Physics::PWGJECore O2Physics::AnalysisCore COMPONENT_NAME Analysis)