Skip to content
Merged
Show file tree
Hide file tree
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
82 changes: 56 additions & 26 deletions PWGLF/Utils/strangenessBuilderHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@
//_______________________________________________________________________
// standard build V0 function. Populates ::v0 object
// ::v0 will be initialized to defaults if build fails
template <bool useSelections = true, typename TTrack, typename TTrackParametrization>
// --- 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 useSelections = true, bool calculateProngDCAtoPV = true, typename TTrack, typename TTrackParametrization>
bool buildV0Candidate(int collisionIndex,
float pvX, float pvY, float pvZ,
TTrack const& positiveTrack,
Expand All @@ -277,6 +280,8 @@
bool calculateCovariance = false,
bool acceptTPCOnly = false)
{
v0 = {}; // safe initialization: start new

if constexpr (useSelections) {
// verify track quality
if (positiveTrack.tpcNClsCrossedRows() < v0selections.minCrossedRows) {
Expand All @@ -296,41 +301,50 @@
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<float, 2> dcaInfo;
if constexpr (calculateProngDCAtoPV) {
// Calculate DCA with respect to the collision associated to the V0
std::array<float, 2> 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
Expand All @@ -340,10 +354,12 @@
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
Expand All @@ -354,6 +370,7 @@
std::array<float, 2> 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];
Expand All @@ -366,14 +383,14 @@
negativeTrackParam.getPxPyPzGlo(v0.negativeMomentum);
positiveTrackParam.getXYZGlo(v0.positivePosition);
negativeTrackParam.getXYZGlo(v0.negativePosition);
for (int i = 0; i < 3; i++) {

Check failure on line 386 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
// avoids misuse if mixed with KF particle use
v0.momentum[i] = v0.positiveMomentum[i] + v0.negativeMomentum[i];
}

// get decay vertex coordinates
const auto& vtx = fitter.getPCACandidate();
for (int i = 0; i < 3; i++) {

Check failure on line 393 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
v0.position[i] = vtx[i];
}

Expand All @@ -384,7 +401,7 @@
}
}

v0.daughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());

Check failure on line 404 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.

if constexpr (useSelections) {
if (v0.daughterDCA > v0selections.dcav0dau) {
Expand All @@ -404,7 +421,7 @@
}
}

v0.pointingAngle = TMath::ACos(cosPA);

Check failure on line 424 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
v0.dcaToPV = CalculateDCAStraightToPV(
v0.position[0], v0.position[1], v0.position[2],
v0.positiveMomentum[0] + v0.negativeMomentum[0],
Expand Down Expand Up @@ -446,7 +463,7 @@
positiveTrackParam.getCovXYZPxPyPzGlo(covTpositive);
negativeTrackParam.getCovXYZPxPyPzGlo(covTnegative);
constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component
for (int i = 0; i < 6; i++) {

Check failure on line 466 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[magic-number]

Avoid magic numbers in expressions. Assign the value to a clearly named variable or constant.
v0.momentumCovariance[i] = covTpositive[MomInd[i]] + covTnegative[MomInd[i]];
}
}
Expand Down Expand Up @@ -499,10 +516,13 @@
// Calculate DCA with respect to the collision associated to the V0
std::array<float, 2> 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];

Expand All @@ -511,6 +531,7 @@
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];

Expand Down Expand Up @@ -586,7 +607,7 @@
v0 = {};
return false;
}
v0.pointingAngle = TMath::ACos(cosPA);

Check failure on line 610 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.

v0.dcaToPV = CalculateDCAStraightToPV(
v0.position[0], v0.position[1], v0.position[2],
Expand Down Expand Up @@ -672,6 +693,8 @@
bool useCascadeMomentumAtPV = false,
bool processCovariances = false)
{
cascade = {}; // initialize / empty (extra safety)

// verify track quality
if (positiveTrack.tpcNClsCrossedRows() < cascadeselections.minCrossedRows) {
cascade = {};
Expand Down Expand Up @@ -726,6 +749,7 @@
// bachelor DCA track to PV
// Calculate DCA with respect to the collision associated to the V0, not individual tracks
std::array<float, 2> 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);
Expand Down Expand Up @@ -771,7 +795,7 @@
lBachelorTrack = fitter.getTrack(1);

// DCA between cascade daughters
cascade.cascadeDaughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());

Check failure on line 798 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.
if (cascade.cascadeDaughterDCA > cascadeselections.dcacascdau) {
cascade = {};
return false;
Expand All @@ -798,7 +822,7 @@
cascade = {};
return false;
}
cascade.pointingAngle = TMath::ACos(cosPA);

Check failure on line 825 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.

// Calculate DCAxy of the cascade (with bending)
auto lCascadeTrack = fitter.createParentTrackParCov();
Expand Down Expand Up @@ -902,6 +926,8 @@
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
Expand Down Expand Up @@ -950,13 +976,18 @@
// bachelor DCA track to PV
// Calculate DCA with respect to the collision associated to the V0, not individual tracks
std::array<float, 2> 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];
Expand Down Expand Up @@ -996,7 +1027,7 @@
return false;
}
// save classical DCA daughters
cascade.v0DaughterDCA = TMath::Sqrt(fitter.getChi2AtPCACandidate());

Check failure on line 1030 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.

// re-acquire from DCA fitter
posTrackParCov = fitter.getTrack(0);
Expand Down Expand Up @@ -1175,7 +1206,7 @@
cascade = {};
return false;
}
cascade.pointingAngle = TMath::ACos(cosPA);

Check failure on line 1209 in PWGLF/Utils/strangenessBuilderHelper.h

View workflow job for this annotation

GitHub Actions / O2 linter

[root/entity]

Replace ROOT entities with equivalents from standard C++ or from O2.

// Calculate masses a priori
float MLambda, SigmaLambda, MXi, SigmaXi, MOmega, SigmaOmega;
Expand Down Expand Up @@ -1272,8 +1303,7 @@
o2::track::TrackPar wrongV0 = fitter.createParentTrackPar();
wrongV0.setAbsCharge(0); // charge zero
std::array<float, 2> 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);
Expand Down
5 changes: 3 additions & 2 deletions PWGLF/Utils/strangenessBuilderModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,9 +914,10 @@ class BuilderModule
} // end TPC drift treatment

// process candidate with helper, generate properties for consulting
// <false>: 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<false>(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) {
if (straHelper.buildV0Candidate<false, false>(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;
Expand Down
Loading