Skip to content

Commit 1f9803d

Browse files
authored
Improve CA selection algorithm
Improve CA selection algorithm
1 parent 41292f1 commit 1f9803d

File tree

16 files changed

+213
-877
lines changed

16 files changed

+213
-877
lines changed

Detectors/ITSMFT/ITS/tracking/GPU/cuda/TrackerTraitsGPU.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ GPUd() void computeLayerCells(DeviceStoreNV& devStore, const int layerIndex,
240240

241241
cellsVector.emplace(currentIndex, currentTracklet.firstClusterIndex,
242242
nextTracklet.firstClusterIndex, nextTracklet.secondClusterIndex, currentTrackletIndex,
243-
iNextLayerTracklet, normalizedPlaneVector, 1.0f / cellTrajectoryRadius);
243+
iNextLayerTracklet, averageTanLambda);
244244
++trackletCellsNum;
245245
}
246246
}

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cell.h

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ namespace its
3131
class Cell final
3232
{
3333
public:
34-
GPUd() Cell(const int, const int, const int, const int, const int, const float3&, const float);
34+
GPUd() Cell(const int, const int, const int, const int, const int, const float);
3535

3636
GPUhdni() int getFirstClusterIndex() const { return mFirstClusterIndex; };
3737
GPUhdni() int getSecondClusterIndex() const { return mSecondClusterIndex; };
3838
GPUhdni() int getThirdClusterIndex() const { return mThirdClusterIndex; };
39-
GPUhd() int getFirstTrackletIndex() const { return mFirstTrackletIndex; };
40-
int getSecondTrackletIndex() const { return mSecondTrackletIndex; };
39+
GPUhdni() int getFirstTrackletIndex() const { return mFirstTrackletIndex; };
40+
GPUhdni() int getSecondTrackletIndex() const { return mSecondTrackletIndex; };
41+
GPUhdni() float getTanLambda() const { return mTanLambda; };
4142
int getLevel() const { return mLevel; };
42-
float getCurvature() const { return mCurvature; };
43-
const float3& getNormalVectorCoordinates() const { return mNormalVectorCoordinates; };
4443
void setLevel(const int level) { mLevel = level; };
4544

4645
private:
@@ -49,21 +48,18 @@ class Cell final
4948
const int mThirdClusterIndex;
5049
const int mFirstTrackletIndex;
5150
const int mSecondTrackletIndex;
52-
const float3 mNormalVectorCoordinates;
53-
const float mCurvature;
51+
const float mTanLambda;
5452
int mLevel;
5553
};
5654

5755
GPUdi() Cell::Cell(const int firstClusterIndex, const int secondClusterIndex, const int thirdClusterIndex,
58-
const int firstTrackletIndex, const int secondTrackletIndex,
59-
const float3& normalVectorCoordinates, const float curvature)
56+
const int firstTrackletIndex, const int secondTrackletIndex, const float tanL)
6057
: mFirstClusterIndex{firstClusterIndex},
6158
mSecondClusterIndex{secondClusterIndex},
6259
mThirdClusterIndex{thirdClusterIndex},
6360
mFirstTrackletIndex(firstTrackletIndex),
6461
mSecondTrackletIndex(secondTrackletIndex),
65-
mNormalVectorCoordinates(normalVectorCoordinates),
66-
mCurvature{curvature},
62+
mTanLambda{tanL},
6763
mLevel{1}
6864
{
6965
// Nothing to do

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,7 @@ struct TrackingParameters {
5151
void CopyCuts(TrackingParameters& other, float scale = 1.)
5252
{
5353
TrackletMaxDeltaPhi = other.TrackletMaxDeltaPhi * scale;
54-
for (unsigned int ii{0}; ii < TrackletMaxDeltaZ.size(); ++ii) {
55-
TrackletMaxDeltaZ[ii] = other.TrackletMaxDeltaZ[ii] * scale;
56-
}
57-
CellMaxDeltaTanLambda = other.CellMaxDeltaTanLambda * scale;
58-
for (unsigned int ii{0}; ii < CellMaxDCA.size(); ++ii) {
59-
CellMaxDCA[ii] = other.CellMaxDCA[ii] * scale;
60-
}
61-
for (unsigned int ii{0}; ii < NeighbourMaxDeltaCurvature.size(); ++ii) {
62-
NeighbourMaxDeltaCurvature[ii] = other.NeighbourMaxDeltaCurvature[ii] * scale;
63-
NeighbourMaxDeltaN[ii] = other.NeighbourMaxDeltaN[ii] * scale;
64-
}
54+
NSigmaCut = other.NSigmaCut * scale;
6555
}
6656

6757
int CellMinimumLevel();
@@ -72,23 +62,21 @@ struct TrackingParameters {
7262
int DeltaROF = 0;
7363
std::vector<float> LayerZ = {16.333f + 1, 16.333f + 1, 16.333f + 1, 42.140f + 1, 42.140f + 1, 73.745f + 1, 73.745f + 1};
7464
std::vector<float> LayerRadii = {2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f};
65+
std::vector<float> LayerxX0 = {5.e-3f, 5.e-3f, 5.e-3f, 1.e-2f, 1.e-2f, 1.e-2f, 1.e-2f};
66+
std::vector<float> LayerResolution = {5.e-4f, 5.e-4f, 5.e-4f, 5.e-4f, 5.e-4f, 5.e-4f, 5.e-4f};
67+
std::vector<float> LayerMisalignment = {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
7568
int ZBins{256};
7669
int PhiBins{128};
7770

7871
/// General parameters
7972
int ClusterSharing = 0;
8073
int MinTrackLength = 7;
74+
float NSigmaCut = 5;
75+
float PVres = 1.e-2f; /// FIXME: this has to be taken directly from the reconstructed vertices
8176
/// Trackleting cuts
8277
float TrackletMaxDeltaPhi = 0.3f;
83-
std::vector<float> TrackletMaxDeltaZ = {0.1f, 0.1f, 0.3f, 0.3f, 0.3f, 0.3f};
8478
/// Cell finding cuts
85-
float CellMaxDeltaTanLambda = 0.025f;
86-
std::vector<float> CellMaxDCA = {0.05f, 0.04f, 0.05f, 0.2f, 0.4f};
87-
float CellMaxDeltaPhi = 0.14f;
88-
std::vector<float> CellMaxDeltaZ = {0.2f, 0.4f, 0.5f, 0.6f, 3.0f};
89-
/// Neighbour finding cuts
90-
std::vector<float> NeighbourMaxDeltaCurvature = {0.008f, 0.0025f, 0.003f, 0.0035f};
91-
std::vector<float> NeighbourMaxDeltaN = {0.002f, 0.0090f, 0.002f, 0.005f};
79+
float CellDeltaTanLambdaSigma = 0.007f;
9280
/// Fitter parameters
9381
bool UseMatBudLUT = false;
9482
std::array<float, 2> FitIterationMaxChi2 = {100, 50};

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class TimeFrame final
7878

7979
float getMinR(int layer) const { return mMinR[layer]; }
8080
float getMaxR(int layer) const { return mMaxR[layer]; }
81+
float getMSangle(int layer) const { return mMSangles[layer]; }
82+
float getPositionResolution(int layer) const { return mPositionResolution[layer]; }
8183

8284
gsl::span<Cluster> getClustersOnLayer(int rofId, int layerId);
8385
gsl::span<const Cluster> getClustersOnLayer(int rofId, int layerId) const;
@@ -142,6 +144,8 @@ class TimeFrame final
142144
float mBeamPos[2] = {0.f, 0.f};
143145
std::vector<float> mMinR;
144146
std::vector<float> mMaxR;
147+
std::vector<float> mMSangles;
148+
std::vector<float> mPositionResolution;
145149
std::vector<bool> mMultiplicityCutMask;
146150
std::vector<int> mROframesPV = {0};
147151
std::vector<std::vector<int>> mROframesClusters;

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Tracker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class Tracker
8383

8484
private:
8585
track::TrackParCov buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2, const Cluster& cluster3,
86-
const TrackingFrameInfo& tf3);
86+
const TrackingFrameInfo& tf3, float resolution);
8787
template <typename... T>
8888
void initialiseTimeFrame(T&&... args);
8989
void computeTracklets();

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include "ITStracking/TimeFrame.h"
3333
#include "ITStracking/Road.h"
3434

35+
// #define OPTIMISATION_OUTPUT
36+
3537
namespace o2
3638
{
3739
namespace gpu

Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
4040

4141
// Use TGeo for mat. budget
4242
bool useMatCorrTGeo = false;
43+
float misalignment[7] = {-1.f, -1.f, -1.f, -1.f, -1.f, -1.f, -1.f};
44+
float nSigmaCut = -1.f;
45+
float deltaTanLres = -1.f;
46+
float phiCut = -1.f;
47+
float pvRes = -1.f;
48+
int LUTbinsPhi = -1;
49+
int LUTbinsZ = -1;
4350

4451
O2ParamDef(TrackerParamConfig, "ITSCATrackerParam");
4552
};

Detectors/ITSMFT/ITS/tracking/include/ITStracking/Tracklet.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace its
2929
struct Tracklet final {
3030
Tracklet();
3131
GPUdi() Tracklet(const int, const int, const Cluster&, const Cluster&, int rof0, int rof1);
32+
GPUdi() Tracklet(const int, const int, float tanL, float phi, int rof0, int rof1);
3233
#ifdef _ALLOW_DEBUG_TREES_ITS_
3334
unsigned char isEmpty() const;
3435
void dump();
@@ -60,6 +61,16 @@ GPUdi() Tracklet::Tracklet(const int firstClusterOrderingIndex, const int second
6061
// Nothing to do
6162
}
6263

64+
GPUdi() Tracklet::Tracklet(const int idx0, const int idx1, float tanL, float phi, int rof0, int rof1)
65+
: firstClusterIndex{idx0},
66+
secondClusterIndex{idx1},
67+
tanLambda{tanL},
68+
phi{phi},
69+
rof{static_cast<unsigned short>(rof0), static_cast<unsigned short>(rof1)}
70+
{
71+
// Nothing to do
72+
}
73+
6374
#ifdef _ALLOW_DEBUG_TREES_ITS_
6475
inline unsigned char Tracklet::isEmpty() const
6576
{

Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "DataFormatsITSMFT/TopologyDictionary.h"
2121
#include "ITSBase/GeometryTGeo.h"
2222
#include "ITSMFTBase/SegmentationAlpide.h"
23+
#include "ITStracking/TrackingConfigParam.h"
2324

2425
#include <iostream>
2526

@@ -31,6 +32,13 @@ struct ClusterHelper {
3132
int bin;
3233
int ind;
3334
};
35+
36+
float MSangle(float mass, float p, float xX0)
37+
{
38+
float beta = p / std::hypot(mass, p);
39+
return 0.0136f * std::sqrt(xX0) * (1.f + 0.038f * std::log(xX0)) / (beta * p);
40+
}
41+
3442
} // namespace
3543

3644
namespace o2
@@ -180,6 +188,8 @@ void TimeFrame::initialise(const int iteration, const MemoryParameters& memParam
180188
mTrackletsLookupTable.resize(trkParam.CellsPerRoad());
181189
mIndexTables.clear();
182190
mIndexTableUtils.setTrackingParameters(trkParam);
191+
mMSangles.resize(trkParam.NLayers);
192+
mPositionResolution.resize(trkParam.NLayers);
183193

184194
for (unsigned int iLayer{0}; iLayer < mClusters.size(); ++iLayer) {
185195
if (mClusters[iLayer].size()) {
@@ -189,6 +199,8 @@ void TimeFrame::initialise(const int iteration, const MemoryParameters& memParam
189199
mClusters[iLayer].resize(mUnsortedClusters[iLayer].size());
190200
mUsedClusters[iLayer].clear();
191201
mUsedClusters[iLayer].resize(mUnsortedClusters[iLayer].size(), false);
202+
mMSangles[iLayer] = MSangle(0.14f, 0.3f, trkParam.LayerxX0[iLayer]);
203+
mPositionResolution[iLayer] = std::hypot(trkParam.LayerMisalignment[iLayer], trkParam.LayerResolution[iLayer]);
192204
}
193205

194206
mIndexTables.resize(mNrof);

Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx

Lines changed: 38 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ void Tracker::computeCells()
9797

9898
void Tracker::findCellsNeighbours(int& iteration)
9999
{
100+
#ifdef OPTIMISATION_OUTPUT
101+
std::ofstream off(fmt::format("cellneighs{}.txt", iteration));
102+
#endif
100103
for (int iLayer{0}; iLayer < mTrkParams[iteration].CellsPerRoad() - 1; ++iLayer) {
101104

102105
if (mTimeFrame->getCells()[iLayer + 1].empty() ||
@@ -114,35 +117,26 @@ void Tracker::findCellsNeighbours(int& iteration)
114117
const int nextLayerTrackletIndex{currentCell.getSecondTrackletIndex()};
115118
const int nextLayerFirstCellIndex{mTimeFrame->getCellsLookupTable()[iLayer][nextLayerTrackletIndex]};
116119
const int nextLayerLastCellIndex{mTimeFrame->getCellsLookupTable()[iLayer][nextLayerTrackletIndex + 1]};
117-
for (int iNextLayerCell{nextLayerFirstCellIndex}; iNextLayerCell < nextLayerLastCellIndex; ++iNextLayerCell) {
120+
for (int iNextCell{nextLayerFirstCellIndex}; iNextCell < nextLayerLastCellIndex; ++iNextCell) {
118121

119-
Cell& nextCell{mTimeFrame->getCells()[iLayer + 1][iNextLayerCell]};
122+
Cell& nextCell{mTimeFrame->getCells()[iLayer + 1][iNextCell]};
120123
if (nextCell.getFirstTrackletIndex() != nextLayerTrackletIndex) {
121124
break;
122125
}
123126

124-
const float3 currentCellNormalVector{currentCell.getNormalVectorCoordinates()};
125-
const float3 nextCellNormalVector{nextCell.getNormalVectorCoordinates()};
126-
const float3 normalVectorsDeltaVector{currentCellNormalVector.x - nextCellNormalVector.x,
127-
currentCellNormalVector.y - nextCellNormalVector.y,
128-
currentCellNormalVector.z - nextCellNormalVector.z};
129-
130-
const float deltaNormalVectorsModulus{(normalVectorsDeltaVector.x * normalVectorsDeltaVector.x) +
131-
(normalVectorsDeltaVector.y * normalVectorsDeltaVector.y) +
132-
(normalVectorsDeltaVector.z * normalVectorsDeltaVector.z)};
133-
const float deltaCurvature{std::abs(currentCell.getCurvature() - nextCell.getCurvature())};
134-
135-
if (deltaNormalVectorsModulus < mTrkParams[iteration].NeighbourMaxDeltaN[iLayer] &&
136-
deltaCurvature < mTrkParams[iteration].NeighbourMaxDeltaCurvature[iLayer]) {
137-
138-
mTimeFrame->getCellsNeighbours()[iLayer][iNextLayerCell].push_back(iCell);
127+
#ifdef OPTIMISATION_OUTPUT
128+
bool good{mTimeFrame->getCellsLabel(iLayer)[iCell] == mTimeFrame->getCellsLabel(iLayer + 1)[iNextCell]};
129+
float signedDelta{currentCell.getTanLambda() - nextCell.getTanLambda()};
130+
off << fmt::format("{}\t{:d}\t{}\t{}", iLayer, good, signedDelta, signedDelta / mTrkParams[iteration].CellDeltaTanLambdaSigma) << std::endl;
131+
#endif
132+
mTimeFrame->getCellsNeighbours()[iLayer][iNextCell].push_back(iCell);
139133

140-
const int currentCellLevel{currentCell.getLevel()};
134+
const int currentCellLevel{currentCell.getLevel()};
141135

142-
if (currentCellLevel >= nextCell.getLevel()) {
143-
nextCell.setLevel(currentCellLevel + 1);
144-
}
136+
if (currentCellLevel >= nextCell.getLevel()) {
137+
nextCell.setLevel(currentCellLevel + 1);
145138
}
139+
// }
146140
}
147141
}
148142
}
@@ -283,7 +277,7 @@ void Tracker::findTracks()
283277
const auto& cluster3_tf = mTimeFrame->getTrackingFrameInfoOnLayer(lastCellLevel).at(clusters[lastCellLevel]);
284278

285279
/// FIXME!
286-
TrackITSExt temporaryTrack{buildTrackSeed(cluster1_glo, cluster2_glo, cluster3_glo, cluster3_tf)};
280+
TrackITSExt temporaryTrack{buildTrackSeed(cluster1_glo, cluster2_glo, cluster3_glo, cluster3_tf, mTimeFrame->getPositionResolution(lastCellLevel))};
287281
for (size_t iC = 0; iC < clusters.size(); ++iC) {
288282
temporaryTrack.setExternalClusterIndex(iC, clusters[iC], clusters[iC] != constants::its::UnusedIndex);
289283
}
@@ -376,12 +370,15 @@ bool Tracker::fitTrack(TrackITSExt& track, int start, int end, int step, const f
376370
return false;
377371
}
378372

379-
auto predChi2{track.getPredictedChi2(trackingHit.positionTrackingFrame, trackingHit.covarianceTrackingFrame)};
373+
GPUArray<float, 3> cov{trackingHit.covarianceTrackingFrame};
374+
cov[0] = std::hypot(cov[0], mTrkParams[0].LayerMisalignment[iLayer]);
375+
cov[2] = std::hypot(cov[2], mTrkParams[0].LayerMisalignment[iLayer]);
376+
auto predChi2{track.getPredictedChi2(trackingHit.positionTrackingFrame, cov)};
380377
if (nCl >= 3 && predChi2 > chi2cut * (nCl * 2 - 5)) {
381378
return false;
382379
}
383380
track.setChi2(track.getChi2() + predChi2);
384-
if (!track.o2::track::TrackParCov::update(trackingHit.positionTrackingFrame, trackingHit.covarianceTrackingFrame)) {
381+
if (!track.o2::track::TrackParCov::update(trackingHit.positionTrackingFrame, cov)) {
385382
return false;
386383
}
387384
nCl++;
@@ -608,7 +605,7 @@ void Tracker::rectifyClusterIndices()
608605
/// whereas the others are referred to the global frame. This function is almost a clone of CookSeed, adapted to return
609606
/// a TrackParCov
610607
track::TrackParCov Tracker::buildTrackSeed(const Cluster& cluster1, const Cluster& cluster2,
611-
const Cluster& cluster3, const TrackingFrameInfo& tf3)
608+
const Cluster& cluster3, const TrackingFrameInfo& tf3, float resolution)
612609
{
613610
const float ca = std::cos(tf3.alphaTrackingFrame), sa = std::sin(tf3.alphaTrackingFrame);
614611
const float x1 = cluster1.xCoordinate * ca + cluster1.yCoordinate * sa;
@@ -628,10 +625,10 @@ track::TrackParCov Tracker::buildTrackSeed(const Cluster& cluster1, const Cluste
628625

629626
const float fy = 1. / (cluster2.radius - cluster3.radius);
630627
const float& tz = fy;
631-
const float cy = (math_utils::computeCurvature(x1, y1, x2, y2 + constants::its::Resolution, x3, y3) - crv) /
632-
(constants::its::Resolution * getBz() * o2::constants::math::B2C) *
628+
const float cy = (math_utils::computeCurvature(x1, y1, x2, y2 + resolution, x3, y3) - crv) /
629+
(resolution * getBz() * o2::constants::math::B2C) *
633630
20.f; // FIXME: MS contribution to the cov[14] (*20 added)
634-
constexpr float s2 = constants::its::Resolution * constants::its::Resolution;
631+
const float s2 = resolution;
635632

636633
return track::TrackParCov(tf3.xTrackingFrame, tf3.alphaTrackingFrame,
637634
{y3, z3, crv * (x3 - x0), 0.5f * (tgl12 + tgl23),
@@ -647,6 +644,19 @@ void Tracker::getGlobalConfiguration()
647644
if (tc.useMatCorrTGeo) {
648645
setCorrType(o2::base::PropagatorImpl<float>::MatCorrType::USEMatCorrTGeo);
649646
}
647+
for (auto& params : mTrkParams) {
648+
if (params.NLayers == 7) {
649+
for (int i{0}; i < 7; ++i) {
650+
params.LayerMisalignment[i] = tc.misalignment[i] > 0 ? tc.misalignment[i] : params.LayerMisalignment[i];
651+
}
652+
}
653+
params.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : params.PhiBins;
654+
params.ZBins = tc.LUTbinsZ > 0 ? tc.LUTbinsZ : params.ZBins;
655+
params.PVres = tc.pvRes > 0 ? tc.pvRes : params.PVres;
656+
params.NSigmaCut *= tc.nSigmaCut > 0 ? tc.nSigmaCut : 1.f;
657+
params.CellDeltaTanLambdaSigma *= tc.deltaTanLres > 0 ? tc.deltaTanLres : 1.f;
658+
params.TrackletMaxDeltaPhi *= tc.phiCut > 0 ? tc.phiCut : 1.f;
659+
}
650660
}
651661

652662
void Tracker::adoptTimeFrame(TimeFrame& tf)

0 commit comments

Comments
 (0)