Skip to content

Commit dd98e39

Browse files
Luca610alibuildvkucera
authored
[Common] RecoDecay: Add matching for decaying tracks in getMatchedMCRec (#8345)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch> Co-authored-by: Vít Kučera <vit.kucera@cern.ch>
1 parent 930ecfc commit dd98e39

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

Common/Core/RecoDecay.h

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@
2020
#include <algorithm> // std::find
2121
#include <array> // std::array
2222
#include <cmath> // std::abs, std::sqrt
23+
#include <cstdio>
2324
#include <utility> // std::move
2425
#include <vector> // std::vector
2526

2627
#include "TMCProcess.h" // for VMC Particle Production Process
28+
#include "TPDGCode.h" // for PDG codes
2729
#include "CommonConstants/MathConstants.h"
2830

2931
/// Base class for calculating properties of reconstructed decays
@@ -663,26 +665,33 @@ struct RecoDecay {
663665
/// Checks whether the reconstructed decay candidate is the expected decay.
664666
/// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles
665667
/// \param acceptIncompleteReco switch to accept candidates with only part of the daughters reconstructed
668+
/// \tparam acceptTrackDecay switch to accept candidates with daughter tracks of pions and kaons which decayed
666669
/// \param particlesMC table with MC particles
667670
/// \param arrDaughters array of candidate daughters
668671
/// \param PDGMother expected mother PDG code
669672
/// \param arrPDGDaughters array of expected daughter PDG codes
670673
/// \param acceptAntiParticles switch to accept the antiparticle version of the expected decay
671674
/// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found
672675
/// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered.
676+
/// \param nPiToMu number of pion prongs decayed to a muon
677+
/// \param nKaToPi number of kaon prongs decayed to a pion
673678
/// \return index of the mother particle if the mother and daughters are correct, -1 otherwise
674-
template <bool acceptFlavourOscillation = false, bool checkProcess = false, bool acceptIncompleteReco = false, std::size_t N, typename T, typename U>
679+
template <bool acceptFlavourOscillation = false, bool checkProcess = false, bool acceptIncompleteReco = false, bool acceptTrackDecay = false, std::size_t N, typename T, typename U>
675680
static int getMatchedMCRec(const T& particlesMC,
676681
const std::array<U, N>& arrDaughters,
677682
int PDGMother,
678683
std::array<int, N> arrPDGDaughters,
679684
bool acceptAntiParticles = false,
680685
int8_t* sign = nullptr,
681-
int depthMax = 1)
686+
int depthMax = 1,
687+
int8_t* nPiToMu = nullptr,
688+
int8_t* nKaToPi = nullptr)
682689
{
683690
// Printf("MC Rec: Expected mother PDG: %d", PDGMother);
684691
int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else
685692
int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother)
693+
int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon
694+
int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion
686695
int indexMother = -1; // index of the mother particle
687696
std::vector<int> arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter
688697
std::array<int, N> arrDaughtersIndex; // array of indices of provided daughters
@@ -708,6 +717,21 @@ struct RecoDecay {
708717
return -1;
709718
}
710719
auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle
720+
if constexpr (acceptTrackDecay) {
721+
// Replace the MC particle associated with the prong by its mother for π → μ and K → π.
722+
auto motherI = particleI.template mothers_first_as<T>();
723+
auto pdgI = std::abs(particleI.pdgCode());
724+
auto pdgMotherI = std::abs(motherI.pdgCode());
725+
if (pdgI == kMuonMinus && pdgMotherI == kPiPlus) {
726+
// π → μ
727+
nPiToMuLocal++;
728+
particleI = motherI;
729+
} else if (pdgI == kPiPlus && pdgMotherI == kKPlus) {
730+
// K → π
731+
nKaToPiLocal++;
732+
particleI = motherI;
733+
}
734+
}
711735
arrDaughtersIndex[iProng] = particleI.globalIndex();
712736
// Get the list of daughter indices from the mother of the first prong.
713737
if (iProng == 0) {
@@ -780,6 +804,14 @@ struct RecoDecay {
780804
if (sign) {
781805
*sign = sgn;
782806
}
807+
if constexpr (acceptTrackDecay) {
808+
if (nPiToMu) {
809+
*nPiToMu = nPiToMuLocal;
810+
}
811+
if (nKaToPi) {
812+
*nKaToPi = nKaToPiLocal;
813+
}
814+
}
783815
return indexMother;
784816
}
785817

0 commit comments

Comments
 (0)