Skip to content

Commit c7d5958

Browse files
authored
ITS: add selections on tracks sharing clusters (#15406)
* ITS: add selections on tracks sharing clusters * Refactor selection function, return simple int instead of reference to int * Use isPhiDifferenceBelow, avoid variable narrowing * Improve memory management for selection of tracks with shared clusters
1 parent f017263 commit c7d5958

7 files changed

Lines changed: 63 additions & 29 deletions

File tree

DataFormats/Detectors/ITSMFT/ITS/include/DataFormatsITS/TrackITS.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,13 @@ class TrackITSExt : public TrackITS
192192
getClusterRefs().setEntries(ncl);
193193
}
194194

195-
GPUhdi() const int& getClusterIndex(int lr) const { return mIndex[lr]; }
195+
GPUhdi() const int getClusterIndex(int lr) const { return mIndex[lr]; }
196+
197+
GPUh() const int getFirstLayerClusterIndex() const
198+
{
199+
int firstLayer = getFirstClusterLayer();
200+
return getClusterIndex(firstLayer);
201+
}
196202

197203
GPUhdi() void setExternalClusterIndex(int layer, int idx, bool newCluster = false)
198204
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ void TrackerTraitsGPU<NLayers>::findRoads(const int iteration)
387387
mTimeFrameGPU->downloadTrackITSExtDevice();
388388

389389
auto& tracks = mTimeFrameGPU->getTrackITSExt();
390-
this->acceptTracks(iteration, tracks, firstClusters, sharedFirstClusters);
390+
this->acceptTracks(iteration, tracks, firstClusters);
391391
mTimeFrameGPU->loadUsedClustersDevice();
392392
}
393-
this->markTracks(iteration, sharedFirstClusters);
393+
this->markTracks(iteration);
394394
// wipe the artefact memory
395395
mTimeFrameGPU->popMemoryStack(iteration);
396396
};

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ struct TrackingParameters {
7070
float DiamondCov[6] = {25.e-6f, 0.f, 0.f, 25.e-6f, 0.f, 36.f};
7171

7272
/// General parameters
73-
bool AllowSharingFirstCluster = false;
7473
int ClusterSharing = 0;
7574
int MinTrackLength = 7;
7675
int MaxHoles = 0;
@@ -98,6 +97,12 @@ struct TrackingParameters {
9897
bool PrintMemory = false; // print allocator usage in epilog report
9998
size_t MaxMemory = std::numeric_limits<size_t>::max();
10099
bool DropTFUponFailure = false;
100+
101+
// Selections on tracks sharing clusters
102+
bool AllowSharingFirstCluster = false;
103+
float SharedClusterMaxDeltaPhi = 0.05f; // For tracks sharing clusters, maximum allowed delta phi at the cluster position
104+
float SharedClusterMaxDeltaEta = 0.03f; // For tracks sharing clusters, maximum allowed delta eta at the cluster position
105+
bool SharedClusterOppositeSign = false; // For tracks sharing clusters, require opposite sign of the tracklets
101106
};
102107

103108
struct VertexingParameters {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ class TrackerTraits
5555
template <typename InputSeed>
5656
void processNeighbours(int iteration, int defaultCellTopologyId, int iLevel, const bounded_vector<InputSeed>& currentCellSeed, const bounded_vector<int>& currentCellId, const bounded_vector<int>& currentCellTopologyId, bounded_vector<TrackSeedN>& updatedCellSeed, bounded_vector<int>& updatedCellId, bounded_vector<int>& updatedCellTopologyId);
5757

58-
void acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters, bounded_vector<bounded_vector<int>>& sharedFirstClusters);
59-
void markTracks(int iteration, bounded_vector<bounded_vector<int>>& sharedFirstClusters);
58+
void acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters);
59+
void markTracks(int iteration);
6060

6161
void updateTrackingParameters(const std::vector<TrackingParameters>& trkPars)
6262
{

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper<TrackerPara
102102
size_t maxMemory = std::numeric_limits<size_t>::max();
103103
bool dropTFUponFailure = false;
104104
bool fataliseUponFailure = true; // granular management of the fatalisation in async mode
105+
106+
// Selections on tracks sharing clusters
105107
bool allowSharingFirstCluster = false; // allow first cluster sharing among tracks
108+
float sharedClusterMaxDeltaPhi = 0.05f; // Maximum allowed delta phi at the cluster position
109+
float sharedClusterMaxDeltaEta = 0.03f; // Maximum allowed delta eta at the cluster position
110+
bool sharedClusterOppositeSign = false; // Require opposite sign of the tracklets
106111

107112
O2ParamDef(TrackerParamConfig, "ITSCATrackerParam");
108113
};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ std::vector<TrackingParameters> TrackingMode::getTrackingParameters(TrackingMode
204204
p.SaveTimeBenchmarks = tc.saveTimeBenchmarks;
205205
p.FataliseUponFailure = tc.fataliseUponFailure;
206206
p.AllowSharingFirstCluster = tc.allowSharingFirstCluster;
207+
p.SharedClusterMaxDeltaPhi = tc.sharedClusterMaxDeltaPhi;
208+
p.SharedClusterMaxDeltaEta = tc.sharedClusterMaxDeltaEta;
209+
p.SharedClusterOppositeSign = tc.sharedClusterOppositeSign;
207210
const auto iter = &p - trackParams.data();
208211
if (iter < constants::MaxIter) {
209212
p.MaxHoles = tc.maxHolesIter[iter];

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

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,7 @@ template <int NLayers>
661661
void TrackerTraits<NLayers>::findRoads(const int iteration)
662662
{
663663
bounded_vector<bounded_vector<int>> firstClusters(mTrkParams[iteration].NLayers, bounded_vector<int>(mMemoryPool.get()), mMemoryPool.get());
664-
bounded_vector<bounded_vector<int>> sharedFirstClusters(mTrkParams[iteration].NLayers, bounded_vector<int>(mMemoryPool.get()), mMemoryPool.get());
665664
firstClusters.resize(mTrkParams[iteration].NLayers);
666-
sharedFirstClusters.resize(mTrkParams[iteration].NLayers);
667665
const auto propagator = o2::base::Propagator::Instance();
668666
const TrackingFrameInfo* tfInfos[NLayers]{};
669667
const Cluster* unsortedClusters[NLayers]{};
@@ -787,13 +785,13 @@ void TrackerTraits<NLayers>::findRoads(const int iteration)
787785
return track::isBetter(a, b);
788786
});
789787

790-
acceptTracks(iteration, tracks, firstClusters, sharedFirstClusters);
788+
acceptTracks(iteration, tracks, firstClusters);
791789
}
792-
markTracks(iteration, sharedFirstClusters);
790+
markTracks(iteration);
793791
}
794792

795793
template <int NLayers>
796-
void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters, bounded_vector<bounded_vector<int>>& sharedFirstClusters)
794+
void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITSExt>& tracks, bounded_vector<bounded_vector<int>>& firstClusters)
797795
{
798796
auto& trks = mTimeFrame->getTracks();
799797
trks.reserve(trks.size() + tracks.size());
@@ -860,34 +858,51 @@ void TrackerTraits<NLayers>::acceptTracks(int iteration, bounded_vector<TrackITS
860858

861859
if (mTrkParams[iteration].AllowSharingFirstCluster) {
862860
firstClusters[firstLayer].push_back(firstCluster);
863-
if (isFirstShared) {
864-
sharedFirstClusters[firstLayer].push_back(firstCluster);
865-
}
866861
}
867862
}
868863
}
869864

870865
template <int NLayers>
871-
void TrackerTraits<NLayers>::markTracks(int iteration, bounded_vector<bounded_vector<int>>& sharedFirstClusters)
866+
void TrackerTraits<NLayers>::markTracks(int iteration)
872867
{
873868
if (mTrkParams[iteration].AllowSharingFirstCluster) {
874869
/// Now we have to set the shared cluster flag
875-
for (int iLayer{0}; iLayer < mTrkParams[iteration].NLayers; ++iLayer) {
876-
std::sort(sharedFirstClusters[iLayer].begin(), sharedFirstClusters[iLayer].end());
877-
}
870+
auto& tracks = mTimeFrame->getTracks();
878871

879-
for (auto& track : mTimeFrame->getTracks()) {
880-
int firstLayer{mTrkParams[iteration].NLayers}, firstCluster{constants::UnusedIndex};
881-
for (int iLayer{0}; iLayer < mTrkParams[iteration].NLayers; ++iLayer) {
882-
if (track.getClusterIndex(iLayer) == constants::UnusedIndex) {
883-
continue;
884-
}
885-
firstLayer = iLayer;
886-
firstCluster = track.getClusterIndex(iLayer);
887-
break;
872+
bounded_vector<int> fclusSort(tracks.size(), mMemoryPool.get());
873+
std::iota(fclusSort.begin(), fclusSort.end(), 0);
874+
std::sort(fclusSort.begin(), fclusSort.end(), [&tracks](int a, int b) {
875+
return tracks[a].getFirstLayerClusterIndex() < tracks[b].getFirstLayerClusterIndex();
876+
});
877+
878+
auto areTracksSelected = [this, iteration](const TrackITSExt& t1, const TrackITSExt& t2) {
879+
const auto t1FirstLayer{t1.getFirstClusterLayer()}, t2FirstLayer{t2.getFirstClusterLayer()};
880+
if (t1FirstLayer != t2FirstLayer) {
881+
return false;
882+
}
883+
if (mTimeFrame->getClusterROF(t1FirstLayer, t1.getClusterIndex(t1FirstLayer)) != mTimeFrame->getClusterROF(t2FirstLayer, t2.getClusterIndex(t2FirstLayer))) {
884+
return false;
885+
}
886+
if (!math_utils::isPhiDifferenceBelow(t1.getPhi(), t2.getPhi(), mTrkParams[iteration].SharedClusterMaxDeltaPhi)) {
887+
return false;
888+
}
889+
if (std::abs(t1.getEta() - t2.getEta()) > mTrkParams[iteration].SharedClusterMaxDeltaEta) {
890+
return false;
888891
}
889-
if (std::binary_search(sharedFirstClusters[firstLayer].begin(), sharedFirstClusters[firstLayer].end(), firstCluster)) {
890-
track.setSharedClusters();
892+
if (mTrkParams[iteration].SharedClusterOppositeSign && t1.getSign() == t2.getSign()) {
893+
return false;
894+
}
895+
return true;
896+
};
897+
898+
for (int i{0}; i < static_cast<int>(fclusSort.size()); ++i) {
899+
auto& track = tracks[fclusSort[i]];
900+
for (int j{i + 1}; j < static_cast<int>(fclusSort.size()) && tracks[fclusSort[j]].getFirstLayerClusterIndex() == track.getFirstLayerClusterIndex(); ++j) {
901+
auto& track2 = tracks[fclusSort[j]];
902+
if (areTracksSelected(track, track2)) {
903+
track.setSharedClusters();
904+
track2.setSharedClusters();
905+
}
891906
}
892907
}
893908
}

0 commit comments

Comments
 (0)