From 2d4b3e703d3c2c482b8b82c93812fe038992efb1 Mon Sep 17 00:00:00 2001 From: Stefanie Mrozinski Date: Wed, 2 Dec 2026 10:34:40 +0100 Subject: [PATCH 1/2] add option to selection precision of stored covariance --- .../TableProducer/photonconversionbuilder.h | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h index 13f1ae9bbdc..5b3a1488ade 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h @@ -78,6 +78,7 @@ #include #include +#include #include #include #include @@ -325,6 +326,7 @@ struct PhotonConversionBuilder { Configurable fillFreeLegIds{"fillFreeLegIds", false, "fill PCMFreeLegIds (the table is written in any case, empty if false): the free legs (as for fillFreeLegs) as AO2D (collision, track) indices only, for the mixer on linked derived data (the leg parameters are read from the parent AO2D); only selected collisions"}; Configurable fillFreeLegsDonorEvery{"fillFreeLegsDonorEvery", 0, "with fillFreeLegs / fillFreeLegIds: free legs only for donor collisions, every N-th selected collision on average (deterministic hash of the collision index); the mixer takes the free legs of the mixed event from donors only (derived-data size). 0, 1 = all collisions"}; Configurable fillFreeLegs{"fillFreeLegs", false, "fill PCMFreeLegs (the table is written in any case, empty if false): tracks that pass the leg cuts (as the finder takes them) and are the leg of no stored photon, with the parameters the V0 fit would use (TPC-only legs moved to their own collision); pooled by the mixer with cfgPoolFreeLegs"}; + Configurable storeCovBits{"storeCovBits", 0, "derived-data size, run 1 only: number of mantissa bits kept; 8 = relative precision 0 = full precision (23 bits)"}; // deduplication settings struct : ConfigurableGroup { @@ -991,6 +993,30 @@ struct PhotonConversionBuilder { return cospaRZ; } + static float roundMantissa(const float x, const int bits) + { + constexpr int NMantissaBits = 23; + if constexpr (kMixedInstance) { + return x; + } + if (bits <= 0 || bits >= NMantissaBits || !std::isfinite(x)) { + return x; + } + const int drop = NMantissaBits - bits; + auto u = std::bit_cast(x); + u += (1u << (drop - 1)); + u &= ~((1u << drop) - 1u); + const float y = std::bit_cast(u); + return std::isfinite(y) ? y : x; + } + std::array roundCov(std::array cov) const + { + for (auto& c : cov) { // o2-linter: disable=const-ref-in-for-loop (elements are rounded in place) + c = roundMantissa(c, storeCovBits.value); + } + return cov; + } + template void fillTrackTable(TTrack const& track, TShiftedTrack const& shiftedtrack, const float dcaXY, const float dcaZ) { @@ -1010,7 +1036,7 @@ struct PhotonConversionBuilder { void fillLegCovTable(o2::track::TrackParCov const& trackParCov) { - const auto cov = trackParCov.getCov(); + const auto cov = roundCov(trackParCov.getCov()); v0legsCov(trackParCov.getX(), trackParCov.getAlpha(), trackParCov.getY(), trackParCov.getZ(), trackParCov.getSnp(), trackParCov.getTgl(), trackParCov.getQ2Pt(), cov.data()); } @@ -1059,7 +1085,7 @@ struct PhotonConversionBuilder { ++nFree; continue; } - const auto cov = par.getCov(); + const auto cov = roundCov(par.getCov()); pcmfreelegs(track.collisionId(), track.globalIndex(), track.sign(), par.getX(), par.getAlpha(), par.getY(), par.getZ(), par.getSnp(), par.getTgl(), par.getQ2Pt(), cov.data(), track.tpcNClsFindable(), track.tpcNClsFindableMinusFound(), track.tpcNClsFindableMinusCrossedRows(), track.tpcNClsShared(), From 34705a9ddc0936f28ec25be0624899f7606c5fb2 Mon Sep 17 00:00:00 2001 From: Stefanie Mrozinski Date: Wed, 2 Dec 2026 11:24:05 +0100 Subject: [PATCH 2/2] include TrackParametrization.h for kCovMatSize, auto for bit_cast --- PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h index 5b3a1488ade..d970c98ed0e 100644 --- a/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h +++ b/PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h @@ -65,6 +65,7 @@ #include #include #include +#include #include // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h) #include @@ -1006,7 +1007,7 @@ struct PhotonConversionBuilder { auto u = std::bit_cast(x); u += (1u << (drop - 1)); u &= ~((1u << drop) - 1u); - const float y = std::bit_cast(u); + const auto y = std::bit_cast(u); return std::isfinite(y) ? y : x; } std::array roundCov(std::array cov) const