Skip to content

Commit 1dba936

Browse files
committed
Construct() candidates only when demanded
1 parent 489a987 commit 1dba936

1 file changed

Lines changed: 39 additions & 19 deletions

File tree

‎PWGHF/TableProducer/candidateCreator3Prong.cxx‎

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -577,33 +577,53 @@ struct HfCandidateCreator3Prong {
577577
const float chi2geoFirstThird = kfCalculateChi2geoBetweenParticles(kfFirstProton, kfThirdPion);
578578
const float chi2geoFirstSecond = kfCalculateChi2geoBetweenParticles(kfFirstProton, kfSecondKaon);
579579

580+
KFParticle* kfCandGeneric{nullptr};
581+
580582
// Λc± → p± K∓ π±, Ξc± → p± K∓ π±
581583
KFParticle kfCandPKPi;
582584
const KFParticle* kfDaughtersPKPi[3] = {&kfFirstProton, &kfSecondKaon, &kfThirdPion};
583585
kfCandPKPi.SetConstructMethod(2);
584-
kfCandPKPi.Construct(kfDaughtersPKPi, 3);
585586
KFParticle kfCandPiKP;
586587
const KFParticle* kfDaughtersPiKP[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdProton};
587588
kfCandPiKP.SetConstructMethod(2);
588-
kfCandPiKP.Construct(kfDaughtersPiKP, 3);
589+
if (createLc || createXic) {
590+
kfCandPKPi.Construct(kfDaughtersPKPi, 3);
591+
kfCandPiKP.Construct(kfDaughtersPiKP, 3);
592+
kfCandGeneric = &kfCandPKPi;
593+
}
589594

590595
// D± → π± K∓ π±
591596
KFParticle kfCandPiKPi;
592597
const KFParticle* kfDaughtersPiKPi[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdPion};
593598
kfCandPiKPi.SetConstructMethod(2);
594-
kfCandPiKPi.Construct(kfDaughtersPiKPi, 3);
599+
if (createDplus) {
600+
kfCandPiKPi.Construct(kfDaughtersPiKPi, 3);
601+
if (kfCandGeneric == nullptr) {
602+
kfCandGeneric = &kfCandPiKPi;
603+
}
604+
}
595605

596606
// Ds± → K± K∓ π±
597607
KFParticle kfCandKKPi;
598608
const KFParticle* kfDaughtersKKPi[3] = {&kfFirstKaon, &kfSecondKaon, &kfThirdPion};
599609
kfCandKKPi.SetConstructMethod(2);
600-
kfCandKKPi.Construct(kfDaughtersKKPi, 3);
601610
KFParticle kfCandPiKK;
602611
const KFParticle* kfDaughtersPiKK[3] = {&kfFirstPion, &kfSecondKaon, &kfThirdKaon};
603612
kfCandPiKK.SetConstructMethod(2);
604-
kfCandPiKK.Construct(kfDaughtersPiKK, 3);
613+
if (createDs) {
614+
kfCandKKPi.Construct(kfDaughtersKKPi, 3);
615+
kfCandPiKK.Construct(kfDaughtersPiKK, 3);
616+
if (kfCandGeneric == nullptr) {
617+
kfCandGeneric = &kfCandKKPi;
618+
}
619+
}
620+
621+
if (kfCandGeneric == nullptr) {
622+
// should never happen, but for redundunt safety
623+
LOGP(fatal, "kfCandGeneric was not assigned with address of any candidate hypothesis. Check the create<...> configurables");
624+
}
605625

606-
const float chi2topo = kfCalculateChi2ToPrimaryVertex(kfCandPKPi, kfpV);
626+
const float chi2topo = kfCalculateChi2ToPrimaryVertex(*kfCandGeneric, kfpV);
607627

608628
if (applyTopoConstraint) { // constraints applied after chi2topo getter - to preserve unbiased value of chi2topo
609629
for (const auto& kfCand : std::array<KFParticle*, 5>{&kfCandPKPi, &kfCandPiKP, &kfCandPiKPi, &kfCandKKPi, &kfCandPiKK}) {
@@ -638,21 +658,21 @@ struct HfCandidateCreator3Prong {
638658
kfCandPiKK.SetNonlinearMassConstraint(static_cast<float>(MassDS));
639659
}
640660

641-
const float chi2geo = kfCandPKPi.Chi2() / static_cast<float>(kfCandPKPi.NDF());
642-
const std::pair<float, float> ldl = kfCalculateLdL(kfCandPKPi, kfpV);
661+
const float chi2geo = kfCandGeneric->Chi2() / static_cast<float>(kfCandGeneric->NDF());
662+
const std::pair<float, float> ldl = kfCalculateLdL(*kfCandGeneric, kfpV);
643663

644664
std::array<float, 3> pProng0 = kfCalculateProngMomentumInSecondaryVertex(kfFirstProton, kfCandPiKP);
645665
std::array<float, 3> pProng1 = kfCalculateProngMomentumInSecondaryVertex(kfSecondKaon, kfCandPiKP);
646666
std::array<float, 3> pProng2 = kfCalculateProngMomentumInSecondaryVertex(kfThirdPion, kfCandPiKP);
647667

648-
registry.fill(HIST("hCovSVXX"), kfCandPKPi.Covariance(0, 0));
649-
registry.fill(HIST("hCovSVYY"), kfCandPKPi.Covariance(1, 1));
650-
registry.fill(HIST("hCovSVXZ"), kfCandPKPi.Covariance(2, 0));
651-
registry.fill(HIST("hCovSVZZ"), kfCandPKPi.Covariance(2, 2));
668+
registry.fill(HIST("hCovSVXX"), kfCandGeneric->Covariance(0, 0));
669+
registry.fill(HIST("hCovSVYY"), kfCandGeneric->Covariance(1, 1));
670+
registry.fill(HIST("hCovSVXZ"), kfCandGeneric->Covariance(2, 0));
671+
registry.fill(HIST("hCovSVZZ"), kfCandGeneric->Covariance(2, 2));
652672

653-
auto* covMatrixSV = kfCandPKPi.CovarianceMatrix();
673+
auto* covMatrixSV = kfCandGeneric->CovarianceMatrix();
654674
double phi{}, theta{};
655-
getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ()}, phi, theta);
675+
getPointDirection(std::array{kfpV.GetX(), kfpV.GetY(), kfpV.GetZ()}, std::array{kfCandGeneric->GetX(), kfCandGeneric->GetY(), kfCandGeneric->GetZ()}, phi, theta);
656676
auto errorDecayLength = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, theta) + getRotatedCovMatrixXX(covMatrixSV, phi, theta));
657677
auto errorDecayLengthXY = std::sqrt(getRotatedCovMatrixXX(covMatrixPV, phi, 0.) + getRotatedCovMatrixXX(covMatrixSV, phi, 0.));
658678

@@ -672,9 +692,9 @@ struct HfCandidateCreator3Prong {
672692
// fill candidate table rows
673693
rowCandidateBase(indexCollision,
674694
kfpV.GetX(), kfpV.GetY(), kfpV.GetZ(),
675-
kfCandPKPi.GetX(), kfCandPKPi.GetY(), kfCandPKPi.GetZ(),
695+
kfCandGeneric->GetX(), kfCandGeneric->GetY(), kfCandGeneric->GetZ(),
676696
errorDecayLength, errorDecayLengthXY,
677-
kfCandPKPi.GetChi2() / static_cast<float>(kfCandPKPi.GetNDF()),
697+
kfCandGeneric->GetChi2() / static_cast<float>(kfCandGeneric->GetNDF()),
678698
pProng0.at(0), pProng0.at(1), pProng0.at(2),
679699
pProng1.at(0), pProng1.at(1), pProng1.at(2),
680700
pProng2.at(0), pProng2.at(1), pProng2.at(2),
@@ -686,11 +706,11 @@ struct HfCandidateCreator3Prong {
686706
rowTrackIndexProng3.hfflag());
687707

688708
// fill KF info
689-
rowCandidateKF(kfCandPKPi.GetErrX(), kfCandPKPi.GetErrY(), kfCandPKPi.GetErrZ(),
709+
rowCandidateKF(kfCandGeneric->GetErrX(), kfCandGeneric->GetErrY(), kfCandGeneric->GetErrZ(),
690710
std::sqrt(kfpV.Covariance(0, 0)), std::sqrt(kfpV.Covariance(1, 1)), std::sqrt(kfpV.Covariance(2, 2)),
691711
massPKPi, massPiKP, massPiKPi, massKKPi, massPiKK, massKPi, massPiK,
692-
kfCandPKPi.GetPx(), kfCandPKPi.GetPy(), kfCandPKPi.GetPz(),
693-
kfCandPKPi.GetErrPx(), kfCandPKPi.GetErrPy(), kfCandPKPi.GetErrPz(),
712+
kfCandGeneric->GetPx(), kfCandGeneric->GetPy(), kfCandGeneric->GetPz(),
713+
kfCandGeneric->GetErrPx(), kfCandGeneric->GetErrPy(), kfCandGeneric->GetErrPz(),
694714
chi2primFirst, chi2primSecond, chi2primThird,
695715
dcaSecondThird, dcaFirstThird, dcaFirstSecond,
696716
chi2geoSecondThird, chi2geoFirstThird, chi2geoFirstSecond,

0 commit comments

Comments
 (0)