Skip to content

Commit

Permalink
PWGLF / strange derived data: rounding some vars for better disk use (A…
Browse files Browse the repository at this point in the history
…liceO2Group#4306)

* Rounding some vars for better disk use

* Please consider the following formatting changes (#217)

---------

Co-authored-by: ALICE Builder <[email protected]>
  • Loading branch information
ddobrigk and alibuild authored Jan 14, 2024
1 parent 53d3b3a commit e70e1f6
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 5 deletions.
38 changes: 38 additions & 0 deletions PWGLF/TableProducer/cascadebuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> roundDCAVariables{"roundDCAVariables", false, "round topological variables"};
Configurable<float> precisionDCAs{"precisionDCAs", 0.01f, "precision to keep the DCAs with"};

int mRunNumber;
float d_bz;
float maxSnp; // max sine phi for propagation
Expand Down Expand Up @@ -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<float>(static_cast<int>((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;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -1345,6 +1374,11 @@ struct cascadeBuilder {
bool validCascadeCandidateKF = buildCascadeCandidateWithKF<TTrackTo>(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(),
Expand Down Expand Up @@ -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,
Expand Down
30 changes: 28 additions & 2 deletions PWGLF/TableProducer/lambdakzerobuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,13 @@ struct lambdakzeroBuilder {
Configurable<std::string> mVtxPath{"mVtxPath", "GLO/Calib/MeanVertex", "Path of the mean vertex file"};
Configurable<bool> 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<bool> roundDCAVariables{"roundDCAVariables", false, "round topological variables"};
Configurable<float> precisionDCAs{"precisionDCAs", 0.01f, "precision to keep the DCAs with"};

// generate and fill extra QA histograms if requested
Configurable<bool> d_doQA{"d_doQA", false, "Do basic QA"};
Configurable<int> dQANBinsRadius{"dQANBinsRadius", 500, "Number of radius bins in QA histo"};
Configurable<int> dQANBinsPtCoarse{"dQANBinsPtCoarse", 10, "Number of pT bins in QA histo"};
Expand Down Expand Up @@ -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<float>(static_cast<int>((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;
Expand Down Expand Up @@ -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;
Expand Down
32 changes: 29 additions & 3 deletions PWGLF/TableProducer/strangederivedbuilder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ struct strangederivedbuilder {

Configurable<bool> 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<bool> roundNSigmaVariables{"roundNSigmaVariables", false, "round NSigma variables"};
Configurable<float> precisionNSigmas{"precisionNSigmas", 0.1f, "precision to keep NSigmas"};

// For manual sliceBy
Preslice<aod::V0Datas> V0perCollision = o2::aod::v0data::collisionId;
Preslice<aod::CascDatas> CascperCollision = o2::aod::cascdata::collisionId;
Expand All @@ -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<float>(static_cast<int>((number) / step)) + TMath::Sign(1.0f, number) * (0.5f) * step;
}

void init(InitContext& context)
{
currentCollIdx = -1;
Expand Down Expand Up @@ -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!
Expand Down

0 comments on commit e70e1f6

Please sign in to comment.