From e70e1f6fb0b0e74d57594bfa7d19d476038ad367 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Sun, 14 Jan 2024 20:01:47 +0100 Subject: [PATCH] PWGLF / strange derived data: rounding some vars for better disk use (#4306) * Rounding some vars for better disk use * Please consider the following formatting changes (#217) --------- Co-authored-by: ALICE Builder --- PWGLF/TableProducer/cascadebuilder.cxx | 38 +++++++++++++++++++ PWGLF/TableProducer/lambdakzerobuilder.cxx | 30 ++++++++++++++- PWGLF/TableProducer/strangederivedbuilder.cxx | 32 ++++++++++++++-- 3 files changed, 95 insertions(+), 5 deletions(-) diff --git a/PWGLF/TableProducer/cascadebuilder.cxx b/PWGLF/TableProducer/cascadebuilder.cxx index b36b445d497..4521d9680ad 100644 --- a/PWGLF/TableProducer/cascadebuilder.cxx +++ b/PWGLF/TableProducer/cascadebuilder.cxx @@ -188,6 +188,12 @@ struct cascadeBuilder { ConfigurableAxis axisTopoVarDCAToPV{"axisTopoVarDCAToPV", {200, -1, 1.0}, "single track DCA to PV (cm)"}; ConfigurableAxis axisTopoVarDCAV0ToPV{"axisTopoVarDCAV0ToPV", {200, 0, 5.0}, "V0 DCA to PV (cm)"}; + // round some V0 core variables up to a certain level of precision if requested + // useful to keep derived data sizes under control + // variables that are rounded include the DCAs but not the CosPA (precision needed) + Configurable roundDCAVariables{"roundDCAVariables", false, "round topological variables"}; + Configurable precisionDCAs{"precisionDCAs", 0.01f, "precision to keep the DCAs with"}; + int mRunNumber; float d_bz; float maxSnp; // max sine phi for propagation @@ -273,6 +279,25 @@ struct cascadeBuilder { {"hNegativeITSClusters", "hNegativeITSClusters", {HistType::kTH1D, {{10, -0.5f, 9.5f}}}}, {"hBachelorITSClusters", "hBachelorITSClusters", {HistType::kTH1D, {{10, -0.5f, 9.5f}}}}}}; + float roundToPrecision(float number, float step = 0.01) + { + // this function rounds a certain number in an axis that is quantized by + // the variable 'step'; the rounded number is placed halfway between + // n*step and (n+1)*step such that analysis can be done with absolutely + // no issue with precision 'step'. + return step * static_cast(static_cast((number) / step)) + TMath::Sign(1.0f, number) * (0.5f) * step; + } + + void roundCascadeCandidateVariables() + { + // Do not round actual cascade (pseudo-)track DCAs -> consider they may be tracked, high precision + cascadecandidate.dcacascdau = roundToPrecision(cascadecandidate.dcacascdau, precisionDCAs); + cascadecandidate.v0dcadau = roundToPrecision(cascadecandidate.v0dcadau, precisionDCAs); + cascadecandidate.v0dcanegtopv = roundToPrecision(cascadecandidate.v0dcanegtopv, precisionDCAs); + cascadecandidate.v0dcapostopv = roundToPrecision(cascadecandidate.v0dcapostopv, precisionDCAs); + cascadecandidate.bachDCAxy = roundToPrecision(cascadecandidate.bachDCAxy, precisionDCAs); + } + void resetHistos() { statisticsRegistry.exceptions = 0; @@ -1287,6 +1312,10 @@ struct cascadeBuilder { if (!validCascadeCandidate) continue; // doesn't pass cascade selections + // round the DCA variables to a certain precision if asked + if (roundDCAVariables) + roundCascadeCandidateVariables(); + cascidx(/*cascadecandidate.v0Id, */ cascade.globalIndex(), cascadecandidate.positiveId, cascadecandidate.negativeId, cascadecandidate.bachelorId, cascade.collisionId()); @@ -1345,6 +1374,11 @@ struct cascadeBuilder { bool validCascadeCandidateKF = buildCascadeCandidateWithKF(cascade); if (!validCascadeCandidateKF) continue; // doesn't pass cascade selections + + // round the DCA variables to a certain precision if asked + if (roundDCAVariables) + roundCascadeCandidateVariables(); + registry.fill(HIST("hKFParticleStatistics"), 2.0f); kfcascidx(/*cascadecandidate.v0Id, */ cascade.globalIndex(), @@ -1408,6 +1442,10 @@ struct cascadeBuilder { if (!validCascadeCandidate) continue; // doesn't pass cascade selections + // round the DCA variables to a certain precision if asked + if (roundDCAVariables) + roundCascadeCandidateVariables(); + // fill regular tables (no strangeness tracking) cascidx(/*cascadecandidate.v0Id, */ cascade.globalIndex(), cascadecandidate.positiveId, cascadecandidate.negativeId, diff --git a/PWGLF/TableProducer/lambdakzerobuilder.cxx b/PWGLF/TableProducer/lambdakzerobuilder.cxx index a695d7c212a..0cee635b5bd 100644 --- a/PWGLF/TableProducer/lambdakzerobuilder.cxx +++ b/PWGLF/TableProducer/lambdakzerobuilder.cxx @@ -147,7 +147,13 @@ struct lambdakzeroBuilder { Configurable mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"}; Configurable skipGRPOquery{"skipGRPOquery", true, "skip grpo query"}; - // generate and fill extra QA histograms is requested + // round some V0 core variables up to a certain level of precision if requested + // useful to keep derived data sizes under control + // variables that are rounded include the DCAs but not the CosPA (precision needed) + Configurable roundDCAVariables{"roundDCAVariables", false, "round topological variables"}; + Configurable precisionDCAs{"precisionDCAs", 0.01f, "precision to keep the DCAs with"}; + + // generate and fill extra QA histograms if requested Configurable d_doQA{"d_doQA", false, "Do basic QA"}; Configurable dQANBinsRadius{"dQANBinsRadius", 500, "Number of radius bins in QA histo"}; Configurable dQANBinsPtCoarse{"dQANBinsPtCoarse", 10, "Number of pT bins in QA histo"}; @@ -238,6 +244,23 @@ struct lambdakzeroBuilder { return std::sqrt((std::pow((pvY - Y) * Pz - (pvZ - Z) * Py, 2) + std::pow((pvX - X) * Pz - (pvZ - Z) * Px, 2) + std::pow((pvX - X) * Py - (pvY - Y) * Px, 2)) / (Px * Px + Py * Py + Pz * Pz)); } + float roundToPrecision(float number, float step = 0.01) + { + // this function rounds a certain number in an axis that is quantized by + // the variable 'step'; the rounded number is placed halfway between + // n*step and (n+1)*step such that analysis can be done with absolutely + // no issue with precision 'step'. + return step * static_cast(static_cast((number) / step)) + TMath::Sign(1.0f, number) * (0.5f) * step; + } + + void roundV0CandidateVariables() + { + v0candidate.dcaV0dau = roundToPrecision(v0candidate.dcaV0dau, precisionDCAs); + v0candidate.posDCAxy = roundToPrecision(v0candidate.posDCAxy, precisionDCAs); + v0candidate.negDCAxy = roundToPrecision(v0candidate.negDCAxy, precisionDCAs); + v0candidate.dcav0topv = roundToPrecision(v0candidate.dcav0topv, precisionDCAs); + } + void resetHistos() { statisticsRegistry.exceptions = 0; @@ -795,9 +818,12 @@ struct lambdakzeroBuilder { continue; // doesn't pass selections } + // round the DCA variables to a certain precision if asked + if (roundDCAVariables) + roundV0CandidateVariables(); + // V0 logic reminder // 0: v0 saved for the only due to the cascade, 1: standalone v0, 3: standard v0 with photon-only test - if (V0.v0Type() > 0) { if (V0.v0Type() > 1 && !storePhotonCandidates) continue; diff --git a/PWGLF/TableProducer/strangederivedbuilder.cxx b/PWGLF/TableProducer/strangederivedbuilder.cxx index b6445933c7f..6c4a6c3b9df 100644 --- a/PWGLF/TableProducer/strangederivedbuilder.cxx +++ b/PWGLF/TableProducer/strangederivedbuilder.cxx @@ -124,6 +124,12 @@ struct strangederivedbuilder { Configurable fillEmptyCollisions{"fillEmptyCollisions", false, "fill collision entries without candidates"}; + // round Nsigma variables up to a certain level of precision if requested + // useful to keep derived data sizes under control + // variables that are rounded include the DCAs but not the CosPA (precision needed) + Configurable roundNSigmaVariables{"roundNSigmaVariables", false, "round NSigma variables"}; + Configurable precisionNSigmas{"precisionNSigmas", 0.1f, "precision to keep NSigmas"}; + // For manual sliceBy Preslice V0perCollision = o2::aod::v0data::collisionId; Preslice CascperCollision = o2::aod::cascdata::collisionId; @@ -132,6 +138,15 @@ struct strangederivedbuilder { int64_t currentCollIdx; + float roundToPrecision(float number, float step = 0.01) + { + // this function rounds a certain number in an axis that is quantized by + // the variable 'step'; the rounded number is placed halfway between + // n*step and (n+1)*step such that analysis can be done with absolutely + // no issue with precision 'step'. + return step * static_cast(static_cast((number) / step)) + TMath::Sign(1.0f, number) * (0.5f) * step; + } + void init(InitContext& context) { currentCollIdx = -1; @@ -329,9 +344,20 @@ struct strangederivedbuilder { if (trackMap[tr.globalIndex()] >= 0) { dauTrackExtras(tr.detectorMap(), tr.itsClusterSizes(), tr.tpcNClsFound(), tr.tpcNClsCrossedRows()); - dauTrackTPCPIDs(tr.tpcSignal(), tr.tpcNSigmaEl(), - tr.tpcNSigmaPi(), tr.tpcNSigmaKa(), - tr.tpcNSigmaPr(), tr.tpcNSigmaHe()); + + // round if requested + if (roundNSigmaVariables) { + dauTrackTPCPIDs(tr.tpcSignal(), + roundToPrecision(tr.tpcNSigmaEl(), precisionNSigmas), + roundToPrecision(tr.tpcNSigmaPi(), precisionNSigmas), + roundToPrecision(tr.tpcNSigmaKa(), precisionNSigmas), + roundToPrecision(tr.tpcNSigmaPr(), precisionNSigmas), + roundToPrecision(tr.tpcNSigmaHe(), precisionNSigmas)); + } else { + dauTrackTPCPIDs(tr.tpcSignal(), tr.tpcNSigmaEl(), + tr.tpcNSigmaPi(), tr.tpcNSigmaKa(), + tr.tpcNSigmaPr(), tr.tpcNSigmaHe()); + } } } // done!