Skip to content

Commit ea90787

Browse files
committed
Fix bugs
1 parent ee5a82c commit ea90787

3 files changed

Lines changed: 77 additions & 96 deletions

File tree

PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,10 +1115,10 @@ struct decay3bodyBuilder {
11151115
registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyDatas);
11161116
}
11171117
if (mEnabledTables[kVtx3BodyCovs]) {
1118-
products.vtx3bodycovs(helper.decay3body.covProton,
1119-
helper.decay3body.covPion,
1120-
helper.decay3body.covDeuteron,
1121-
helper.decay3body.covariance);
1118+
products.vtx3bodycovs(helper.decay3body.covProton.data(),
1119+
helper.decay3body.covPion.data(),
1120+
helper.decay3body.covDeuteron.data(),
1121+
helper.decay3body.covariance.data());
11221122
registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyCovs);
11231123
}
11241124
if (mEnabledTables[kMcVtx3BodyDatas]) {

PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
using namespace o2;
7171
using namespace o2::framework;
7272

73+
o2::common::core::MetadataHelper metadataInfo{};
74+
7375
namespace
7476
{
7577
using Collisions = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0As, aod::CentFT0Cs, aod::CentFT0Ms, aod::EvTimeTOFFT0>;
@@ -94,8 +96,6 @@ enum ZorroTrigger : std::size_t {
9496
} // namespace
9597

9698
struct TrackedHypertritonRecoTask {
97-
o2::common::core::MetadataHelper metadataInfo{};
98-
9999
Produces<aod::DataHypCands> dataHypCands;
100100
Produces<aod::MCHypCands> mcHypCands;
101101
Produces<aod::Vtx3BodyDatas> vtx3BodyDatas;
@@ -208,9 +208,9 @@ struct TrackedHypertritonRecoTask {
208208
std::array<float, 3> posHelium{};
209209
std::array<float, 3> posPion{};
210210
// vertex properties
211-
float mass;
212-
float chi2;
213-
float cosPA;
211+
float mass{};
212+
float chi2{};
213+
float cosPA{};
214214
std::array<float, 3> decayVertex{};
215215
std::array<float, 3> momentum{};
216216
};
@@ -565,14 +565,14 @@ struct TrackedHypertritonRecoTask {
565565
TTrackParCov const& trackPionCov)
566566
{
567567
// initialise KF primary vertex
568-
KFVertex kfpVertex = createKFPVertexFromCollision(collision);
569-
KFParticle kfpv(kfpVertex);
568+
KFParticle kfpv(createKFPVertexFromCollision(collision));
570569

571570
// create KFParticle objects
572571
KFParticle kfpHelium, kfpPion;
573572
// helium
574-
std::array<float, 3> xyz, pxpypz;
575-
float xyzpxpypz[6];
573+
std::array<float, 3> xyz{};
574+
std::array<float, 3> pxpypz{};
575+
std::array<float, 6> xyzpxpypz{};
576576
trackHeliumCov.getPxPyPzGlo(pxpypz);
577577
trackHeliumCov.getXYZGlo(xyz);
578578
for (int i = 0; i < 3; ++i) {
@@ -582,7 +582,7 @@ struct TrackedHypertritonRecoTask {
582582
std::array<float, 21> cv{};
583583
trackHeliumCov.getCovXYZPxPyPzGlo(cv);
584584
KFParticle kfHelium;
585-
kfHelium.Create(xyzpxpypz, cv.data(), trackHelium.sign() * 2, constants::physics::MassHelium3);
585+
kfHelium.Create(xyzpxpypz.data(), cv.data(), trackHelium.sign() * 2, constants::physics::MassHelium3);
586586
// pion
587587
kfpPion = createKFParticleFromTrackParCov(trackPionCov, trackPion.sign(), constants::physics::MassPionCharged);
588588

@@ -591,12 +591,7 @@ struct TrackedHypertritonRecoTask {
591591
int nDaughtersV0 = 2;
592592
const KFParticle* DaughtersV0[2] = {&kfpHelium, &kfpPion};
593593
KFV0.SetConstructMethod(2);
594-
try {
595-
KFV0.Construct(DaughtersV0, nDaughtersV0);
596-
} catch (std::runtime_error& e) {
597-
LOG(debug) << "Failed to create V0 vertex." << e.what();
598-
return;
599-
}
594+
KFV0.Construct(DaughtersV0, nDaughtersV0);
600595

601596
// topological constraint
602597
if (twoBody.kfSetTopologicalConstraint) {
@@ -637,7 +632,8 @@ struct TrackedHypertritonRecoTask {
637632
v0.momPion[2] = kfpPion.GetPz();
638633

639634
// candidate mass
640-
float mass, massErr;
635+
float mass{};
636+
float massErr{};
641637
KFV0.GetMass(mass, massErr);
642638
v0.mass = mass;
643639

@@ -790,7 +786,7 @@ struct TrackedHypertritonRecoTask {
790786
candidate.averageITSClSize[0], candidate.averageITSClSize[1], candidate.averageITSClSize[2],
791787
static_cast<int>(candidate.tpcNCl[0]), static_cast<int>(candidate.tpcNCl[1]), static_cast<int>(candidate.tpcNCl[2]),
792788
static_cast<uint32_t>(candidate.pidForTrackingDeuteron));
793-
vtx3BodyCovs(candidate.covProton, candidate.covPion, candidate.covDeuteron, candidate.covariance);
789+
vtx3BodyCovs(candidate.covProton.data(), candidate.covPion.data(), candidate.covDeuteron.data(), candidate.covariance.data());
794790
vtx3BodyTrackedInfo(candidate.itsTrackDCAToSV[0], candidate.itsTrackDCAToSV[1]);
795791
}
796792

@@ -1130,7 +1126,6 @@ struct TrackedHypertritonRecoTask {
11301126

11311127
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
11321128
{
1133-
auto metadataInfo = o2::common::core::MetadataHelper{};
11341129
metadataInfo.initMetadata(cfgc);
1135-
return WorkflowSpec{adaptAnalysisTask<TrackedHypertritonRecoTask>(cfgc, std::move(metadataInfo))};
1130+
return WorkflowSpec{adaptAnalysisTask<TrackedHypertritonRecoTask>(cfgc)};
11361131
}

PWGLF/Utils/decay3bodyBuilderHelper.h

Lines changed: 58 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@
3838
#include <cstdlib>
3939
#include <stdexcept>
4040

41-
namespace o2
42-
{
43-
namespace pwglf
41+
namespace o2::pwglf
4442
{
4543

4644
//_______________________________________________________________________
@@ -54,46 +52,46 @@ struct decay3bodyCandidate {
5452
int deuteronID = -1;
5553

5654
// daughter properties
57-
std::array<float, 3> momProton = {0.0f, 0.0f, 0.0f};
58-
std::array<float, 3> momPion = {0.0f, 0.0f, 0.0f};
59-
std::array<float, 3> momDeuteron = {0.0f, 0.0f, 0.0f};
60-
std::array<float, 3> posProton = {0.0f, 0.0f, 0.0f};
61-
std::array<float, 3> posPion = {0.0f, 0.0f, 0.0f};
62-
std::array<float, 3> posDeuteron = {0.0f, 0.0f, 0.0f};
63-
float xProton = 0.0f;
64-
float xPion = 0.0f;
65-
float xDeuteron = 0.0f;
66-
std::array<float, 3> trackDCAxyToPV = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
67-
std::array<float, 3> trackDCAToPV = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
68-
std::array<float, 3> trackDCAxyToPVprop = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
69-
std::array<float, 3> trackDCAToPVprop = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
70-
std::array<float, 4> tpcNsigma = {0.0f, 0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp
71-
double tofNsigmaDeuteron = 0.0f;
72-
std::array<float, 3> averageITSClSize = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
73-
std::array<float, 3> tpcNCl = {0.0f, 0.0f, 0.0f}; // 0 - proton, 1 - pion, 2 - deuteron
74-
int pidForTrackingDeuteron = 0;
55+
std::array<float, 3> momProton{};
56+
std::array<float, 3> momPion{};
57+
std::array<float, 3> momDeuteron{};
58+
std::array<float, 3> posProton{};
59+
std::array<float, 3> posPion{};
60+
std::array<float, 3> posDeuteron{};
61+
float xProton{};
62+
float xPion{};
63+
float xDeuteron{};
64+
std::array<float, 3> trackDCAxyToPV{}; // 0 - proton, 1 - pion, 2 - deuteron
65+
std::array<float, 3> trackDCAToPV{}; // 0 - proton, 1 - pion, 2 - deuteron
66+
std::array<float, 3> trackDCAxyToPVprop{}; // 0 - proton, 1 - pion, 2 - deuteron
67+
std::array<float, 3> trackDCAToPVprop{}; // 0 - proton, 1 - pion, 2 - deuteron
68+
std::array<float, 4> tpcNsigma{}; // 0 - proton, 1 - pion, 2 - deuteron, 3 - bach with pion hyp
69+
double tofNsigmaDeuteron{};
70+
std::array<float, 3> averageITSClSize{}; // 0 - proton, 1 - pion, 2 - deuteron
71+
std::array<float, 3> tpcNCl{}; // 0 - proton, 1 - pion, 2 - deuteron
72+
int pidForTrackingDeuteron{};
7573

7674
// vertex properties
77-
float mass;
78-
float massV0;
79-
int sign;
80-
float momentum[3];
81-
float position[3];
82-
float chi2 = 0.0f;
83-
float trackedClSize = 0.0f;
84-
float cosPA = 0.0f; // cosine of pointing angle
85-
float ctau = 0.0f; // ctau of the candidate
86-
float daughterDCAtoSVaverage = 0.0f; // average of quadratic sum of daughter DCAs to SV
87-
std::array<float, 3> daughterDCAtoSV = {0.0f, 0.0f, 0.0f}; // 0 - pos, 1 - neg, 2 - bach
75+
float mass{};
76+
float massV0{};
77+
int sign{};
78+
std::array<float, 3> momentum{};
79+
std::array<float, 3> position{};
80+
float chi2{};
81+
float trackedClSize{};
82+
float cosPA{}; // cosine of pointing angle
83+
float ctau{}; // ctau of the candidate
84+
float daughterDCAtoSVaverage{}; // average of quadratic sum of daughter DCAs to SV
85+
std::array<float, 3> daughterDCAtoSV{}; // 0 - pos, 1 - neg, 2 - bach
8886

8987
// covariance matrix
90-
float covProton[21] = {0.0f};
91-
float covPion[21] = {0.0f};
92-
float covDeuteron[21] = {0.0f};
93-
float covariance[21] = {0.0f};
88+
std::array<float, 21> covProton{};
89+
std::array<float, 21> covPion{};
90+
std::array<float, 21> covDeuteron{};
91+
std::array<float, 21> covariance{};
9492

9593
// strangeness tracking
96-
std::array<float, 2> itsTrackDCAToSV;
94+
std::array<float, 2> itsTrackDCAToSV{};
9795
};
9896

9997
//_______________________________________________________________________
@@ -166,7 +164,7 @@ class decay3bodyBuilderHelper
166164
float maxCtau;
167165
float minCosPA;
168166
float maxChi2;
169-
} decay3bodyselections;
167+
} decay3bodyselections{};
170168

171169
// SVertexer selection criteria
172170
struct {
@@ -180,7 +178,7 @@ class decay3bodyBuilderHelper
180178
float maxTgl3Body;
181179
float maxDCAXY3Body;
182180
float maxDCAZ3Body;
183-
} svertexerselections;
181+
} svertexerselections{};
184182

185183
//_______________________________________________________________________
186184
// build Decay3body from three tracks, including V0 building.
@@ -298,8 +296,8 @@ class decay3bodyBuilderHelper
298296

299297
//_______________________________________________________________________
300298
// daughter track DCA to PV associated with decay3body --> computed with KFParticle
301-
float pvXY[2] = {pvX, pvY};
302-
float pv[3] = {pvX, pvY, pvZ};
299+
std::array<float, 2> pvXY = {pvX, pvY};
300+
std::array<float, 3> pv = {pvX, pvY, pvZ};
303301
auto trackParCovProtonCopy = trackParCovProton;
304302
auto trackParCovPionCopy = trackParCovPion;
305303
auto trackParCovDeuteronCopy = trackParCovDeuteron;
@@ -308,14 +306,14 @@ class decay3bodyBuilderHelper
308306
KFParticle kfdeuteron = createKFParticleFromTrackParCov(trackParCovDeuteronCopy, trackDeuteron.sign(), constants::physics::MassDeuteron);
309307

310308
// proton DCA to PV
311-
decay3body.trackDCAxyToPV[0] = kfproton.GetDistanceFromVertexXY(pvXY);
312-
decay3body.trackDCAToPV[0] = kfproton.GetDistanceFromVertex(pv);
309+
decay3body.trackDCAxyToPV[0] = kfproton.GetDistanceFromVertexXY(pvXY.data());
310+
decay3body.trackDCAToPV[0] = kfproton.GetDistanceFromVertex(pv.data());
313311
// pion DCA to PV
314-
decay3body.trackDCAxyToPV[1] = kfpion.GetDistanceFromVertexXY(pvXY);
315-
decay3body.trackDCAToPV[1] = kfpion.GetDistanceFromVertex(pv);
312+
decay3body.trackDCAxyToPV[1] = kfpion.GetDistanceFromVertexXY(pvXY.data());
313+
decay3body.trackDCAToPV[1] = kfpion.GetDistanceFromVertex(pv.data());
316314
// deuteron DCA to PV
317-
decay3body.trackDCAxyToPV[2] = kfdeuteron.GetDistanceFromVertexXY(pvXY);
318-
decay3body.trackDCAToPV[2] = kfdeuteron.GetDistanceFromVertex(pv);
315+
decay3body.trackDCAxyToPV[2] = kfdeuteron.GetDistanceFromVertexXY(pvXY.data());
316+
decay3body.trackDCAToPV[2] = kfdeuteron.GetDistanceFromVertex(pv.data());
319317
// selection
320318
if (useSelections) {
321319
if (decay3body.trackDCAToPV[0] < decay3bodyselections.minDCAProtonToPV) {
@@ -441,14 +439,14 @@ class decay3bodyBuilderHelper
441439
}
442440

443441
// rapidity
444-
float rapidity = RecoDecay::y(std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]}, o2::constants::physics::MassHyperTriton);
442+
float rapidity = RecoDecay::y(decay3body.momentum, o2::constants::physics::MassHyperTriton);
445443
if (std::fabs(rapidity) > decay3bodyselections.maxRapidity) {
446444
decay3body = {};
447445
return false;
448446
}
449447

450448
// pT
451-
float pT = RecoDecay::pt(std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]});
449+
float pT = RecoDecay::pt(decay3body.momentum);
452450
if (pT < decay3bodyselections.minPt || pT > decay3bodyselections.maxPt) {
453451
decay3body = {};
454452
return false;
@@ -468,7 +466,7 @@ class decay3bodyBuilderHelper
468466
}
469467

470468
// pointing angle
471-
float cpa = RecoDecay::cpa(std::array{pvX, pvY, pvZ}, std::array{decay3body.position[0], decay3body.position[1], decay3body.position[2]}, std::array{decay3body.momentum[0], decay3body.momentum[1], decay3body.momentum[2]});
469+
float cpa = RecoDecay::cpa(std::array{pvX, pvY, pvZ}, decay3body.position, decay3body.momentum);
472470
if (useSelections) {
473471
if (cpa < decay3bodyselections.minCosPA) {
474472
decay3body = {};
@@ -558,8 +556,7 @@ class decay3bodyBuilderHelper
558556
auto trackParCovDeuteron = getTrackParCov(trackDeuteron);
559557

560558
// initialise KF primary vertex
561-
KFVertex kfpVertex = createKFPVertexFromCollision(collision);
562-
KFParticle kfpv(kfpVertex);
559+
KFParticle kfpv(createKFPVertexFromCollision(collision));
563560

564561
// create KFParticle objects
565562
KFParticle kfpProton, kfpPion, kfpDeuteron;
@@ -609,9 +606,9 @@ class decay3bodyBuilderHelper
609606
decay3body.sign = KFH3L.GetQ() / std::abs(KFH3L.GetQ());
610607

611608
// transport all daughter tracks to hypertriton vertex
612-
kfpProton.TransportToPoint(decay3body.position);
613-
kfpPion.TransportToPoint(decay3body.position);
614-
kfpDeuteron.TransportToPoint(decay3body.position);
609+
kfpProton.TransportToPoint(decay3body.position.data());
610+
kfpPion.TransportToPoint(decay3body.position.data());
611+
kfpDeuteron.TransportToPoint(decay3body.position.data());
615612

616613
// daughter positions
617614
decay3body.posProton[0] = kfpProton.GetX();
@@ -651,10 +648,8 @@ class decay3bodyBuilderHelper
651648
// caluclate covariance matrices
652649
if (calculateCovariance) {
653650
// candidate covariance matrix
654-
std::array<float, 21> covKF;
655651
for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle)
656-
covKF[i] = KFH3L.GetCovariance(i);
657-
decay3body.covariance[i] = covKF[i];
652+
decay3body.covariance[i] = KFH3L.GetCovariance(i);
658653
}
659654
// daughter track covariance matrices
660655
for (int i = 0; i < 21; i++) { // get covariance matrix elements (lower triangle)
@@ -738,21 +733,13 @@ class decay3bodyBuilderHelper
738733
decay3body.covariance[4] = covVtxV(2, 1);
739734
decay3body.covariance[5] = covVtxV(2, 2);
740735
// daughter covariance matrices
741-
std::array<float, 21> covTproton = {0.};
742-
std::array<float, 21> covTpion = {0.};
743-
std::array<float, 21> covTdeuteron = {0.};
744-
propagatedTrackProton.getCovXYZPxPyPzGlo(covTproton);
745-
propagatedTrackPion.getCovXYZPxPyPzGlo(covTpion);
746-
propagatedTrackDeuteron.getCovXYZPxPyPzGlo(covTdeuteron);
747-
for (int i = 0; i < 21; i++) {
748-
decay3body.covProton[i] = covTproton[i];
749-
decay3body.covPion[i] = covTpion[i];
750-
decay3body.covDeuteron[i] = covTdeuteron[i];
751-
}
736+
propagatedTrackProton.getCovXYZPxPyPzGlo(decay3body.covProton);
737+
propagatedTrackPion.getCovXYZPxPyPzGlo(decay3body.covPion);
738+
propagatedTrackDeuteron.getCovXYZPxPyPzGlo(decay3body.covDeuteron);
752739
// candidate momentum covairance matrix
753740
constexpr int MomInd[6] = {9, 13, 14, 18, 19, 20}; // cov matrix elements for momentum component
754741
for (int i = 0; i < 6; i++) {
755-
decay3body.covariance[MomInd[i]] = covTproton[MomInd[i]] + covTpion[MomInd[i]] + covTdeuteron[MomInd[i]];
742+
decay3body.covariance[MomInd[i]] = decay3body.covProton[MomInd[i]] + decay3body.covPion[MomInd[i]] + decay3body.covDeuteron[MomInd[i]];
756743
}
757744
/// WARNING: position-momentum covariances are not calculated in the DCAFitter - remain zero
758745
}
@@ -898,7 +885,6 @@ class decay3bodyBuilderHelper
898885
}
899886
};
900887

901-
} // namespace pwglf
902-
} // namespace o2
888+
} // namespace o2::pwglf
903889

904890
#endif // PWGLF_UTILS_DECAY3BODYBUILDERHELPER_H_

0 commit comments

Comments
 (0)