diff --git a/PWGLF/Utils/strangenessBuilderHelper.h b/PWGLF/Utils/strangenessBuilderHelper.h index c4adf1c2874..23be7279c56 100644 --- a/PWGLF/Utils/strangenessBuilderHelper.h +++ b/PWGLF/Utils/strangenessBuilderHelper.h @@ -266,7 +266,10 @@ class strangenessBuilderHelper //_______________________________________________________________________ // standard build V0 function. Populates ::v0 object // ::v0 will be initialized to defaults if build fails - template + // --- useSelections: meant to maximize recovery, but beware high cost in CPU + // --- calculateProngDCAtoPV: optionally don't propagate prongs to PV, saves + // CPU, of interest when dealing with de-duplication (variable not checked) + template bool buildV0Candidate(int collisionIndex, float pvX, float pvY, float pvZ, TTrack const& positiveTrack, @@ -277,6 +280,8 @@ class strangenessBuilderHelper bool calculateCovariance = false, bool acceptTPCOnly = false) { + v0 = {}; // safe initialization: start new + if constexpr (useSelections) { // verify track quality if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) { @@ -296,41 +301,50 @@ class strangenessBuilderHelper v0 = {}; return false; } - if (!acceptTPCOnly && !positiveTrack.hasITS()) { + if (!acceptTPCOnly && !positiveTrack.hasITS() && !negativeTrack.hasTRD() && !negativeTrack.hasTOF()) { v0 = {}; return false; } - if (!acceptTPCOnly && !negativeTrack.hasITS()) { + if (!acceptTPCOnly && !negativeTrack.hasITS() && !negativeTrack.hasTRD() && !negativeTrack.hasTOF()) { v0 = {}; return false; } } - // Calculate DCA with respect to the collision associated to the V0 - std::array dcaInfo; + if constexpr (calculateProngDCAtoPV) { + // Calculate DCA with respect to the collision associated to the V0 + std::array dcaInfo; - // do DCA to PV on copies instead of originals - auto positiveTrackParamCopy = positiveTrackParam; - auto negativeTrackParamCopy = negativeTrackParam; + // do DCA to PV on TrackPar copies and not TrackParCov + // TrackPar preferred: don't calculate multiple scattering / CovMat changes + // Spares CPU since variables not checked + o2::track::TrackPar positiveTrackParamCopy(positiveTrackParam); + o2::track::TrackPar negativeTrackParamCopy(negativeTrackParam); - o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); - v0.positiveDCAxy = dcaInfo[0]; + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.positiveDCAxy = dcaInfo[0]; - if constexpr (useSelections) { - if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) { - v0 = {}; - return false; + if constexpr (useSelections) { + if (std::fabs(v0.positiveDCAxy) < v0selections.dcapostopv) { + v0 = {}; + return false; + } } - } - o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); - v0.negativeDCAxy = dcaInfo[0]; + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted + o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); + v0.negativeDCAxy = dcaInfo[0]; - if constexpr (useSelections) { - if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { - v0 = {}; - return false; + if constexpr (useSelections) { + if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) { + v0 = {}; + return false; + } } + } else { + v0.positiveDCAxy = 0.0f; // default invalid + v0.negativeDCAxy = 0.0f; // default invalid } // Perform DCA fit @@ -340,10 +354,12 @@ class strangenessBuilderHelper nCand = fitter.process(positiveTrackParam, negativeTrackParam); } catch (...) { v0 = {}; + fitter.setCollinear(false); // even if returned, reset return false; } if (nCand == 0) { v0 = {}; + fitter.setCollinear(false); // even if returned, reset return false; } fitter.setCollinear(false); // proper cleaning: when exiting this loop, always reset to not collinear @@ -354,6 +370,7 @@ class strangenessBuilderHelper std::array dcaV0Info; // propagate to collision vertex + dcaV0Info[0] = dcaV0Info[1] = 999.0f; // default DCA: large, use with care if propagation fails o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, V0Temp, 2.f, fitter.getMatCorrType(), &dcaV0Info); v0.v0DCAToPVxy = dcaV0Info[0]; v0.v0DCAToPVz = dcaV0Info[1]; @@ -499,10 +516,13 @@ class strangenessBuilderHelper // Calculate DCA with respect to the collision associated to the V0 std::array dcaInfo; - // do DCA to PV on copies instead of originals - auto positiveTrackParamCopy = positiveTrackParam; - auto negativeTrackParamCopy = negativeTrackParam; + // do DCA to PV on TrackPar copies and not TrackParCov + // TrackPar preferred: don't calculate multiple scattering / CovMat changes + // Spares CPU since variables not checked + o2::track::TrackPar positiveTrackParamCopy(positiveTrackParam); + o2::track::TrackPar negativeTrackParamCopy(negativeTrackParam); + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); v0.positiveDCAxy = dcaInfo[0]; @@ -511,6 +531,7 @@ class strangenessBuilderHelper return false; } + dcaInfo[0] = dcaInfo[1] = 999.0f; // reset to default value o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo); v0.negativeDCAxy = dcaInfo[0]; @@ -672,6 +693,8 @@ class strangenessBuilderHelper bool useCascadeMomentumAtPV = false, bool processCovariances = false) { + cascade = {}; // initialize / empty (extra safety) + // verify track quality if (positiveTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) { cascade = {}; @@ -726,6 +749,7 @@ class strangenessBuilderHelper // bachelor DCA track to PV // Calculate DCA with respect to the collision associated to the V0, not individual tracks std::array dcaInfo; + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted auto bachTrackPar = getTrackPar(bachelorTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); @@ -902,6 +926,8 @@ class strangenessBuilderHelper bool kfDoDCAFitterPreMinimV0 = false, bool kfDoDCAFitterPreMinimCasc = false) { + cascade = {}; // initialize / empty (extra safety) + //*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<*>~<* // KF particle based rebuilding // dispenses prior V0 generation, uses constrained (re-)fit based on bachelor charge @@ -950,13 +976,18 @@ class strangenessBuilderHelper // bachelor DCA track to PV // Calculate DCA with respect to the collision associated to the V0, not individual tracks std::array dcaInfo; + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted auto bachTrackPar = getTrackPar(bachelorTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, bachTrackPar, 2.f, fitter.getMatCorrType(), &dcaInfo); cascade.bachelorDCAxy = dcaInfo[0]; + + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted o2::track::TrackParCov posTrackParCovForDCA = getTrackParCov(positiveTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, posTrackParCovForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); cascade.positiveDCAxy = dcaInfo[0]; + + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value to make sure candidate accepted o2::track::TrackParCov negTrackParCovForDCA = getTrackParCov(negativeTrack); o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negTrackParCovForDCA, 2.f, fitter.getMatCorrType(), &dcaInfo); cascade.negativeDCAxy = dcaInfo[0]; @@ -1272,8 +1303,7 @@ class strangenessBuilderHelper o2::track::TrackPar wrongV0 = fitter.createParentTrackPar(); wrongV0.setAbsCharge(0); // charge zero std::array dcaInfo; - dcaInfo[0] = 999; - dcaInfo[1] = 999; + dcaInfo[0] = dcaInfo[1] = 999.0f; // by default, take large value // bachelor-baryon DCAxy to PV o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, wrongV0, 2.f, fitter.getMatCorrType(), &dcaInfo); diff --git a/PWGLF/Utils/strangenessBuilderModule.h b/PWGLF/Utils/strangenessBuilderModule.h index e49ed71f14b..5b9dc2533d9 100644 --- a/PWGLF/Utils/strangenessBuilderModule.h +++ b/PWGLF/Utils/strangenessBuilderModule.h @@ -914,9 +914,10 @@ class BuilderModule } // end TPC drift treatment // process candidate with helper, generate properties for consulting - // : do not apply selections: do as much as possible to preserve + // first 'false' : do not apply selections: do as much as possible to preserve + // second 'false': do not calculate prong DCA to PV, unnecessary, costly if XIU = 83.1f // candidate at this level and do not select with topo selections - if (straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) { + if (straHelper.buildV0Candidate(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) { // candidate built, check pointing angle if (straHelper.v0.pointingAngle < bestPointingAngle) { bestPointingAngle = straHelper.v0.pointingAngle;