Skip to content

Commit b98aa1c

Browse files
committed
Feat: improve kstar & q3 calculation
1 parent b6b9a12 commit b98aa1c

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

PWGCF/Femto/Core/pairHistManager.h

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -903,15 +903,20 @@ class PairHistManager
903903

904904
float getKstar(ROOT::Math::PtEtaPhiMVector const& part1, ROOT::Math::PtEtaPhiMVector const& part2)
905905
{
906-
// compute pair momentum
907-
auto sum = part1 + part2;
908-
// Boost particle 1 to the pair rest frame (Prf) and calculate k* (would be equivalent using particle 2)
909-
// make a copy of particle 1
910-
auto particle1Prf = ROOT::Math::PtEtaPhiMVector(part1);
911-
// get lorentz boost into pair rest frame
912-
ROOT::Math::Boost boostPrf(sum.BoostToCM());
913-
// boost particle 1 into pair rest frame and calculate its momentum, which has the same value as k*
914-
return static_cast<float>(boostPrf(particle1Prf).P());
906+
// Use Cartesian 4-vectors: addition/M2() become pure arithmetic
907+
const ROOT::Math::PxPyPzEVector p1(part1);
908+
const ROOT::Math::PxPyPzEVector p2(part2);
909+
910+
// Mandelstam s = (p1 + p2)^2
911+
const double s = (p1 + p2).M2();
912+
const double m1sq = p1.M2();
913+
const double m2sq = p2.M2();
914+
915+
// Källen function λ(s, m1^2, m2^2) = (s - m1^2 - m2^2)² - 4*m1^2*m2^2
916+
const double kallen = (s - m1sq - m2sq) * (s - m1sq - m2sq) - 4.0 * m1sq * m2sq;
917+
918+
// k* = 0.5 * sqrt(λ/s)
919+
return static_cast<float>(0.5 * std::sqrt(std::max(0.0, kallen) / s));
915920
}
916921

917922
o2::framework::HistogramRegistry* mHistogramRegistry = nullptr;

PWGCF/Femto/Core/tripletHistManager.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,23 +383,24 @@ class TripletHistManager
383383
float getQ3() const { return mQ3; }
384384

385385
private:
386-
ROOT::Math::PxPyPzEVector getqij(ROOT::Math::PtEtaPhiMVector const& pi, ROOT::Math::PtEtaPhiMVector const& pj)
386+
ROOT::Math::PxPyPzEVector getqij(ROOT::Math::PxPyPzEVector const& vi, ROOT::Math::PxPyPzEVector const& vj)
387387
{
388-
// Convert to PxPyPzEVector to get proper Lorentz dot product
389-
ROOT::Math::PxPyPzEVector vi(pi);
390-
ROOT::Math::PxPyPzEVector vj(pj);
391-
392388
auto trackSum = vi + vj;
393389
auto trackDifference = vi - vj;
394-
double scaling = trackDifference.Dot(trackSum) / trackSum.Dot(trackSum);
390+
const double s = trackSum.M2();
391+
const double scaling = (s != 0.0) ? (vi.M2() - vj.M2()) / s : 0.0;
395392
return trackDifference - scaling * trackSum;
396393
}
397394

398395
float getQ3(ROOT::Math::PtEtaPhiMVector const& part1, ROOT::Math::PtEtaPhiMVector const& part2, ROOT::Math::PtEtaPhiMVector const& part3)
399396
{
400-
auto q12 = getqij(part1, part2);
401-
auto q23 = getqij(part2, part3);
402-
auto q31 = getqij(part3, part1);
397+
// upfront conversion to PxPyPzEVector
398+
const ROOT::Math::PxPyPzEVector p1(part1);
399+
const ROOT::Math::PxPyPzEVector p2(part2);
400+
const ROOT::Math::PxPyPzEVector p3(part3);
401+
auto q12 = getqij(p1, p2);
402+
auto q23 = getqij(p2, p3);
403+
auto q31 = getqij(p3, p1);
403404
double q = q12.M2() + q23.M2() + q31.M2();
404405
return static_cast<float>(std::sqrt(-q));
405406
}

0 commit comments

Comments
 (0)