From ad50ace838b6a6d3f9db91bbac7f7527516a50db Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:44:28 +0100 Subject: [PATCH 1/7] Fix issue in DCA cut --- PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx index 2b10cc1f498..5137841cac4 100644 --- a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx +++ b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx @@ -1,6 +1,6 @@ // 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. +// 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". @@ -8,9 +8,11 @@ // 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. - +/// /// \file trHeAnalysis.cxx +/// /// \brief triton and helion analysis on Run 3 pp data +/// /// \author Esther Bartsch , Goethe University Frankfurt #include "MetadataHelper.h" @@ -285,6 +287,7 @@ struct TrHeAnalysis { Configurable cfgMaxDCAXY{"cfgMaxDCAXY", 10000.f, "Maximum DCA to PV in Z"}; Configurable cfgMinDCAZ{"cfgMinDCAZ", 0.f, "Minimum DCA to PV in XY"}; Configurable cfgMaxDCAZ{"cfgMaxDCAZ", 10000.f, "Maximum DCA to PV in Z"}; + Configurable cfgTrackSign{"cfgTrackSign", 0, "1: positive only, -1: negative only, 0: all tracks"}; } trackCuts; Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", @@ -459,6 +462,8 @@ struct TrHeAnalysis { if (!track.has_mcParticle()) continue; } + if (track.sign() * trackCuts.cfgTrackSign < 0) + continue; float rigidity = getRigidity(track); histos.fill(HIST("PID/histdEdx"), track.sign() * rigidity, track.tpcSignal()); @@ -584,13 +589,13 @@ struct TrHeAnalysis { continue; histCuts.at(species)->Fill(12., pt); - if (track.dcaXY() < trackCuts.cfgMinDCAXY || - track.dcaXY() > trackCuts.cfgMaxDCAXY) + if (std::abs(track.dcaXY()) < trackCuts.cfgMinDCAXY || + std::abs(track.dcaXY()) > trackCuts.cfgMaxDCAXY) continue; histCuts.at(species)->Fill(13., pt); - if (track.dcaZ() < trackCuts.cfgMinDCAZ || - track.dcaZ() > trackCuts.cfgMaxDCAZ) + if (std::abs(track.dcaZ()) < trackCuts.cfgMinDCAZ || + std::abs(track.dcaZ()) > trackCuts.cfgMaxDCAZ) continue; histCuts.at(species)->Fill(14., pt); From 791f4f6ec52f9bfbea2775d63dd002ca185ecea6 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 16:56:20 +0100 Subject: [PATCH 2/7] Update hypKfTreeCreator.cxx --- .../TableProducer/Nuspex/hypKfTreeCreator.cxx | 344 ++---------------- 1 file changed, 31 insertions(+), 313 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx b/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx index 47c40e6c550..7999fe2de82 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfTreeCreator.cxx @@ -15,26 +15,10 @@ #include "PWGLF/DataModel/LFHypernucleiKfTables.h" -#include "Common/Core/PID/TPCPIDResponse.h" #include "Common/Core/RecoDecay.h" -#include "Common/Core/trackUtilities.h" -#include "Common/DataModel/Centrality.h" -#include "Common/DataModel/EventSelection.h" -#include "Common/DataModel/TrackSelectionTables.h" - -#include "CCDB/BasicCCDBManager.h" -#include "CommonConstants/PhysicsConstants.h" -#include "DCAFitter/DCAFitterN.h" -#include "DataFormatsParameters/GRPMagField.h" -#include "DataFormatsParameters/GRPObject.h" -#include "MathUtils/BetheBlochAleph.h" -#include "DetectorsBase/GeometryManager.h" -#include "DetectorsBase/Propagator.h" -#include "Framework/ASoAHelpers.h" -#include "Framework/AnalysisDataModel.h" + #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" -#include "ReconstructionDataFormats/Track.h" #include @@ -44,13 +28,14 @@ typedef std::array arr3; namespace { -std::vector> hPt; +enum Decays { kTwoBody = 2, + kThreeBody = 3 }; struct TrackProperties { - TrackProperties() : x(0), y(0), z(0), px(0), py(0), pz(0), tpcNcls(0), itsNcls(0), tpcChi2(0), itsChi2(0), itsMeanClsSize(0), itsMeanClsSizeL(0), rigidity(0), tpcSignal(0), tpcNsigma(0), tpcNsigmaNhp(0), tpcNsigmaNlp(0), tofMass(0), dcaXY(0), dcaZ(0), isPvContributor(0), subMass(0) {} + TrackProperties() : x(0), y(0), z(0), px(0), py(0), pz(0), tpcNcls(0), itsNcls(0), tpcChi2(0), itsChi2(0), itsMeanClsSizeL(0), rigidity(0), tpcSignal(0), tpcNsigma(0), tpcNsigmaNhp(0), tpcNsigmaNlp(0), tofMass(0), dcaXY(0), dcaZ(0), isPvContributor(0), subMass(0) {} float x, y, z, px, py, pz; uint8_t tpcNcls, itsNcls; - float tpcChi2, itsChi2, itsMeanClsSize, itsMeanClsSizeL; + float tpcChi2, itsChi2, itsMeanClsSizeL; float rigidity, tpcSignal, tpcNsigma, tpcNsigmaNhp, tpcNsigmaNlp; float tofMass, dcaXY, dcaZ; bool isPvContributor; @@ -58,24 +43,18 @@ struct TrackProperties { }; struct HyperNucleus { - HyperNucleus() : pdgCode(0), isReconstructed(0), globalIndex(0), species(0), speciesMC(0), isPrimaryCandidate(0), isMatter(0), isCascade(0), isCascadeMC(0), passedEvSel(0), isMatterMC(0), passedEvSelMC(0), isPhysicalPrimary(0), collisionMcTrue(0), mass(0), y(0), pt(0), ct(0), yGen(0), ptGen(0), ctGen(0), cpaPvGen(0), cpaPv(0), cpaSv(0), maxDcaTracks(0), maxDcaTracksSv(0), dcaToPvXY(0), dcaToPvZ(0), dcaToVtxXY(0), dcaToVtxZ(0), devToPvXY(0), chi2(0), pvx(0), pvy(0), pvz(0), svx(0), svy(0), svz(0), px(0), py(0), pz(0), pvxGen(0), pvyGen(0), pvzGen(0), svxGen(0), svyGen(0), svzGen(0), pxGen(0), pyGen(0), pzGen(0), nSingleDaughters(0), nCascadeDaughters(0), mcTrue(0), mcTrueVtx(0), mcPhysicalPrimary(0), hypNucDaughter(0) {} + HyperNucleus() : pdgCode(0), isReconstructed(0), globalIndex(0), species(0), speciesMC(0), isMatter(0), passedEvSel(0), isMatterMC(0), passedEvSelMC(0), isPhysicalPrimary(0), collisionMcTrue(0), mass(0), y(0), pt(0), ct(0), yGen(0), ptGen(0), ctGen(0), cpaPvGen(0), cpaPv(0), cpaSv(0), maxDcaTracks(0), maxDcaTracksSv(0), dcaToPvXY(0), dcaToPvZ(0), dcaToVtxXY(0), dcaToVtxZ(0), devToPvXY(0), chi2(0), pvx(0), pvy(0), pvz(0), svx(0), svy(0), svz(0), px(0), py(0), pz(0), pvxGen(0), pvyGen(0), pvzGen(0), svxGen(0), svyGen(0), svzGen(0), pxGen(0), pyGen(0), pzGen(0), nSingleDaughters(0), mcTrue(0), mcTrueVtx(0), mcPhysicalPrimary(0) {} int pdgCode, isReconstructed, globalIndex; uint8_t species, speciesMC; - bool isPrimaryCandidate, isMatter, isCascade, isCascadeMC, passedEvSel, isMatterMC, passedEvSelMC, isPhysicalPrimary, collisionMcTrue; + bool isMatter, passedEvSel, isMatterMC, passedEvSelMC, isPhysicalPrimary, collisionMcTrue; float mass, y, pt, ct, yGen, ptGen, ctGen, cpaPvGen, cpaPv, cpaSv, maxDcaTracks, maxDcaTracksSv; float dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, devToPvXY, chi2; float pvx, pvy, pvz, svx, svy, svz, px, py, pz; float pvxGen, pvyGen, pvzGen, svxGen, svyGen, svzGen, pxGen, pyGen, pzGen; - int nSingleDaughters, nCascadeDaughters, cent, occu, runNumber; + int nSingleDaughters, cent, occu, runNumber; bool mcTrue, mcTrueVtx, mcPhysicalPrimary; std::vector daughterTracks; std::vector subDaughterMassVec; - HyperNucleus* hypNucDaughter; - ~HyperNucleus() - { - if (hypNucDaughter) - delete hypNucDaughter; - } }; } // namespace namespace o2::aod @@ -129,7 +108,6 @@ DECLARE_SOA_COLUMN(D1TPCnCls, d1TPCnCls, uint8_t); DECLARE_SOA_COLUMN(D1TPCchi2, d1TPCchi2, float); DECLARE_SOA_COLUMN(D1ITSnCls, d1ITSnCls, uint8_t); DECLARE_SOA_COLUMN(D1ITSchi2, d1ITSchi2, float); -DECLARE_SOA_COLUMN(D1ITSmeanClsSize, d1ITSmeanClsSize, float); DECLARE_SOA_COLUMN(D1ITSmeanClsSizeL, d1ITSmeanClsSizeL, float); DECLARE_SOA_COLUMN(D1Rigidity, d1Rigidity, float); DECLARE_SOA_COLUMN(D1TPCsignal, d1TPCsignal, float); @@ -150,7 +128,6 @@ DECLARE_SOA_COLUMN(D2TPCnCls, d2TPCnCls, uint8_t); DECLARE_SOA_COLUMN(D2TPCchi2, d2TPCchi2, float); DECLARE_SOA_COLUMN(D2ITSnCls, d2ITSnCls, uint8_t); DECLARE_SOA_COLUMN(D2ITSchi2, d2ITSchi2, float); -DECLARE_SOA_COLUMN(D2ITSmeanClsSize, d2ITSmeanClsSize, float); DECLARE_SOA_COLUMN(D2ITSmeanClsSizeL, d2ITSmeanClsSizeL, float); DECLARE_SOA_COLUMN(D2Rigidity, d2Rigidity, float); DECLARE_SOA_COLUMN(D2TPCsignal, d2TPCsignal, float); @@ -171,7 +148,6 @@ DECLARE_SOA_COLUMN(D3TPCnCls, d3TPCnCls, uint8_t); DECLARE_SOA_COLUMN(D3TPCchi2, d3TPCchi2, float); DECLARE_SOA_COLUMN(D3ITSnCls, d3ITSnCls, uint8_t); DECLARE_SOA_COLUMN(D3ITSchi2, d3ITSchi2, float); -DECLARE_SOA_COLUMN(D3ITSmeanClsSize, d3ITSmeanClsSize, float); DECLARE_SOA_COLUMN(D3ITSmeanClsSizeL, d3ITSmeanClsSizeL, float); DECLARE_SOA_COLUMN(D3Rigidity, d3Rigidity, float); DECLARE_SOA_COLUMN(D3TPCsignal, d3TPCsignal, float); @@ -185,120 +161,23 @@ DECLARE_SOA_COLUMN(D1d2Mass, d1d2Mass, float); DECLARE_SOA_COLUMN(D1d3Mass, d1d3Mass, float); DECLARE_SOA_COLUMN(D2d3Mass, d2d3Mass, float); DECLARE_SOA_COLUMN(D3IsPvContributor, d3IsPvContributor, bool); -DECLARE_SOA_COLUMN(D0X, d0X, float); -DECLARE_SOA_COLUMN(D0Y, d0Y, float); -DECLARE_SOA_COLUMN(D0Z, d0Z, float); -DECLARE_SOA_COLUMN(D0Px, d0Px, float); -DECLARE_SOA_COLUMN(D0Py, d0Py, float); -DECLARE_SOA_COLUMN(D0Pz, d0Pz, float); -DECLARE_SOA_COLUMN(D0Mass, d0Mass, float); -DECLARE_SOA_COLUMN(D0ct, d0ct, float); -DECLARE_SOA_COLUMN(D0cosPa, d0cosPa, float); -DECLARE_SOA_COLUMN(D0dcaTracks, d0dcaTracks, float); -DECLARE_SOA_COLUMN(D0dcaTracksTv, d0dcaTracksTv, float); -DECLARE_SOA_COLUMN(D0dcaToPvXY, d0dcaToPvXY, float); -DECLARE_SOA_COLUMN(D0dcaToPvZ, d0dcaToPvZ, float); -DECLARE_SOA_COLUMN(D0dcaToSvXY, d0dcaToSvXY, float); -DECLARE_SOA_COLUMN(D0dcaToSvZ, d0dcaToSvZ, float); -DECLARE_SOA_COLUMN(D0chi2, d0chi2, float); -DECLARE_SOA_COLUMN(Sd1X, sd1X, float); -DECLARE_SOA_COLUMN(Sd1Y, sd1Y, float); -DECLARE_SOA_COLUMN(Sd1Z, sd1Z, float); -DECLARE_SOA_COLUMN(Sd1Px, sd1Px, float); -DECLARE_SOA_COLUMN(Sd1Py, sd1Py, float); -DECLARE_SOA_COLUMN(Sd1Pz, sd1Pz, float); -DECLARE_SOA_COLUMN(Sd1TPCnCls, sd1TPCnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd1TPCchi2, sd1TPCchi2, float); -DECLARE_SOA_COLUMN(Sd1ITSnCls, sd1ITSnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd1ITSchi2, sd1ITSchi2, float); -DECLARE_SOA_COLUMN(Sd1ITSmeanClsSize, sd1ITSmeanClsSize, float); -DECLARE_SOA_COLUMN(Sd1ITSmeanClsSizeL, sd1ITSmeanClsSizeL, float); -DECLARE_SOA_COLUMN(Sd1Rigidity, sd1Rigidity, float); -DECLARE_SOA_COLUMN(Sd1TPCsignal, sd1TPCsignal, float); -DECLARE_SOA_COLUMN(Sd1TPCnSigma, sd1TPCnSigma, float); -DECLARE_SOA_COLUMN(Sd1TPCnSigmaNhp, sd1TPCnSigmaNhp, float); -DECLARE_SOA_COLUMN(Sd1TPCnSigmaNlp, sd1TPCnSigmaNlp, float); -DECLARE_SOA_COLUMN(Sd1TOFmass, sd1TOFmass, float); -DECLARE_SOA_COLUMN(Sd1DcaXY, sd1DcaXY, float); -DECLARE_SOA_COLUMN(Sd1DcaZ, sd1DcaZ, float); -DECLARE_SOA_COLUMN(Sd1IsPvContributor, sd1IsPvContributor, bool); -DECLARE_SOA_COLUMN(Sd2X, sd2X, float); -DECLARE_SOA_COLUMN(Sd2Y, sd2Y, float); -DECLARE_SOA_COLUMN(Sd2Z, sd2Z, float); -DECLARE_SOA_COLUMN(Sd2Px, sd2Px, float); -DECLARE_SOA_COLUMN(Sd2Py, sd2Py, float); -DECLARE_SOA_COLUMN(Sd2Pz, sd2Pz, float); -DECLARE_SOA_COLUMN(Sd2TPCnCls, sd2TPCnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd2TPCchi2, sd2TPCchi2, float); -DECLARE_SOA_COLUMN(Sd2ITSnCls, sd2ITSnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd2ITSchi2, sd2ITSchi2, float); -DECLARE_SOA_COLUMN(Sd2ITSmeanClsSize, sd2ITSmeanClsSize, float); -DECLARE_SOA_COLUMN(Sd2ITSmeanClsSizeL, sd2ITSmeanClsSizeL, float); -DECLARE_SOA_COLUMN(Sd2Rigidity, sd2Rigidity, float); -DECLARE_SOA_COLUMN(Sd2TPCsignal, sd2TPCsignal, float); -DECLARE_SOA_COLUMN(Sd2TPCnSigma, sd2TPCnSigma, float); -DECLARE_SOA_COLUMN(Sd2TPCnSigmaNhp, sd2TPCnSigmaNhp, float); -DECLARE_SOA_COLUMN(Sd2TPCnSigmaNlp, sd2TPCnSigmaNlp, float); -DECLARE_SOA_COLUMN(Sd2TOFmass, sd2TOFmass, float); -DECLARE_SOA_COLUMN(Sd2DcaXY, sd2DcaXY, float); -DECLARE_SOA_COLUMN(Sd2DcaZ, sd2DcaZ, float); -DECLARE_SOA_COLUMN(Sd2IsPvContributor, sd2IsPvContributor, bool); -DECLARE_SOA_COLUMN(Sd3X, sd3X, float); -DECLARE_SOA_COLUMN(Sd3Y, sd3Y, float); -DECLARE_SOA_COLUMN(Sd3Z, sd3Z, float); -DECLARE_SOA_COLUMN(Sd3Px, sd3Px, float); -DECLARE_SOA_COLUMN(Sd3Py, sd3Py, float); -DECLARE_SOA_COLUMN(Sd3Pz, sd3Pz, float); -DECLARE_SOA_COLUMN(Sd3TPCnCls, sd3TPCnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd3TPCchi2, sd3TPCchi2, float); -DECLARE_SOA_COLUMN(Sd3ITSnCls, sd3ITSnCls, uint8_t); -DECLARE_SOA_COLUMN(Sd3ITSchi2, sd3ITSchi2, float); -DECLARE_SOA_COLUMN(Sd3ITSmeanClsSize, sd3ITSmeanClsSize, float); -DECLARE_SOA_COLUMN(Sd3ITSmeanClsSizeL, sd3ITSmeanClsSizeL, float); -DECLARE_SOA_COLUMN(Sd3Rigidity, sd3Rigidity, float); -DECLARE_SOA_COLUMN(Sd3TPCsignal, sd3TPCsignal, float); -DECLARE_SOA_COLUMN(Sd3TPCnSigma, sd3TPCnSigma, float); -DECLARE_SOA_COLUMN(Sd3TPCnSigmaNhp, sd3TPCnSigmaNhp, float); -DECLARE_SOA_COLUMN(Sd3TPCnSigmaNlp, sd3TPCnSigmaNlp, float); -DECLARE_SOA_COLUMN(Sd3TOFmass, sd3TOFmass, float); -DECLARE_SOA_COLUMN(Sd3DcaXY, sd3DcaXY, float); -DECLARE_SOA_COLUMN(Sd3DcaZ, sd3DcaZ, float); -DECLARE_SOA_COLUMN(Sd3IsPvContributor, sd3IsPvContributor, bool); -DECLARE_SOA_COLUMN(Sd1sd2Mass, sd1sd2Mass, float); -DECLARE_SOA_COLUMN(Sd1sd3Mass, sd1sd3Mass, float); -DECLARE_SOA_COLUMN(Sd2sd3Mass, sd2sd3Mass, float); -DECLARE_SOA_COLUMN(D1sd1Mass, d1sd1Mass, float); -DECLARE_SOA_COLUMN(D1sd2Mass, d1sd2Mass, float); -DECLARE_SOA_COLUMN(D1sd3Mass, d1sd3Mass, float); } // namespace hypkftree #define HYPKFGENBASE hypkftree::SpeciesMC, mcparticle::PdgCode, hypkftree::IsMatterGen, hypkftree::IsReconstructed, hykfmc::IsPhysicalPrimary, hypkftree::PassedEvSelMC, hypkftree::YGen, hypkftree::PtGen, hypkftree::CtGen #define HYPKFGENEXT hypkftree::CpaPvGen, hypkftree::PxGen, hypkftree::PyGen, hypkftree::PzGen, hypkftree::PvxGen, hypkftree::PvyGen, hypkftree::PvzGen, hypkftree::SvxGen, hypkftree::SvyGen, hypkftree::SvzGen -#define HYPKFGENCAS hypkftree::TvxGen, hypkftree::TvyGen, hypkftree::TvzGen - #define HYPKFHYPNUC hykfmc::Species, hypkftree::IsMatter, hypkftree::Centrality, hypkftree::Occupancy, hypkftree::RunNumber, hykfmccoll::PassedEvSel, hykfhyp::Mass, hypkftree::Y, track::Pt, hypkftree::Ct, hypkftree::CosPa, hypkftree::DcaTracks, hypkftree::DcaTrackSv, hykfhyp::DcaToPvXY, hykfhyp::DcaToPvZ, hykfhyp::DevToPvXY, hykfhyp::Chi2, hypkftree::Pvx, hypkftree::Pvy, hypkftree::Pvz, hykfmc::Svx, hykfmc::Svy, hykfmc::Svz, hykfhyp::Px, hykfhyp::Py, hykfhyp::Pz, hypkftree::CollMcTrue #define HYPKFHYPNUCMC hypkftree::McTrue, hykfmc::IsPhysicalPrimary -#define HYPKFD0 hypkftree::Tvx, hypkftree::Tvy, hypkftree::Tvz, hypkftree::D0X, hypkftree::D0Y, hypkftree::D0Z, hypkftree::D0Px, hypkftree::D0Py, hypkftree::D0Pz, hypkftree::D0Mass, hypkftree::D0ct, hypkftree::D0cosPa, hypkftree::D0dcaTracks, hypkftree::D0dcaToPvXY, hypkftree::D0dcaToPvZ, hypkftree::D0dcaToSvXY, hypkftree::D0dcaToSvZ, hypkftree::D0chi2 - #define HYPKFD1 hypkftree::D1X, hypkftree::D1Y, hypkftree::D1Z, hypkftree::D1Px, hypkftree::D1Py, hypkftree::D1Pz, hypkftree::D1TPCnCls, hypkftree::D1TPCchi2, hypkftree::D1ITSnCls, hypkftree::D1ITSchi2, hypkftree::D1ITSmeanClsSizeL, hypkftree::D1Rigidity, hypkftree::D1TPCsignal, hypkftree::D1TPCnSigma, hypkftree::D1TPCnSigmaNhp, hypkftree::D1TPCnSigmaNlp, hypkftree::D1TOFmass, hypkftree::D1DcaXY, hypkftree::D1DcaZ, hypkftree::D1IsPvContributor #define HYPKFD2 hypkftree::D2X, hypkftree::D2Y, hypkftree::D2Z, hypkftree::D2Px, hypkftree::D2Py, hypkftree::D2Pz, hypkftree::D2TPCnCls, hypkftree::D2TPCchi2, hypkftree::D2ITSnCls, hypkftree::D2ITSchi2, hypkftree::D2ITSmeanClsSizeL, hypkftree::D2Rigidity, hypkftree::D2TPCsignal, hypkftree::D2TPCnSigma, hypkftree::D2TPCnSigmaNhp, hypkftree::D2TPCnSigmaNlp, hypkftree::D2TOFmass, hypkftree::D2DcaXY, hypkftree::D2DcaZ, hypkftree::D2IsPvContributor #define HYPKFD3 hypkftree::D3X, hypkftree::D3Y, hypkftree::D3Z, hypkftree::D3Px, hypkftree::D3Py, hypkftree::D3Pz, hypkftree::D3TPCnCls, hypkftree::D3TPCchi2, hypkftree::D3ITSnCls, hypkftree::D3ITSchi2, hypkftree::D3ITSmeanClsSizeL, hypkftree::D3Rigidity, hypkftree::D3TPCsignal, hypkftree::D3TPCnSigma, hypkftree::D3TPCnSigmaNhp, hypkftree::D3TPCnSigmaNlp, hypkftree::D3TOFmass, hypkftree::D3DcaXY, hypkftree::D3DcaZ, hypkftree::D3IsPvContributor -#define HYPKFSD1 hypkftree::Sd1X, hypkftree::Sd1Y, hypkftree::Sd1Z, hypkftree::Sd1Px, hypkftree::Sd1Py, hypkftree::Sd1Pz, hypkftree::Sd1TPCnCls, hypkftree::Sd1TPCchi2, hypkftree::Sd1ITSnCls, hypkftree::Sd1ITSchi2, hypkftree::Sd1ITSmeanClsSizeL, hypkftree::Sd1Rigidity, hypkftree::Sd1TPCsignal, hypkftree::Sd1TPCnSigma, hypkftree::Sd1TPCnSigmaNhp, hypkftree::Sd1TPCnSigmaNlp, hypkftree::Sd1TOFmass, hypkftree::Sd1DcaXY, hypkftree::Sd1DcaZ, hypkftree::Sd1IsPvContributor - -#define HYPKFSD2 hypkftree::Sd2X, hypkftree::Sd2Y, hypkftree::Sd2Z, hypkftree::Sd2Px, hypkftree::Sd2Py, hypkftree::Sd2Pz, hypkftree::Sd2TPCnCls, hypkftree::Sd2TPCchi2, hypkftree::Sd2ITSnCls, hypkftree::Sd2ITSchi2, hypkftree::Sd2ITSmeanClsSizeL, hypkftree::Sd2Rigidity, hypkftree::Sd2TPCsignal, hypkftree::Sd2TPCnSigma, hypkftree::Sd2TPCnSigmaNhp, hypkftree::Sd2TPCnSigmaNlp, hypkftree::Sd2TOFmass, hypkftree::Sd2DcaXY, hypkftree::Sd2DcaZ, hypkftree::Sd2IsPvContributor - -#define HYPKFSD3 hypkftree::Sd3X, hypkftree::Sd3Y, hypkftree::Sd3Z, hypkftree::Sd3Px, hypkftree::Sd3Py, hypkftree::Sd3Pz, hypkftree::Sd3TPCnCls, hypkftree::Sd3TPCchi2, hypkftree::Sd3ITSnCls, hypkftree::Sd3ITSchi2, hypkftree::Sd3ITSmeanClsSizeL, hypkftree::Sd3Rigidity, hypkftree::Sd3TPCsignal, hypkftree::Sd3TPCnSigma, hypkftree::Sd3TPCnSigmaNhp, hypkftree::Sd3TPCnSigmaNlp, hypkftree::Sd3TOFmass, hypkftree::Sd3DcaXY, hypkftree::Sd3DcaZ, hypkftree::Sd3IsPvContributor - #define HYPKFSDMASS hypkftree::D1d2Mass, hypkftree::D1d3Mass, hypkftree::D2d3Mass -#define HYPKFSSDMASS hypkftree::Sd1sd2Mass, hypkftree::Sd1sd3Mass, hypkftree::Sd2sd3Mass -#define HYPKFCSDMASS hypkftree::D1sd1Mass, hypkftree::D1sd2Mass, hypkftree::D1sd3Mass DECLARE_SOA_TABLE(HypKfGens, "AOD", "HYPKFGEN", HYPKFGENBASE); using HypKfGen = HypKfGens::iterator; @@ -315,17 +194,6 @@ using HypKfSingleThreeBodyCandidate = HypKfSingleThreeBodyCandidates::iterator; DECLARE_SOA_TABLE(HypKfMcSingleThreeBodyCandidates, "AOD", "HYPKFMCCAND3", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD1, HYPKFD2, HYPKFD3, HYPKFSDMASS); using HypKfMcSingleThreeBodyCandidate = HypKfMcSingleThreeBodyCandidates::iterator; -DECLARE_SOA_TABLE(HypKfCascadeTwoThreeCandidates, "AOD", "HYPKFCAND23", HYPKFHYPNUC, HYPKFHYPNUCMC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS, HYPKFCSDMASS); -using HypKfCascadeTwoThreeCandidate = HypKfCascadeTwoThreeCandidates::iterator; - -DECLARE_SOA_TABLE(HypKfMcCascadeTwoThreeCandidates, "AOD", "HYPKFMCCAND23", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD0, HYPKFD1, HYPKFSD1, HYPKFSD2, HYPKFSD3, HYPKFSSDMASS, HYPKFCSDMASS); -using HypKfMcCascadeTwoThreeCandidate = HypKfMcCascadeTwoThreeCandidates::iterator; - -DECLARE_SOA_TABLE(HypKfCascadeThreeTwoCandidates, "AOD", "HYPKFCAND32", HYPKFHYPNUC, HYPKFHYPNUCMC, HYPKFD0, HYPKFD1, HYPKFD2, HYPKFSDMASS, HYPKFSD1, HYPKFSD2); -using HypKfCascadeThreeTwoCandidate = HypKfCascadeThreeTwoCandidates::iterator; - -DECLARE_SOA_TABLE(HypKfMcCascadeThreeTwoCandidates, "AOD", "HYPKFMCCAND32", HYPKFGENBASE, HYPKFGENEXT, HYPKFHYPNUC, HYPKFD0, HYPKFD1, HYPKFD2, HYPKFSDMASS, HYPKFSD1, HYPKFSD2); -using HypKfMcCascadeThreeTwoCandidate = HypKfMcCascadeThreeTwoCandidates::iterator; } // namespace o2::aod struct HypKfTreeCreator { @@ -336,15 +204,10 @@ struct HypKfTreeCreator { Produces outputTableMcTwo; Produces outputTableThree; Produces outputTableMcThree; - Produces outputTableTwoThree; - Produces outputTableMcTwoThree; - Produces outputTableThreeTwo; - Produces outputTableMcThreeTwo; PresliceUnsorted perMcParticle = aod::hykfhyp::hypKfMcPartId; Configurable cfgSpecies{"cfgSpecies", 0, "Select species"}; Configurable cfgNprimDaughters{"cfgNprimDaughters", 0, "Number of primary daughters"}; - Configurable cfgNsecDaughters{"cfgNsecDaughters", 0, "Number of secondary daughters (cascades only)"}; Configurable cfgMCGenerated{"cfgMCGenerated", false, "create MC generated tree"}; Configurable cfgMCReconstructed{"cfgMCReconstructed", false, "create MC reconstructed tree"}; Configurable cfgMCCombined{"cfgMCCombined", false, "create MC tree containig generated and reconstructed"}; @@ -354,33 +217,11 @@ struct HypKfTreeCreator { void init(InitContext const&) { - const AxisSpec axisPt{10, 0., 10., "#it{p}_{T} (GeV/#it{c})"}; - hPt.resize(3); - hPt[0] = histos.add("hGen", "", HistType::kTH1F, {axisPt}); - hPt[0]->Sumw2(); - hPt[1] = histos.add("hRec", "", HistType::kTH1F, {axisPt}); - hPt[1]->Sumw2(); - hPt[2] = histos.add("hEff", "", HistType::kTH1F, {axisPt}); isMC = false; } - //___________________________________________________________________________________________________________________________________________________________ - void processData(aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub) - { - for (const auto& hypNuc : hypNucs) { - if (cfgSpecies && std::abs(hypNuc.species()) != cfgSpecies) - continue; - HyperNucleus candidate, hypNucDaughter; - fillCandidatePrim(candidate, hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - if (hypNuc.hypDaughterId() >= 0) { - fillCandidateSec(hypNucDaughter, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - } - fillTable(candidate, hypNucDaughter); - } - } - PROCESS_SWITCH(HypKfTreeCreator, processData, "single tree", false); //___________________________________________________________________________________________________________________________________________________________ - void fillTable(HyperNucleus& cand, HyperNucleus& hypDaughter) + void fillTable(HyperNucleus& cand) { if (isMC && cfgMCGenerated) outputMcGenTable( @@ -389,19 +230,16 @@ struct HypKfTreeCreator { if (!cand.isReconstructed) { cand.daughterTracks.resize(4); cand.subDaughterMassVec.resize(4); - hypDaughter.daughterTracks.resize(4); - hypDaughter.subDaughterMassVec.resize(8); } - if (cfgNprimDaughters == 2 && cfgNsecDaughters == 0) { // o2-linter: disable=magic-number (To be checked) + if (cfgNprimDaughters == Decays::kTwoBody) { const auto& d1 = cand.daughterTracks.at(0); const auto& d2 = cand.daughterTracks.at(1); if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) outputTableTwo( cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, - cand.mcTrue, cand.mcPhysicalPrimary, - d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, + cand.mcTrue, cand.mcPhysicalPrimary, d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, d2.x, d2.y, d2.z, d2.px, d2.py, d2.pz, d2.tpcNcls, d2.tpcChi2, d2.itsNcls, d2.itsChi2, d2.itsMeanClsSizeL, d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor); @@ -417,7 +255,7 @@ struct HypKfTreeCreator { d2.x, d2.y, d2.z, d2.px, d2.py, d2.pz, d2.tpcNcls, d2.tpcChi2, d2.itsNcls, d2.itsChi2, d2.itsMeanClsSizeL, d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor); } - if (((!isMC && cand.isPrimaryCandidate) || (isMC && cand.isPhysicalPrimary)) && ((cfgNprimDaughters == 3 && cfgNsecDaughters == 0) || (cfgNsecDaughters == 3 && cfgSpecies == 0))) { // o2-linter: disable=magic-number (To be checked) + if (cfgNprimDaughters == Decays::kThreeBody) { const auto& d1 = cand.daughterTracks.at(0); const auto& d2 = cand.daughterTracks.at(1); const auto& d3 = cand.daughterTracks.at(2); @@ -448,103 +286,6 @@ struct HypKfTreeCreator { d3.rigidity, d3.tpcSignal, d3.tpcNsigma, d3.tpcNsigmaNhp, d3.tpcNsigmaNlp, d3.tofMass, d3.dcaXY, d3.dcaZ, d3.isPvContributor, d1.subMass, d2.subMass, d3.subMass); } - if ((!isMC && !cand.isCascade) || (isMC && !cand.isCascadeMC)) - return; - if (cfgNprimDaughters == 2 && cfgNsecDaughters == 3) { // o2-linter: disable=magic-number (To be checked) - const auto& d0 = cand.daughterTracks.at(0); - const auto& d1 = cand.daughterTracks.at(1); - const auto& sd1 = hypDaughter.daughterTracks.at(0); - const auto& sd2 = hypDaughter.daughterTracks.at(1); - const auto& sd3 = hypDaughter.daughterTracks.at(2); - if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) - outputTableTwoThree( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, - cand.mcTrue, cand.mcPhysicalPrimary, - hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, - hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, - d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, - d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, - sd1.x, sd1.y, sd1.z, sd1.px, sd1.py, sd1.pz, sd1.tpcNcls, sd1.tpcChi2, sd1.itsNcls, sd1.itsChi2, sd1.itsMeanClsSizeL, - sd1.rigidity, sd1.tpcSignal, sd1.tpcNsigma, sd1.tpcNsigmaNhp, sd1.tpcNsigmaNlp, sd1.tofMass, sd1.dcaXY, sd1.dcaZ, sd1.isPvContributor, - sd2.x, sd2.y, sd2.z, sd2.px, sd2.py, sd2.pz, sd2.tpcNcls, sd2.tpcChi2, sd2.itsNcls, sd2.itsChi2, sd2.itsMeanClsSizeL, - sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor, - sd3.x, sd3.y, sd3.z, sd3.px, sd3.py, sd3.pz, sd3.tpcNcls, sd3.tpcChi2, sd3.itsNcls, sd3.itsChi2, sd3.itsMeanClsSizeL, - sd3.rigidity, sd3.tpcSignal, sd3.tpcNsigma, sd3.tpcNsigmaNhp, sd3.tpcNsigmaNlp, sd3.tofMass, sd3.dcaXY, sd3.dcaZ, sd3.isPvContributor, - sd1.subMass, sd2.subMass, sd3.subMass, cand.subDaughterMassVec.at(0), cand.subDaughterMassVec.at(1), cand.subDaughterMassVec.at(2)); - if (isMC && cfgMCCombined) - outputTableMcTwoThree( - cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, - cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, - cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, - hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, - hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, - d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, - d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, - sd1.x, sd1.y, sd1.z, sd1.px, sd1.py, sd1.pz, sd1.tpcNcls, sd1.tpcChi2, sd1.itsNcls, sd1.itsChi2, sd1.itsMeanClsSizeL, - sd1.rigidity, sd1.tpcSignal, sd1.tpcNsigma, sd1.tpcNsigmaNhp, sd1.tpcNsigmaNlp, sd1.tofMass, sd1.dcaXY, sd1.dcaZ, sd1.isPvContributor, - sd2.x, sd2.y, sd2.z, sd2.px, sd2.py, sd2.pz, sd2.tpcNcls, sd2.tpcChi2, sd2.itsNcls, sd2.itsChi2, sd2.itsMeanClsSizeL, - sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor, - sd3.x, sd3.y, sd3.z, sd3.px, sd3.py, sd3.pz, sd3.tpcNcls, sd3.tpcChi2, sd3.itsNcls, sd3.itsChi2, sd3.itsMeanClsSizeL, - sd3.rigidity, sd3.tpcSignal, sd3.tpcNsigma, sd3.tpcNsigmaNhp, sd3.tpcNsigmaNlp, sd3.tofMass, sd3.dcaXY, sd3.dcaZ, sd3.isPvContributor, - sd1.subMass, sd2.subMass, sd3.subMass, cand.subDaughterMassVec.at(0), cand.subDaughterMassVec.at(1), cand.subDaughterMassVec.at(2)); - } - if (cfgNprimDaughters == 3 && cfgNsecDaughters == 1) { // o2-linter: disable=magic-number (To be checked) - const auto& d0 = cand.daughterTracks.at(0); - const auto& d1 = cand.daughterTracks.at(1); - const auto& d2 = cand.daughterTracks.at(2); - const auto& sd1 = hypDaughter.daughterTracks.at(0); - const auto& sd2 = hypDaughter.daughterTracks.at(1); - if (!isMC || (isMC && cfgMCReconstructed && cand.isReconstructed)) - outputTableThreeTwo( - cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, - cand.mcTrue, cand.mcPhysicalPrimary, hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, - hypDaughter.cpaPv, hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, - d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, - d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, - d2.x, d2.y, d2.z, d2.px, d2.py, d2.pz, d2.tpcNcls, d2.tpcChi2, d2.itsNcls, d2.itsChi2, d2.itsMeanClsSizeL, - d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor, - d0.subMass, d1.subMass, d2.subMass, - sd1.x, sd1.y, sd1.z, sd1.px, sd1.py, sd1.pz, sd1.tpcNcls, sd1.tpcChi2, sd1.itsNcls, sd1.itsChi2, sd1.itsMeanClsSizeL, - sd1.rigidity, sd1.tpcSignal, sd1.tpcNsigma, sd1.tpcNsigmaNhp, sd1.tpcNsigmaNlp, sd1.tofMass, sd1.dcaXY, sd1.dcaZ, sd1.isPvContributor, - sd2.x, sd2.y, sd2.z, sd2.px, sd2.py, sd2.pz, sd2.tpcNcls, sd2.tpcChi2, sd2.itsNcls, sd2.itsChi2, sd2.itsMeanClsSizeL, - sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor); - if (isMC && cfgMCCombined) - outputTableMcThreeTwo( - cand.speciesMC, cand.pdgCode, cand.isMatterMC, cand.isReconstructed, cand.isPhysicalPrimary, cand.passedEvSelMC, cand.yGen, cand.ptGen, cand.ctGen, - cand.cpaPvGen, cand.pxGen, cand.pyGen, cand.pzGen, cand.pvxGen, cand.pvyGen, cand.pvzGen, cand.svxGen, cand.svyGen, cand.svzGen, - cand.species, cand.isMatter, cand.cent, cand.occu, cand.runNumber, cand.passedEvSel, cand.mass, cand.y, cand.pt, cand.ct, cand.cpaPv, cand.maxDcaTracks, cand.maxDcaTracksSv, - cand.dcaToPvXY, cand.dcaToPvZ, cand.devToPvXY, cand.chi2, cand.pvx, cand.pvy, cand.pvz, cand.svx, cand.svy, cand.svz, cand.px, cand.py, cand.pz, cand.collisionMcTrue, - hypDaughter.svx, hypDaughter.svy, hypDaughter.svz, d0.x, d0.y, d0.z, d0.px, d0.py, d0.pz, hypDaughter.mass, hypDaughter.ct, hypDaughter.cpaPv, - hypDaughter.maxDcaTracks, hypDaughter.dcaToPvXY, hypDaughter.dcaToPvZ, hypDaughter.dcaToVtxXY, hypDaughter.dcaToVtxZ, hypDaughter.chi2, - d1.x, d1.y, d1.z, d1.px, d1.py, d1.pz, d1.tpcNcls, d1.tpcChi2, d1.itsNcls, d1.itsChi2, d1.itsMeanClsSizeL, - d1.rigidity, d1.tpcSignal, d1.tpcNsigma, d1.tpcNsigmaNhp, d1.tpcNsigmaNlp, d1.tofMass, d1.dcaXY, d1.dcaZ, d1.isPvContributor, - d2.x, d2.y, d2.z, d2.px, d2.py, d2.pz, d2.tpcNcls, d2.tpcChi2, d2.itsNcls, d2.itsChi2, d2.itsMeanClsSizeL, - d2.rigidity, d2.tpcSignal, d2.tpcNsigma, d2.tpcNsigmaNhp, d2.tpcNsigmaNlp, d2.tofMass, d2.dcaXY, d2.dcaZ, d2.isPvContributor, - d0.subMass, d1.subMass, d2.subMass, - sd1.x, sd1.y, sd1.z, sd1.px, sd1.py, sd1.pz, sd1.tpcNcls, sd1.tpcChi2, sd1.itsNcls, sd1.itsChi2, sd1.itsMeanClsSizeL, - sd1.rigidity, sd1.tpcSignal, sd1.tpcNsigma, sd1.tpcNsigmaNhp, sd1.tpcNsigmaNlp, sd1.tofMass, sd1.dcaXY, sd1.dcaZ, sd1.isPvContributor, - sd2.x, sd2.y, sd2.z, sd2.px, sd2.py, sd2.pz, sd2.tpcNcls, sd2.tpcChi2, sd2.itsNcls, sd2.itsChi2, sd2.itsMeanClsSizeL, - sd2.rigidity, sd2.tpcSignal, sd2.tpcNsigma, sd2.tpcNsigmaNhp, sd2.tpcNsigmaNlp, sd2.tofMass, sd2.dcaXY, sd2.dcaZ, sd2.isPvContributor); - } - } - //___________________________________________________________________________________________________________________________________________________________ - void fillCandidatePrim(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& colls, aod::HypKfTracks const& tracks, aod::HypKfDaughtAdds const& daughterAdds, aod::HypKfSubDs const& subDs) - { - auto coll = hypNuc.hypKfColl(); - cand.ct = ct(coll, hypNuc); - cand.cpaPv = cpa(coll, hypNuc); - fillCandidate(cand, hypNuc, hypNucs, colls, tracks, daughterAdds, subDs); - } - //___________________________________________________________________________________________________________________________________________________________ - void fillCandidateSec(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNuc const& mother, aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& colls, aod::HypKfTracks const& tracks, aod::HypKfDaughtAdds const& daughterAdds, aod::HypKfSubDs const& subDs) - { - cand.ct = ct(mother, hypNuc); - cand.cpaPv = cpa(mother, hypNuc); - fillCandidate(cand, hypNuc, hypNucs, colls, tracks, daughterAdds, subDs); } //___________________________________________________________________________________________________________________________________________________________ void fillCandidate(HyperNucleus& cand, aod::HypKfHypNuc const& hypNuc, aod::HypKfHypNucs const&, aod::HypKfColls const&, aod::HypKfTracks const&, aod::HypKfDaughtAdds const&, aod::HypKfSubDs const&) @@ -555,10 +296,8 @@ struct HypKfTreeCreator { auto addOns = hypNuc.hypKfDaughtAdd_as(); auto posVec = posVector(addOns); cand.species = std::abs(hypNuc.species()); - cand.isPrimaryCandidate = hypNuc.primary(); cand.isMatter = hypNuc.isMatter(); cand.mcTrue = hypNuc.mcTrue(); - cand.isCascade = cand.species > 10; // o2-linter: disable=magic-number (To be checked) cand.cent = coll.centFT0C(); cand.occu = coll.occupancy(); cand.runNumber = coll.runNumber(); @@ -583,10 +322,7 @@ struct HypKfTreeCreator { cand.px = hypNuc.px(); cand.py = hypNuc.py(); cand.pz = hypNuc.pz(); - if (hypNuc.hypDaughterId() >= 0) { - TrackProperties hypDaughter; - cand.daughterTracks.push_back(hypDaughter); - } + auto daughterTracks = hypNuc.hypKfTrack_as(); for (const auto& track : daughterTracks) { TrackProperties daughter; @@ -594,7 +330,6 @@ struct HypKfTreeCreator { daughter.itsNcls = track.itsNcluster(); daughter.tpcChi2 = track.tpcChi2NCl(); daughter.itsChi2 = track.itsChi2NCl(); - daughter.itsMeanClsSize = track.itsMeanClsSize(); daughter.itsMeanClsSizeL = track.itsMeanClsSize() * track.lambda(); daughter.rigidity = track.rigidity(); daughter.tpcSignal = track.tpcSignal(); @@ -618,15 +353,8 @@ struct HypKfTreeCreator { trackCount++; } - if (cand.isCascade) { - auto subDaughters = hypNuc.hypKfSubD_as(); - for (const auto& subDaughter : subDaughters) { - cand.subDaughterMassVec.push_back(subDaughter.subMass()); - } - } - cand.nSingleDaughters = trackCount; - if (cand.nSingleDaughters < 3) // o2-linter: disable=magic-number (To be checked) + if (cand.nSingleDaughters < Decays::kThreeBody) return; trackCount = 0; @@ -637,6 +365,20 @@ struct HypKfTreeCreator { } //___________________________________________________________________________________________________________________________________________________________ + void processData(aod::HypKfHypNucs const& hypNucs, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub) + { + for (const auto& hypNuc : hypNucs) { + if (cfgSpecies && std::abs(hypNuc.species()) != cfgSpecies) + continue; + HyperNucleus candidate; + fillCandidate(candidate, hypNuc, hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); + fillTable(candidate); + } + } + PROCESS_SWITCH(HypKfTreeCreator, processData, "data tree", false); + + //___________________________________________________________________________________________________________________________________________________________ + void processMC(aod::HypKfMcParts const& mcHypNucs, aod::HypKfHypNucs const& hypNucs, aod::HypKfMcColls const&, aod::HypKfColls const& hypKfColls, aod::HypKfTracks const& hypKfTrks, aod::HypKfDaughtAdds const& hypKfDAdd, aod::HypKfSubDs const& hypKfDSub) { isMC = true; @@ -648,7 +390,6 @@ struct HypKfTreeCreator { auto hypNucsByMc = hypNucs.sliceBy(perMcParticle, mcParticleIdx); HyperNucleus candidate, hypNucDaughter; candidate.speciesMC = mcHypNuc.species(); - candidate.isCascadeMC = candidate.speciesMC > 10; // o2-linter: disable=magic-number (To be checked) candidate.pdgCode = mcHypNuc.pdgCode(); candidate.isMatterMC = mcHypNuc.isMatter(); candidate.isPhysicalPrimary = mcHypNuc.isPhysicalPrimary(); @@ -674,19 +415,12 @@ struct HypKfTreeCreator { candidate.collisionMcTrue = true; } candidate.isReconstructed++; - fillCandidatePrim(candidate, hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - if (hypNuc.hypDaughterId() >= 0) { - fillCandidateSec(hypNucDaughter, hypNucs.rawIteratorAt(hypNuc.hypDaughterId()), hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); - } + fillCandidate(candidate, hypNucs.rawIteratorAt(hypNuc.globalIndex()), hypNucs, hypKfColls, hypKfTrks, hypKfDAdd, hypKfDSub); } - fillTable(candidate, hypNucDaughter); - hPt[0]->Fill(mcHypNuc.pt()); - if (candidate.isReconstructed) - hPt[1]->Fill(candidate.pt); + fillTable(candidate); } - hPt[2]->Divide(hPt[1].get(), hPt[0].get()); } - PROCESS_SWITCH(HypKfTreeCreator, processMC, "MC Gen tree", false); + PROCESS_SWITCH(HypKfTreeCreator, processMC, "MC tree", false); //___________________________________________________________________________________________________________________________________________________________ std::vector dcaTracksAll(std::vector& posVec, TString opt = "") @@ -787,22 +521,6 @@ struct HypKfTreeCreator { { return RecoDecay::cpa(primVtx(coll), decayVtx(hypNuc), momenta(hypNuc)); } - // only for Cascades - template - float decayLength(TPart const& mother, TPart const& daughter) - { - return RecoDecay::distance(decayVtx(mother), decayVtx(daughter)); - } - template - float ct(TPart const& mother, TPart const& daughter) - { - return RecoDecay::ct(momenta(daughter), decayLength(mother, daughter), daughter.mass()); - } - template - double cpa(TPart const& mother, TPart const& daughter) - { - return RecoDecay::cpa(decayVtx(mother), decayVtx(daughter), momenta(daughter)); - } }; WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) From a3b1cf71b2b1b4fe438640b3ae4d313f83ea0c22 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:07:56 +0100 Subject: [PATCH 3/7] Update hypKfRecoTask.cxx --- PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx | 888 +++++++++---------- 1 file changed, 429 insertions(+), 459 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx index 12e6344e84e..5104536a667 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx @@ -17,12 +17,12 @@ #include "PWGLF/DataModel/LFHypernucleiKfTables.h" -#include "Common/Core/PID/TPCPIDResponse.h" #include "Common/Core/RecoDecay.h" #include "Common/Core/trackUtilities.h" #include "Common/DataModel/Centrality.h" #include "Common/DataModel/CollisionAssociationTables.h" #include "Common/DataModel/EventSelection.h" +#include "Common/DataModel/PIDResponseITS.h" #include "Common/DataModel/PIDResponseTOF.h" #include "Common/DataModel/PIDResponseTPC.h" #include "Common/DataModel/TrackSelectionTables.h" @@ -33,18 +33,16 @@ #include "DCAFitter/DCAFitterN.h" #include "DataFormatsParameters/GRPMagField.h" #include "DataFormatsParameters/GRPObject.h" -#include "MathUtils/BetheBlochAleph.h" #include "DetectorsBase/GeometryManager.h" #include "DetectorsBase/Propagator.h" #include "Framework/ASoAHelpers.h" #include "Framework/AnalysisDataModel.h" #include "Framework/AnalysisTask.h" #include "Framework/runDataProcessing.h" +#include "MathUtils/BetheBlochAleph.h" #include "ReconstructionDataFormats/PID.h" #include "ReconstructionDataFormats/Track.h" -#include "TRandom3.h" - #include #include #include @@ -64,9 +62,9 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -using CollisionsFull = soa::Join; +using CollisionsFull = soa::Join; using CollisionsFullMC = soa::Join; -using TracksFull = soa::Join; +using TracksFull = soa::Join; o2::common::core::MetadataHelper metadataInfo; // Metadata helper //---------------------------------------------------------------------------------------------------------------- @@ -80,69 +78,96 @@ enum DAUGHTERS { kPion, kTriton, kHe3, kAlpha }; +enum Decays { kTwoBody = 2, + kThreeBody = 3 }; +constexpr float NoVal = -999.f; static const std::vector particleNames{"pion", "proton", "deuteron", "triton", "helion", "alpha"}; static const std::vector particlePdgCodes{211, 2212, o2::constants::physics::kDeuteron, o2::constants::physics::kTriton, o2::constants::physics::kHelium3, o2::constants::physics::kAlpha}; static const std::vector particleMasses{o2::constants::physics::MassPionCharged, o2::constants::physics::MassProton, o2::constants::physics::MassDeuteron, o2::constants::physics::MassTriton, o2::constants::physics::MassHelium3, o2::constants::physics::MassAlpha}; static const std::vector particleCharge{1, 1, 1, 1, 2, 2}; -const int nBetheParams = 6; -static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution"}; -constexpr double betheBlochDefault[nDaughterParticles][nBetheParams]{ - {13.611469, 3.598765, -0.021138, 2.039562, 0.651040, 0.09}, // pion - {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // proton - {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // deuteron - {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09}, // triton - {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}, // helion - {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09}}; // alpha - -const int nTrkSettings = 15; -static const std::vector trackPIDsettingsNames{"useBBparams", "minITSnCls", "minTPCnCls", "maxTPCchi2", "maxITSchi2", "minRigidity", "maxRigidity", "maxTPCnSigma", "TOFrequiredabove", "minTOFmass", "maxTOFmass", "minDcaToPvXY", "minDcaToPvZ", "minITSclsSize", "maxITSclsSize"}; -constexpr double trackPIDsettings[nDaughterParticles][nTrkSettings]{ - {0, 0, 60, 3.0, 5000, 0.15, 1.2, 2.5, -1, 0, 100, 0., 0., 0., 1000}, - {1, 0, 70, 2.5, 5000, 0.20, 4.0, 3.0, -1, 0, 100, 0., 0., 0., 1000}, - {1, 0, 70, 5.0, 5000, 0.50, 5.0, 3.0, -1, 0, 100, 0., 0., 0., 1000}, - {1, 0, 70, 5.0, 5000, 0.50, 5.0, 3.0, -1, 0, 100, 0., 0., 0., 1000}, - {1, 0, 75, 1.5, 5000, 0.50, 5.0, 3.0, -1, 0, 100, 0., 0., 0., 1000}, - {1, 0, 70, 1.5, 5000, 0.50, 5.0, 3.0, -1, 0, 100, 0., 0., 0., 1000}}; +const int nBetheParams = 8; +enum BBPAR { kP0, + kP1, + kP2, + kP3, + kP4, + kResolution, + kMip, + kExp }; +static const std::vector betheBlochParNames{"p0", "p1", "p2", "p3", "p4", "resolution", "mip", "exp"}; +constexpr double BetheBlochDefault[nDaughterParticles][nBetheParams]{ + {13.611469, 3.598765, -0.021138, 2.039562, 0.651040, 0.09, 1., 0.}, // pion + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09, 1., 0.}, // proton + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09, 1., 0.}, // deuteron + {5.393020, 7.859534, 0.004048, 2.323197, 1.609307, 0.09, 1., 0.}, // triton + {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09, 1., 0.}, // helion + {-126.557359, -0.858569, 1.111643, 1.210323, 2.656374, 0.09, 1., 0.}}; // alpha + +const int nTrkSettings = 18; +enum TRACKPIDSETTINGS { kPIDmethodTPC, + kMinITSnCls, + kMinTPCnCls, + kMaxTPCchi2, + kMaxITSchi2, + kMinRigidity, + kMaxRigidity, + kMaxTPCnSigma, + kMaxITSnSigma, + kTOFrequiredabove, + kMinTOFmass, + kMaxTOFmass, + kMinDcaToPvXY, + kMinDcaToPvZ, + kMinITSmeanClsSize, + kMaxITSmeanClsSize, + kTrackCharge, + kUsePVcontributors }; +static const std::vector trackPIDsettingNames{"PIDmethodTPC", "minITSnCls", "minTPCnCls", "maxTPCchi2", "maxITSchi2", "minRigidity", "maxRigidity", "maxTPCnSigma", "maxITSnSigma", "TOFrequiredabove", "minTOFmass", "maxTOFmass", "minDcaToPvXY", "minDcaToPvZ", "minITSclsSize", "maxITSclsSize", "trackCharge", "usePVcontributors"}; +constexpr double TrackPIDsettings[nDaughterParticles][nTrkSettings]{ + {0, 0, 60, 3.0, 5000, 0.15, 1.2, 2.5, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}, + {1, 0, 70, 2.5, 5000, 0.20, 4.0, 3.0, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}, + {1, 0, 70, 5.0, 5000, 0.50, 5.0, 3.0, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}, + {1, 0, 70, 5.0, 5000, 0.50, 5.0, 3.0, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}, + {1, 0, 75, 1.5, 5000, 0.50, 5.0, 3.0, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}, + {1, 0, 70, 1.5, 5000, 0.50, 5.0, 3.0, 3.0, -1, 0, 100, 0., 0., 0., 1000, 0, 0}}; static const int nHyperNuclei = 10; static const std::vector hyperNucNames{"L->p+pi", "3LH->3He+pi", "3LH->d+p+pi", "4LH->4He+pi", "4LH->t+p+pi", "4LHe->3He+p+pi", "5LHe->4He+p+pi", "5LHe->3He+d+pi", "custom1", "custom2"}; -static const std::vector hyperNucEnabledLb{"enabled"}; -static const std::vector reduceLb{"reduce factor"}; -constexpr int hyperNucEnabled[nHyperNuclei][1]{{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}}; -constexpr float reduceFactor[nHyperNuclei][1]{{1.}, {1.}, {1.}, {1.}, {1.}, {1.}, {1.}, {1.}, {1.}, {1.}}; -static const std::vector hyperNucPdgLb{"PDG code"}; -static constexpr int hyperNucPdgCodes[nHyperNuclei][1]{ - {3122}, - {o2::constants::physics::kHyperTriton}, - {o2::constants::physics::kHyperTriton}, - {o2::constants::physics::kHyperHydrogen4}, - {o2::constants::physics::kHyperHydrogen4}, - {o2::constants::physics::kHyperHelium4}, - {o2::constants::physics::kHyperHelium5}, - {o2::constants::physics::kHyperHelium5}, - {0}, - {0}}; -static const std::vector hyperNucDaughtersLb{"daughter1", "daughter2", "daughter3", "daughter4"}; -static const std::string hyperNucDaughters[nHyperNuclei][4]{{"proton", "pion", "none", "none"}, {"helion", "pion", "none", "none"}, {"deuteron", "proton", "pion", "none"}, {"alpha", "pion", "none", "none"}, {"triton", "proton", "pion", "none"}, {"helion", "proton", "pion", "none"}, {"alpha", "proton", "pion", "none"}, {"helion", "deuteron", "pion", "none"}, {"none", "none", "none", "none"}, {"none", "none", "none", "none"}}; // NOLINT: runtime/string -static const std::string hyperNucSigns[nHyperNuclei][4]{{"+", "-", "", ""}, {"+", "-", "", ""}, {"+", "+", "-", ""}, {"+", "-", "", ""}, {"+", "+", "-", ""}, {"+", "+", "-", ""}, {"+", "+", "-", ""}, {"+", "+", "-", ""}, {"", "", "", ""}, {"", "", "", ""}}; // NOLINT: runtime/string +static const int nHypNucDefs = 8; +enum HYPNUCDEFS { kEnabled, + kPdgCode, + kD1, + kD2, + kD3, + kD4, + kDsigns, + kUseV0for }; +static const std::vector hypNucDefsLb{"Enabled", "PDGCode", "d1", "d2", "d3", "d4", "daughterSigns", "useV0for"}; +static const std::string hypNucDefs[nHyperNuclei][nHypNucDefs]{ + {"0", "3122", "proton", "pion", "none", "none", "+-", ""}, + {"0", "1010010030", "helion", "pion", "none", "none", "+-", ""}, + {"0", "1010010030", "deuteron", "proton", "pion", "none", "++-", ""}, + {"0", "1010010040", "alpha", "pion", "none", "none", "+-", ""}, + {"0", "1010010040", "triton", "proton", "pion", "none", "++-", ""}, + {"0", "1010020040", "helion", "proton", "pion", "none", "++-", ""}, + {"0", "1010020050", "alpha", "proton", "pion", "none", "++-", ""}, + {"0", "1010020050", "helion", "deuteron", "pion", "none", "++-", ""}, + {"0", "0", "none", "none", "none", "none", "", ""}, + {"0", "0", "none", "none", "none", "none", "", ""}}; // NOLINT: runtime/string + const int nSelPrim = 8; +enum PRESELECTIONSPRIMARIES { kMinMass, + kMaxMass, + kMinCt, + kMaxCt, + kMinCosPa, + kMaxDcaTracks, + kMaxDcaMotherToPvXY, + kMaxDcaMotherToPvZ }; static const std::vector preSelectionPrimNames{"minMass", "maxMass", "minCt", "maxCt", "minCosPa", "maxDcaTracks", "maxDcaMotherToPvXY", "maxDcaMotherToPvZ"}; -constexpr double preSelectionsPrimaries[nHyperNuclei][nSelPrim]{ - {1.00, 1.30, 0, 50, 0.90, 100., 2.0, 5.0}, - {2.96, 3.04, 0, 30, 0.99, 100., 1.5, 4.0}, - {2.96, 3.04, 0, 30, 0.99, 100., 1.5, 4.0}, - {3.87, 3.97, 0, 30, 0.95, 100., 2.0, 5.0}, - {3.87, 3.97, 0, 30, 0.95, 100., 2.0, 5.0}, - {3.85, 3.99, 0, 30, 0.98, 100., 1.5, 4.0}, - {4.60, 5.20, 0, 100, -1., 100., 10., 10.}, - {4.60, 5.20, 0, 100, -1., 100., 10., 10.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}}; -const int nSelSec = 8; -static const std::vector preSelectionSecNames{"minMass", "maxMass", "minCt", "maxCt", "minCosPaSv", "maxDcaTracks", "maxDcaMotherToSvXY", "maxDcaMotherToSvZ"}; -constexpr double preSelectionsSecondaries[nHyperNuclei][nSelSec]{ +constexpr double PreSelectionsPrimaries[nHyperNuclei][nSelPrim]{ {1.00, 1.30, 0, 50, 0.90, 100., 2.0, 5.0}, {2.96, 3.04, 0, 30, 0.99, 100., 1.5, 4.0}, {2.96, 3.04, 0, 30, 0.99, 100., 1.5, 4.0}, @@ -153,83 +178,83 @@ constexpr double preSelectionsSecondaries[nHyperNuclei][nSelSec]{ {4.60, 5.20, 0, 100, -1., 100., 10., 10.}, {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, {0.00, 9.90, 0, 100, -1., 100., 10., 10.}}; - -static const int nCascades = 6; -static const std::vector cascadeNames{"4LLH->4LHe+pi", "4XHe->4LHe+pi", "custom1", "custom2", "custom3", "custom4"}; -constexpr int cascadeEnabled[nCascades][1]{{0}, {0}, {0}, {0}, {0}, {0}}; -constexpr int cascadePdgCodes[nCascades][1]{ - {1020010040}, - {1120020040}, - {0}, - {0}, - {0}, - {0}}; -static const std::vector cascadeHypDaughterLb{"hypernucleus"}; -static const std::string cascadeHypDaughter[nCascades][1]{{"4LHe->3He+p+pi"}, {"4LHe->3He+p+pi"}, {"none"}, {"none"}, {"none"}, {"none"}}; // NOLINT: runtime/string -static const std::vector cascadeDaughtersLb{"daughter2", "daughter3", "daughter4"}; -static const std::string cascadeDaughters[nCascades][3]{{"pion", "none", "none"}, {"pion", "none", "none"}, {"none", "none", "none"}, {"none", "none", "none"}, {"none", "none", "none"}, {"none", "none", "none"}}; // NOLINT: runtime/string -static const std::string cascadeSigns[nCascades][4]{{"+", "-", "", ""}, {"+", "-", "", ""}, {"", "", "", ""}, {"", "", "", ""}, {"", "", "", ""}, {"", "", "", ""}}; // NOLINT: runtime/string -const int nSelCas = 8; -static const std::vector preSelectionCascadeNames{"minMass", "maxMass", "minCt", "maxCt", "minCosPa", "maxDcaTracks", "maxDcaMotherToPvXY", "maxDcaMotherToPvZ"}; -constexpr double preSelectionsCascades[nCascades][nSelCas]{ - {4.00, 4.20, 0, 30, 0.95, 100., 2.0, 5.}, - {4.00, 4.20, 0, 30, 0.95, 100., 2.0, 5.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}, - {0.00, 9.90, 0, 100, -1., 100., 10., 10.}}; //---------------------------------------------------------------------------------------------------------------- + struct DaughterParticle { TString name; int pdgCode, charge; - double mass, resolution; - std::array betheParams; + double mass; + std::array betheParams; + std::array trkSettings; bool active; - DaughterParticle(std::string name_, int pdgCode_, double mass_, int charge_, LabeledArray bethe) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false) + DaughterParticle(std::string name_, int pdgCode_, double mass_, int charge_, LabeledArray bethe, LabeledArray settings) : name(name_), pdgCode(pdgCode_), charge(charge_), mass(mass_), active(false) { - resolution = bethe.get(name, "resolution"); - for (unsigned int i = 0; i < betheParams.size(); i++) + for (unsigned int i = 0; i < betheParams.size(); i++) { betheParams[i] = bethe.get(name, i); + } + for (unsigned int i = 0; i < trkSettings.size(); i++) { + trkSettings[i] = settings.get(name, i); + } + } + float getTPCnSigmaBB(float rigidity, float tpcSignal) + { + float expBethe = betheParams[kMip] * std::pow(charge, betheParams[kExp]) * o2::common::BetheBlochAleph(static_cast(charge * rigidity / mass), betheParams[kP0], betheParams[kP1], betheParams[kP2], betheParams[kP3], betheParams[kP4]); + return (tpcSignal - expBethe) / (expBethe * betheParams[kResolution]); } - int getCentralPIDIndex() { return getPIDIndex(pdgCode); } }; // struct DaughterParticle struct HyperNucleus { TString name; int pdgCode; bool active, savePrimary; - std::vector daughters, daughterTrackSigns; - HyperNucleus(std::string name_, int pdgCode_, bool active_, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_) + std::vector daughters, daughterTrackSigns, v0DaughterVec; + std::vector primSettings; + HyperNucleus(std::string name_, int pdgCode_, bool active_, std::vector daughters_, std::vector daughterTrackSigns_, std::vector v0DaughterVec_, LabeledArray primSettings_) : pdgCode(pdgCode_), active(active_), savePrimary(active_) { - init(name_, daughters_, daughterTrackSigns_); + init(name_, daughters_, daughterTrackSigns_, v0DaughterVec_); + for (unsigned int i = 0; i < nSelPrim; i++) { + primSettings.push_back(primSettings_.get(name, i)); + } } HyperNucleus(std::string name_, int pdgCode_, bool active_, int hypDaughter, std::vector daughters_, std::vector daughterTrackSigns_) : pdgCode(pdgCode_), active(active_), savePrimary(active_) { daughters.push_back(hypDaughter); init(name_, daughters_, daughterTrackSigns_); } - void init(std::string name_, std::vector daughters_, std::vector daughterTrackSigns_) + void init(std::string name_, std::vector daughters_, std::vector daughterTrackSigns_, std::vector v0DaughterVec_ = {}) { name = TString(name_); for (const int& d : daughters_) daughters.push_back(d); for (const int& dc : daughterTrackSigns_) daughterTrackSigns.push_back(dc); + for (const int& dv0 : v0DaughterVec_) + v0DaughterVec.push_back(dv0 - 1); } int getNdaughters() { return static_cast(daughters.size()); } + std::vector getV0daughters() { return v0DaughterVec; }; + std::vector getNonV0daughters() + { + std::vector vec; + for (int daughter = 0; daughter < getNdaughters(); daughter++) { + if (std::find(v0DaughterVec.begin(), v0DaughterVec.end(), daughter) == v0DaughterVec.end()) + vec.push_back(daughter); + } + return vec; + }; const char* motherName() { return name.Contains("->") ? ((TString)name(0, name.First("-"))).Data() : name.Data(); } const char* daughterNames() { return name.Contains("->") ? ((TString)name(name.First("-") + 2, name.Length())).Data() : ""; } }; // struct HyperNucleus struct DaughterKf { + static int uniqueId; int64_t daughterTrackId; - int species, hypNucId; + int id, species, sign, hypNucId; KFParticle daughterKfp; float dcaToPv, dcaToPvXY, dcaToPvZ, tpcNsigma, tpcNsigmaNLP, tpcNsigmaNHP; bool active; std::vector vtx; - DaughterKf(int species_, int64_t daughterTrackId_, std::vector vtx_, float tpcNsigma_, float tpcNsigmaNLP_, float tpcNsigmaNHP_) : daughterTrackId(daughterTrackId_), species(species_), hypNucId(-1), tpcNsigma(tpcNsigma_), tpcNsigmaNLP(tpcNsigmaNLP_), tpcNsigmaNHP(tpcNsigmaNHP_), vtx(vtx_) {} - DaughterKf(int species_, KFParticle daughterKfp_, int hypNucId_) : daughterTrackId(-999), species(species_), hypNucId(hypNucId_), daughterKfp(daughterKfp_), dcaToPv(-999), dcaToPvXY(-999), dcaToPvZ(-999) {} + DaughterKf(int species_, int64_t daughterTrackId_, int sign_, std::vector vtx_, float tpcNsigma_, float tpcNsigmaNLP_, float tpcNsigmaNHP_) : daughterTrackId(daughterTrackId_), id(uniqueId++), species(species_), sign(sign_), hypNucId(-1), tpcNsigma(tpcNsigma_), tpcNsigmaNLP(tpcNsigmaNLP_), tpcNsigmaNHP(tpcNsigmaNHP_), vtx(vtx_) {} void addKfp(KFParticle daughterKfp_) { daughterKfp = daughterKfp_; @@ -239,7 +264,9 @@ struct DaughterKf { } bool isTrack() { return daughterTrackId >= 0; } -}; // struct DaughterKf +}; +int DaughterKf::uniqueId = 0; +// struct DaughterKf struct HyperNucCandidate { int species; @@ -249,11 +276,11 @@ struct HyperNucCandidate { std::vector recoSV; std::vector> daughterPosMoms; float mass, px, py, pz; - float devToPvXY, dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, chi2; + float devToPvXY, dcaToPvXY, dcaToPvZ, dcaToVtxXY, dcaToVtxZ, chi2, itsMeanClsSize; bool mcTrue, isPhysPrimary, isPrimaryCandidate, isSecondaryCandidate, isUsedSecondary; int64_t mcParticleId; int tableId; - HyperNucCandidate(int species_, HyperNucCandidate* hypNucDaughter_, std::vector daughters_) : species(species_), hypNucDaughter(hypNucDaughter_), devToPvXY(999), dcaToPvXY(999), dcaToPvZ(999), dcaToVtxXY(999), dcaToVtxZ(999), chi2(999), mcTrue(false), isPhysPrimary(false), isPrimaryCandidate(false), isSecondaryCandidate(false), isUsedSecondary(false), mcParticleId(-1), tableId(-1) + HyperNucCandidate(int species_, HyperNucCandidate* hypNucDaughter_, std::vector daughters_) : species(species_), hypNucDaughter(hypNucDaughter_), devToPvXY(-999), dcaToPvXY(-999), dcaToPvZ(-999), dcaToVtxXY(-999), dcaToVtxZ(-999), chi2(-999), itsMeanClsSize(-1), mcTrue(false), isPhysPrimary(false), isPrimaryCandidate(false), isSecondaryCandidate(false), isUsedSecondary(false), mcParticleId(-1), tableId(-1) { for (const auto& d : daughters_) daughters.push_back(d); @@ -284,7 +311,7 @@ struct HyperNucCandidate { bool checkKfp() { return mass != 0 && !std::isnan(mass); } int getDaughterTableId() { return hypNucDaughter ? hypNucDaughter->tableId : -1; } bool isCascade() { return hypNucDaughter != 0; } - int getSign() + int getSign() // K0s !!!!! { if (kfp.GetQ() == 0) return daughters.front()->daughterKfp.GetQ() / std::abs(daughters.front()->daughterKfp.GetQ()); @@ -341,7 +368,7 @@ struct HyperNucCandidate { } void calcDcaToVtx(KFPVertex& vtx) { - if (devToPvXY != 999) // o2-linter: disable=magic-number (To be checked) + if (devToPvXY != NoVal) return; devToPvXY = kfp.GetDeviationFromVertexXY(vtx); dcaToPvXY = kfp.GetDistanceFromVertexXY(vtx); @@ -361,7 +388,7 @@ struct HyperNucCandidate { { if (!isCascade()) { LOGF(warning, "Primary hypernucleus has no hypernucleus daughter!"); - return -999; + return NoVal; } return calcSubDaughterMass(daughters.at(d1)->daughterKfp, hypNucDaughter->daughters.at(d2)->daughterKfp); } @@ -409,6 +436,40 @@ struct McCollInfo { McCollInfo() : hasRecoColl(false), passedEvSel(false), hasRecoParticle(false), tableIndex(-1) {} }; // struct McCollInfo +struct DaughterCombinations { + std::vector::iterator> it, itBegin, itEnd; + int nVecs, nCombinations; + bool end; + std::vector nonV0daughters; + DaughterCombinations(std::vector*>& vecs, std::vector nonV0daughters_) : nVecs(0), nCombinations(1), end(false), nonV0daughters(nonV0daughters_) + { + for (const auto& vec : vecs) { + nVecs++; + nCombinations *= vec->size(); + it.push_back(vec->begin()); + itEnd.push_back(vec->end()); + } + itBegin = it; + } + void getNextCombination(std::vector& vec) + { + int counter = 0; + for (const auto& i : it) { + vec.at(nonV0daughters.at(counter++)) = &(*i); + } + it[nVecs - 1]++; + for (int i = nVecs - 1; i && it[i] == itEnd[i]; i--) { + it[i] = itBegin[i]; + it[i - 1]++; + } + if (it[0] == itEnd[0]) + end = true; + } + void init() { it = itBegin; } + bool isEmpty() { return nCombinations == 0; } + int getNcombinations() { return nCombinations; } +}; // struct DaughterCombinations + //---------------------------------------------------------------------------------------------------------------- std::vector> hDeDx; std::vector> hInvMass; @@ -427,40 +488,26 @@ struct HypKfRecoTask { Produces outputHypNucTable; Preslice perCollision = aod::track_association::collisionId; + Preslice perCollisionV0 = o2::aod::v0::collisionId; + Preslice perCollision3b = o2::aod::decay3body::collisionId; + PresliceUnsorted perV0 = aod::strangenesstracking::v0Id; + PresliceUnsorted perDec3 = aod::strangenesstracking::decay3BodyId; HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject}; Configurable cfgSaveOnlyMcTrue{"cfgSaveOnlyMcTrue", true, "save only MCtrue candidates"}; Configurable cfgDebug{"cfgDebug", 1, "debug level"}; - Configurable cfgRigidityCorrection{"cfgRigidityCorrection", false, "apply rigidity correction"}; Configurable cfgCutEta{"cfgCutEta", 0.9f, "Eta range for tracks"}; - Configurable cfgUsePVcontributors{"cfgUsePVcontributors", true, "use tracks that are PV contibutors"}; - - Configurable> cfgHyperNucsActive{"cfgHyperNucsActive", {hyperNucEnabled[0], nHyperNuclei, 1, hyperNucNames, hyperNucEnabledLb}, "enable or disable reconstruction"}; - Configurable> cfgReduce{"cfgReduce", {reduceFactor[0], nHyperNuclei, 1, hyperNucNames, reduceLb}, "reconstruct only a percentage of all possible hypernuclei"}; - Configurable> cfgHyperNucPdg{"cfgHyperNucPdg", {hyperNucPdgCodes[0], nHyperNuclei, 1, hyperNucNames, hyperNucPdgLb}, "PDG codes"}; - Configurable> cfgHyperNucDaughters{"cfgHyperNucDaughters", {hyperNucDaughters[0], nHyperNuclei, 4, hyperNucNames, hyperNucDaughtersLb}, "Daughter particles"}; - Configurable> cfgHyperNucSigns{"cfgHyperNucSigns", {hyperNucSigns[0], nHyperNuclei, 4, hyperNucNames, hyperNucDaughtersLb}, "Daughter signs"}; - - Configurable> cfgCascadesActive{"cfgCascadesActive", {cascadeEnabled[0], nCascades, 1, cascadeNames, hyperNucEnabledLb}, "enable or disable reconstruction"}; - Configurable> cfgCascadesPdg{"cfgCascadesPdg", {cascadePdgCodes[0], nCascades, 1, cascadeNames, hyperNucPdgLb}, "PDG codes"}; - Configurable> cfgCascadeHypDaughter{"cfgCascadeHypDaughter", {cascadeHypDaughter[0], nCascades, 1, cascadeNames, cascadeHypDaughterLb}, "Hyernuclei daugther"}; - Configurable> cfgCascadeDaughters{"cfgCascadeDaughters", {cascadeDaughters[0], nCascades, 3, cascadeNames, cascadeDaughtersLb}, "Daughter particles"}; - Configurable> cfgCascadeSigns{"cfgCascadeSigns", {cascadeSigns[0], nCascades, 4, cascadeNames, hyperNucDaughtersLb}, "Daughter signs"}; - - Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {betheBlochDefault[0], nDaughterParticles, nBetheParams, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; - Configurable> cfgTrackPIDsettings{"cfgTrackPIDsettings", {trackPIDsettings[0], nDaughterParticles, nTrkSettings, particleNames, trackPIDsettingsNames}, "track selection and PID criteria"}; - Configurable> cfgPreSelectionsPrimaries{"cfgPreSelectionsPrimaries", {preSelectionsPrimaries[0], nHyperNuclei, nSelPrim, hyperNucNames, preSelectionPrimNames}, "selection criteria for primary hypernuclei"}; - Configurable> cfgPreSelectionsSecondaries{"cfgPreSelectionsSecondaries", {preSelectionsSecondaries[0], nHyperNuclei, nSelSec, hyperNucNames, preSelectionSecNames}, "selection criteria for secondary hypernuclei"}; - Configurable> cfgPreSelectionsCascades{"cfgPreSelectionsCascades", {preSelectionsCascades[0], nCascades, nSelCas, cascadeNames, preSelectionCascadeNames}, "selection criteria for cascade hypernuclei"}; - - // TPC PID Response - bool usePidResponse; - o2::pid::tpc::Response* response; + Configurable> cfgHypNucDefs{"cfgHypNucDefs", {hypNucDefs[0], nHyperNuclei, nHypNucDefs, hyperNucNames, hypNucDefsLb}, "Hypernuclei definition"}; + Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", {BetheBlochDefault[0], nDaughterParticles, nBetheParams, particleNames, betheBlochParNames}, "TPC Bethe-Bloch parameterisation for light nuclei"}; + Configurable> cfgTrackPIDsettings{"cfgTrackPIDsettings", {TrackPIDsettings[0], nDaughterParticles, nTrkSettings, particleNames, trackPIDsettingNames}, "track selection and PID criteria"}; + Configurable> cfgPreSelectionsPrimaries{"cfgPreSelectionsPrimaries", {PreSelectionsPrimaries[0], nHyperNuclei, nSelPrim, hyperNucNames, preSelectionPrimNames}, "selection criteria for primary hypernuclei"}; + Configurable cfgVtxCutZ{"cfgVtxCutZ", 10.0f, "Accepted z-vertex range"}; + std::map metadata; - std::array betheParams; + o2::aod::ITSResponse itsResponse; // CCDB Service ccdb; Configurable bField{"bField", -999, "bz field, -999 is automatic"}; @@ -473,8 +520,8 @@ struct HypKfRecoTask { std::vector activePdgs; std::vector daughterParticles; - std::vector> foundDaughterKfs, hypNucDaughterKfs; - std::vector> singleHyperNucCandidates, cascadeHyperNucCandidates; + std::vector> foundDaughterKfs; + std::vector> singleHyperNucCandidates; std::vector singleHyperNuclei, cascadeHyperNuclei; std::vector primVtx, cents; std::vector mcCollInfos; @@ -484,52 +531,31 @@ struct HypKfRecoTask { int64_t mcCollTableIndex; int mRunNumber, occupancy; float dBz; - TRandom3 rand; //---------------------------------------------------------------------------------------------------------------- - void init(InitContext const&) + void init(o2::framework::InitContext& context) { - isMC = false; + isMC = doprocessMC ? true : false; mRunNumber = 0; dBz = 0; - rand.SetSeed(0); - + o2::aod::ITSResponse::setParameters(context, isMC); ccdb->setURL(ccdbUrl); ccdb->setCaching(true); ccdb->setLocalObjectValidityChecking(); ccdb->setFatalWhenNull(false); - usePidResponse = false; for (unsigned int i = 0; i < nDaughterParticles; i++) { // create daughterparticles - daughterParticles.push_back(DaughterParticle(particleNames.at(i), particlePdgCodes.at(i), particleMasses.at(i), particleCharge.at(i), cfgBetheBlochParams)); - if (cfgTrackPIDsettings->get(i, "useBBparams") == 2 || cfgTrackPIDsettings->get(i, "useBBparams") == 0) // o2-linter: disable=magic-number (To be checked) - usePidResponse = true; + daughterParticles.push_back(DaughterParticle(particleNames.at(i), particlePdgCodes.at(i), particleMasses.at(i), particleCharge.at(i), cfgBetheBlochParams, cfgTrackPIDsettings)); } for (unsigned int i = 0; i < nHyperNuclei; i++) { // create hypernuclei - auto active = cfgHyperNucsActive->get(i, 0u); - auto pdg = cfgHyperNucPdg->get(i, 0u); - singleHyperNuclei.push_back(HyperNucleus(hyperNucNames.at(i), pdg, active, getDaughterVec(i, cfgHyperNucDaughters), getDaughterSignVec(i, cfgHyperNucSigns))); + auto active = cfgHypNucDefs->get(i, "Enabled") != "0"; + auto pdg = std::stoi(cfgHypNucDefs->get(i, "PDGCode")); + singleHyperNuclei.push_back(HyperNucleus(hyperNucNames.at(i), pdg, active, getDaughterVec(i, cfgHypNucDefs), getDaughterSignVec(i, cfgHypNucDefs), getV0DaughterVec(i, cfgHypNucDefs), cfgPreSelectionsPrimaries)); if (active) activePdgs.push_back(pdg); } - activeCascade = false; - for (unsigned int i = 0; i < nCascades; i++) { // create cascades - auto active = cfgCascadesActive->get(i, 0u); - auto pdg = cfgCascadesPdg->get(i, 0u); - auto hypDaughter = getHypDaughterVec(i, cfgCascadeHypDaughter); - cascadeHyperNuclei.push_back(HyperNucleus(cascadeNames.at(i), pdg, active, hypDaughter, getDaughterVec(i, cfgCascadeDaughters), getDaughterSignVec(i, cfgCascadeSigns))); - if (active) { - activePdgs.push_back(pdg); - if (!singleHyperNuclei.at(hypDaughter).active) { - singleHyperNuclei.at(hypDaughter).active = true; - activePdgs.push_back(singleHyperNuclei.at(hypDaughter).pdgCode); - } - activeCascade = true; - } - } - // define histogram axes const AxisSpec axisMagField{10, -10., 10., "magnetic field"}; const AxisSpec axisNev{3, 0., 3., "Number of events"}; @@ -554,9 +580,9 @@ struct HypKfRecoTask { hDeDx[2 * i + 1] = histos.add(Form("histdEdx_%s_Cuts", histName.Data()), ";p_{TPC}/z (GeV/#it{c}); d#it{E}/d#it{x}", HistType::kTH2F, {axisRigidity, axisdEdx}); } // create invariant mass histograms - hInvMass.resize(nHyperNuclei + nCascades); + hInvMass.resize(nHyperNuclei); int histCount = 0; - std::vector> hypNucVectors = {singleHyperNuclei, cascadeHyperNuclei}; + std::vector> hypNucVectors = {singleHyperNuclei}; for (size_t i = 0; i < hypNucVectors.size(); i++) { for (size_t j = 0; j < hypNucVectors.at(i).size(); j++) { if (hypNucVectors.at(i).at(j).active) { @@ -568,46 +594,29 @@ struct HypKfRecoTask { } //---------------------------------------------------------------------------------------------------------------- - void findDaughterParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks, CollisionsFull::iterator const& coll) + void findDaughterParticles(aod::TrackAssoc const& tracksByColl, TracksFull const& tracks, CollisionsFull::iterator const&) { // track loop, store daughter candidates in std::vector for (const auto& trackId : tracksByColl) { const auto& track = tracks.rawIteratorAt(trackId.trackId()); filldedx(track, nDaughterParticles); - if (std::abs(track.eta()) > cfgCutEta) - continue; - if (!cfgUsePVcontributors && track.isPVContributor()) - continue; for (size_t i = 0; i < daughterParticles.size(); i++) { - if (track.tpcNClsFound() < cfgTrackPIDsettings->get(i, "minTPCnCls")) + if (!checkTrack(track, daughterParticles.at(i))) continue; - if (track.tpcChi2NCl() > cfgTrackPIDsettings->get(i, "maxTPCchi2")) + const float tpcNsigma = getTPCnSigma(track, daughterParticles.at(i)); + if (daughterParticles.at(i).trkSettings[kMaxTPCnSigma] >= 0 && std::abs(tpcNsigma) > daughterParticles.at(i).trkSettings[kMaxTPCnSigma]) continue; - if (track.itsNCls() < cfgTrackPIDsettings->get(i, "minITSnCls")) - continue; - if (track.itsChi2NCl() > cfgTrackPIDsettings->get(i, "maxITSchi2")) - continue; - if (getRigidity(track) < cfgTrackPIDsettings->get(i, "minRigidity") || getRigidity(track) > cfgTrackPIDsettings->get(i, "maxRigidity")) - continue; - float tpcNsigma = getTPCnSigma(track, coll, daughterParticles.at(i)); - if (std::abs(tpcNsigma) > cfgTrackPIDsettings->get(i, "maxTPCnSigma")) + const float itsNsigma = getITSnSigma(track, daughterParticles.at(i)); + if (daughterParticles.at(i).trkSettings[kMaxITSnSigma] >= 0 && std::abs(itsNsigma) > daughterParticles.at(i).trkSettings[kMaxITSnSigma]) continue; filldedx(track, i); - if (getMeanItsClsSize(track) < cfgTrackPIDsettings->get(i, "minITSclsSize")) - continue; - if (getMeanItsClsSize(track) > cfgTrackPIDsettings->get(i, "maxITSclsSize")) - continue; - if (cfgTrackPIDsettings->get(i, "TOFrequiredabove") >= 0 && getRigidity(track) > cfgTrackPIDsettings->get(i, "TOFrequiredabove") && (track.mass() < cfgTrackPIDsettings->get(i, "minTOFmass") || track.mass() > cfgTrackPIDsettings->get(i, "maxTOFmass"))) - continue; - float tpcNsigmaNHP = (i == kAlpha ? -999 : getTPCnSigma(track, coll, daughterParticles.at(i + 1))); - float tpcNsigmaNLP = (i == kPion ? 999 : getTPCnSigma(track, coll, daughterParticles.at(i - 1))); - foundDaughterKfs.at(i).push_back(DaughterKf(i, track.globalIndex(), primVtx, tpcNsigma, tpcNsigmaNLP, tpcNsigmaNHP)); + foundDaughterKfs.at(i).push_back(DaughterKf(i, track.globalIndex(), track.sign(), primVtx, 0, 0, 0)); } } // track loop } //---------------------------------------------------------------------------------------------------------------- - void checkMCTrueTracks(aod::McTrackLabels const& trackLabels, aod::McParticles const&, TracksFull const& tracks, CollisionsFull::iterator const& coll) + void checkMCTrueTracks(aod::McTrackLabels const& trackLabels, aod::McParticles const&) { for (int i = 0; i < nDaughterParticles; i++) { auto& daughterVec = foundDaughterKfs.at(i); @@ -640,17 +649,6 @@ struct HypKfRecoTask { continue; } } - if (cfgTrackPIDsettings->get(i, "useBBparams") == 0) { - const auto& trk = tracks.rawIteratorAt(it->daughterTrackId); - const auto tpcNsigmaMC = getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i)); - if (std::abs(tpcNsigmaMC) <= cfgTrackPIDsettings->get(i, "maxTPCnSigma")) { - it->tpcNsigma = tpcNsigmaMC; - it->tpcNsigmaNHP = (i == kAlpha ? -999 : getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i + 1))); - it->tpcNsigmaNLP = (i == kPion ? 999 : getTPCnSigmaMC(trk, coll, daughterParticles.at(i), daughterParticles.at(i - 1))); - } else { - daughterVec.erase(it); - } - } } } } @@ -660,7 +658,7 @@ struct HypKfRecoTask { for (size_t daughterCount = 0; daughterCount < daughterParticles.size(); daughterCount++) { daughterParticles.at(daughterCount).active = false; } - std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; + std::vector*> hypNucVectors = {&singleHyperNuclei}; bool singleHypNucActive = false; for (size_t vec = 0; vec < hypNucVectors.size(); vec++) { for (const auto& hyperNuc : *(hypNucVectors.at(vec))) { @@ -698,7 +696,7 @@ struct HypKfRecoTask { } //---------------------------------------------------------------------------------------------------------------- - void createKFHypernuclei(TracksFull const& tracks) + void createKFHypernuclei(aod::V0s const& V0s, aod::Decay3Bodys const& decay3Bodys, aod::TrackedV0s const& trackedV0s, aod::Tracked3Bodys const& tracked3Bodys) { // loop over all hypernuclei that are to be reconstructed for (size_t hyperNucIter = 0; hyperNucIter < singleHyperNuclei.size(); hyperNucIter++) { @@ -706,165 +704,86 @@ struct HypKfRecoTask { if (!hyperNuc->active) continue; int nDaughters = hyperNuc->getNdaughters(); - std::vector::iterator> it; - int nCombinations = 1; - for (int i = 0; i < nDaughters; i++) { - nCombinations *= foundDaughterKfs.at(hyperNuc->daughters.at(i)).size(); - it.push_back(foundDaughterKfs.at(hyperNuc->daughters.at(i)).begin()); + auto nonV0daughters = hyperNuc->getNonV0daughters(); + std::vector*> nonV0daughterKfs; + for (const auto& d : nonV0daughters) { + nonV0daughterKfs.push_back(&foundDaughterKfs.at(hyperNuc->daughters.at(d))); } - if (!nCombinations) + bool hasNonV0daughters = nonV0daughters.size() > 0; + DaughterCombinations nonV0daughterComb(nonV0daughterKfs, nonV0daughters); + if (hasNonV0daughters && nonV0daughterComb.isEmpty()) continue; - const float reduceFactor = cfgReduce->get(hyperNucIter, 0u); - const float minMassPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "minMass"); - const float maxMassPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "maxMass"); - const float minCtPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "minCt"); - const float maxCtPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "maxCt"); - const float minCosPaPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "minCosPa"); - const float maxDcaTracksPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "maxDcaTracks"); - const float maxDcaMotherToPvXYPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "maxDcaMotherToPvXY"); - const float maxDcaMotherToPvZPrim = cfgPreSelectionsPrimaries->get(hyperNucIter, "maxDcaMotherToPvZ"); - const float minMassSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minMass"); - const float maxMassSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxMass"); - const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "minCt"); - const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxCt"); - const float maxDcaTracksSec = cfgPreSelectionsSecondaries->get(hyperNucIter, "maxDcaTracks"); - while (it[0] != foundDaughterKfs.at(hyperNuc->daughters.at(0)).end()) { - // check for correct signs, avoid double usage of tracks - bool passedChecks = true; - int checkSign = 0; - std::vector vec; - for (int i = 0; i < nDaughters; i++) { - const auto& daughterTrack = tracks.rawIteratorAt(it[i]->daughterTrackId); - if (!i) - checkSign = daughterTrack.sign(); - if (daughterTrack.sign() != checkSign * hyperNuc->daughterTrackSigns.at(i) || std::find(vec.begin(), vec.end(), it[i]->daughterTrackId) != vec.end()) { - passedChecks = false; - break; - } - vec.push_back(it[i]->daughterTrackId); + + auto v0daughters = hyperNuc->getV0daughters(); + bool useDecay3Body = (v0daughters.size() == Decays::kThreeBody), useV0 = (v0daughters.size() == Decays::kTwoBody); + bool hasV0daughters = useDecay3Body || useV0; + if ((useDecay3Body && !decay3Bodys.size()) || (useV0 && !V0s.size())) + continue; + auto v0Size = !hasV0daughters ? 0 : (useV0 ? V0s.size() : decay3Bodys.size()); + int v0Count = 0; + + do { + std::vector daughters; + daughters.resize(nDaughters); + std::vector trackIds; + if (useDecay3Body) { + const auto& v0 = decay3Bodys.rawIteratorAt(v0Count); + trackIds = std::vector{v0.track0Id(), v0.track1Id(), v0.track2Id()}; + } + if (useV0) { + const auto& v0 = V0s.rawIteratorAt(v0Count); + trackIds = std::vector{v0.posTrackId(), v0.negTrackId()}; } - if (passedChecks && rand.Rndm() <= reduceFactor) { - std::vector daughters; + if (hasV0daughters && !findDaughterKfComb(daughters, hyperNuc, v0daughters, trackIds)) + continue; + nonV0daughterComb.init(); + do { + if (hasNonV0daughters) + nonV0daughterComb.getNextCombination(daughters); + + // check for correct signs, avoid double usage of tracks + bool passedChecks = true; + int checkSign = daughters[0]->sign; + ; + std::vector vec; ///!!! index + sign für daughterKFs??? for (int i = 0; i < nDaughters; i++) { - daughters.push_back(&(*it[i])); + if (daughters[i]->sign != checkSign * hyperNuc->daughterTrackSigns.at(i) || std::find(vec.begin(), vec.end(), daughters[i]->id) != vec.end()) { + passedChecks = false; + break; + } + vec.push_back(daughters[i]->id); } + if (!passedChecks) + continue; HyperNucCandidate candidate(hyperNucIter, static_cast(0), daughters); // check preselections - if (candidate.checkKfp()) { - if (candidate.mass <= maxMassPrim && candidate.mass >= minMassPrim && candidate.getDcaTracks() <= maxDcaTracksPrim && candidate.getCt(primVtx) <= maxCtPrim && candidate.getCt(primVtx) >= minCtPrim && candidate.getCpa(primVtx) >= minCosPaPrim) { - candidate.calcDcaToVtx(kfPrimVtx); - if (std::abs(candidate.dcaToPvXY) <= maxDcaMotherToPvXYPrim && std::abs(candidate.dcaToPvZ) <= maxDcaMotherToPvZPrim) { - candidate.isPrimaryCandidate = true; - collHasCandidate = true; - } + if (checkPrimaryHypNuc(candidate, hyperNuc->primSettings) && hyperNuc->savePrimary) { + collHasCandidate = true; + candidate.isPrimaryCandidate = true; + if (useV0) { + auto trackedByDecay = trackedV0s.sliceBy(perV0, v0Count); + if (trackedByDecay.size()) + candidate.itsMeanClsSize = trackedByDecay.rawIteratorAt(0).itsClsSize(); } - if (activeCascade && candidate.mass <= maxMassSec && candidate.mass >= minMassSec && candidate.getDcaTracks() <= maxDcaTracksSec && candidate.getCt(primVtx) <= maxCtSec && candidate.getCt(primVtx) >= minCtSec) { - candidate.calcDcaToVtx(kfPrimVtx); - candidate.isSecondaryCandidate = true; + if (useDecay3Body) { + auto trackedByDecay = tracked3Bodys.sliceBy(perDec3, v0Count); + if (trackedByDecay.size()) + candidate.itsMeanClsSize = trackedByDecay.rawIteratorAt(0).itsClsSize(); } - if ((candidate.isPrimaryCandidate && hyperNuc->savePrimary) || (candidate.isSecondaryCandidate && activeCascade)) - singleHyperNucCandidates.at(hyperNucIter).push_back(candidate); + singleHyperNucCandidates.at(hyperNucIter).push_back(candidate); } - } - it[nDaughters - 1]++; - for (int i = nDaughters - 1; i && it[i] == foundDaughterKfs.at(hyperNuc->daughters.at(i)).end(); i--) { - it[i] = foundDaughterKfs.at(hyperNuc->daughters.at(i)).begin(); - it[i - 1]++; - } - } + } while (hasNonV0daughters && !nonV0daughterComb.end); + } while (hasV0daughters && ++v0Count < v0Size); } } //---------------------------------------------------------------------------------------------------------------- - void createKFCascades(TracksFull const& tracks) - { - // loop over all cascade hypernuclei that are to be reconstructed - for (size_t hyperNucIter = 0; hyperNucIter < cascadeHyperNuclei.size(); hyperNucIter++) { - HyperNucleus* hyperNuc = &(cascadeHyperNuclei.at(hyperNucIter)); - if (!hyperNuc->active) - continue; - int nDaughters = hyperNuc->getNdaughters(); - int nHypNucDaughters = singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).size(); - for (int64_t i = 0; i < static_cast(nHypNucDaughters); i++) { - if (singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).at(i).isSecondaryCandidate) { - auto hypNucDaughter = &(singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).at(i)); - hypNucDaughterKfs.at(hyperNucIter).push_back(DaughterKf(hyperNuc->daughters.at(0), hypNucDaughter->kfp, i)); - } - } - int nCombinations = hypNucDaughterKfs.at(hyperNucIter).size(); - std::vector::iterator> it; - it.push_back(hypNucDaughterKfs.at(hyperNucIter).begin()); - for (int i = 1; i < nDaughters; i++) { - nCombinations *= foundDaughterKfs.at(hyperNuc->daughters.at(i)).size(); - it.push_back(foundDaughterKfs.at(hyperNuc->daughters.at(i)).begin()); - } - if (!nCombinations) - continue; - const float minMassCas = cfgPreSelectionsCascades->get(hyperNucIter, "minMass"); - const float maxMassCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxMass"); - const float minCtCas = cfgPreSelectionsCascades->get(hyperNucIter, "minCt"); - const float maxCtCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxCt"); - const float minCosPaCas = cfgPreSelectionsCascades->get(hyperNucIter, "minCosPa"); - const float maxDcaTracksCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaTracks"); - const float maxDcaMotherToPvXYCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvXY"); - const float maxDcaMotherToPvZCas = cfgPreSelectionsCascades->get(hyperNucIter, "maxDcaMotherToPvZ"); - const float minCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCt"); - const float maxCtSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxCt"); - const float minCosPaSvSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "minCosPaSv"); - const float maxDcaMotherToSvXYSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvXY"); - const float maxDcaMotherToSvZSec = cfgPreSelectionsSecondaries->get(hyperNuc->daughters.at(0), "maxDcaMotherToSvZ"); - - while (it[0] != hypNucDaughterKfs.at(hyperNucIter).end()) { - // select hypernuclei daughter KFParticle - auto hypNucDaughter = &(singleHyperNucCandidates.at(hyperNuc->daughters.at(0)).at(it[0]->hypNucId)); - // check for correct signs - int checkSign = hypNucDaughter->getSign(); - bool passedChecks = true; - std::vector vec = hypNucDaughter->daughterTrackIds(); - for (int i = 1; i < nDaughters; i++) { - const auto& daughterTrack = tracks.rawIteratorAt(it[i]->daughterTrackId); - if (daughterTrack.sign() != checkSign * hyperNuc->daughterTrackSigns.at(i) || std::find(vec.begin(), vec.end(), it[i]->daughterTrackId) != vec.end()) { - passedChecks = false; - break; - } - vec.push_back(it[i]->daughterTrackId); - } - if (passedChecks) { - std::vector daughters; - daughters.push_back(&(*it[0])); - for (int i = 1; i < nDaughters; i++) { - daughters.push_back(&(*it[i])); - } - HyperNucCandidate candidate(hyperNucIter, hypNucDaughter, daughters); - if (candidate.checkKfp()) { - // preselections for cascade and hypernucleus daughter - if (candidate.mass <= maxMassCas && candidate.mass >= minMassCas && candidate.getDcaTracks() <= maxDcaTracksCas && candidate.getCt(primVtx) >= minCtCas && candidate.getCt(primVtx) <= maxCtCas && hypNucDaughter->getCt(candidate.recoSV) >= minCtSec && hypNucDaughter->getCt(candidate.recoSV) <= maxCtSec && candidate.getCpa(primVtx) >= minCosPaCas && hypNucDaughter->getCpa(candidate.recoSV) >= minCosPaSvSec) { - candidate.calcDcaToVtx(kfPrimVtx); - if (std::abs(candidate.dcaToPvXY) <= maxDcaMotherToPvXYCas && std::abs(candidate.dcaToPvZ) <= maxDcaMotherToPvZCas) { - hypNucDaughter->calcDcaToVtx(candidate); - if (hypNucDaughter->dcaToVtxXY <= maxDcaMotherToSvXYSec && hypNucDaughter->dcaToVtxZ <= maxDcaMotherToSvZSec) { - collHasCandidate = true; - hypNucDaughter->isUsedSecondary = true; - cascadeHyperNucCandidates.at(hyperNucIter).push_back(candidate); - } - } - } - } - } - it[nDaughters - 1]++; - for (int i = nDaughters - 1; i && it[i] == foundDaughterKfs.at(hyperNuc->daughters.at(i)).end(); i--) { - it[i] = foundDaughterKfs.at(hyperNuc->daughters.at(i)).begin(); - it[i - 1]++; - } - } - } - } //---------------------------------------------------------------------------------------------------------------- - void createMCinfo(aod::McTrackLabels const& trackLabels, aod::McCollisionLabels const&, aod::McParticles const& particlesMC, aod::McCollisions const&, bool cascadesOnly = false) + void createMCinfo(aod::McTrackLabels const& trackLabels, aod::McCollisionLabels const&, aod::McParticles const&, aod::McCollisions const&, bool cascadesOnly = false) { - // check for mcTrue: single (primary & cascade daughter) and cascade hypernuclei - std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; - std::vector>*> candidateVectors = {&singleHyperNucCandidates, &cascadeHyperNucCandidates}; + // check for mcTrue + std::vector*> hypNucVectors = {&singleHyperNuclei}; + std::vector>*> candidateVectors = {&singleHyperNucCandidates}; const int nVecs = candidateVectors.size(); const int startVec = cascadesOnly ? 1 : 0; for (int vec = startVec; vec < nVecs; vec++) { @@ -875,19 +794,6 @@ struct HypKfRecoTask { continue; for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=[const-ref-in-for-loop] (Object is non const and modified in loop) std::vector motherIds; - if (hypCand.isCascade()) { - if (!hypCand.hypNucDaughter->mcTrue) - continue; - const auto& mcPart = particlesMC.rawIteratorAt(hypCand.hypNucDaughter->mcParticleId); - if (!mcPart.has_mothers()) - continue; - for (const auto& mother : mcPart.mothers_as()) { - if (mother.pdgCode() == hyperNuc->pdgCode * hypCand.getSign()) { - motherIds.push_back(mother.globalIndex()); - break; - } - } - } for (const auto& daughter : hypCand.daughters) { if (!daughter->isTrack()) continue; @@ -937,8 +843,8 @@ struct HypKfRecoTask { primVtx.at(0), primVtx.at(1), primVtx.at(2), cents.at(0), cents.at(1), cents.at(2), occupancy, mRunNumber); - std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; - std::vector>*> candidateVectors = {&singleHyperNucCandidates, &cascadeHyperNucCandidates}; + std::vector*> hypNucVectors = {&singleHyperNuclei}; + std::vector>*> candidateVectors = {&singleHyperNucCandidates}; for (unsigned int vec = 0; vec < candidateVectors.size(); vec++) { auto candidateVector = candidateVectors.at(vec); @@ -947,7 +853,7 @@ struct HypKfRecoTask { if (!hyperNuc->active) continue; for (auto& hypCand : candidateVector->at(hyperNucIter)) { // o2-linter: disable=const-ref-in-for-loop (Object is non const and modified in loop) - if (!hypCand.isPrimaryCandidate && !hypCand.isUsedSecondary && !hypCand.isCascade()) + if (!hypCand.isPrimaryCandidate) continue; if (saveOnlyMcTrue && !hypCand.mcTrue && !hypCand.isCascade()) continue; @@ -975,7 +881,7 @@ struct HypKfRecoTask { posMom.at(0), posMom.at(1), posMom.at(2), posMom.at(3), posMom.at(4), posMom.at(5)); vecAddons.push_back(outputDaughterAddonTable.lastIndex()); } - if (hypCand.getNdaughters() > 2) { // o2-linter: disable=magic-number (To be checked) + if (hypCand.getNdaughters() > Decays::kTwoBody) { for (int i = 0; i < hypCand.getNdaughters(); i++) { for (int j = i + 1; j < hypCand.getNdaughters(); j++) { outputSubDaughterTable(hypCand.getSubDaughterMass(i, j)); @@ -983,15 +889,6 @@ struct HypKfRecoTask { } } } - if (hypCand.isCascade()) { - for (int i = 1; i < hypCand.getNdaughters(); i++) { - for (int j = 0; j < hypCand.hypNucDaughter->getNdaughters(); j++) { - outputSubDaughterTable(hypCand.getSubDaughterMassCascade(i, j)); - vecSubDaughters.push_back(outputSubDaughterTable.lastIndex()); - } - } - } - hypCand.kfp.TransportToDecayVertex(); int mcPartTableId; outputHypNucTable( @@ -999,7 +896,7 @@ struct HypKfRecoTask { outputCollisionTable.lastIndex(), vecDaugtherTracks, vecAddons, hypCand.getDaughterTableId(), vecSubDaughters, (vec * nHyperNuclei + hyperNucIter + 1) * hypCand.getSign(), hypCand.isPrimaryCandidate, hypCand.mass, hypCand.px, hypCand.py, hypCand.pz, hypCand.dcaToPvXY, hypCand.dcaToPvZ, hypCand.devToPvXY, - hypCand.dcaToVtxXY, hypCand.dcaToVtxZ, hypCand.chi2, hypCand.recoSV.at(0), hypCand.recoSV.at(1), hypCand.recoSV.at(2)); + hypCand.dcaToVtxXY, hypCand.dcaToVtxZ, hypCand.chi2, /* hypCand.itsMeanClsSize,*/ hypCand.recoSV.at(0), hypCand.recoSV.at(1), hypCand.recoSV.at(2)); hypCand.tableId = outputHypNucTable.lastIndex(); } } @@ -1007,19 +904,18 @@ struct HypKfRecoTask { } //---------------------------------------------------------------------------------------------------------------- - void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcColls, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& particlesMC, aod::McTrackLabels const& trackLabelsMC, aod::McCollisionLabels const& collLabels, aod::TrackAssoc const& tracksColl, CollisionsFull const& colls) + void processMC(CollisionsFullMC const& collisions, aod::McCollisions const& mcColls, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::McParticles const& particlesMC, aod::McTrackLabels const& trackLabelsMC, aod::McCollisionLabels const& collLabels, aod::TrackAssoc const& tracksColl, CollisionsFull const& colls, aod::V0s const& V0s, aod::Decay3Bodys const& decay3bodys, aod::TrackedV0s const& trackedV0s, aod::Tracked3Bodys const& tracked3Bodys) { - isMC = true; mcCollInfos.clear(); mcCollInfos.resize(mcColls.size()); mcPartIndices.clear(); for (const auto& collision : collisions) { if (!collision.has_mcCollision()) continue; - if (collision.sel8() && std::abs(collision.posZ()) < 10) // o2-linter: disable=magic-number (To be checked) + if (collision.sel8() && std::abs(collision.posZ()) < cfgVtxCutZ) mcCollInfos.at(collision.mcCollisionId()).passedEvSel = true; } - std::vector*> hypNucVectors = {&singleHyperNuclei, &cascadeHyperNuclei}; + std::vector*> hypNucVectors = {&singleHyperNuclei}; for (const auto& mcPart : particlesMC) { if (!mcCollInfos.at(mcPart.mcCollisionId()).passedEvSel) continue; @@ -1074,14 +970,15 @@ struct HypKfRecoTask { const uint64_t collIdx = collision.globalIndex(); auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + auto decay3bodyThisCollision = decay3bodys.sliceBy(perCollision3b, collIdx); + findDaughterParticles(tracksByColl, tracks, colls.rawIteratorAt(collision.globalIndex())); - if (cfgSaveOnlyMcTrue || usePidResponse) - checkMCTrueTracks(trackLabelsMC, particlesMC, tracks, colls.rawIteratorAt(collision.globalIndex())); + if (cfgSaveOnlyMcTrue) + checkMCTrueTracks(trackLabelsMC, particlesMC); createKFDaughters(tracks); - createKFHypernuclei(tracks); + createKFHypernuclei(v0TableThisCollision, decay3bodyThisCollision, trackedV0s, tracked3Bodys); createMCinfo(trackLabelsMC, collLabels, particlesMC, mcColls); - createKFCascades(tracks); - createMCinfo(trackLabelsMC, collLabels, particlesMC, mcColls, true); if (!collHasCandidate) continue; @@ -1101,7 +998,7 @@ struct HypKfRecoTask { } PROCESS_SWITCH(HypKfRecoTask, processMC, "MC analysis", false); //---------------------------------------------------------------------------------------------------------------- - void processData(CollisionsFull const& collisions, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::TrackAssoc const& tracksColl) + void processData(CollisionsFull const& collisions, TracksFull const& tracks, aod::BCsWithTimestamps const&, aod::TrackAssoc const& tracksColl, aod::V0s const& V0s, aod::Decay3Bodys const& decay3bodys, aod::TrackedV0s const& trackedV0s, aod::Tracked3Bodys const& tracked3Bodys) { for (const auto& collision : collisions) { @@ -1112,10 +1009,11 @@ struct HypKfRecoTask { continue; const uint64_t collIdx = collision.globalIndex(); auto tracksByColl = tracksColl.sliceBy(perCollision, collIdx); + auto v0TableThisCollision = V0s.sliceBy(perCollisionV0, collIdx); + auto decay3bodyThisCollision = decay3bodys.sliceBy(perCollision3b, collIdx); findDaughterParticles(tracksByColl, tracks, collision); createKFDaughters(tracks); - createKFHypernuclei(tracks); - createKFCascades(tracks); + createKFHypernuclei(v0TableThisCollision, decay3bodyThisCollision, trackedV0s, tracked3Bodys); if (!collHasCandidate) continue; mcCollTableIndex = -1; @@ -1135,7 +1033,7 @@ struct HypKfRecoTask { o2::parameters::GRPMagField* grpmag = 0x0; if (grpo) { o2::base::Propagator::initFieldFromGRP(grpo); - if (bField < -990) { // o2-linter: disable=magic-number (To be checked) + if (bField <= NoVal) { // Fetch magnetic field from ccdb for current collision dBz = grpo->getNominalL3Field(); LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; @@ -1148,7 +1046,7 @@ struct HypKfRecoTask { LOG(fatal) << "Got nullptr from CCDB for path " << grpmagPath << " of object GRPMagField and " << grpPath << " of object GRPObject for timestamp " << run3grpTimestamp; } o2::base::Propagator::initFieldFromGRP(grpmag); - if (bField < -990) { // o2-linter: disable=magic-number (To be checked) + if (bField <= NoVal) { // Fetch magnetic field from ccdb for current collision dBz = std::lround(5.f * grpmag->getL3Current() / 30000.f); LOG(info) << "Retrieved GRP for timestamp " << run3grpTimestamp << " with magnetic field of " << dBz << " kZG"; @@ -1158,30 +1056,6 @@ struct HypKfRecoTask { } mRunNumber = bc.runNumber(); KFParticle::SetField(dBz); - - // PID response - if (!usePidResponse) - return; - if (metadataInfo.isFullyDefined()) { - metadata["RecoPassName"] = metadataInfo.get("RecoPassName"); - LOGP(info, "Automatically setting reco pass for TPC Response to {} from AO2D", metadata["RecoPassName"]); - } else { - LOG(info) << "Setting reco pass for TPC response to default name"; - metadata["RecoPassName"] = "apass5"; - } - const std::string path = pidPath.value; - ccdb->setTimestamp(run3grpTimestamp); - response = ccdb->getSpecific(path, run3grpTimestamp, metadata); - if (!response) { - LOGF(warning, "Unable to find TPC parametrisation for specified pass name - falling back to latest object"); - response = ccdb->getForTimeStamp(path, run3grpTimestamp); - if (!response) { - LOGF(fatal, "Unable to find any TPC object corresponding to timestamp {}!", run3grpTimestamp); - } - } - LOG(info) << "Successfully retrieved TPC PID object from CCDB for timestamp " << run3grpTimestamp << ", recoPass " << metadata["RecoPassName"]; - response->PrintAll(); - betheParams = response->GetBetheBlochParams(); } //---------------------------------------------------------------------------------------------------------------- template @@ -1189,18 +1063,14 @@ struct HypKfRecoTask { { foundDaughterKfs.clear(); foundDaughterKfs.resize(nDaughterParticles); - hypNucDaughterKfs.clear(); - hypNucDaughterKfs.resize(nCascades); singleHyperNucCandidates.clear(); singleHyperNucCandidates.resize(nHyperNuclei); - cascadeHyperNucCandidates.clear(); - cascadeHyperNucCandidates.resize(nCascades); trackIndices.clear(); collHasCandidate = false; collHasMcTrueCandidate = false; histos.fill(HIST("histMagField"), dBz); histos.fill(HIST("histNev"), 0.5); - collPassedEvSel = collision.sel8() && std::abs(collision.posZ()) < 10; // o2-linter: disable=magic-number (To be checked) + collPassedEvSel = collision.sel8() && std::abs(collision.posZ()) < cfgVtxCutZ; occupancy = collision.trackOccupancyInTimeRange(); if (collPassedEvSel) { histos.fill(HIST("histNev"), 1.5); @@ -1214,73 +1084,146 @@ struct HypKfRecoTask { primVtx.assign({collision.posX(), collision.posY(), collision.posZ()}); cents.assign({collision.centFT0A(), collision.centFT0C(), collision.centFT0M()}); } + //---------------------------------------------------------------------------------------------------------------- + bool checkPrimaryHypNuc(HyperNucCandidate& candidate, std::vector& settings) + { + if (!candidate.checkKfp()) + return false; + if (candidate.mass >= settings[kMaxMass] || candidate.mass <= settings[kMinMass]) + return false; + if (candidate.getDcaTracks() >= settings[kMaxDcaTracks]) + return false; + if (candidate.getCt(primVtx) >= settings[kMaxCt] || candidate.getCt(primVtx) <= settings[kMinCt]) + return false; + if (candidate.getCpa(primVtx) <= settings[kMinCosPa]) + return false; + candidate.calcDcaToVtx(kfPrimVtx); + if (std::abs(candidate.dcaToPvXY) >= settings[kMaxDcaMotherToPvXY] || std::abs(candidate.dcaToPvZ) >= settings[kMaxDcaMotherToPvZ]) + return false; + return true; + } + //---------------------------------------------------------------------------------------------------------------- + bool findDaughterKfComb(std::vector& kfDaughters, HyperNucleus* hyperNuc, std::vector& daughterPos, std::vector trackIds) + { + if (daughterPos.size() != trackIds.size()) + return false; + auto vecSize = daughterPos.size(); + std::set foundMatches; + for (size_t dpos = 0; dpos < vecSize; dpos++) { + auto daughterParticle = hyperNuc->daughters.at(daughterPos.at(dpos)); + for (size_t trackId = 0; trackId < vecSize; trackId++) { + auto daughterKf = findDaughterKfByTrackId(daughterParticle, trackIds.at(trackId)); + if (daughterKf >= 0) { + kfDaughters.at(daughterPos.at(dpos)) = &foundDaughterKfs.at(daughterParticle).at(daughterKf); + foundMatches.insert(dpos); + break; + } + } + if (foundMatches.size() != dpos + 1) + return false; + } + return true; + } //---------------------------------------------------------------------------------------------------------------- template void filldedx(T const& track, int species) { + constexpr int NTpcClsMin = 100; + constexpr int NItsClsMin = 2; const float rigidity = getRigidity(track); hDeDx[2 * species]->Fill(track.sign() * rigidity, track.tpcSignal()); - if (track.tpcNClsFound() < 100 || track.itsNCls() < 2) // o2-linter: disable=magic-number (To be checked) + if (track.tpcNClsFound() < NTpcClsMin || track.itsNCls() < NItsClsMin) return; hDeDx[2 * species + 1]->Fill(track.sign() * rigidity, track.tpcSignal()); } - //---------------------------------------------------------------------------------------------------------------- - template - float getTPCnSigma(T const& track, C const& coll, DaughterParticle& particle) + template + bool checkTrack(T const& track, DaughterParticle& particle) + { + if (std::abs(track.eta()) > cfgCutEta) + return false; + if (track.sign() * particle.trkSettings[kTrackCharge] < 0) + return false; + if (particle.trkSettings[kUsePVcontributors] >= 0 && particle.trkSettings[kUsePVcontributors] == track.isPVContributor()) + return false; + if (track.tpcNClsFound() < particle.trkSettings[kMinTPCnCls]) + return false; + if (track.tpcChi2NCl() > particle.trkSettings[kMaxTPCchi2]) + return false; + if (track.itsNCls() < particle.trkSettings[kMinITSnCls]) + return false; + if (track.itsChi2NCl() > particle.trkSettings[kMaxITSchi2]) + return false; + if (getRigidity(track) < particle.trkSettings[kMinRigidity] || getRigidity(track) > particle.trkSettings[kMaxRigidity]) + return false; + if (getMeanItsClsSize(track) < particle.trkSettings[kMinITSmeanClsSize]) + return false; + if (getMeanItsClsSize(track) > particle.trkSettings[kMaxITSmeanClsSize]) + return false; + if (particle.trkSettings[kTOFrequiredabove] >= 0 && getRigidity(track) > particle.trkSettings[kTOFrequiredabove] && (track.mass() < particle.trkSettings[kMinTOFmass] || track.mass() > particle.trkSettings[kMaxTOFmass])) + return false; + return true; + } + //---------------------------------------------------------------------------------------------------------------- + template + float getITSnSigma(T const& track, DaughterParticle& particle) + { + switch (std::abs(particle.pdgCode)) { + case 211: + return itsResponse.nSigmaITS(track); + case 2212: + return itsResponse.nSigmaITS(track); + case o2::constants::physics::kDeuteron: + return itsResponse.nSigmaITS(track); + case o2::constants::physics::kTriton: + return itsResponse.nSigmaITS(track); + case o2::constants::physics::kHelium3: + return itsResponse.nSigmaITS(track); + case o2::constants::physics::kAlpha: + return itsResponse.nSigmaITS(track); + default: + return NoVal; + } + } + //---------------------------------------------------------------------------------------------------------------- + template + float getTPCnSigma(T const& track, DaughterParticle& particle) { const float rigidity = getRigidity(track); - if (!track.hasTPC()) - return -999; - float mMip = 1, chargeFactor = 1; - float* parBB; - - switch (static_cast(cfgTrackPIDsettings->get(particle.name, "useBBparams"))) { + switch (static_cast(cfgTrackPIDsettings->get(particle.name, "PIDmethodTPC"))) { case -1: return 0; case 0: - return isMC ? 0 : response->GetNumberOfSigma(coll, track, particle.getCentralPIDIndex()); + if (particle.name == "proton") + return track.tpcNSigmaPr(); + else if (particle.name == "pion") + return track.tpcNSigmaPi(); + else + return NoVal; case 1: - parBB = &particle.betheParams[0]; - break; - case 2: - mMip = response->GetMIP(); - chargeFactor = std::pow(particle.charge, response->GetChargeFactor()); - parBB = &betheParams[0]; - break; + return particle.getTPCnSigmaBB(rigidity, track.tpcSignal()); default: - return -999; + return NoVal; } - double expBethe{mMip * chargeFactor * o2::common::BetheBlochAleph(static_cast(particle.charge * rigidity / particle.mass), parBB[0], parBB[1], parBB[2], parBB[3], parBB[4])}; - double expSigma{expBethe * particle.resolution}; - float sigmaTPC = static_cast((track.tpcSignal() - expBethe) / expSigma); - return sigmaTPC; - } - //---------------------------------------------------------------------------------------------------------------- - - template - float getTPCnSigmaMC(T const& trk, C const& coll, DaughterParticle& particle1, DaughterParticle& particle2) - { - const float pidval1 = particle1.getCentralPIDIndex(); - const float pidval2 = particle2.getCentralPIDIndex(); - const auto expSignal = response->GetExpectedSignal(trk, pidval2); - const auto expSigma = response->GetExpectedSigma(coll, trk, pidval2); - const auto mcTunedTPCSignal = gRandom->Gaus(expSignal, expSigma); - return response->GetNumberOfSigmaMCTuned(coll, trk, pidval1, mcTunedTPCSignal); } //---------------------------------------------------------------------------------------------------------------- - template float getMeanItsClsSize(T const& track) { + constexpr int NLayers = 8; + constexpr int NBitsPerLayer = 4; + constexpr int BitMask = (1 << NBitsPerLayer) - 1; int sum = 0, n = 0; - for (int i = 0; i < 0x08; i++) { - sum += (track.itsClusterSizes() >> (0x04 * i) & 0x0f); - if (track.itsClusterSizes() >> (0x04 * i) & 0x0f) + for (int i = 0; i < NLayers; i++) { + int clsSize = (track.itsClusterSizes() >> (NBitsPerLayer * i)) & BitMask; + sum += clsSize; + if (clsSize) { n++; + } } - return n > 0 ? static_cast(sum) / n : 0.f; + const float lambda = 1. / std::cosh(track.eta()); + return n > 0 ? (static_cast(sum) / n) * lambda : 0.f; } //---------------------------------------------------------------------------------------------------------------- template @@ -1296,17 +1239,19 @@ struct HypKfRecoTask { template KFParticle createKFParticle(const T& track, float mass, int charge) { + constexpr int Ndim = 3; auto trackparCov = getTrackParCov(track); - std::array fP; - std::array fM; + std::array fP; + std::array fM; trackparCov.getXYZGlo(fP); trackparCov.getPxPyPzGlo(fM); - float fPM[6]; - for (int i = 0; i < 0x03; i++) { + float fPM[2 * Ndim]; + for (int i = 0; i < Ndim; i++) { fPM[i] = fP[i]; - fPM[i + 3] = fM[i] * std::abs(charge); + fPM[i + Ndim] = fM[i] * std::abs(charge); } - std::array fC; + constexpr int NcovPars = 21; + std::array fC; trackparCov.getCovXYZPxPyPzGlo(fC); KFParticle part; part.Create(fPM, fC.data(), std::abs(charge) * track.sign(), mass); @@ -1338,7 +1283,7 @@ struct HypKfRecoTask { std::vector getDaughterVec(unsigned int hypNuc, LabeledArray cfg) { std::vector vec; - for (unsigned int i = 0; i < 0x04; i++) { + for (unsigned int i = kD1; i <= kD4; i++) { std::string daughter = cfg.get(hypNuc, i); if (std::find(particleNames.begin(), particleNames.end(), daughter) == particleNames.end()) break; @@ -1351,8 +1296,9 @@ struct HypKfRecoTask { std::vector getDaughterSignVec(unsigned int hypNuc, LabeledArray cfg) { std::vector vec; - for (unsigned int i = 0; i < 0x04; i++) { - std::string sign = cfg.get(hypNuc, i); + std::string signs = cfg.get(hypNuc, "daughterSigns"); + for (size_t i = 0; i < signs.size(); i++) { + std::string sign(1, signs.at(i)); if (sign != "+" && sign != "-") break; vec.push_back(sign == "+" ? +1 : -1); @@ -1360,6 +1306,30 @@ struct HypKfRecoTask { return vec; } //---------------------------------------------------------------------------------------------------------------- + std::vector getV0DaughterVec(unsigned int hypNuc, LabeledArray cfg) + { + std::vector vec; + std::string v0ds = cfg.get(hypNuc, "useV0for"); + for (size_t i = 0; i < v0ds.size(); i++) { + std::string v0d(1, v0ds.at(i)); + vec.push_back(std::stoi(v0d)); + } + return vec; + } + + //---------------------------------------------------------------------------------------------------------------- + int findDaughterKfByTrackId(int daughter, int trackId) + { + const auto& daughterKfVector = foundDaughterKfs.at(daughter); + int count = 0; + for (const auto& d : daughterKfVector) { + if (d.daughterTrackId == trackId) + return count; + count++; + } + return -1; + } + //---------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------- }; //---------------------------------------------------------------------------------------------------------------- From 304fa1b120211e1a08f8d77f30d33036cd7db7f9 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:13:59 +0100 Subject: [PATCH 4/7] Update trHeAnalysis.cxx --- PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx index 5137841cac4..46a054b75d8 100644 --- a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx +++ b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx @@ -287,7 +287,7 @@ struct TrHeAnalysis { Configurable cfgMaxDCAXY{"cfgMaxDCAXY", 10000.f, "Maximum DCA to PV in Z"}; Configurable cfgMinDCAZ{"cfgMinDCAZ", 0.f, "Minimum DCA to PV in XY"}; Configurable cfgMaxDCAZ{"cfgMaxDCAZ", 10000.f, "Maximum DCA to PV in Z"}; - Configurable cfgTrackSign{"cfgTrackSign", 0, "1: positive only, -1: negative only, 0: all tracks"}; + Configurable cfgTrackSign{"cfgTrackSign", 0, "1: positive only, -1: negative only, 0: all tracks"}; } trackCuts; Configurable> cfgBetheBlochParams{"cfgBetheBlochParams", From 58b6c8ba0d939bc773fc46f250591b67081d35b3 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:19:36 +0100 Subject: [PATCH 5/7] Update trHeAnalysis.cxx --- PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx index 46a054b75d8..5cfed67e4b4 100644 --- a/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx +++ b/PWGLF/TableProducer/Nuspex/trHeAnalysis.cxx @@ -1,6 +1,6 @@ // 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. +// 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". @@ -10,9 +10,7 @@ // or submit itself to any jurisdiction. /// /// \file trHeAnalysis.cxx -/// /// \brief triton and helion analysis on Run 3 pp data -/// /// \author Esther Bartsch , Goethe University Frankfurt #include "MetadataHelper.h" From eaba46ad17ec8802e358835531637af678b95634 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:30:31 +0100 Subject: [PATCH 6/7] Update hypKfRecoTask.cxx --- PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx index 5104536a667..165e8a40dff 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx @@ -47,7 +47,7 @@ #include #include #include - +#include // KFParticle #ifndef HomogeneousField #define HomogeneousField // o2-linter: disable=name/macro (Name is defined in KFParticle package) @@ -232,7 +232,7 @@ struct HyperNucleus { v0DaughterVec.push_back(dv0 - 1); } int getNdaughters() { return static_cast(daughters.size()); } - std::vector getV0daughters() { return v0DaughterVec; }; + std::vector getV0daughters() { return v0DaughterVec; } std::vector getNonV0daughters() { std::vector vec; From 94e43405cbb6eebbdd2bb74252faa7315a26d2e7 Mon Sep 17 00:00:00 2001 From: mhartung71 <50153519+mhartung71@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:34:13 +0100 Subject: [PATCH 7/7] Update hypKfRecoTask.cxx --- PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx index 165e8a40dff..2018c6a53d4 100644 --- a/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/hypKfRecoTask.cxx @@ -45,9 +45,10 @@ #include #include +#include #include #include -#include + // KFParticle #ifndef HomogeneousField #define HomogeneousField // o2-linter: disable=name/macro (Name is defined in KFParticle package)