@@ -718,6 +718,10 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
718718template <int nLayers>
719719void TrackerTraits<nLayers>::findRoads(const int iteration)
720720{
721+ bounded_vector<bounded_vector<int >> firstClusters (mTrkParams [iteration].NLayers , bounded_vector<int >(mMemoryPool .get ()), mMemoryPool .get ());
722+ bounded_vector<bounded_vector<int >> sharedFirstClusters (mTrkParams [iteration].NLayers , bounded_vector<int >(mMemoryPool .get ()), mMemoryPool .get ());
723+ firstClusters.resize (mTrkParams [iteration].NLayers );
724+ sharedFirstClusters.resize (mTrkParams [iteration].NLayers );
721725 for (int startLevel{mTrkParams [iteration].CellsPerRoad ()}; startLevel >= mTrkParams [iteration].CellMinimumLevel (); --startLevel) {
722726
723727 auto seedFilter = [&](const auto & seed) {
@@ -827,15 +831,22 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
827831 for (auto & track : tracks) {
828832 int nShared = 0 ;
829833 bool isFirstShared{false };
834+ int firstLayer{-1 }, firstCluster{-1 };
830835 for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
831836 if (track.getClusterIndex (iLayer) == constants::UnusedIndex) {
832837 continue ;
833838 }
834- nShared += int (mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer)));
835- isFirstShared |= !iLayer && mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer));
839+ bool isShared = mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer));
840+ nShared += int (isShared);
841+ if (firstLayer < 0 ) {
842+ firstCluster = track.getClusterIndex (iLayer);
843+ isFirstShared = isShared && mTrkParams [0 ].AllowSharingFirstCluster && std::find (firstClusters[iLayer].begin (), firstClusters[iLayer].end (), firstCluster) != firstClusters[iLayer].end ();
844+ firstLayer = iLayer;
845+ }
836846 }
837847
838- if (nShared > mTrkParams [0 ].ClusterSharing ) {
848+ // / do not account for the first cluster in the shared clusters number if it is allowed
849+ if (nShared - int (isFirstShared && mTrkParams [0 ].AllowSharingFirstCluster ) > mTrkParams [0 ].ClusterSharing ) {
839850 continue ;
840851 }
841852
@@ -864,6 +875,33 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
864875 track.setNextROFbit ();
865876 }
866877 mTimeFrame ->getTracks (o2::gpu::CAMath::Min (rofs[0 ], rofs[1 ])).emplace_back (track);
878+
879+ firstClusters[firstLayer].push_back (firstCluster);
880+ if (isFirstShared) {
881+ sharedFirstClusters[firstLayer].push_back (firstCluster);
882+ }
883+ }
884+ }
885+
886+ // / Now we have to set the shared cluster flag
887+ for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
888+ std::sort (sharedFirstClusters[iLayer].begin (), sharedFirstClusters[iLayer].end ());
889+ }
890+
891+ for (int iROF{0 }; iROF < mTimeFrame ->getNrof (); ++iROF) {
892+ for (auto & track : mTimeFrame ->getTracks (iROF)) {
893+ int firstLayer{mTrkParams [0 ].NLayers }, firstCluster{constants::UnusedIndex};
894+ for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
895+ if (track.getClusterIndex (iLayer) == constants::UnusedIndex) {
896+ continue ;
897+ }
898+ firstLayer = iLayer;
899+ firstCluster = track.getClusterIndex (iLayer);
900+ break ;
901+ }
902+ if (std::binary_search (sharedFirstClusters[firstLayer].begin (), sharedFirstClusters[firstLayer].end (), firstCluster)) {
903+ track.setSharedClusters ();
904+ }
867905 }
868906 }
869907}
0 commit comments