Skip to content

Commit 54bce8a

Browse files
committed
port from aliroot tracks xyzPxPyPz cov.matrix extraction
1 parent 5b8c98a commit 54bce8a

2 files changed

Lines changed: 64 additions & 0 deletions

File tree

‎DataFormats/Reconstruction/include/ReconstructionDataFormats/Track.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ class TrackParCov : public TrackPar
257257
float getCovarElem(int i, int j) const { return mC[CovarMap[i][j]]; }
258258
float getDiagError2(int i) const { return mC[DiagMap[i]]; }
259259

260+
bool getCovXYZPxPyPzGlo(std::array<float, 21>& c) const;
261+
260262
#ifndef GPUCA_ALIGPUCODE
261263
void print() const;
262264
std::string asString() const;

‎DataFormats/Reconstruction/src/Track.cxx‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,68 @@ bool TrackParCov::correctForMaterial(float x2x0, float xrho, float mass, bool an
16491649
return true;
16501650
}
16511651

1652+
//______________________________________________________________
1653+
bool TrackParCov::getCovXYZPxPyPzGlo(std::array<float, 21>& cv) const
1654+
{
1655+
//---------------------------------------------------------------------
1656+
// This function returns the global covariance matrix of the track params
1657+
//
1658+
// Cov(x,x) ... : cv[0]
1659+
// Cov(y,x) ... : cv[1] cv[2]
1660+
// Cov(z,x) ... : cv[3] cv[4] cv[5]
1661+
// Cov(px,x)... : cv[6] cv[7] cv[8] cv[9]
1662+
// Cov(py,x)... : cv[10] cv[11] cv[12] cv[13] cv[14]
1663+
// Cov(pz,x)... : cv[15] cv[16] cv[17] cv[18] cv[19] cv[20]
1664+
//
1665+
// Results for (nearly) straight tracks are meaningless !
1666+
//---------------------------------------------------------------------
1667+
if (std::abs(getQ2Pt()) <= Almost0 || std::abs(getSnp()) > Almost1) {
1668+
for (int i = 0; i < 21; i++) {
1669+
cv[i] = 0.;
1670+
}
1671+
return false;
1672+
}
1673+
1674+
auto pt = getPt();
1675+
float sn, cs;
1676+
o2::utils::sincos(getAlpha(), sn, cs);
1677+
auto r = std::sqrt((1. - getSnp()) * (1. + getSnp()));
1678+
auto m00 = -sn, m10 = cs;
1679+
auto m23 = -pt * (sn + getSnp() * cs / r), m43 = -pt * pt * (r * cs - getSnp() * sn);
1680+
auto m24 = pt * (cs - getSnp() * sn / r), m44 = -pt * pt * (r * sn + getSnp() * cs);
1681+
auto m35 = pt, m45 = -pt * pt * getTgl();
1682+
1683+
if (getSign() < 0) {
1684+
m43 = -m43;
1685+
m44 = -m44;
1686+
m45 = -m45;
1687+
}
1688+
1689+
cv[0] = mC[0] * m00 * m00;
1690+
cv[1] = mC[0] * m00 * m10;
1691+
cv[2] = mC[0] * m10 * m10;
1692+
cv[3] = mC[1] * m00;
1693+
cv[4] = mC[1] * m10;
1694+
cv[5] = mC[2];
1695+
cv[6] = m00 * (mC[3] * m23 + mC[10] * m43);
1696+
cv[7] = m10 * (mC[3] * m23 + mC[10] * m43);
1697+
cv[8] = mC[4] * m23 + mC[11] * m43;
1698+
cv[9] = m23 * (mC[5] * m23 + mC[12] * m43) + m43 * (mC[12] * m23 + mC[14] * m43);
1699+
cv[10] = m00 * (mC[3] * m24 + mC[10] * m44);
1700+
cv[11] = m10 * (mC[3] * m24 + mC[10] * m44);
1701+
cv[12] = mC[4] * m24 + mC[11] * m44;
1702+
cv[13] = m23 * (mC[5] * m24 + mC[12] * m44) + m43 * (mC[12] * m24 + mC[14] * m44);
1703+
cv[14] = m24 * (mC[5] * m24 + mC[12] * m44) + m44 * (mC[12] * m24 + mC[14] * m44);
1704+
cv[15] = m00 * (mC[6] * m35 + mC[10] * m45);
1705+
cv[16] = m10 * (mC[6] * m35 + mC[10] * m45);
1706+
cv[17] = mC[7] * m35 + mC[11] * m45;
1707+
cv[18] = m23 * (mC[8] * m35 + mC[12] * m45) + m43 * (mC[13] * m35 + mC[14] * m45);
1708+
cv[19] = m24 * (mC[8] * m35 + mC[12] * m45) + m44 * (mC[13] * m35 + mC[14] * m45);
1709+
cv[20] = m35 * (mC[9] * m35 + mC[13] * m45) + m45 * (mC[13] * m35 + mC[14] * m45);
1710+
1711+
return true;
1712+
}
1713+
16521714
#ifndef GPUCA_ALIGPUCODE
16531715
//______________________________________________________________
16541716
std::string TrackParCov::asString() const

0 commit comments

Comments
 (0)