Skip to content

Commit f7564de

Browse files
committed
Optimize de-duplication and DCAtoPV calculation
1 parent 649891b commit f7564de

File tree

2 files changed

+37
-24
lines changed

2 files changed

+37
-24
lines changed

PWGLF/Utils/strangenessBuilderHelper.h

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ class strangenessBuilderHelper
266266
//_______________________________________________________________________
267267
// standard build V0 function. Populates ::v0 object
268268
// ::v0 will be initialized to defaults if build fails
269-
template <bool useSelections = true, typename TTrack, typename TTrackParametrization>
269+
// --- useSelections: meant to maximize recovery, but beware high cost in CPU
270+
// --- calculateProngDCAtoPV: optionally don't propagate prongs to PV, saves
271+
// CPU, of interest when dealing with de-duplication (variable not checked)
272+
template <bool useSelections = true, bool calculateProngDCAtoPV = true, typename TTrack, typename TTrackParametrization>
270273
bool buildV0Candidate(int collisionIndex,
271274
float pvX, float pvY, float pvZ,
272275
TTrack const& positiveTrack,
@@ -306,31 +309,38 @@ class strangenessBuilderHelper
306309
}
307310
}
308311

309-
// Calculate DCA with respect to the collision associated to the V0
310-
std::array<float, 2> dcaInfo;
312+
if constexpr (calculateProngDCAtoPV) {
313+
// Calculate DCA with respect to the collision associated to the V0
314+
std::array<float, 2> dcaInfo;
311315

312-
// do DCA to PV on copies instead of originals
313-
auto positiveTrackParamCopy = positiveTrackParam;
314-
auto negativeTrackParamCopy = negativeTrackParam;
316+
// do DCA to PV on TrackPar copies and not TrackParCov
317+
// TrackPar preferred: don't calculate multiple scattering / CovMat changes
318+
// Spares CPU since variables not checked
319+
o2::track::TrackPar positiveTrackParamCopy(positiveTrackParam);
320+
o2::track::TrackPar negativeTrackParamCopy(negativeTrackParam);
315321

316-
o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo);
317-
v0.positiveDCAxy = dcaInfo[0];
322+
o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo);
323+
v0.positiveDCAxy = dcaInfo[0];
318324

319-
if constexpr (useSelections) {
320-
if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) {
321-
v0 = {};
322-
return false;
325+
if constexpr (useSelections) {
326+
if (std::fabs(v0.positiveDCAxy) < v0selections.dcanegtopv) {
327+
v0 = {};
328+
return false;
329+
}
323330
}
324-
}
325331

326-
o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo);
327-
v0.negativeDCAxy = dcaInfo[0];
332+
o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, negativeTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo);
333+
v0.negativeDCAxy = dcaInfo[0];
328334

329-
if constexpr (useSelections) {
330-
if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) {
331-
v0 = {};
332-
return false;
335+
if constexpr (useSelections) {
336+
if (std::fabs(v0.negativeDCAxy) < v0selections.dcanegtopv) {
337+
v0 = {};
338+
return false;
339+
}
333340
}
341+
}else{
342+
v0.positiveDCAxy = 0.0f; // default invalid
343+
v0.negativeDCAxy = 0.0f; // default invalid
334344
}
335345

336346
// Perform DCA fit
@@ -499,9 +509,11 @@ class strangenessBuilderHelper
499509
// Calculate DCA with respect to the collision associated to the V0
500510
std::array<float, 2> dcaInfo;
501511

502-
// do DCA to PV on copies instead of originals
503-
auto positiveTrackParamCopy = positiveTrackParam;
504-
auto negativeTrackParamCopy = negativeTrackParam;
512+
// do DCA to PV on TrackPar copies and not TrackParCov
513+
// TrackPar preferred: don't calculate multiple scattering / CovMat changes
514+
// Spares CPU since variables not checked
515+
o2::track::TrackPar positiveTrackParamCopy(positiveTrackParam);
516+
o2::track::TrackPar negativeTrackParamCopy(negativeTrackParam);
505517

506518
o2::base::Propagator::Instance()->propagateToDCABxByBz({pvX, pvY, pvZ}, positiveTrackParamCopy, 2.f, fitter.getMatCorrType(), &dcaInfo);
507519
v0.positiveDCAxy = dcaInfo[0];

PWGLF/Utils/strangenessBuilderModule.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,10 @@ class BuilderModule
914914
} // end TPC drift treatment
915915

916916
// process candidate with helper, generate properties for consulting
917-
// <false>: do not apply selections: do as much as possible to preserve
917+
// first 'false' : do not apply selections: do as much as possible to preserve
918+
// second 'false': do not calculate prong DCA to PV, unnecessary, costly if XIU = 83.1f
918919
// candidate at this level and do not select with topo selections
919-
if (straHelper.buildV0Candidate<false>(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) {
920+
if (straHelper.buildV0Candidate<false, false>(v0tableGrouped[iV0].collisionIds[ic], collision.posX(), collision.posY(), collision.posZ(), pTrack, nTrack, posTrackPar, negTrackPar, true, false, true)) {
920921
// candidate built, check pointing angle
921922
if (straHelper.v0.pointingAngle < bestPointingAngle) {
922923
bestPointingAngle = straHelper.v0.pointingAngle;

0 commit comments

Comments
 (0)