Skip to content

Commit 405307c

Browse files
bovulpesshahor02
authored andcommitted
MFT: fill vector tree with cluster external indices
1 parent 46648d6 commit 405307c

9 files changed

Lines changed: 113 additions & 131 deletions

File tree

‎DataFormats/Detectors/ITSMFT/MFT/include/DataFormatsMFT/TrackMFT.h‎

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -53,44 +53,25 @@ class TrackMFT : public o2::track::TrackParCovFwd
5353
void setChi2QPtSeed(Double_t chi2) { mSeedinvQPtFitChi2 = chi2; }
5454
const Double_t getChi2QPtSeed() const { return mSeedinvQPtFitChi2; }
5555

56-
// Other functions
57-
int getNumberOfClusters() const { return mClusRef.getEntries(); }
58-
int getFirstClusterEntry() const { return mClusRef.getFirstEntry(); }
59-
int getClusterEntry(int i) const { return getFirstClusterEntry() + i; }
60-
void shiftFirstClusterEntry(int bias)
61-
{
62-
mClusRef.setFirstEntry(mClusRef.getFirstEntry() + bias);
63-
}
64-
void setFirstClusterEntry(int offs)
65-
{
66-
mClusRef.setFirstEntry(offs);
67-
}
68-
void setNumberOfClusters(int n)
69-
{
70-
mClusRef.setEntries(n);
71-
}
72-
void setClusterRefs(int firstEntry, int n)
73-
{
74-
mClusRef.set(firstEntry, n);
75-
}
76-
77-
const ClusRefs& getClusterRefs() const { return mClusRef; }
78-
ClusRefs& getClusterRefs() { return mClusRef; }
79-
8056
std::uint32_t getROFrame() const { return mROFrame; }
8157
void setROFrame(std::uint32_t f) { mROFrame = f; }
8258

83-
const Int_t getNPoints() const { return mNPoints; }
59+
const int getNumberOfPoints() const { return mClusRef.getEntries(); }
60+
61+
const int getExternalClusterIndexOffset() const { return mClusRef.getFirstEntry(); }
62+
63+
void setExternalClusterIndexOffset(int offset = 0) { mClusRef.setFirstEntry(offset); }
64+
65+
void setNumberOfPoints(int n) { mClusRef.setEntries(n); }
8466

8567
void print() const;
8668

87-
const o2::track::TrackParCovFwd& GetOutParam() const { return mOutParameters; }
88-
void SetOutParam(const o2::track::TrackParCovFwd parcov) { mOutParameters = parcov; }
69+
const o2::track::TrackParCovFwd& getOutParam() const { return mOutParameters; }
70+
void setOutParam(const o2::track::TrackParCovFwd parcov) { mOutParameters = parcov; }
8971

9072
private:
91-
std::uint32_t mROFrame = 0; ///< RO Frame
92-
Int_t mNPoints{0}; // Number of clusters
93-
Bool_t mIsCA = false; // Track finding method CA vs. LTF
73+
std::uint32_t mROFrame = 0; ///< RO Frame
74+
Bool_t mIsCA = false; // Track finding method CA vs. LTF
9475

9576
ClusRefs mClusRef; ///< references on clusters
9677

@@ -114,24 +95,16 @@ class TrackMFTExt : public TrackMFT
11495
static constexpr int MaxClusters = 10;
11596
using TrackMFT::TrackMFT; // inherit base constructors
11697

117-
void setClusterIndex(int l, int i, int ncl)
118-
{
119-
mIndex[ncl] = (l << 27) + i;
120-
getClusterRefs().setEntries(ncl);
121-
}
122-
123-
int getClusterIndex(int lr) const { return mIndex[lr]; }
98+
int getExternalClusterIndex(int i) const { return mExtClsIndex[i]; }
12499

125-
void setExternalClusterIndex(int layer, int idx, bool newCluster = false)
100+
void setExternalClusterIndex(int np, int idx)
126101
{
127-
if (newCluster) {
128-
getClusterRefs().setEntries(getNumberOfClusters() + 1);
129-
}
130-
mIndex[layer] = idx;
102+
mExtClsIndex[np] = idx;
131103
}
132104

133-
private:
134-
std::array<int, MaxClusters> mIndex = {-1}; ///< Indices of associated clusters
105+
protected:
106+
std::array<int, MaxClusters> mExtClsIndex = {-1}; ///< External indices of associated clusters
107+
135108
ClassDefNV(TrackMFTExt, 1);
136109
};
137110
} // namespace mft

‎Detectors/ITSMFT/MFT/tracking/include/MFTTracking/Cluster.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ namespace mft
2626
{
2727

2828
struct Cluster : public o2::BaseCluster<float> {
29-
Cluster(const Float_t x, const Float_t y, const Float_t z, const Float_t phi, const Float_t r, const Int_t idx, const Int_t bin, const Float_t sigX2, const Float_t sigY2, const Int_t sensorID)
29+
Cluster(const Float_t x, const Float_t y, const Float_t z, const Float_t phi, const Float_t r, const Int_t id, const Int_t bin, const Float_t sigX2, const Float_t sigY2, const Int_t sensorID)
3030
: BaseCluster(sensorID, x, y, z),
3131
phiCoordinate{phi},
3232
rCoordinate{r},
33-
clusterId{idx},
33+
clusterId{id},
3434
indexTableBin{bin},
3535
sigmaX2{sigX2},
3636
sigmaY2{sigY2} {};

‎Detectors/ITSMFT/MFT/tracking/include/MFTTracking/ROframe.h‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ class ROframe final
5252
const std::vector<Cluster>& getClustersInLayer(Int_t layerId) const { return mClusters[layerId]; }
5353

5454
const MCCompLabel& getClusterLabels(Int_t layerId, const Cluster& cl) const { return mClusterLabels[layerId][cl.clusterId]; }
55-
const MCCompLabel& getClusterLabels(Int_t layerId, const Int_t clId) const { return mClusterLabels[layerId][clId]; }
55+
const MCCompLabel& getClusterLabels(Int_t layerId, const Int_t clusterId) const { return mClusterLabels[layerId][clusterId]; }
5656

5757
const std::map<Int_t, std::pair<Int_t, Int_t>>& getClusterBinIndexRange(Int_t layerId) const { return mClusterBinIndexRange[layerId]; }
58-
Int_t getClusterExternalIndex(Int_t layerId, const Int_t clId) const { return mClusterExternalIndices[layerId][clId]; }
58+
const Int_t getClusterExternalIndex(Int_t layerId, const Int_t clusterId) const { return mClusterExternalIndices[layerId][clusterId]; }
5959

6060
const std::array<std::vector<Cell>, constants::mft::LayersNumber>& getCells() const;
6161
const std::vector<Cell>& getCellsInLayer(Int_t layerId) const { return mCells[layerId]; }
@@ -135,7 +135,6 @@ inline Bool_t ROframe::isClusterUsed(Int_t layer, Int_t clusterId) const
135135

136136
inline void ROframe::markUsedCluster(Int_t layer, Int_t clusterId) { mUsedClusters[layer][clusterId] = kTRUE; }
137137

138-
139138
inline TrackLTF& ROframe::getCurrentTrackLTF()
140139
{
141140
return mTracksLTF.back();

‎Detectors/ITSMFT/MFT/tracking/include/MFTTracking/TrackCA.h‎

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class TrackLTF : public TrackMFTExt
3333
TrackLTF() = default;
3434
TrackLTF(const TrackLTF& t) = default;
3535
~TrackLTF() = default;
36-
const Int_t getNPoints() const { return mNPoints; }
3736
const std::array<Float_t, constants::mft::LayersNumber>& getXCoordinates() const { return mX; }
3837
const std::array<Float_t, constants::mft::LayersNumber>& getYCoordinates() const { return mY; }
3938
const std::array<Float_t, constants::mft::LayersNumber>& getZCoordinates() const { return mZ; }
@@ -42,13 +41,10 @@ class TrackLTF : public TrackMFTExt
4241
const std::array<Int_t, constants::mft::LayersNumber>& getLayers() const { return mLayer; }
4342
const std::array<Int_t, constants::mft::LayersNumber>& getClustersId() const { return mClusterId; }
4443
const std::array<MCCompLabel, constants::mft::LayersNumber>& getMCCompLabels() const { return mMCCompLabels; }
45-
void setPoint(const Cluster, const Int_t layer, const Int_t clusterId, const MCCompLabel label, Bool_t& newPoint);
44+
void setPoint(const Cluster, const Int_t layer, const Int_t clusterId, const MCCompLabel label, const Int_t extClsIndex, Bool_t& newPoint);
4645

4746
void sort();
4847

49-
protected:
50-
Int_t mNPoints{0};
51-
5248
private:
5349
std::array<Float_t, constants::mft::LayersNumber> mX = {-25., -25., -25., -25., -25., -25., -25., -25., -25., -25.};
5450
std::array<Float_t, constants::mft::LayersNumber> mY = {-25., -25., -25., -25., -25., -25., -25., -25., -25., -25.};
@@ -105,46 +101,48 @@ inline void TrackCA::removeLastCell(Int_t& layer, Int_t& cellId)
105101
layer = mCellLayer[mNCells - 1];
106102
cellId = mCellId[mNCells - 1];
107103

108-
if (mNPoints == 2) { // we have only a single cell in the track
109-
mNPoints--;
104+
auto nPoints = getNumberOfPoints();
105+
if (nPoints == 2) { // we have only a single cell in the track
106+
setNumberOfPoints(--nPoints);
110107
}
111-
mNPoints--;
108+
setNumberOfPoints(--nPoints);
112109
mNCells--;
113110
}
114111

115112
//_________________________________________________________________________________________________
116-
inline void TrackLTF::setPoint(const Cluster cl, const Int_t layer, const Int_t clusterId, const MCCompLabel label, Bool_t& newPoint)
113+
inline void TrackLTF::setPoint(const Cluster cl, const Int_t layer, const Int_t clusterId, const MCCompLabel label, const Int_t extClsIndex, Bool_t& newPoint)
117114
{
115+
auto nPoints = getNumberOfPoints();
118116
if (newPoint) {
119-
if (mNPoints > 0)
120-
if (mZ[mNPoints - 1] == cl.getZ()) {
117+
if (nPoints > 0)
118+
if (mZ[nPoints - 1] == cl.getZ()) {
121119
LOG(WARN) << "MFT TrackLTF: skipping setPoint (1 cluster per layer!)";
122120
return;
123121
}
124-
if (mNPoints >= constants::mft::LayersNumber - 1) {
122+
if (nPoints > constants::mft::LayersNumber) {
125123
LOG(WARN) << "MFT TrackLTF Overflow";
126124
return;
127125
}
128-
mX[mNPoints] = cl.getX();
129-
mY[mNPoints] = cl.getY();
130-
mZ[mNPoints] = cl.getZ();
131-
mSigmaX2[mNPoints] = cl.sigmaX2;
132-
mSigmaY2[mNPoints] = cl.sigmaY2;
133-
mLayer[mNPoints] = layer;
134-
mClusterId[mNPoints] = clusterId;
135-
mMCCompLabels[mNPoints] = label;
136-
mNPoints++;
137-
setClusterIndex(layer, clusterId, mNPoints);
126+
mX[nPoints] = cl.getX();
127+
mY[nPoints] = cl.getY();
128+
mZ[nPoints] = cl.getZ();
129+
mSigmaX2[nPoints] = cl.sigmaX2;
130+
mSigmaY2[nPoints] = cl.sigmaY2;
131+
mLayer[nPoints] = layer;
132+
mClusterId[nPoints] = clusterId;
133+
mMCCompLabels[nPoints] = label;
134+
setExternalClusterIndex(nPoints, extClsIndex);
135+
setNumberOfPoints(nPoints + 1);
138136
} else {
139-
mX[mNPoints] = cl.getX();
140-
mY[mNPoints] = cl.getY();
141-
mZ[mNPoints] = cl.getZ();
142-
mSigmaX2[mNPoints] = cl.sigmaX2;
143-
mSigmaY2[mNPoints] = cl.sigmaY2;
144-
mLayer[mNPoints] = layer;
145-
mClusterId[mNPoints] = clusterId;
146-
mMCCompLabels[mNPoints] = label;
147-
setClusterIndex(layer, clusterId, mNPoints);
137+
mX[nPoints] = cl.getX();
138+
mY[nPoints] = cl.getY();
139+
mZ[nPoints] = cl.getZ();
140+
mSigmaX2[nPoints] = cl.sigmaX2;
141+
mSigmaY2[nPoints] = cl.sigmaY2;
142+
mLayer[nPoints] = layer;
143+
mClusterId[nPoints] = clusterId;
144+
mMCCompLabels[nPoints] = label;
145+
setExternalClusterIndex(nPoints, extClsIndex);
148146
}
149147
}
150148

@@ -161,11 +159,12 @@ inline void TrackLTF::sort()
161159
Int_t layer;
162160
Int_t clusterId;
163161
MCCompLabel label;
162+
Int_t extClsIndex;
164163
};
165164
std::vector<ClusterData> points;
166165

167166
// Loading cluster data
168-
for (Int_t point = 0; point < getNPoints(); ++point) {
167+
for (Int_t point = 0; point < getNumberOfPoints(); ++point) {
169168
auto& somepoint = points.emplace_back();
170169
somepoint.x = mX[point];
171170
somepoint.y = mY[point];
@@ -175,13 +174,14 @@ inline void TrackLTF::sort()
175174
somepoint.layer = mLayer[point];
176175
somepoint.clusterId = mClusterId[point];
177176
somepoint.label = mMCCompLabels[point];
177+
somepoint.extClsIndex = mExtClsIndex[point];
178178
}
179179

180180
// Sorting cluster data
181181
std::sort(points.begin(), points.end(), [](ClusterData a, ClusterData b) { return a.z > b.z; });
182182

183183
// Storing sorted cluster data
184-
for (Int_t point = 0; point < getNPoints(); ++point) {
184+
for (Int_t point = 0; point < getNumberOfPoints(); ++point) {
185185
mX[point] = points[point].x;
186186
mY[point] = points[point].y;
187187
mZ[point] = points[point].z;
@@ -190,6 +190,7 @@ inline void TrackLTF::sort()
190190
mLayer[point] = points[point].layer;
191191
mClusterId[point] = points[point].clusterId;
192192
mMCCompLabels[point] = points[point].label;
193+
mExtClsIndex[point] = points[point].extClsIndex;
193194
}
194195
}
195196

‎Detectors/ITSMFT/MFT/tracking/include/MFTTracking/Tracker.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ inline void Tracker::computeTracksMClabels(const T& tracks)
255255
MCCompLabel maxOccurrencesValue{-1, -1, -1, false};
256256
int count{0};
257257
bool isFakeTrack{false};
258-
auto nClusters = track.getNumberOfClusters();
258+
auto nClusters = track.getNumberOfPoints();
259259
for (int iCluster = 0; iCluster < nClusters; ++iCluster) {
260260
const MCCompLabel& currentLabel = track.getMCCompLabels()[iCluster];
261261
if (currentLabel == maxOccurrencesValue) {

‎Detectors/ITSMFT/MFT/tracking/src/IOUtils.cxx‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,11 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
4949
Point3D<float> locXYZ;
5050
float sigmaX2 = ioutils::DefClusError2Row, sigmaY2 = ioutils::DefClusError2Col; //Dummy COG errors (about half pixel size)
5151
if (pattID != itsmft::CompCluster::InvalidPatternID) {
52-
sigmaX2 = dict.getErr2X(pattID); // ALPIDE local X coordinate => MFT global X coordinate (ALPIDE rows)
53-
sigmaY2 = dict.getErr2Z(pattID); // ALPIDE local Z coordinate => MFT global Y coordinate (ALPIDE columns)
52+
//sigmaX2 = dict.getErr2X(pattID); // ALPIDE local X coordinate => MFT global X coordinate (ALPIDE rows)
53+
//sigmaY2 = dict.getErr2Z(pattID); // ALPIDE local Z coordinate => MFT global Y coordinate (ALPIDE columns)
54+
// temporary, until ITS bug fix
55+
sigmaX2 = dict.getErrX(pattID) * dict.getErrX(pattID);
56+
sigmaY2 = dict.getErrZ(pattID) * dict.getErrZ(pattID);
5457
if (!dict.isGroup(pattID)) {
5558
locXYZ = dict.getClusterCoordinates(c);
5659
} else {
@@ -73,7 +76,6 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g
7376
int phiBinIndex = constants::index_table::getPhiBinIndex(phiCoord);
7477
int binIndex = constants::index_table::getBinIndex(rBinIndex, phiBinIndex);
7578
// TODO: Check consistency of sigmaX2 and sigmaY2
76-
// std::cout << "ClusterID = " << clusterId << " ; pattID = " << pattID << " ; sigmaX2 = " << sigmaX2 << " ; sigmaY2 = " << sigmaY2 << std::endl;
7779
event.addClusterToLayer(layer, gloXYZ.x(), gloXYZ.y(), gloXYZ.z(), phiCoord, rCoord, event.getClustersInLayer(layer).size(), binIndex, sigmaX2, sigmaY2, sensorID);
7880
if (mcLabels) {
7981
event.addClusterLabelToLayer(layer, *(mcLabels->getLabels(first + clusterId).begin()));

‎Detectors/ITSMFT/MFT/tracking/src/TrackFitter.cxx‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool TrackFitter::fit(TrackLTF& track, bool outward)
5757
/// Returns false in case of failure
5858

5959
auto& mftTrackingParam = MFTTrackingParam::Instance();
60-
auto nClusters = track.getNPoints();
60+
auto nClusters = track.getNumberOfPoints();
6161

6262
if (mftTrackingParam.verbose) {
6363
std::cout << "Seed covariances: \n"
@@ -100,7 +100,7 @@ bool TrackFitter::initTrack(TrackLTF& track, bool outward)
100100
// initialize the starting track parameters and cluster
101101
double chi2invqptquad;
102102
double invQPtSeed;
103-
auto nPoints = track.getNPoints();
103+
auto nPoints = track.getNumberOfPoints();
104104
auto k = TMath::Abs(o2::constants::math::B2C * mBZField);
105105
auto Hz = std::copysign(1, mBZField);
106106
invQPtSeed = invQPtFromFCF(track, mBZField, chi2invqptquad);
@@ -171,6 +171,8 @@ bool TrackFitter::initTrack(TrackLTF& track, bool outward)
171171
std::cout << " initTrack: X = " << x0 << " Y = " << y0 << " Z = " << z0 << " Tgl = " << track.getTanl() << " Phi = " << track.getPhi() << " pz = " << track.getPz() << " qpt = " << 1.0 / track.getInvQPt() << std::endl;
172172
}
173173

174+
auto model = (mftTrackingParam.trackmodel == Helix) ? "Helix" : (mftTrackingParam.trackmodel == Quadratic) ? "Quadratic" : "Linear";
175+
174176
// compute the track parameter covariances at the last cluster (as if the other clusters did not exist)
175177
SMatrix55 lastParamCov;
176178
lastParamCov(0, 0) = sigmax0sq; // <X,X>
@@ -297,14 +299,14 @@ bool TrackFitter::computeCluster(TrackLTF& track, int cluster)
297299
Double_t invQPtFromFCF(const TrackLTF& track, Double_t bFieldZ, Double_t& chi2)
298300
{
299301

300-
const std::array<Float_t, constants::mft::LayersNumber>& xPositons = track.getXCoordinates();
301-
const std::array<Float_t, constants::mft::LayersNumber>& yPositons = track.getYCoordinates();
302-
const std::array<Float_t, constants::mft::LayersNumber>& zPositons = track.getZCoordinates();
302+
const std::array<Float_t, constants::mft::LayersNumber>& xPositions = track.getXCoordinates();
303+
const std::array<Float_t, constants::mft::LayersNumber>& yPositions = track.getYCoordinates();
304+
const std::array<Float_t, constants::mft::LayersNumber>& zPositions = track.getZCoordinates();
303305
const std::array<Float_t, constants::mft::LayersNumber>& SigmasX2 = track.getSigmasX2();
304306
const std::array<Float_t, constants::mft::LayersNumber>& SigmasY2 = track.getSigmasY2();
305307

306308
// Fast Circle Fit (Hansroul, Jeremie, Savard, 1987)
307-
auto nPoints = track.getNPoints();
309+
auto nPoints = track.getNumberOfPoints();
308310
Double_t* xVal = new Double_t[nPoints];
309311
Double_t* yVal = new Double_t[nPoints];
310312
Double_t* zVal = new Double_t[nPoints];
@@ -319,29 +321,29 @@ Double_t invQPtFromFCF(const TrackLTF& track, Double_t bFieldZ, Double_t& chi2)
319321
xErr[np] = SigmasX2[np];
320322
yErr[np] = SigmasY2[np];
321323
if (np > 0) {
322-
xVal[np] = xPositons[np] - xVal[0];
323-
yVal[np] = yPositons[np] - yVal[0];
324+
xVal[np] = xPositions[np] - xVal[0];
325+
yVal[np] = yPositions[np] - yVal[0];
324326
xErr[np] *= std::sqrt(2.);
325327
yErr[np] *= std::sqrt(2.);
326328
} else {
327329
xVal[np] = 0.;
328330
yVal[np] = 0.;
329331
}
330-
zVal[np] = zPositons[np];
332+
zVal[np] = zPositions[np];
331333
}
332334
for (int i = 0; i < (nPoints - 1); i++) {
333335
x2 = xVal[i + 1] * xVal[i + 1];
334336
y2 = yVal[i + 1] * yVal[i + 1];
335337
invx2y2 = 1. / (x2 + y2);
336338
uVal[i] = xVal[i + 1] * invx2y2;
337339
vVal[i] = yVal[i + 1] * invx2y2;
338-
vErr[i] = std::sqrt(8. * xErr[i + 1] * xErr[i + 1] * x2 * y2 + 2. * yErr[i + 1] * yErr[i + 1] * (x2 - y2)) * invx2y2 * invx2y2;
340+
vErr[i] = std::sqrt(8. * xErr[i + 1] * xErr[i + 1] * x2 * y2 + 2. * yErr[i + 1] * yErr[i + 1] * (x2 - y2) * (x2 - y2)) * invx2y2 * invx2y2;
339341
}
340342

341343
Double_t invqpt_fcf;
342344
Int_t qfcf;
343345
chi2 = 0.;
344-
if (LinearRegression((nPoints - 1), uVal, vVal, yErr, a, ae, b, be)) {
346+
if (LinearRegression((nPoints - 1), uVal, vVal, vErr, a, ae, b, be)) {
345347
// v = a * u + b
346348
// circle passing through (0,0):
347349
// (x - rx)^2 + (y - ry)^2 = r^2
@@ -350,7 +352,6 @@ Double_t invQPtFromFCF(const TrackLTF& track, Double_t bFieldZ, Double_t& chi2)
350352
ry = 1. / (2. * b);
351353
rx = -a * ry;
352354
r = std::sqrt(rx * rx + ry * ry);
353-
354355
// pt --->
355356
Double_t invpt = 1. / (o2::constants::math::B2C * bFieldZ * r);
356357

@@ -378,7 +379,7 @@ Double_t invQPtFromFCF(const TrackLTF& track, Double_t bFieldZ, Double_t& chi2)
378379

379380
invqpt_fcf = qfcf * invpt;
380381
} else { // the linear regression failed...
381-
printf("BV LinearRegression failed!\n");
382+
LOG(WARN) << "LinearRegression failed!";
382383
invqpt_fcf = 1. / 100.;
383384
}
384385

0 commit comments

Comments
 (0)