@@ -661,9 +661,7 @@ template <int NLayers>
661661void 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
795793template <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
870865template <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