@@ -718,6 +718,9 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
718718template <int nLayers>
719719void TrackerTraits<nLayers>::findRoads(const int iteration)
720720{
721+ std::vector<std::vector<int >> firstClusters, sharedFirstClusters;
722+ firstClusters.resize (mTrkParams [iteration].NLayers );
723+ sharedFirstClusters.resize (mTrkParams [iteration].NLayers );
721724 for (int startLevel{mTrkParams [iteration].CellsPerRoad ()}; startLevel >= mTrkParams [iteration].CellMinimumLevel (); --startLevel) {
722725
723726 auto seedFilter = [&](const auto & seed) {
@@ -827,15 +830,22 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
827830 for (auto & track : tracks) {
828831 int nShared = 0 ;
829832 bool isFirstShared{false };
833+ int firstLayer{-1 }, firstCluster{-1 };
830834 for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
831835 if (track.getClusterIndex (iLayer) == constants::UnusedIndex) {
832836 continue ;
833837 }
834- nShared += int (mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer)));
835- isFirstShared |= !iLayer && mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer));
838+ bool isShared = mTimeFrame ->isClusterUsed (iLayer, track.getClusterIndex (iLayer));
839+ nShared += int (isShared);
840+ if (firstLayer < 0 ) {
841+ firstCluster = track.getClusterIndex (iLayer);
842+ isFirstShared = isShared && mTrkParams [0 ].AllowSharingFirstCluster && std::find (firstClusters[iLayer].begin (), firstClusters[iLayer].end (), firstCluster) != firstClusters[iLayer].end ();
843+ firstLayer = iLayer;
844+ }
836845 }
837846
838- if (nShared > mTrkParams [0 ].ClusterSharing ) {
847+ // / do not account for the first cluster in the shared clusters number if it is allowed
848+ if (nShared - int (isFirstShared && mTrkParams [0 ].AllowSharingFirstCluster ) > mTrkParams [0 ].ClusterSharing ) {
839849 continue ;
840850 }
841851
@@ -864,6 +874,33 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
864874 track.setNextROFbit ();
865875 }
866876 mTimeFrame ->getTracks (o2::gpu::CAMath::Min (rofs[0 ], rofs[1 ])).emplace_back (track);
877+
878+ firstClusters[firstLayer].push_back (firstCluster);
879+ if (isFirstShared) {
880+ sharedFirstClusters[firstLayer].push_back (firstCluster);
881+ }
882+ }
883+ }
884+
885+ // / Now we have to set the shared cluster flag
886+ for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
887+ std::sort (sharedFirstClusters[iLayer].begin (), sharedFirstClusters[iLayer].end ());
888+ }
889+
890+ for (int iROF{0 }; iROF < mTimeFrame ->getNrof (); ++iROF) {
891+ for (auto & track : mTimeFrame ->getTracks (iROF)) {
892+ int firstLayer{mTrkParams [0 ].NLayers }, firstCluster{constants::its::UnusedIndex};
893+ for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
894+ if (track.getClusterIndex (iLayer) == constants::its::UnusedIndex) {
895+ continue ;
896+ }
897+ firstLayer = iLayer;
898+ firstCluster = track.getClusterIndex (iLayer);
899+ break ;
900+ }
901+ if (std::binary_search (sharedFirstClusters[firstLayer].begin (), sharedFirstClusters[firstLayer].end (), firstCluster)) {
902+ track.setSharedClusters ();
903+ }
867904 }
868905 }
869906}
0 commit comments