From f59ce23728d7fdb9e34ebcb7f87913f7f31f7b57 Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Wed, 25 Nov 2026 16:38:39 +0100 Subject: [PATCH 1/3] SVertexer: fix V0 causality check for prongs without ITS For global tracks with a TPC part but no ITS part (TPC-TOF, TPC-TRD, TPC-TRD-TOF) the radius used in the V0 causality check was the radius of the track parameters, i.e. the TPC inner reference (~83 cm). A V0 decaying inside the TPC with such a prong was therefore always rejected, since its radius exceeded this "innermost point" by more than causalityRTolerance. The upper side of the check (V0 radius must not exceed the prong's innermost measured point) now uses the radius of the innermost TPC cluster of these tracks, as already done for TPC-only tracks (correctTPCTrack, now through getTPCInnermostR). The lower side (maxV0ToProngsRDiff) is unchanged: with the innermost cluster it would reject V0s whose TPC track misses its inner part. The TPC cluster references are also set up when TPC-only tracks are excluded (mExcludeTPCtracks), so that the check works in that configuration too. Pb-Pb MC TF (anchored, production settings): identical V0s except one additional true K0s at r = 110 cm, also with mExcludeTPCtracks=true. K0s gun MC, K0s decaying at 85-200 cm with both prongs reconstructed: found 2 -> 18 of 42 (with maxRIni=250 and maxDCAXYToMeanVertex=2 for this test). Co-Authored-By: Claude Opus 5.5 --- .../include/DetectorsVertexing/SVertexer.h | 2 + Detectors/Vertexing/src/SVertexer.cxx | 44 +++++++++++++++---- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index 4d783b0018fc3..14c5d49b7c271 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -103,6 +103,7 @@ class SVertexer bool hasTPC = false; int8_t nITSclu = -1; bool compatibleProton = false; // dE/dx compatibility with proton hypothesis (FIXME: use better, uint8_t compat mask?) + float innermostR = -1.f; // radius of the innermost measured point if it differs from minR (tracks with TPC but without ITS), < 0: minR bool hasITS() const { return nITSclu > 0; @@ -161,6 +162,7 @@ class SVertexer bool acceptTrack(const GIndex gid, const o2::track::TrackParCov& trc) const; bool processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int vtxid); float correctTPCTrack(TrackCand& trc, const o2::tpc::TrackTPC& tTPC, float tmus, float tmusErr) const; + float getTPCInnermostR(const o2::tpc::TrackTPC& tTPC, float tTB) const; uint64_t getPairIdx(GIndex id1, GIndex id2) const { diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index 44e78fd911056..6747d2ca6a498 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -455,6 +455,7 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a bool isTPCloaded = recoData.isTrackSourceLoaded(GIndex::TPC); bool isITSloaded = recoData.isTrackSourceLoaded(GIndex::ITS); bool isITSTPCloaded = recoData.isTrackSourceLoaded(GIndex::ITSTPC); + mTPCClusterIdxStruct = nullptr; if (isTPCloaded && !mSVParams->mExcludeTPCtracks) { mTPCTracksArray = recoData.getTPCTracks(); mTPCTrackClusIdx = recoData.getTPCTracksClusterRefs(); @@ -462,6 +463,9 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a mTPCRefitterShMap = recoData.clusterShMapTPC; mTPCRefitterOccMap = mRecoCont->occupancyMapTPC; mTPCRefitter = std::make_unique(mTPCClusterIdxStruct, mTPCCorrMaps, o2::base::Propagator::Instance()->getNominalBz(), mTPCTrackClusIdx.data(), 0, mTPCRefitterShMap.data(), mTPCRefitterOccMap.data(), mTPCRefitterOccMap.size(), nullptr, o2::base::Propagator::Instance()); + } else if (isTPCloaded && recoData.inputsTPCclusters) { // TPC-only tracks excluded: clusters still needed for the innermost radius of global tracks + mTPCTrackClusIdx = recoData.getTPCTracksClusterRefs(); + mTPCClusterIdxStruct = &recoData.inputsTPCclusters->clusterIndex; } std::unordered_map> tmap; @@ -557,6 +561,13 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a int posneg = trc.getSign() < 0 ? 1 : 0; float r = std::sqrt(trc.getX() * trc.getX() + trc.getY() * trc.getY()); mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r, hasTPC, nITSclu, compatibleWithProton}); + if (hasTPC && !itsGID.isIndexSet() && tvid.getSource() != GIndex::TPC && mTPCClusterIdxStruct && mTPCCorrMaps) { + // track with TPC but without ITS (e.g. TPC-TOF, TPC-TRD): its parameters are at the TPC inner reference; the V0 must not lie + // beyond its innermost measured point, the innermost TPC cluster (transformed with the TPC track's time, the radius barely + // depends on it). Needs the TPC clusters, i.e. TPC among the vertexing sources. + const auto& tpcTrack = recoData.getTPCTrack(tpcGID); + mTracksPool[posneg].back().innermostR = getTPCInnermostR(tpcTrack, tpcTrack.getTime0()); + } if (tvid.getSource() == GIndex::TPC) { // constrained TPC track? correctTPCTrack(mTracksPool[posneg].back(), mTPCTracksArray[tvid], -1, -1); } @@ -648,9 +659,14 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, return false; } float rv0 = std::sqrt(r2v0), drv0P = rv0 - seedP.minR, drv0N = rv0 - seedN.minR; - if (drv0P > mSVParams->causalityRTolerance || drv0P < -mSVParams->maxV0ToProngsRDiff || - drv0N > mSVParams->causalityRTolerance || drv0N < -mSVParams->maxV0ToProngsRDiff) { - LOG(debug) << "RejCausality " << drv0P << " " << drv0N; + // upper side of the causality check: the V0 must not lie beyond the innermost measured point of a prong. The lower side + // (maxV0ToProngsRDiff) stays with minR, the TPC inner reference for tracks with TPC but without ITS: with the innermost cluster + // it would reject V0s whose TPC track misses its inner part. + const float drv0PUp = seedP.innermostR > 0.f ? rv0 - seedP.innermostR : drv0P; + const float drv0NUp = seedN.innermostR > 0.f ? rv0 - seedN.innermostR : drv0N; + if (drv0PUp > mSVParams->causalityRTolerance || drv0P < -mSVParams->maxV0ToProngsRDiff || + drv0NUp > mSVParams->causalityRTolerance || drv0N < -mSVParams->maxV0ToProngsRDiff) { + LOG(debug) << "RejCausality " << drv0PUp << " " << drv0P << " " << drv0NUp << " " << drv0N; return false; } const int cand = 0; @@ -1362,16 +1378,28 @@ float SVertexer::correctTPCTrack(SVertexer::TrackCand& trc, const o2::tpc::Track // eventually should be refitted, at the moment we simply shift... trc.setZ(tTPC.getZ() + (tTPC.hasASideClustersOnly() ? dDrift : -dDrift)); trc.setCov(trc.getSigmaZ2() + driftErr * driftErr, o2::track::kSigZ2); - uint8_t sector, row; + trc.minR = getTPCInnermostR(tTPC, tTB); + return driftErr; +} + +//______________________________________________ +float SVertexer::getTPCInnermostR(const o2::tpc::TrackTPC& tTPC, float tTB) const +{ + // radius of the innermost TPC cluster of the track, transformed with the time tTB [TPC time bins], at least the TPC inner + // reference radius + uint8_t sector; + uint8_t row; auto cl = &tTPC.getCluster(mTPCTrackClusIdx, tTPC.getNClusters() - 1, *mTPCClusterIdxStruct, sector, row); - float x = 0, y = 0, z = 0; + float x = 0; + float y = 0; + float z = 0; mTPCCorrMaps->Transform(sector, row, cl->getPad(), cl->getTime(), x, y, z, tTB); if (x < o2::constants::geom::XTPCInnerRef) { x = o2::constants::geom::XTPCInnerRef; } - trc.minR = std::sqrt(x * x + y * y); - LOGP(debug, "set MinR = {} for row {}, x:{}, y:{}, z:{}", trc.minR, row, x, y, z); - return driftErr; + const float r = std::sqrt(x * x + y * y); + LOGP(debug, "innermost TPC cluster R = {} for row {}, x:{}, y:{}, z:{}", r, row, x, y, z); + return r; } //______________________________________________ From 373356ecb00fdca5a87d670585d248623418d1c7 Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Wed, 25 Nov 2026 20:09:29 +0100 Subject: [PATCH 2/3] SVertexer: rename innermostR to rInnerUpdate, place it after minR Review: more explicit name; next to minR the struct has less padding. Co-Authored-By: Claude Opus 5.5 --- .../Vertexing/include/DetectorsVertexing/SVertexer.h | 4 ++-- Detectors/Vertexing/src/SVertexer.cxx | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index 14c5d49b7c271..e7cd41ae3ed10 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -99,11 +99,11 @@ class SVertexer struct TrackCand : o2::track::TrackParCov { GIndex gid{}; VBracket vBracket{}; - float minR = 0; // track lowest point r + float minR = 0; // track lowest point r + float rInnerUpdate = -1.f; // radius of the innermost measured point if it differs from minR (tracks with TPC but without ITS), < 0: minR bool hasTPC = false; int8_t nITSclu = -1; bool compatibleProton = false; // dE/dx compatibility with proton hypothesis (FIXME: use better, uint8_t compat mask?) - float innermostR = -1.f; // radius of the innermost measured point if it differs from minR (tracks with TPC but without ITS), < 0: minR bool hasITS() const { return nITSclu > 0; diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index 6747d2ca6a498..efa610999abf5 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -560,13 +560,13 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a int posneg = trc.getSign() < 0 ? 1 : 0; float r = std::sqrt(trc.getX() * trc.getX() + trc.getY() * trc.getY()); - mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r, hasTPC, nITSclu, compatibleWithProton}); + mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r, -1.f, hasTPC, nITSclu, compatibleWithProton}); if (hasTPC && !itsGID.isIndexSet() && tvid.getSource() != GIndex::TPC && mTPCClusterIdxStruct && mTPCCorrMaps) { // track with TPC but without ITS (e.g. TPC-TOF, TPC-TRD): its parameters are at the TPC inner reference; the V0 must not lie // beyond its innermost measured point, the innermost TPC cluster (transformed with the TPC track's time, the radius barely // depends on it). Needs the TPC clusters, i.e. TPC among the vertexing sources. const auto& tpcTrack = recoData.getTPCTrack(tpcGID); - mTracksPool[posneg].back().innermostR = getTPCInnermostR(tpcTrack, tpcTrack.getTime0()); + mTracksPool[posneg].back().rInnerUpdate = getTPCInnermostR(tpcTrack, tpcTrack.getTime0()); } if (tvid.getSource() == GIndex::TPC) { // constrained TPC track? correctTPCTrack(mTracksPool[posneg].back(), mTPCTracksArray[tvid], -1, -1); @@ -662,8 +662,8 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, // upper side of the causality check: the V0 must not lie beyond the innermost measured point of a prong. The lower side // (maxV0ToProngsRDiff) stays with minR, the TPC inner reference for tracks with TPC but without ITS: with the innermost cluster // it would reject V0s whose TPC track misses its inner part. - const float drv0PUp = seedP.innermostR > 0.f ? rv0 - seedP.innermostR : drv0P; - const float drv0NUp = seedN.innermostR > 0.f ? rv0 - seedN.innermostR : drv0N; + const float drv0PUp = seedP.rInnerUpdate > 0.f ? rv0 - seedP.rInnerUpdate : drv0P; + const float drv0NUp = seedN.rInnerUpdate > 0.f ? rv0 - seedN.rInnerUpdate : drv0N; if (drv0PUp > mSVParams->causalityRTolerance || drv0P < -mSVParams->maxV0ToProngsRDiff || drv0NUp > mSVParams->causalityRTolerance || drv0N < -mSVParams->maxV0ToProngsRDiff) { LOG(debug) << "RejCausality " << drv0PUp << " " << drv0P << " " << drv0NUp << " " << drv0N; @@ -1324,7 +1324,7 @@ bool SVertexer::processTPCTrack(const o2::tpc::TrackTPC& trTPC, GIndex gid, int } } - auto& trLoc = mTracksPool[posneg].emplace_back(TrackCand{trTPC, gid, {vtxid, vtxid}, 0., true, -1, compatibleWithProton}); + auto& trLoc = mTracksPool[posneg].emplace_back(TrackCand{trTPC, gid, {vtxid, vtxid}, 0., -1.f, true, -1, compatibleWithProton}); auto err = correctTPCTrack(trLoc, trTPC, twe.getTimeStamp(), twe.getTimeStampError()); if (err < 0) { mTracksPool[posneg].pop_back(); // discard From 17d1bc316bbe1366b91fce8ab7c7cc039f21a9cf Mon Sep 17 00:00:00 2001 From: Matthias Kleiner Date: Wed, 25 Nov 2026 20:46:02 +0100 Subject: [PATCH 3/3] SVertexer: TPC-only tracks like TPC-TRD / TPC-TOF in the V0 causality check Review: for all tracks with TPC but without ITS the upper side of the check uses the innermost cluster (rInnerUpdate) and the lower side (maxV0ToProngsRDiff) the TPC inner reference (minR). TPC-only tracks so far had minR = innermost cluster for both sides, i.e. a tighter lower side for tracks missing their inner part. 12 LHC26h3 Pb-Pb MC TFs (CCDB settings), V0s with a leg without ITS: +182 true photons (+6.6 %), K0s / Lambda unchanged, +394 fakes (fake fraction 32 -> 36 %); all V0s +2.2 %, same CPU. With the photon tuning off: +42 photons, +2 K0s / Lambda, +736 fakes. Co-Authored-By: Claude Opus 5.5 --- .../include/DetectorsVertexing/SVertexer.h | 2 +- Detectors/Vertexing/src/SVertexer.cxx | 15 +++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h index e7cd41ae3ed10..ac38909accc8d 100644 --- a/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h +++ b/Detectors/Vertexing/include/DetectorsVertexing/SVertexer.h @@ -99,7 +99,7 @@ class SVertexer struct TrackCand : o2::track::TrackParCov { GIndex gid{}; VBracket vBracket{}; - float minR = 0; // track lowest point r + float minR = 0; // track lowest point r (tracks with TPC but without ITS: the TPC inner reference) float rInnerUpdate = -1.f; // radius of the innermost measured point if it differs from minR (tracks with TPC but without ITS), < 0: minR bool hasTPC = false; int8_t nITSclu = -1; diff --git a/Detectors/Vertexing/src/SVertexer.cxx b/Detectors/Vertexing/src/SVertexer.cxx index efa610999abf5..87153fe6844b5 100644 --- a/Detectors/Vertexing/src/SVertexer.cxx +++ b/Detectors/Vertexing/src/SVertexer.cxx @@ -562,9 +562,9 @@ void SVertexer::buildT2V(const o2::globaltracking::RecoContainer& recoData) // a float r = std::sqrt(trc.getX() * trc.getX() + trc.getY() * trc.getY()); mTracksPool[posneg].emplace_back(TrackCand{trc, tvid, {iv, iv}, r, -1.f, hasTPC, nITSclu, compatibleWithProton}); if (hasTPC && !itsGID.isIndexSet() && tvid.getSource() != GIndex::TPC && mTPCClusterIdxStruct && mTPCCorrMaps) { - // track with TPC but without ITS (e.g. TPC-TOF, TPC-TRD): its parameters are at the TPC inner reference; the V0 must not lie - // beyond its innermost measured point, the innermost TPC cluster (transformed with the TPC track's time, the radius barely - // depends on it). Needs the TPC clusters, i.e. TPC among the vertexing sources. + // track with TPC but without ITS (e.g. TPC-TOF, TPC-TRD): its parameters are at the TPC inner reference (minR); the V0 must + // not lie beyond its innermost measured point, the innermost TPC cluster (transformed with the TPC track's time, the radius + // barely depends on it). Needs the TPC clusters, i.e. TPC among the vertexing sources. TPC-only tracks: in correctTPCTrack. const auto& tpcTrack = recoData.getTPCTrack(tpcGID); mTracksPool[posneg].back().rInnerUpdate = getTPCInnermostR(tpcTrack, tpcTrack.getTime0()); } @@ -660,8 +660,8 @@ bool SVertexer::checkV0(const TrackCand& seedP, const TrackCand& seedN, int iP, } float rv0 = std::sqrt(r2v0), drv0P = rv0 - seedP.minR, drv0N = rv0 - seedN.minR; // upper side of the causality check: the V0 must not lie beyond the innermost measured point of a prong. The lower side - // (maxV0ToProngsRDiff) stays with minR, the TPC inner reference for tracks with TPC but without ITS: with the innermost cluster - // it would reject V0s whose TPC track misses its inner part. + // (maxV0ToProngsRDiff) uses minR, for all tracks with TPC but without ITS the TPC inner reference: with the innermost cluster it + // would reject V0s whose TPC track misses its inner part. const float drv0PUp = seedP.rInnerUpdate > 0.f ? rv0 - seedP.rInnerUpdate : drv0P; const float drv0NUp = seedN.rInnerUpdate > 0.f ? rv0 - seedN.rInnerUpdate : drv0N; if (drv0PUp > mSVParams->causalityRTolerance || drv0P < -mSVParams->maxV0ToProngsRDiff || @@ -1378,7 +1378,10 @@ float SVertexer::correctTPCTrack(SVertexer::TrackCand& trc, const o2::tpc::Track // eventually should be refitted, at the moment we simply shift... trc.setZ(tTPC.getZ() + (tTPC.hasASideClustersOnly() ? dDrift : -dDrift)); trc.setCov(trc.getSigmaZ2() + driftErr * driftErr, o2::track::kSigZ2); - trc.minR = getTPCInnermostR(tTPC, tTB); + // as for the other tracks with TPC but without ITS: upper side of the V0 causality check at the innermost cluster, lower side at + // the TPC inner reference + trc.rInnerUpdate = getTPCInnermostR(tTPC, tTB); + trc.minR = o2::constants::geom::XTPCInnerRef; return driftErr; }