From b2c4284b2c9e5a88e0a433c7c101926a45a75f76 Mon Sep 17 00:00:00 2001 From: Luca Aglietta Date: Thu, 7 Nov 2024 15:30:02 +0100 Subject: [PATCH 1/7] Modified getMatchedMCRec to match particles with tracks that decay during transport --- Common/Core/RecoDecay.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 9fc810a17f7..2b8c425df9a 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -663,6 +663,7 @@ struct RecoDecay { /// Checks whether the reconstructed decay candidate is the expected decay. /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles /// \param acceptIncompleteReco switch to accept candidates with only part of the daughters reconstructed + /// \param acceptTrackDecay switch to accept candidates with one or more tracks decayed during transport /// \param particlesMC table with MC particles /// \param arrDaughters array of candidate daughters /// \param PDGMother expected mother PDG code @@ -670,15 +671,19 @@ struct RecoDecay { /// \param acceptAntiParticles switch to accept the antiparticle version of the expected decay /// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found /// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered. + /// \param nPiToMu number of pions decayed in a muon during transport + /// \param nKaToPi number of kaons decayed in a pion during transport /// \return index of the mother particle if the mother and daughters are correct, -1 otherwise - template + template static int getMatchedMCRec(const T& particlesMC, const std::array& arrDaughters, int PDGMother, std::array arrPDGDaughters, bool acceptAntiParticles = false, int8_t* sign = nullptr, - int depthMax = 1) + int depthMax = 1, + int8_t* nPiToMu = nullptr, + int8_t* nKaToPi = nullptr) { // Printf("MC Rec: Expected mother PDG: %d", PDGMother); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else @@ -708,6 +713,17 @@ struct RecoDecay { return -1; } auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle + auto motherI = particleI.template mothers_first_as(); + if (acceptTrackDecay){ + if (std::abs(particleI.pdgCode()) == std::abs(kMuonPlus) && std::abs(motherI.pdgCode()) == std::abs(kPiPlus)){ + // LOGF(info, "found muon %d with mother %d", particleI.pdgCode(), motherI.pdgCode()); + piToMu +=1; + particleI = motherI; + } else if (std::abs(particleI.pdgCode()) == std::abs(kPiPlus) && std::abs(motherI.pdgCode()) == std::abs(kKPlus)){ + kaToPi +=1; + particleI = motherI; + } + } arrDaughtersIndex[iProng] = particleI.globalIndex(); // Get the list of daughter indices from the mother of the first prong. if (iProng == 0) { @@ -780,6 +796,12 @@ struct RecoDecay { if (sign) { *sign = sgn; } + if (nPiToMu){ + *nPiToMu = piToMu; + } + if (nKaToPi){ + *nKaToPi = kaToPi; + } return indexMother; } From 3d0e4b0bdbaafa3ab65847619b29b10580366fc4 Mon Sep 17 00:00:00 2001 From: Luca Aglietta Date: Thu, 7 Nov 2024 15:39:52 +0100 Subject: [PATCH 2/7] fixed typo --- Common/Core/RecoDecay.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 2b8c425df9a..817ed1b3bca 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -24,6 +24,7 @@ #include // std::vector #include "TMCProcess.h" // for VMC Particle Production Process +#include "TPDGCode.h" // for PDG codes #include "CommonConstants/MathConstants.h" /// Base class for calculating properties of reconstructed decays @@ -688,6 +689,8 @@ struct RecoDecay { // Printf("MC Rec: Expected mother PDG: %d", PDGMother); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) + int8_t piToMu = 0; // number of pions decayed to a muon >=1 if any are found + int8_t kaToPi = 0; // number of kaons decayed to a pion >=1 if any are found int indexMother = -1; // index of the mother particle std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter std::array arrDaughtersIndex; // array of indices of provided daughters From 189310bc7c1324fef26869ea333432c7c9abcfad Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Thu, 7 Nov 2024 14:43:49 +0000 Subject: [PATCH 3/7] Please consider the following formatting changes --- Common/Core/RecoDecay.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 817ed1b3bca..f3fca7c3981 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -24,7 +24,7 @@ #include // std::vector #include "TMCProcess.h" // for VMC Particle Production Process -#include "TPDGCode.h" // for PDG codes +#include "TPDGCode.h" // for PDG codes #include "CommonConstants/MathConstants.h" /// Base class for calculating properties of reconstructed decays @@ -717,13 +717,13 @@ struct RecoDecay { } auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle auto motherI = particleI.template mothers_first_as(); - if (acceptTrackDecay){ - if (std::abs(particleI.pdgCode()) == std::abs(kMuonPlus) && std::abs(motherI.pdgCode()) == std::abs(kPiPlus)){ + if (acceptTrackDecay) { + if (std::abs(particleI.pdgCode()) == std::abs(kMuonPlus) && std::abs(motherI.pdgCode()) == std::abs(kPiPlus)) { // LOGF(info, "found muon %d with mother %d", particleI.pdgCode(), motherI.pdgCode()); - piToMu +=1; + piToMu += 1; particleI = motherI; - } else if (std::abs(particleI.pdgCode()) == std::abs(kPiPlus) && std::abs(motherI.pdgCode()) == std::abs(kKPlus)){ - kaToPi +=1; + } else if (std::abs(particleI.pdgCode()) == std::abs(kPiPlus) && std::abs(motherI.pdgCode()) == std::abs(kKPlus)) { + kaToPi += 1; particleI = motherI; } } @@ -799,10 +799,10 @@ struct RecoDecay { if (sign) { *sign = sgn; } - if (nPiToMu){ + if (nPiToMu) { *nPiToMu = piToMu; } - if (nKaToPi){ + if (nKaToPi) { *nKaToPi = kaToPi; } return indexMother; From a13240d118dd2838453f9b1ebfbfa01475d195d6 Mon Sep 17 00:00:00 2001 From: Luca Aglietta Date: Thu, 7 Nov 2024 15:53:15 +0100 Subject: [PATCH 4/7] fixed include for linter --- Common/Core/RecoDecay.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index f3fca7c3981..2aaa3eb4325 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -20,6 +20,7 @@ #include // std::find #include // std::array #include // std::abs, std::sqrt +#include #include // std::move #include // std::vector From 9154ad4a3d99a2d6f8f64a66210d19ee57634ef3 Mon Sep 17 00:00:00 2001 From: Luca Aglietta <75362880+Luca610@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:15:05 +0100 Subject: [PATCH 5/7] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vít Kučera --- Common/Core/RecoDecay.h | 42 ++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 2aaa3eb4325..869ada4979e 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -665,7 +665,7 @@ struct RecoDecay { /// Checks whether the reconstructed decay candidate is the expected decay. /// \param checkProcess switch to accept only decay daughters by checking the production process of MC particles /// \param acceptIncompleteReco switch to accept candidates with only part of the daughters reconstructed - /// \param acceptTrackDecay switch to accept candidates with one or more tracks decayed during transport + /// \tparam acceptTrackDecay switch to accept candidates with daughter tracks of pions and kaons which decayed /// \param particlesMC table with MC particles /// \param arrDaughters array of candidate daughters /// \param PDGMother expected mother PDG code @@ -673,8 +673,8 @@ struct RecoDecay { /// \param acceptAntiParticles switch to accept the antiparticle version of the expected decay /// \param sign antiparticle indicator of the found mother w.r.t. PDGMother; 1 if particle, -1 if antiparticle, 0 if mother not found /// \param depthMax maximum decay tree level to check; Daughters up to this level will be considered. If -1, all levels are considered. - /// \param nPiToMu number of pions decayed in a muon during transport - /// \param nKaToPi number of kaons decayed in a pion during transport + /// \param nPiToMu number of pion prongs decayed to a muon + /// \param nKaToPi number of kaon prongs decayed to a pion /// \return index of the mother particle if the mother and daughters are correct, -1 otherwise template static int getMatchedMCRec(const T& particlesMC, @@ -690,8 +690,10 @@ struct RecoDecay { // Printf("MC Rec: Expected mother PDG: %d", PDGMother); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) - int8_t piToMu = 0; // number of pions decayed to a muon >=1 if any are found - int8_t kaToPi = 0; // number of kaons decayed to a pion >=1 if any are found + if constexpr (acceptTrackDecay) { + int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon + int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion + } int indexMother = -1; // index of the mother particle std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter std::array arrDaughtersIndex; // array of indices of provided daughters @@ -717,14 +719,18 @@ struct RecoDecay { return -1; } auto particleI = arrDaughters[iProng].mcParticle(); // ith daughter particle - auto motherI = particleI.template mothers_first_as(); - if (acceptTrackDecay) { - if (std::abs(particleI.pdgCode()) == std::abs(kMuonPlus) && std::abs(motherI.pdgCode()) == std::abs(kPiPlus)) { - // LOGF(info, "found muon %d with mother %d", particleI.pdgCode(), motherI.pdgCode()); - piToMu += 1; + if constexpr (acceptTrackDecay) { + // Replace the MC particle associated with the prong by its mother for π → μ and K → π. + auto motherI = particleI.template mothers_first_as(); + auto pdgI = std::abs(particleI.pdgCode()); + auto pdgMotherI = std::abs(motherI.pdgCode()); + if (pdgI == kMuonMinus && pdgMotherI == kPiPlus) { + // π → μ + nPiToMuLocal++; particleI = motherI; - } else if (std::abs(particleI.pdgCode()) == std::abs(kPiPlus) && std::abs(motherI.pdgCode()) == std::abs(kKPlus)) { - kaToPi += 1; + } else if (pdgI == kPiPlus && pdgMotherI == kKPlus) { + // K → π + nKaToPiLocal++; particleI = motherI; } } @@ -800,11 +806,13 @@ struct RecoDecay { if (sign) { *sign = sgn; } - if (nPiToMu) { - *nPiToMu = piToMu; - } - if (nKaToPi) { - *nKaToPi = kaToPi; + if constexpr (acceptTrackDecay) { + if (nPiToMu) { + *nPiToMu = nPiToMuLocal; + } + if (nKaToPi) { + *nKaToPi = nKaToPiLocal; + } } return indexMother; } From c3db05fce1b6d09212f53d87338abef6f00b551c Mon Sep 17 00:00:00 2001 From: Luca Aglietta <75362880+Luca610@users.noreply.github.com> Date: Fri, 8 Nov 2024 15:53:56 +0100 Subject: [PATCH 6/7] Moved variable initialization outside of if statement --- Common/Core/RecoDecay.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 869ada4979e..4ec836399e8 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -690,10 +690,8 @@ struct RecoDecay { // Printf("MC Rec: Expected mother PDG: %d", PDGMother); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) - if constexpr (acceptTrackDecay) { - int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon - int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion - } + int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon + int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion int indexMother = -1; // index of the mother particle std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter std::array arrDaughtersIndex; // array of indices of provided daughters From c8e0775af63a0aaf38915fa76acfd0484d6f162c Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Fri, 8 Nov 2024 14:54:36 +0000 Subject: [PATCH 7/7] Please consider the following formatting changes --- Common/Core/RecoDecay.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/Core/RecoDecay.h b/Common/Core/RecoDecay.h index 4ec836399e8..ce2469e66e7 100644 --- a/Common/Core/RecoDecay.h +++ b/Common/Core/RecoDecay.h @@ -690,8 +690,8 @@ struct RecoDecay { // Printf("MC Rec: Expected mother PDG: %d", PDGMother); int8_t coefFlavourOscillation = 1; // 1 if no B0(s) flavour oscillation occured, -1 else int8_t sgn = 0; // 1 if the expected mother is particle, -1 if antiparticle (w.r.t. PDGMother) - int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon - int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion + int8_t nPiToMuLocal = 0; // number of pion prongs decayed to a muon + int8_t nKaToPiLocal = 0; // number of kaon prongs decayed to a pion int indexMother = -1; // index of the mother particle std::vector arrAllDaughtersIndex; // vector of indices of all daughters of the mother of the first provided daughter std::array arrDaughtersIndex; // array of indices of provided daughters