Skip to content

Commit bc633ab

Browse files
mpuccioMohammadAlTurany
authored andcommitted
Bug fix in the track updated (thanks @shahor02)
Adapt some interfaces to the new coding guidelines (still some work to do to adapt and cleanup the rest)
1 parent c659beb commit bc633ab

5 files changed

Lines changed: 43 additions & 45 deletions

File tree

Detectors/ITSMFT/ITS/reconstruction/include/ITSReconstruction/CATracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ namespace AliceO2 {
4949
Tracker(const Tracker&);
5050
Tracker &operator=(const Tracker &tr);
5151
//
52-
bool CellParams(int l, Cluster* c1, Cluster* c2, Cluster* c3, float &curv, array<float,3> &np);
52+
bool CellParams(int l, const Cluster& c1, const Cluster& c2, const Cluster& c3, float &curv, array<float,3> &np);
5353
void CellsTreeTraversal(vector<Road> &roads, const int &iD, const int &doubl);
5454
void FindTracksCA(int iteration);
5555
void MakeCells(int iteration);

Detectors/ITSMFT/ITS/reconstruction/include/ITSReconstruction/CATrackingStation.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ namespace AliceO2 {
3434
TrackingStation(int id,float zMin, float zMax, int nzbins,int nphibins);
3535

3636
virtual ~TrackingStation();
37-
ClsInfo_t* operator[](int i) const
38-
{return (ClsInfo_t*)&mSortedClInfo[i];}
37+
const ClsInfo_t& operator[](int i) const {return mSortedClInfo[i];}
3938
//
4039
int GetVIDOffset() const {return mVIDOffset;}
4140
int GetNClusters() const {return mNClusters;}
@@ -64,8 +63,7 @@ namespace AliceO2 {
6463
int GetFoundBin(int i) const {return mFoundBins[i];}
6564
int GetFoundBinClusters(int i, int &first) const;
6665
void ResetFoundIterator();
67-
ClsInfo_t* GetClusterInfo(int i) const
68-
{return (ClsInfo_t*)&mSortedClInfo[i];}
66+
const ClsInfo_t& GetClusterInfo(int i) const {return mSortedClInfo[i];}
6967
ClsInfo_t* GetNextClusterInfo();
7068
int GetNextClusterInfoID();
7169
//

Detectors/ITSMFT/ITS/reconstruction/include/ITSReconstruction/CAaux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ namespace AliceO2 {
105105
void SetLabel(int label) { mLabel = label; }
106106
void SetChi2(float chi) { mChi2 = chi; }
107107

108-
bool Update(const Cluster* cl);
108+
bool Update(const Cluster& cl);
109109
bool GetPhiZat(float r, float bfield,float &phi, float &z) const;
110110
private:
111111
Base::Track::TrackParCov mT;

Detectors/ITSMFT/ITS/reconstruction/src/CATracker.cxx

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,20 @@ const float kDoublPhi1 = 0.2f;
7878
// This default constructor needs to be provided
7979
}
8080

81-
bool Tracker::CellParams(int l, ClsInfo_t* c1, ClsInfo_t* c2, ClsInfo_t* c3,
81+
bool Tracker::CellParams(int l, const ClsInfo_t& c1, const ClsInfo_t& c2, const ClsInfo_t& c3,
8282
float &curv, array<float,3> &n) {
8383
// Calculation of cell params and filtering using a DCA cut wrt beam line position.
8484
// The hit are mapped on a paraboloid space: there a circle is described as plane.
8585
// The parameter n of the cells is the normal vector to the plane describing the circle in the
8686
// paraboloid.
8787

8888
// Mapping the hits
89-
const float mHit0[3] = {c1->x, c1->y, c1->r * c1->r};
90-
const float mHit1[3] = {c2->x, c2->y, c2->r * c2->r};
91-
const float mHit2[3] = {c3->x, c3->y, c3->r * c3->r};
89+
const array<float,3> mHit0{c1.x, c1.y, c1.r * c1.r};
90+
const array<float,3> mHit1{c2.x, c2.y, c2.r * c2.r};
91+
const array<float,3> mHit2{c3.x, c3.y, c3.r * c3.r};
9292
// Computing the deltas
93-
const float mD10[3] = {mHit1[0] - mHit0[0],mHit1[1] - mHit0[1],mHit1[2] - mHit0[2]};
94-
const float mD20[3] = {mHit2[0] - mHit0[0],mHit2[1] - mHit0[1],mHit2[2] - mHit0[2]};
93+
const array<float,3> mD10{mHit1[0] - mHit0[0],mHit1[1] - mHit0[1],mHit1[2] - mHit0[2]};
94+
const array<float,3> mD20{mHit2[0] - mHit0[0],mHit2[1] - mHit0[1],mHit2[2] - mHit0[2]};
9595
// External product of the deltas -> n
9696
n[0] = (mD10[1] * mD20[2]) - (mD10[2] * mD20[1]);
9797
n[1] = (mD10[2] * mD20[0]) - (mD10[0] * mD20[2]);
@@ -106,7 +106,7 @@ bool Tracker::CellParams(int l, ClsInfo_t* c1, ClsInfo_t* c2, ClsInfo_t* c3,
106106
n[1] *= norm;
107107
n[2] *= norm;
108108
// Center of the circle
109-
const float c[2] = {-0.5f * n[0] / n[2], -0.5f * n[1] / n[2]};
109+
const float c[2]{-0.5f * n[0] / n[2], -0.5f * n[1] / n[2]};
110110
// Constant
111111
const float k = - n[0] * mHit1[0] - n[1] * mHit1[1] - n[2] * mHit1[2];
112112
// Radius of the circle
@@ -272,37 +272,36 @@ void Tracker::FindTracksCA(int iteration) {
272272
continue;
273273
int indices[7] = {-1};
274274
int first = -1,last = -1;
275-
ClsInfo_t *cl0 = 0x0,*cl1 = 0x0,*cl2 = 0x0;
276275
for(int i = 0; i < 5; ++i) {
277276
if (roads[iR][i] < 0)
278277
continue;
279278

280279
if (first < 0) {
281-
cl0 = (*mLayer[i])[mCells[i][roads[iR][i]].x()];
282280
indices[i] = mCells[i][roads[iR][i]].x();
283281
indices[i + 1] = mCells[i][roads[iR][i]].y();
284282
first = i;
285283
}
286284
indices[i + 2] = mCells[i][roads[iR][i]].z();
287285
last = i;
288286
}
289-
cl2 = (*mLayer[last + 2])[mCells[last][roads[iR][last]].z()];
290-
first = (last + first) / 2;
291-
cl1 = (*mLayer[first + 1])[mCells[first][roads[iR][first]].y()];
287+
const int mid = (last + first) / 2;
288+
const Cluster& cl0 = (*mLayer[first])[mCells[first][roads[iR][first]].x()];
289+
const Cluster& cl1 = (*mLayer[mid + 1])[mCells[mid][roads[iR][mid]].y()];
290+
const Cluster& cl2 = (*mLayer[last + 2])[mCells[last][roads[iR][last]].z()];
292291
// Init track parameters
293-
float cv = Curvature(cl0->x,cl0->y,cl1->x,cl1->y,cl2->x,cl2->y);
294-
float tgl = TanLambda(cl0->x,cl0->y,cl2->x,cl2->y,cl0->z,cl2->z);
292+
float cv = Curvature(cl0.x,cl0.y,cl1.x,cl1.y,cl2.x,cl2.y);
293+
float tgl = TanLambda(cl0.x,cl0.y,cl2.x,cl2.y,cl0.z,cl2.z);
295294

296-
ITSDetInfo_t det = (*mLayer[last + 2]).GetDetInfo(cl2->detid);
297-
float x = det.xTF + cl2->x; // I'd like to avoit using AliITSUClusterPix...
295+
ITSDetInfo_t det = (*mLayer[last + 2]).GetDetInfo(cl2.detid);
296+
float x = det.xTF + cl2.x; // I'd like to avoit using AliITSUClusterPix...
298297
float alp = det.phiTF;
299-
std::array<float,5> par {cl2->y,cl2->z,0,tgl,cv};
298+
std::array<float,5> par {cl2.y,cl2.z,0,tgl,cv};
300299
std::array<float,15> cov {
301-
5*5,
302-
0, 5*5,
303-
0, 0 , 0.7*0.7,
304-
0, 0, 0, 0.7*0.7,
305-
0, 0, 0, 0, 10
300+
5.f*5.f,
301+
0.f, 5.f*5.f,
302+
0.f, 0.f , 0.7f*0.7f,
303+
0.f, 0.f, 0.f, 0.7f*0.7f,
304+
0.f, 0.f, 0.f, 0.f, 10.f
306305
};
307306
Track tt{x,alp,par,cov,indices};
308307
if (RefitAt(2.1, &tt))
@@ -346,30 +345,30 @@ void Tracker::MakeCells(int iteration) {
346345
if (dLUT[iL - 1].size() == 0u)
347346
continue;
348347
for (int iC = 0; iC < mLayer[iL]->GetNClusters(); ++iC) {
349-
ClsInfo_t* cls = mLayer[iL]->GetClusterInfo(iC);
348+
const ClsInfo_t& cls = mLayer[iL]->GetClusterInfo(iC);
350349
if (mUsedClusters[iL][iC]) {
351350
continue;
352351
}
353-
const float tanL = (cls->z - GetZ()) / cls->r;
354-
const float extz = tanL * (mkR[iL + 1] - cls->r) + cls->z;
352+
const float tanL = (cls.z - GetZ()) / cls.r;
353+
const float extz = tanL * (mkR[iL + 1] - cls.r) + cls.z;
355354
const int nClust = mLayer[iL + 1]->SelectClusters(extz - 2 * mCZ, extz + 2 * mCZ,
356-
cls->phi - mCPhi, cls->phi + mCPhi);
355+
cls.phi - mCPhi, cls.phi + mCPhi);
357356
bool first = true;
358357

359358
for (int iC2 = 0; iC2 < nClust; ++iC2) {
360359
const int iD2 = mLayer[iL + 1]->GetNextClusterInfoID();
361-
ClsInfo_t* cls2 = mLayer[iL + 1]->GetClusterInfo(iD2);
360+
const ClsInfo_t& cls2 = mLayer[iL + 1]->GetClusterInfo(iD2);
362361
if (mUsedClusters[iL + 1][iC2]) {
363362
continue;
364363
}
365-
const float dz = tanL * (cls2->r - cls->r) + cls->z - cls2->z;
366-
if (fabs(dz) < mCDZ[iL] && CompareAngles(cls->phi, cls2->phi, mCPhi)) {
364+
const float dz = tanL * (cls2.r - cls.r) + cls.z - cls2.z;
365+
if (fabs(dz) < mCDZ[iL] && CompareAngles(cls.phi, cls2.phi, mCPhi)) {
367366
if (first && iL > 0) {
368367
dLUT[iL - 1][iC] = mDoublets[iL].size();
369368
first = false;
370369
}
371-
const float dTanL = (cls->z - cls2->z) / (cls->r - cls2->r);
372-
const float phi = atan2(cls->y - cls2->y, cls->x - cls2->x);
370+
const float dTanL = (cls.z - cls2.z) / (cls.r - cls2.r);
371+
const float phi = atan2(cls.y - cls2.y, cls.x - cls2.x);
373372
mDoublets[iL].push_back(Doublets(iC,iD2,dTanL,phi));
374373
}
375374
}
@@ -399,8 +398,8 @@ void Tracker::MakeCells(int iteration) {
399398
if (fabs(mDoublets[iD][iD0].tanL - mDoublets[iD + 1][iD1].tanL) < mCDTanL &&
400399
fabs(mDoublets[iD][iD0].phi - mDoublets[iD + 1][iD1].phi) < mCDPhi) {
401400
const float tan = 0.5f * (mDoublets[iD][iD0].tanL + mDoublets[iD + 1][iD1].tanL);
402-
const float extz = -tan * (*mLayer[iD])[mDoublets[iD][iD0].x]->r +
403-
(*mLayer[iD])[mDoublets[iD][iD0].x]->z;
401+
const float extz = -tan * (*mLayer[iD])[mDoublets[iD][iD0].x].r +
402+
(*mLayer[iD])[mDoublets[iD][iD0].x].z;
404403
if (fabs(extz - GetZ()) < mCDCAz[iD]) {
405404
float curv = 0.f;
406405
array<float,3> n {0.f};
@@ -501,8 +500,8 @@ bool Tracker::RefitAt(float xx, Track *track) {
501500
for (int i = from; i != to; i += step) {
502501
int idx = index[i];
503502
if (idx >= 0) {
504-
const Cluster *cl = (*mLayer[i])[idx];
505-
float xr = cl->x,ar = mLayer[i]->GetDetInfo(cl->detid).phiTF;
503+
const Cluster &cl = (*mLayer[i])[idx];
504+
float xr = cl.x, ar = mLayer[i]->GetDetInfo(cl.detid).phiTF;
506505
if (!t->Rotate(ar) || !t->PropagateTo(xr, mBz)) {
507506
return false;
508507
}

Detectors/ITSMFT/ITS/reconstruction/src/CAaux.cxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ Track::Track(float x, float a, array<float,Base::Track::kNParams> p, array<float
3232
for (int i = 0; i < 7; ++i) mCl[i] = cl[i];
3333
}
3434

35-
bool Track::Update(const Cluster *cl) {
36-
array<float,2> p{cl->y,cl->z};
37-
if (!mT.Update(p,cl->cov)) return false;
38-
SetChi2(mT.GetPredictedChi2(p,cl->cov));
35+
bool Track::Update(const Cluster &cl) {
36+
array<float,2> p{cl.y,cl.z};
37+
const float dChi2 = mT.GetPredictedChi2(p,cl.cov);
38+
if (!mT.Update(p,cl.cov)) return false;
39+
else mChi2 += dChi2;
3940
return true;
4041
}
4142

0 commit comments

Comments
 (0)