Project
Loading...
Searching...
No Matches
AlignmentTrack.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
16
23#ifndef ALIGNMENTTRACK_H
24#define ALIGNMENTTRACK_H
25
29#include <TObjArray.h>
30#include <TArrayI.h>
32
33namespace o2
34{
35namespace align
36{
37
38class AlignmentTrack : public trackParam_t, public TObject
39{
40 public:
46 using trackParam_t::setParam;
47 static constexpr double MaxDefStep = 3.0;
48 static constexpr double MaxDefSnp = 0.95;
49
50 enum { kCosmicBit = BIT(14),
51 kFieldONBit = BIT(15),
52 kResidDoneBit = BIT(16),
53 kDerivDoneBit = BIT(17),
54 kKalmanDoneBit = BIT(18) };
55 enum { kNKinParBOFF = 4, // N params for ExternalTrackParam part w/o field
56 kNKinParBON = 5, // N params for ExternalTrackParam part with field
57 kParY = 0, // track parameters
62 };
63 AlignmentTrack() = default;
64 ~AlignmentTrack() override = default;
67 void defineDOFs();
68 int getNPoints() const { return mPoints.size(); }
69 int getInnerPointID() const { return mInnerPointID; }
72 const AlignmentPoint* getPoint(int i) const { return mPoints[i]; }
73 auto getPoints() { return mPoints; }
74 auto& addDetectorPoint() { return mDetPoints.emplace_back(); }
75 std::vector<AlignmentPoint>& getDetPoints() { return mDetPoints; }
76 void suppressLastPoints(int n);
77 void setRefPoint(AlignmentPoint* p) { mPoints.emplace_back(p); }
78 int getNLocPar() const { return mNLocPar; }
79 int getNLocExtPar() const { return mNLocExtPar; }
80 //
81 void Clear(Option_t* opt = "") final;
82 void Print(Option_t* opt = "") const final;
83 virtual void dumpCoordinates() const;
84 //
85 template <typename P>
86 void copyFrom(const o2::track::TrackParametrizationWithError<P>& trc);
87 bool propagateToPoint(trackParam_t& tr, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, track::TrackLTIntegral* tLT = nullptr, int signCorr = 0);
88 bool propagateParamToPoint(trackPar_t& tr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // param only
89 bool propagateParamToPoint(trackPar_t* trSet, int nTr, const AlignmentPoint* pnt, double maxStep = 3, double maxSnp = 0.95, MatCorrType mt = MatCorrType::USEMatCorrLUT, int signCorr = 0); // params only
90 //
91 bool calcResiduals(const double* params = nullptr);
92 bool calcResidDeriv(double* params = nullptr);
94 bool testLocalSolution();
95 //
96 bool isCosmic() const { return TestBit(kCosmicBit); }
97 void setCosmic(bool v = true) { SetBit(kCosmicBit, v); }
98 bool getFieldON() const { return TestBit(kFieldONBit); }
99 void setFieldON(bool v = true) { SetBit(kFieldONBit, v); }
100 bool getResidDone() const { return TestBit(kResidDoneBit); }
101 void setResidDone(bool v = true) { SetBit(kResidDoneBit, v); }
102 bool getDerivDone() const { return TestBit(kDerivDoneBit); }
103 void setDerivDone(bool v = true) { SetBit(kDerivDoneBit, v); }
104 bool getKalmanDone() const { return TestBit(kKalmanDoneBit); }
105 void setKalmanDone(bool v = true) { SetBit(kKalmanDoneBit, v); }
106 //
107 void sortPoints();
108 bool iniFit();
109 bool residKalman();
110 bool processMaterials();
111 bool combineTracks(trackParam_t& trcL, const trackParam_t& trcU);
112 //
113 void setChi2(double c) { mChi2 = c; };
114 double getChi2() const { return mChi2; }
115 void setChi2Ini(double c) { mChi2Ini = c; };
116 double getChi2Ini() const { return mChi2Ini; }
117 double getChi2CosmUp() const { return mChi2CosmUp; }
118 double getChi2CosmDn() const { return mChi2CosmDn; }
119 //
120 void imposePtBOff(double pt) { setQ2Pt(1. / pt); }
121 // propagation methods
122 void copyFrom(const trackParam_t* etp);
123 bool applyMatCorr(trackPar_t& trPar, const double* corrDiag, const AlignmentPoint* pnt);
124 bool applyMatCorr(trackPar_t* trSet, int ntr, const double* corrDiaf, const AlignmentPoint* pnt);
125 bool applyMatCorr(trackPar_t& trPar, const double* corrpar);
126 //
127 double getResidual(int dim, int pntID) const { return mResid[dim][pntID]; }
128 const double* getDResDLoc(int dim, int pntID) const { return mDResDLoc[dim].data() + (pntID * mNLocPar); }
129 const double* getDResDGlo(int dim, int id) const { return mDResDGlo[dim].data() + id; }
130 const int* getGloParID() const { return mGloParID.data(); }
131 //
132 void setParams(trackPar_t& tr, double x, double alp, const double* par, bool add);
133 void setParams(trackPar_t* trSet, int ntr, double x, double alp, const double* par, bool add);
134 void setParam(trackPar_t& tr, int par, double val);
135 void setParam(trackPar_t* trSet, int ntr, int par, double val);
136 void modParam(trackPar_t& tr, int par, double delta);
137 void modParam(trackPar_t* trSet, int ntr, int par, double delta);
138 //
139 void richardsonDeriv(const trackPar_t* trSet, const double* delta,
140 const AlignmentPoint* pnt, double& derY, double& derZ);
141 //
142 const double* getLocPars() const { return mLocPar.data(); }
143 std::vector<double>& getLocParsV() { return mLocPar; }
144 void setLocPars(const double* pars);
145 void addLocPars(const double* pars);
146 //
147 protected:
148 //
149 bool calcResidDeriv(double* params, bool invert, int pFrom, int pTo);
150 bool calcResiduals(const double* params, bool invert, int pFrom, int pTo);
151 bool fitLeg(trackParam_t& trc, int pFrom, int pTo, bool& inv);
152 bool processMaterials(trackParam_t& trc, int pFrom, int pTo);
153 //
154 void checkExpandDerGloBuffer(unsigned int minSize);
155 //
156 static double richardsonExtrap(double* val, int ord = 1);
157 static double richardsonExtrap(const double* val, int ord = 1);
158 //
159 // ---------- dummies ----------
162 //
163 protected:
164 int mNLocPar = 0; // number of local params
165 int mNLocExtPar = 0; // number of local params for the external track param
166 int mNGloPar = 0; // number of free global parameters the track depends on
167 int mNDF = 0; // number of degrees of freedom
168 int mInnerPointID = 0; // ID of inner point in sorted track. For 2-leg cosmics - innermost point of lower leg
169 bool mNeedInv[2] = {}; // set if one of cosmic legs need inversion
170 double mChi2 = 0; // chi2 with current residuals
171 double mChi2CosmUp = 0; // chi2 for cosmic upper leg
172 double mChi2CosmDn = 0; // chi2 for cosmic down leg
173 double mChi2Ini = 0; // chi2 with current residuals
174 GTrackID mCurrenTrackID = {}; // currently processed track ID
175 std::vector<AlignmentPoint*> mPoints{}; // alignment points pointers sorted in X
176 std::vector<AlignmentPoint> mDetPoints{}; // alignment points added by detectors
177 std::vector<double> mResid[2]; // residuals array
178 std::vector<double> mDResDLoc[2]; // array for derivatives over local params
179 std::vector<double> mDResDGlo[2]; // array for derivatives over global params
180 std::vector<double> mLocPar; // local parameters array
181 std::vector<int> mGloParID; // IDs of relevant global params
182 private:
183 bool propagate(trackParam_t& tr, trackPar_t* linRef, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr = 0);
184 bool propagate(trackPar_t& tr, const AlignmentPoint* pnt, double maxStep, double maxSnp, MatCorrType mt, track::TrackLTIntegral* tLT, int signCorr = 0);
185 //
186 ClassDefOverride(AlignmentTrack, 2)
187};
188
189//____________________________________________________________________________________________
190inline void AlignmentTrack::setParams(trackPar_t& tr, double x, double alp, const double* par, bool add)
191{
192 // set track params
193 const double kDefQ2PtCosm = 1;
194 const double kDefG2PtColl = 1. / 0.6;
195 params_t tmp;
196 std::copy(par, par + kNKinParBON, std::begin(tmp));
197 tr.set(x, alp, tmp);
198 if (add) { // par is correction to reference params
199 for (size_t i = 0; i < kNKinParBON; ++i) {
200 const double val = tr.getParam(i) + this->getParam(i);
201 tr.setParam(val, i);
202 }
203 }
204 if (!getFieldON()) {
205 tr.setQ2Pt(isCosmic() ? kDefQ2PtCosm : kDefG2PtColl); // only 4 params are valid
206 }
207}
208
209//____________________________________________________________________________________________
210inline void AlignmentTrack::setParams(trackPar_t* trSet, int ntr, double x, double alp, const double* par, bool add)
211{
212 // set parames for multiple tracks (VECTORIZE THIS)
213 if (!add) { // full parameter supplied
214 for (int itr = ntr; itr--;) {
215 setParams(trSet[itr], x, alp, par, false);
216 }
217 return;
218 }
219 params_t partr{0}; // par is a correction to reference parameter
220 for (int i = mNLocExtPar; i--;) {
221 partr[i] = getParam(i) + par[i];
222 }
223 for (int itr = ntr; itr--;) {
224 setParams(trSet[itr], x, alp, partr.data(), false);
225 }
226}
227
228//____________________________________________________________________________________________
229inline void AlignmentTrack::setParam(trackPar_t& tr, int par, double val)
230{
231 // set track parameter
232 tr.setParam(val, par);
233}
234
235//____________________________________________________________________________________________
236inline void AlignmentTrack::setParam(trackPar_t* trSet, int ntr, int par, double val)
237{
238 // set parames for multiple tracks (VECTORIZE THIS)
239 for (int i = 0; i < ntr; ++i) {
240 setParam(trSet[i], par, val);
241 }
242}
243
244//____________________________________________________________________________________________
245inline void AlignmentTrack::modParam(trackPar_t& tr, int par, double delta)
246{
247 // modify track parameter
248 const auto val = tr.getParam(par) + delta;
249 setParam(tr, par, val);
250}
251
252//____________________________________________________________________________________________
253inline void AlignmentTrack::modParam(trackPar_t* trSet, int ntr, int par, double delta)
254{
255 // modify track parameter (VECTORIZE THOS)
256 for (int i = 0; i < ntr; ++i) {
257 modParam(trSet[i], par, delta);
258 }
259}
260
261//______________________________________________
263{
264 // assign kinematics
265 set(etp->getX(), etp->getAlpha(), etp->getParams(), etp->getCov().data());
266}
267
268//______________________________________________
269template <typename P>
271{
272 setX(trc.getX());
273 setAlpha(trc.getAlpha());
274 setAbsCharge(trc.getAbsCharge());
275 setPID(trc.getPID());
276 for (int i = o2::track::kNParams; i--;) {
277 setParam(double(trc.getParam(i)), i);
278 }
279 for (int i = o2::track::kCovMatSize; i--;) {
280 setCov(double(trc.getCov()[i]), i);
281 }
282}
283
284} // namespace align
285} // namespace o2
286#endif
Meausered point in the sensor.
size_t minSize
Base track model for the Barrel, params only, w/o covariance.
Global index for barrel track: provides provenance (detectors combination), index in respective array...
uint32_t c
Definition RawData.h:2
void addLocPars(const double *pars)
void setRefPoint(AlignmentPoint *p)
static constexpr double MaxDefStep
o2::track::TrackParametrization< double > trackPar_t
std::vector< AlignmentPoint > & getDetPoints()
static constexpr double MaxDefSnp
void setKalmanDone(bool v=true)
std::vector< AlignmentPoint * > mPoints
AlignmentTrack(const AlignmentTrack &)
virtual void dumpCoordinates() const
~AlignmentTrack() override=default
double getResidual(int dim, int pntID) const
AlignmentPoint * getPoint(int i)
bool calcResiduals(const double *params=nullptr)
const double * getDResDGlo(int dim, int id) const
std::vector< double > mDResDGlo[2]
const int * getGloParID() const
bool calcResidDeriv(double *params=nullptr)
void setFieldON(bool v=true)
const AlignmentPoint * getPoint(int i) const
std::vector< double > & getLocParsV()
void checkExpandDerGloBuffer(unsigned int minSize)
bool propagateToPoint(trackParam_t &tr, trackPar_t *linRef, const AlignmentPoint *pnt, double maxStep, double maxSnp=0.95, MatCorrType mt=MatCorrType::USEMatCorrLUT, track::TrackLTIntegral *tLT=nullptr, int signCorr=0)
bool fitLeg(trackParam_t &trc, int pFrom, int pTo, bool &inv)
std::vector< double > mDResDLoc[2]
void setCosmic(bool v=true)
std::vector< AlignmentPoint > mDetPoints
std::vector< double > mLocPar
void setDerivDone(bool v=true)
void setLocPars(const double *pars)
bool calcResidDerivGlo(AlignmentPoint *pnt)
void Clear(Option_t *opt="") final
const AlignmentPoint * getInnerPoint() const
bool combineTracks(trackParam_t &trcL, const trackParam_t &trcU)
void setCurrentTrackID(GTrackID id)
AlignmentTrack & operator=(const AlignmentTrack &)
std::vector< int > mGloParID
void setResidDone(bool v=true)
bool applyMatCorr(trackPar_t &trPar, const double *corrDiag, const AlignmentPoint *pnt)
const double * getDResDLoc(int dim, int pntID) const
void copyFrom(const o2::track::TrackParametrizationWithError< P > &trc)
void setParams(trackPar_t &tr, double x, double alp, const double *par, bool add)
void Print(Option_t *opt="") const final
GTrackID getCurrentTrackID() const
void modParam(trackPar_t &tr, int par, double delta)
bool propagateParamToPoint(trackPar_t &tr, const AlignmentPoint *pnt, double maxStep=3, double maxSnp=0.95, MatCorrType mt=MatCorrType::USEMatCorrLUT, int signCorr=0)
std::vector< double > mResid[2]
void setParam(trackPar_t &tr, int par, double val)
const double * getLocPars() const
static double richardsonExtrap(double *val, int ord=1)
void richardsonDeriv(const trackPar_t *trSet, const double *delta, const AlignmentPoint *pnt, double &derY, double &derZ)
std::array< value_t, kNParams > params_t
GLdouble n
Definition glcorearb.h:1982
GLint GLenum GLint x
Definition glcorearb.h:403
const GLdouble * v
Definition glcorearb.h:832
GLenum const GLfloat * params
Definition glcorearb.h:272
GLuint GLfloat * val
Definition glcorearb.h:1582
GLuint id
Definition glcorearb.h:650
GLboolean invert
Definition glcorearb.h:543
typename track::TrackParametrizationWithError< double > trackParam_t
Definition utils.h:29
PropagatorImpl< double > PropagatorD
Definition Propagator.h:222
void align(gsl::span< ElinkEncoder< BareFormat, CHARGESUM > > elinks)
constexpr int kCovMatSize
constexpr int kNParams
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...