From 573ccd474e069f31e204a3186c1411177ed92f43 Mon Sep 17 00:00:00 2001 From: ffionda Date: Thu, 2 Apr 2026 17:32:22 +0200 Subject: [PATCH 1/2] add decay length related variables for MCtruth pairs --- PWGDQ/Core/VarManager.h | 32 ++++++++++++++++++++++++++ PWGDQ/Tasks/dqEfficiency_withAssoc.cxx | 14 +++++++++++ 2 files changed, 46 insertions(+) diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 594317a5cd4..15918abf1f9 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -1330,6 +1330,8 @@ class VarManager : public TObject static void FillTrackCollision(T const& track, C const& collision, float* values = nullptr); template static void FillTrackCollisionMC(T1 const& track, T2 const& MotherTrack, C const& collision, float* values = nullptr); + template + static void FillTrackCollisionMC(T1 const& track, const std::array& collPos, float massHyp = -1., float* values = nullptr); template static void FillTrackCollisionMatCorr(T const& track, C const& collision, M const& materialCorr, P const& propagator, float* values = nullptr); template @@ -3301,6 +3303,36 @@ void VarManager::FillTrackCollisionMC(T1 const& track, T2 const& MotherTrack, C values[kMCVertexingTauxyzProjected] = values[kMCVertexingLxyzProjected] * m / (MotherTrack.p()); } +template +void VarManager::FillTrackCollisionMC(T1 const& track, const std::array& collPos, float massHyp, float* values){ + + if (!values) { + values = fgValues; + } + + float m = o2::constants::physics::MassJPsi; + if(massHyp) m = massHyp; + + // displaced vertex is computed with decay product (track) and vertex collPos + values[kMCVertexingLxy] = (collPos[0]-track.vx()) * (collPos[0]-track.vx()) + + (collPos[1]-track.vy()) * (collPos[1]-track.vy()); + values[kMCVertexingLz] = (collPos[2]-track.vz()) * (collPos[2]-track.vz()); + values[kMCVertexingLxyz] = values[kMCVertexingLxy] + values[kMCVertexingLz]; + values[kMCVertexingLxy] = std::sqrt(values[kMCVertexingLxy]); + values[kMCVertexingLz] = std::sqrt(values[kMCVertexingLz]); + values[kMCVertexingLxyz] = std::sqrt(values[kMCVertexingLxyz]); + values[kMCVertexingTauz] = (collPos[2]-track.vz()) * m / (TMath::Abs(track.pz()) * o2::constants::physics::LightSpeedCm2NS); + values[kMCVertexingTauxy] = values[kMCVertexingLxy] * m / (track.pt() * o2::constants::physics::LightSpeedCm2NS); + + values[kMCVertexingLzProjected] = ((track.vz()-collPos[2]) * track.pz()) / TMath::Abs(track.pz()); + values[kMCVertexingLxyProjected] = (((track.vx()-collPos[0]) * track.px()) + ((track.vy()-collPos[1]) * track.py())) / TMath::Abs(track.pt()); + values[kMCVertexingLxyzProjected] = (((track.vx()-collPos[0]) * track.px()) + ((track.vy()-collPos[1]) * track.py()) + ((track.vz()-collPos[2]) * track.pz())) / track.p(); + values[kMCVertexingTauxyProjected] = values[kMCVertexingLxyProjected] * m / (track.pt()); + values[kMCVertexingTauzProjected] = values[kMCVertexingLzProjected] * m / TMath::Abs(track.pz()); + values[kMCVertexingTauxyzProjected] = values[kMCVertexingLxyzProjected] * m / (track.p()); +} + + template void VarManager::FillEnergyCorrelatorsMC(T const& track, T1 const& t1, float* values, float Translow, float Transhigh) { diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 62d9bc01b32..45e435717c1 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -1397,6 +1398,9 @@ struct AnalysisSameEventPairing { Service fCCDB; + // PDG database + Service pdgDB; + // Filter filterEventSelected = aod::dqanalysisflags::isEventSelected & uint32_t(1); Filter eventFilter = aod::dqanalysisflags::isEventSelected > static_cast(0); @@ -2275,6 +2279,16 @@ struct AnalysisSameEventPairing { // cout << " Signal matched!" << endl; mcDecision |= (static_cast(1) << isig); VarManager::FillPairMC(t1_raw, t2_raw); + // check if t1_raw and t2_raw have same mother to compute decay length related variables + if(t1_raw.has_mothers() && t2_raw.has_mothers()){ + auto motherMCParticle_t1 = t1_raw.template mothers_first_as(); + auto motherMCParticle_t2 = t2_raw.template mothers_first_as(); + if(motherMCParticle_t1 == motherMCParticle_t2){ + auto mcEvent = mcEvents.rawIteratorAt(motherMCParticle_t1.reducedMCeventId()); + std::array collVtxPos = {mcEvent.mcPosX(), mcEvent.mcPosY(), mcEvent.mcPosZ()}; + VarManager::FillTrackCollisionMC(motherMCParticle_t1,collVtxPos,pdgDB->Mass(motherMCParticle_t1.pdgCode())); + } + } // cout << " Filled VarManager for the pair." << endl; fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues); fHistMan->FillHistClass(Form("MCTruthGenPseudoPolPairSel_%s", sig->GetName()), VarManager::fgValues); From 74a17252fb667be8326f6895fcddbb7e83fdc902 Mon Sep 17 00:00:00 2001 From: ALICE Action Bot Date: Thu, 2 Apr 2026 15:36:09 +0000 Subject: [PATCH 2/2] Please consider the following formatting changes --- PWGDQ/Core/VarManager.h | 23 ++++++++++++----------- PWGDQ/Tasks/dqEfficiency_withAssoc.cxx | 22 +++++++++++----------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/PWGDQ/Core/VarManager.h b/PWGDQ/Core/VarManager.h index 15918abf1f9..795dfa62ab1 100644 --- a/PWGDQ/Core/VarManager.h +++ b/PWGDQ/Core/VarManager.h @@ -3304,35 +3304,36 @@ void VarManager::FillTrackCollisionMC(T1 const& track, T2 const& MotherTrack, C } template -void VarManager::FillTrackCollisionMC(T1 const& track, const std::array& collPos, float massHyp, float* values){ +void VarManager::FillTrackCollisionMC(T1 const& track, const std::array& collPos, float massHyp, float* values) +{ - if (!values) { + if (!values) { values = fgValues; } float m = o2::constants::physics::MassJPsi; - if(massHyp) m = massHyp; + if (massHyp) + m = massHyp; // displaced vertex is computed with decay product (track) and vertex collPos - values[kMCVertexingLxy] = (collPos[0]-track.vx()) * (collPos[0]-track.vx()) + - (collPos[1]-track.vy()) * (collPos[1]-track.vy()); - values[kMCVertexingLz] = (collPos[2]-track.vz()) * (collPos[2]-track.vz()); + values[kMCVertexingLxy] = (collPos[0] - track.vx()) * (collPos[0] - track.vx()) + + (collPos[1] - track.vy()) * (collPos[1] - track.vy()); + values[kMCVertexingLz] = (collPos[2] - track.vz()) * (collPos[2] - track.vz()); values[kMCVertexingLxyz] = values[kMCVertexingLxy] + values[kMCVertexingLz]; values[kMCVertexingLxy] = std::sqrt(values[kMCVertexingLxy]); values[kMCVertexingLz] = std::sqrt(values[kMCVertexingLz]); values[kMCVertexingLxyz] = std::sqrt(values[kMCVertexingLxyz]); - values[kMCVertexingTauz] = (collPos[2]-track.vz()) * m / (TMath::Abs(track.pz()) * o2::constants::physics::LightSpeedCm2NS); + values[kMCVertexingTauz] = (collPos[2] - track.vz()) * m / (TMath::Abs(track.pz()) * o2::constants::physics::LightSpeedCm2NS); values[kMCVertexingTauxy] = values[kMCVertexingLxy] * m / (track.pt() * o2::constants::physics::LightSpeedCm2NS); - values[kMCVertexingLzProjected] = ((track.vz()-collPos[2]) * track.pz()) / TMath::Abs(track.pz()); - values[kMCVertexingLxyProjected] = (((track.vx()-collPos[0]) * track.px()) + ((track.vy()-collPos[1]) * track.py())) / TMath::Abs(track.pt()); - values[kMCVertexingLxyzProjected] = (((track.vx()-collPos[0]) * track.px()) + ((track.vy()-collPos[1]) * track.py()) + ((track.vz()-collPos[2]) * track.pz())) / track.p(); + values[kMCVertexingLzProjected] = ((track.vz() - collPos[2]) * track.pz()) / TMath::Abs(track.pz()); + values[kMCVertexingLxyProjected] = (((track.vx() - collPos[0]) * track.px()) + ((track.vy() - collPos[1]) * track.py())) / TMath::Abs(track.pt()); + values[kMCVertexingLxyzProjected] = (((track.vx() - collPos[0]) * track.px()) + ((track.vy() - collPos[1]) * track.py()) + ((track.vz() - collPos[2]) * track.pz())) / track.p(); values[kMCVertexingTauxyProjected] = values[kMCVertexingLxyProjected] * m / (track.pt()); values[kMCVertexingTauzProjected] = values[kMCVertexingLzProjected] * m / TMath::Abs(track.pz()); values[kMCVertexingTauxyzProjected] = values[kMCVertexingLxyzProjected] * m / (track.p()); } - template void VarManager::FillEnergyCorrelatorsMC(T const& track, T1 const& t1, float* values, float Translow, float Transhigh) { diff --git a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx index 45e435717c1..578e161bcdd 100644 --- a/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx +++ b/PWGDQ/Tasks/dqEfficiency_withAssoc.cxx @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #include @@ -2279,16 +2279,16 @@ struct AnalysisSameEventPairing { // cout << " Signal matched!" << endl; mcDecision |= (static_cast(1) << isig); VarManager::FillPairMC(t1_raw, t2_raw); - // check if t1_raw and t2_raw have same mother to compute decay length related variables - if(t1_raw.has_mothers() && t2_raw.has_mothers()){ - auto motherMCParticle_t1 = t1_raw.template mothers_first_as(); - auto motherMCParticle_t2 = t2_raw.template mothers_first_as(); - if(motherMCParticle_t1 == motherMCParticle_t2){ - auto mcEvent = mcEvents.rawIteratorAt(motherMCParticle_t1.reducedMCeventId()); - std::array collVtxPos = {mcEvent.mcPosX(), mcEvent.mcPosY(), mcEvent.mcPosZ()}; - VarManager::FillTrackCollisionMC(motherMCParticle_t1,collVtxPos,pdgDB->Mass(motherMCParticle_t1.pdgCode())); - } - } + // check if t1_raw and t2_raw have same mother to compute decay length related variables + if (t1_raw.has_mothers() && t2_raw.has_mothers()) { + auto motherMCParticle_t1 = t1_raw.template mothers_first_as(); + auto motherMCParticle_t2 = t2_raw.template mothers_first_as(); + if (motherMCParticle_t1 == motherMCParticle_t2) { + auto mcEvent = mcEvents.rawIteratorAt(motherMCParticle_t1.reducedMCeventId()); + std::array collVtxPos = {mcEvent.mcPosX(), mcEvent.mcPosY(), mcEvent.mcPosZ()}; + VarManager::FillTrackCollisionMC(motherMCParticle_t1, collVtxPos, pdgDB->Mass(motherMCParticle_t1.pdgCode())); + } + } // cout << " Filled VarManager for the pair." << endl; fHistMan->FillHistClass(Form("MCTruthGenPairSel_%s", sig->GetName()), VarManager::fgValues); fHistMan->FillHistClass(Form("MCTruthGenPseudoPolPairSel_%s", sig->GetName()), VarManager::fgValues);