Skip to content

Commit d85ec04

Browse files
authored
Complete RecoDecay. Update related tables and tasks. (#4256)
Implement calculation of decay length uncertainty. Replace DCA with Chi2. Rename tasks and move to PWGHF. Remove obsolete files. Minor fixes.
1 parent 7b6ea2e commit d85ec04

14 files changed

Lines changed: 107 additions & 520 deletions

‎Analysis/DataModel/CMakeLists.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
# submit itself to any jurisdiction.
1010

1111
o2_add_library(AnalysisDataModel
12-
SOURCES src/dummy.cxx
13-
src/ParamBase.cxx
12+
SOURCES src/ParamBase.cxx
1413
src/DetectorResponse.cxx
1514
src/PIDTOF.cxx
1615
src/PIDTPC.cxx

‎Analysis/DataModel/include/Analysis/RecoDecay.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RecoDecay
5656
/// \param num a number of arbitrary type
5757
/// \return number squared
5858
template <typename T>
59-
auto static sq(T num)
59+
static auto sq(T num)
6060
{
6161
return (double)num * (double)num;
6262
}
@@ -128,16 +128,16 @@ class RecoDecay
128128
/// \param point1,point2 {x, y, z} coordinates of points
129129
/// \return 3D distance between two points
130130
template <typename T, typename U>
131-
static auto distance(const array<T, 3>& point1, const array<U, 3>& point2)
131+
static auto distance(const T& point1, const U& point2)
132132
{
133133
return sqrtSumOfSquares(point1[0] - point2[0], point1[1] - point2[1], point1[2] - point2[2]);
134134
}
135135

136136
/// Calculates 2D {x, y} distance between two points.
137137
/// \param point1,point2 {x, y, z} or {x, y} coordinates of points
138138
/// \return 2D {x, y} distance between two points
139-
template <std::size_t N, std::size_t O, typename T, typename U>
140-
static auto distanceXY(const array<T, N>& point1, const array<U, O>& point2)
139+
template <typename T, typename U>
140+
static auto distanceXY(const T& point1, const U& point2)
141141
{
142142
return sqrtSumOfSquares(point1[0] - point2[0], point1[1] - point2[1]);
143143
}
@@ -279,8 +279,8 @@ class RecoDecay
279279
/// \note AliRoot version
280280
/// \param arrMom array of two 3-momentum arrays
281281
/// \param arrMass array of two masses (in the same order as arrMom)
282-
/// \param iProng index of the prong
283282
/// \param mTot assumed mass of mother particle
283+
/// \param iProng index of the prong
284284
/// \return cosine of θ* of the i-th prong under the assumption of the invariant mass
285285
template <typename T, typename U, typename V>
286286
static auto CosThetaStarA(const array<array<T, 3>, 2>& arrMom, const array<U, 2>& arrMass, V mTot, int iProng)
@@ -294,7 +294,7 @@ class RecoDecay
294294
// p* = √[(M^2 - m1^2 - m2^2)^2 - 4 m1^2 m2^2]/2M
295295
// Lorentz transformation of the longitudinal momentum of the prong into the detector frame:
296296
// p_L,i = γ (p*_L,i + β E*_i)
297-
// p*_L,i = p_L,i/γ - β E*_i)
297+
// p*_L,i = p_L,i/γ - β E*_i
298298
// cos(θ*_i) = (p_L,i/γ - β E*_i)/p*
299299
return (dotProd(arrMom[iProng], pVecTot) / (pTot * gamma) - beta * E(pStar, arrMass[iProng])) / pStar;
300300
}

‎Analysis/DataModel/include/Analysis/SecondaryVertex.h‎

Lines changed: 0 additions & 75 deletions
This file was deleted.

‎Analysis/DataModel/include/Analysis/SecondaryVertexHF.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ DECLARE_SOA_COLUMN(XSecondaryVertex, xSecondaryVertex, float);
5656
DECLARE_SOA_COLUMN(YSecondaryVertex, ySecondaryVertex, float);
5757
DECLARE_SOA_COLUMN(ZSecondaryVertex, zSecondaryVertex, float);
5858
DECLARE_SOA_DYNAMIC_COLUMN(RSecondaryVertex, rSecondaryVertex, [](float xVtxS, float yVtxS) { return RecoDecay::sqrtSumOfSquares(xVtxS, yVtxS); });
59+
DECLARE_SOA_COLUMN(Chi2PCA, chi2PCA, float); // sum of (non-weighted) distances of the secondary vertex to its prongs
5960
// prong properties
6061
DECLARE_SOA_COLUMN(PxProng0, pxProng0, float);
6162
DECLARE_SOA_COLUMN(PyProng0, pyProng0, float);
@@ -108,7 +109,6 @@ DECLARE_SOA_DYNAMIC_COLUMN(Ct, ct, [](float xVtxP, float yVtxP, float zVtxP, flo
108109
// specific 2-prong decay properties
109110
namespace hf_cand_prong2
110111
{
111-
DECLARE_SOA_COLUMN(DCA, dca, float);
112112
DECLARE_SOA_EXPRESSION_COLUMN(Px, px, float, 1.f * aod::hf_cand::pxProng0 + 1.f * aod::hf_cand::pxProng1);
113113
DECLARE_SOA_EXPRESSION_COLUMN(Py, py, float, 1.f * aod::hf_cand::pyProng0 + 1.f * aod::hf_cand::pyProng1);
114114
DECLARE_SOA_EXPRESSION_COLUMN(Pz, pz, float, 1.f * aod::hf_cand::pzProng0 + 1.f * aod::hf_cand::pzProng1);
@@ -122,43 +122,43 @@ DECLARE_SOA_DYNAMIC_COLUMN(CosThetaStar, cosThetaStar, [](float px0, float py0,
122122
// D0(bar) → π± K∓
123123

124124
template <typename T>
125-
auto CtD0(T candidate)
125+
auto CtD0(const T& candidate)
126126
{
127127
return candidate.ct(RecoDecay::getMassPDG(421));
128128
}
129129

130130
template <typename T>
131-
auto YD0(T candidate)
131+
auto YD0(const T& candidate)
132132
{
133133
return candidate.y(RecoDecay::getMassPDG(421));
134134
}
135135

136136
template <typename T>
137-
auto ED0(T candidate)
137+
auto ED0(const T& candidate)
138138
{
139139
return candidate.e(RecoDecay::getMassPDG(421));
140140
}
141141

142142
template <typename T>
143-
auto InvMassD0(T candidate)
143+
auto InvMassD0(const T& candidate)
144144
{
145145
return candidate.m(array{RecoDecay::getMassPDG(kPiPlus), RecoDecay::getMassPDG(kKPlus)});
146146
}
147147

148148
template <typename T>
149-
auto InvMassD0bar(T candidate)
149+
auto InvMassD0bar(const T& candidate)
150150
{
151151
return candidate.m(array{RecoDecay::getMassPDG(kKPlus), RecoDecay::getMassPDG(kPiPlus)});
152152
}
153153

154154
template <typename T>
155-
auto CosThetaStarD0(T candidate)
155+
auto CosThetaStarD0(const T& candidate)
156156
{
157157
return candidate.cosThetaStar(array{RecoDecay::getMassPDG(kPiPlus), RecoDecay::getMassPDG(kKPlus)}, RecoDecay::getMassPDG(421), 1);
158158
}
159159

160160
template <typename T>
161-
auto CosThetaStarD0bar(T candidate)
161+
auto CosThetaStarD0bar(const T& candidate)
162162
{
163163
return candidate.cosThetaStar(array{RecoDecay::getMassPDG(kKPlus), RecoDecay::getMassPDG(kPiPlus)}, RecoDecay::getMassPDG(421), 0);
164164
}
@@ -168,6 +168,7 @@ DECLARE_SOA_TABLE(HfCandBase, "AOD", "HFCANDBASE",
168168
collision::PosX, collision::PosY, collision::PosZ,
169169
hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex, hf_cand::ZSecondaryVertex,
170170
hf_cand::ErrorDecayLength, hf_cand::ErrorDecayLengthXY,
171+
hf_cand::Chi2PCA,
171172
/* dynamic columns */
172173
hf_cand::RSecondaryVertex<hf_cand::XSecondaryVertex, hf_cand::YSecondaryVertex>,
173174
hf_cand::ImpactParameterNormalised0<hf_cand::ImpactParameter0, hf_cand::ErrorImpactParameter0>,
@@ -188,7 +189,6 @@ DECLARE_SOA_TABLE(HfCandBase, "AOD", "HFCANDBASE",
188189
hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1,
189190
hf_cand::ImpactParameter0, hf_cand::ImpactParameter1,
190191
hf_cand::ErrorImpactParameter0, hf_cand::ErrorImpactParameter1,
191-
hf_cand_prong2::DCA,
192192
/* dynamic columns */
193193
hf_cand_prong2::ImpactParameterProduct<hf_cand::ImpactParameter0, hf_cand::ImpactParameter1>,
194194
hf_cand_prong2::M<hf_cand::PxProng0, hf_cand::PyProng0, hf_cand::PzProng0, hf_cand::PxProng1, hf_cand::PyProng1, hf_cand::PzProng1>,

‎Analysis/DataModel/include/Analysis/decayUtilities.h‎

Lines changed: 0 additions & 86 deletions
This file was deleted.

‎Analysis/DataModel/include/Analysis/trackUtilities.h‎

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,25 @@
77
// In applying this license CERN does not waive the privileges and immunities
88
// granted to it by virtue of its status as an Intergovernmental Organization
99
// or submit itself to any jurisdiction.
10-
#include "ReconstructionDataFormats/Track.h"
11-
#include "ReconstructionDataFormats/Vertex.h"
1210

1311
/// \file trackUtilities.h
14-
/// \brief Utilities for manipulating track parameters
12+
/// \brief Utilities for manipulating parameters of tracks and vertices
1513
///
1614
/// \author Vít Kučera <vit.kucera@cern.ch>, CERN
1715

1816
#ifndef O2_ANALYSIS_TRACKUTILITIES_H_
1917
#define O2_ANALYSIS_TRACKUTILITIES_H_
2018

19+
#include <cmath>
20+
21+
#include "ReconstructionDataFormats/Track.h"
22+
#include "ReconstructionDataFormats/Vertex.h"
23+
#include "Analysis/RecoDecay.h"
24+
2125
/// Extracts track parameters and covariance matrix from a track.
2226
/// \return o2::track::TrackParCov
2327
template <typename T>
24-
auto getTrackParCov(T track)
28+
auto getTrackParCov(const T& track)
2529
{
2630
std::array<float, 5> arraypar = {track.y(), track.z(), track.snp(),
2731
track.tgl(), track.signed1Pt()};
@@ -37,11 +41,47 @@ auto getTrackParCov(T track)
3741
/// Extracts primary vertex position and covariance matrix from a collision.
3842
/// \return o2::dataformats::VertexBase
3943
template <typename T>
40-
auto getPrimaryVertex(T collision)
44+
auto getPrimaryVertex(const T& collision)
4145
{
4246
Point3D<float> vtxXYZ(collision.posX(), collision.posY(), collision.posZ());
4347
std::array<float, 6> vtxCov{collision.covXX(), collision.covXY(), collision.covYY(), collision.covXZ(), collision.covYZ(), collision.covZZ()};
4448
return o2::dataformats::VertexBase{std::move(vtxXYZ), std::move(vtxCov)};
4549
}
4650

51+
/// Calculates direction of one point w.r.t another point.
52+
/// \param point1,point2 points with {x, y, z} coordinates accessible by index
53+
/// \param phi azimuth angle in the {x, y} plane (taken w.r.t. the x-axis towards the y-axis)
54+
/// \param theta angle w.r.t the {x, y} plane towards the z-axis
55+
/// \return phi,theta of point2 w.r.t. point1
56+
template <typename T, typename U, typename V, typename W>
57+
void getPointDirection(const T& point1, const U& point2, V& phi, W& theta)
58+
{
59+
phi = std::atan2(point2[1] - point1[1], point2[0] - point1[0]);
60+
//auto x1 = point1[0] * std::cos(phi) + point1[1] * std::sin(phi);
61+
//auto x2 = point2[0] * std::cos(phi) + point2[1] * std::sin(phi);
62+
//theta = std::atan2(point2[2] - point1[2], x2 - x1);
63+
theta = std::atan2(point2[2] - point1[2], RecoDecay::distanceXY(point1, point2));
64+
}
65+
66+
/// Calculates the XX element of a XYZ covariance matrix after rotation of the coordinate system
67+
/// by phi around the z-axis and by minus theta around the new y-axis.
68+
/// \param matrix matrix
69+
/// \param phi azimuth angle in the {x, y} plane (taken w.r.t. the x-axis towards the y-axis)
70+
/// \param theta angle w.r.t the {x, y} plane towards the z-axis
71+
/// \return XX element of the rotated covariance matrix
72+
template <typename T, typename U, typename V>
73+
auto getRotatedCovMatrixXX(const T& matrix, U phi, V theta)
74+
{
75+
auto cp = std::cos(phi);
76+
auto sp = std::sin(phi);
77+
auto ct = std::cos(theta);
78+
auto st = std::sin(theta);
79+
return matrix[0] * cp * cp * ct * ct // covXX
80+
+ matrix[1] * 2. * cp * sp * ct * ct // covXY
81+
+ matrix[2] * sp * sp * ct * ct // covYY
82+
+ matrix[3] * 2. * cp * ct * st // covXZ
83+
+ matrix[4] * 2. * sp * ct * st // covYZ
84+
+ matrix[5] * st * st; // covZZ
85+
}
86+
4787
#endif // O2_ANALYSIS_TRACKUTILITIES_H_

‎Analysis/DataModel/src/dummy.cxx‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)