Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions PWGEM/PhotonMeson/TableProducer/photonconversionbuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#include <ReconstructionDataFormats/HelixHelper.h>
#include <ReconstructionDataFormats/PID.h>
#include <ReconstructionDataFormats/Track.h>
#include <ReconstructionDataFormats/TrackParametrization.h>

#include <Math/Vector4D.h> // IWYU pragma: keep (do not replace with Math/Vector4Dfwd.h)
#include <Math/Vector4Dfwd.h>
Expand All @@ -78,6 +79,7 @@

#include <algorithm>
#include <array>
#include <bit>
#include <chrono>
#include <cmath>
#include <cstddef>
Expand Down Expand Up @@ -325,6 +327,7 @@ struct PhotonConversionBuilder {
Configurable<bool> 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<int> 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<bool> 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<int> 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 {
Expand Down Expand Up @@ -991,6 +994,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<uint32_t>(x);
u += (1u << (drop - 1));
u &= ~((1u << drop) - 1u);
const auto y = std::bit_cast<float>(u);
return std::isfinite(y) ? y : x;
}
std::array<float, o2::track::kCovMatSize> roundCov(std::array<float, o2::track::kCovMatSize> 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 <bool isMC, o2::soa::is_iterator TTrack, typename TShiftedTrack>
void fillTrackTable(TTrack const& track, TShiftedTrack const& shiftedtrack, const float dcaXY, const float dcaZ)
{
Expand All @@ -1010,7 +1037,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());
}
Expand Down Expand Up @@ -1059,7 +1086,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(),
Expand Down
Loading