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