Project
Loading...
Searching...
No Matches
PVertexerHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
15
16#ifndef O2_PVERTEXER_HELPERS_H
17#define O2_PVERTEXER_HELPERS_H
18
19#include "gsl/span"
27
28namespace o2
29{
30namespace vertexing
31{
32
38
40 gsl::span<int> idRange;
41 TimeEst timeEst{0, -1.}; // negative error means don't use time info
42 float scaleSigma2 = 10;
43};
44
46struct VertexSeed : public PVertex {
47 double wghSum = 0.; // sum of tracks weights
48 double wghChi2 = 0.; // sum of tracks weighted chi2's
49 double tMeanAcc = 0.; // sum of track times * inv.err^2 wotj real time error
50 double tMeanAccErr = 0.; // some of tracks times inv.err^2 with real time error
51 double tMeanAccTB = 0.; // sum of track times * inv.err^2 with time error from time bracket, i.e. ITS
52 double tMeanAccErrTB = 0.; // sum of tracks times inv.err^2 with time error from time bracket, i.e. ITS
53 double wghSumTB = 0.; // sum of weights for tracks with time error from time bracket, i.e. ITS
54 double cxx = 0., cyy = 0., czz = 0., cxy = 0., cxz = 0., cyz = 0., cx0 = 0., cy0 = 0., cz0 = 0.; // elements of lin.equation matrix
55 float scaleSigma2 = 1.; // scaling parameter on top of Tukey param
56 float scaleSigma2Prev = 1.;
58 float scaleSig2ITuk2I = 0; // inverse squared Tukey parameter scaled by scaleSigma2
59 int nContributorsTB = 0; // number of contributors with time error coming from Time Bracker
62 int nIterations = 0;
63
64 void setScale(float scale2, float tukey2I)
65 {
67 scaleSigma2 = scale2;
68 scaleSig2ITuk2I = tukey2I / scale2;
69 }
70
72 {
73 setNContributors(0);
75 //setTimeStamp({0., 0.});
76 wghSum = 0.;
77 wghChi2 = 0.;
78 wghSumTB = 0.;
79 tMeanAcc = 0.;
80 tMeanAccErr = 0.;
81 tMeanAccTB = 0.;
82 tMeanAccErrTB = 0.;
83 cxx = cyy = czz = cxy = cxz = cyz = cx0 = cy0 = cz0 = 0.;
84 }
85
86 VertexSeed() = default;
87 VertexSeed(const PVertex& vtx)
88 : PVertex(vtx) {}
89
90 void print() const;
91};
92
98
99struct TrackVF {
105 enum { kUsed,
106 kNoVtx = -1,
108 enum { kITSTPCAdjust = 0x1,
109 kDummyHBin = 0xffff };
110 float x;
111 float y;
112 float z;
113 float sig2YI = 0.f;
114 float sig2ZI = 0.f;
115 float sigYZI = 0.f;
116 float tgP;
117 float tgL;
118 float cosAlp;
119 float sinAlp;
120
122 float wgh = 0.;
123 float wghHisto = 0.; // weight based on track errors, used for histogramming
124 int entry;
125 int vtxID = kNoVtx;
127 uint16_t bin = kDummyHBin; // seeds histo bin
128 uint16_t flags = 0;
129 //
131 bool isITSTPCAdjusted() const { return flags & kITSTPCAdjust; }
132 bool canAssign() const { return wgh > 0. && vtxID == kNoVtx; }
133 bool canUse() const { return vtxID == kNoVtx; }
134 bool canUse(float zmin, float zmax) const
135 {
136 return canUse() && (z > zmin && z < zmax);
137 }
138 bool operator<(const TrackVF& trc) const { return z < trc.z; }
139
140 float getZForXY(float vx, float vy) const
141 {
142 return z + tgL * (vx * cosAlp + vy * sinAlp - x);
143 }
144
145 // weighted distance^2 to other track (accounting for own errors only)
146 float getDist2(const TrackVF& o) const
147 {
148 auto dt = timeEst.getTimeStamp() - o.timeEst.getTimeStamp();
149 auto dte2 = timeEst.getTimeStampError() * timeEst.getTimeStampError() + o.timeEst.getTimeStampError() * o.timeEst.getTimeStampError();
150 auto dtnorm2 = dt * dt / dte2;
151 auto dz = z - o.z;
152 return dtnorm2 + dz * dz * sig2ZI;
153 }
154
155 // weighted distance^2 to other track (accounting for both track errors errors only)
156 float getDist2Sym(const TrackVF& o) const
157 {
158 auto dt = timeEst.getTimeStamp() - o.timeEst.getTimeStamp();
159 auto dz = z - o.z;
160 float dte2 = o.timeEst.getTimeStampError() * o.timeEst.getTimeStampError() + timeEst.getTimeStampError() * timeEst.getTimeStampError();
161 return dt / dte2 + dz * dz / (1. / sig2ZI + 1. / o.sig2ZI);
162 }
163
164 float getResiduals(const PVertex& vtx, float& dy, float& dz) const
165 {
166 // get residuals (Y and Z DCA in track frame) and calculate chi2
167 float dx = vtx.getX() * cosAlp + vtx.getY() * sinAlp - x; // VX rotated to track frame - trackX
168 dy = y + tgP * dx - (-vtx.getX() * sinAlp + vtx.getY() * cosAlp);
169 dz = z + tgL * dx - vtx.getZ();
170 return (dy * dy * sig2YI + dz * dz * sig2ZI) + 2. * dy * dz * sigYZI;
171 }
172
173 float getResiduals(const PVertex& vtx) const
174 {
175 // get residuals (Y and Z DCA in track frame) and calculate chi2
176 float dx = vtx.getX() * cosAlp + vtx.getY() * sinAlp - x; // VX rotated to track frame - trackX
177 auto dy = y + tgP * dx - (-vtx.getX() * sinAlp + vtx.getY() * cosAlp);
178 auto dz = z + tgL * dx - vtx.getZ();
179 return (dy * dy * sig2YI + dz * dz * sig2ZI) + 2. * dy * dz * sigYZI;
180 }
181
182 float evalChi2ToVertex(const PVertex& vtx, bool useTime)
183 {
184 constexpr float NDOF2I = 1. / 2, NDOF3I = 1. / 3;
185 float chi2T = getResiduals(vtx); // track-vertex residuals and chi2
186 if (useTime) {
187 float dt = timeEst.getTimeStamp() - vtx.getTimeStamp().getTimeStamp();
188 chi2T += dt * dt / (timeEst.getTimeStampError() * timeEst.getTimeStampError());
189 chi2T *= NDOF3I;
190 } else {
191 chi2T *= NDOF2I;
192 }
193 return chi2T;
194 }
195
196 TrackVF() = default;
197 TrackVF(const o2::track::TrackParCov& src, const TimeEst& t_est, int _entry, GTrackID _gid, float addHTErr2 = 0., float addHZErr2 = 0.)
198 : x(src.getX()), y(src.getY()), z(src.getZ()), tgL(src.getTgl()), tgP(src.getSnp() / std::sqrt(1. - src.getSnp()) * (1. + src.getSnp())), timeEst(t_est), entry(_entry), gid(_gid)
199 {
200 o2::math_utils::sincos(src.getAlpha(), sinAlp, cosAlp);
201 double syy = src.getSigmaY2(), szz = src.getSigmaZ2(), syz = src.getSigmaZY();
202 auto det = syy * szz - syz * syz;
203 if (det <= 1e-20) {
204 wghHisto = -1;
205 reportBadTrack(src, t_est, gid);
206 return;
207 }
208 auto detI = 1. / det;
209 sig2YI = szz * detI;
210 sig2ZI = syy * detI;
211 sigYZI = -syz * detI;
212 wghHisto = 1. / ((szz + addHZErr2) * (t_est.getTimeStampError() * t_est.getTimeStampError() + addHTErr2));
213 }
214
215 void reportBadTrack(const o2::track::TrackParCov& src, const TimeEst& t_est, GTrackID _gid);
216
218};
219
222
223 uint16_t fillAndFlagBin(float x, float y, float w)
224 {
225 uint32_t bin = getBin(x, y);
226 if (isValidBin(bin)) {
227 if (isBinEmpty(bin)) {
228 filledBins.push_back(bin);
229 }
230 fillBin(bin, w);
231 nEntries++;
232 return uint16_t(bin);
233 }
234 return 0xffff;
235 }
236
237 void clear()
238 {
240 filledBins.clear();
241 }
242
243 int findPeakBin();
244
245 std::vector<int> filledBins;
246 int nEntries{};
247};
248
250 std::vector<int> trackIDs{};
252};
253
254// structure to produce debug dump for neighbouring vertices comparison
258 float chi2z{0};
259 float chi2t{0};
260 float chi2zE{0};
261 float chi2tE{0};
262 bool rej = false;
264};
265
266// structure to produce debug dump for DBSCAN clusters
268 float z = 0;
269 float ze2i = 0.;
270 float t = 0;
271 float te = 0;
272 float wh = 0.;
274};
275
277 float time = 0;
278 float amplitude = 0;
279 uint32_t flag = 0; // origin, etc.
280};
281
282} // namespace vertexing
283} // namespace o2
284
285#endif
Base track model for the Barrel, params only, w/o covariance.
2D messeageable histo class
bool o
Extention of GlobalTrackID by flags relevant for verter-track association.
Referenc on track indices contributing to the vertex, with possibility chose tracks from specific sou...
uint32_t getBin(T x, T y) const
void fillBin(uint32_t bin, T w)
bool isValidBin(uint32_t bin) const
bool isBinEmpty(uint32_t bin) const
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum src
Definition glcorearb.h:1767
GLuint entry
Definition glcorearb.h:5735
GLbitfield flags
Definition glcorearb.h:1570
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
TrackParCovF TrackParCov
Definition Track.h:33
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Defining DataPointCompositeObject explicitly as copiable.
ClassDefNV(PVtxCompDump, 1)
uint16_t fillAndFlagBin(float x, float y, float w)
std::vector< int > filledBins
ClassDefNV(TrackVFDump, 1)
float getResiduals(const PVertex &vtx) const
float tgL
tangent(lambda)
bool canUse(float zmin, float zmax) const
float tgP
tangent(phi) in tracking frame
TrackVF(const o2::track::TrackParCov &src, const TimeEst &t_est, int _entry, GTrackID _gid, float addHTErr2=0., float addHZErr2=0.)
float sigYZI
YZ component of inverse cov.matrix.
float evalChi2ToVertex(const PVertex &vtx, bool useTime)
int vtxID
assigned vertex
void reportBadTrack(const o2::track::TrackParCov &src, const TimeEst &t_est, GTrackID _gid)
float wgh
track weight wrt current vertex seed
float getResiduals(const PVertex &vtx, float &dy, float &dz) const
bool operator<(const TrackVF &trc) const
float getDist2(const TrackVF &o) const
float getZForXY(float vx, float vy) const
float sig2YI
YY component of inverse cov.matrix.
float cosAlp
cos of alpha frame
int entry
track entry in the input vector
float sig2ZI
ZZ component of inverse cov.matrix.
float sinAlp
sin of alpha frame
float getDist2Sym(const TrackVF &o) const
generic track with timestamp
void setScale(float scale2, float tukey2I)
VertexSeed(const PVertex &vtx)
weights and scaling params for current vertex