@@ -36,6 +36,7 @@ namespace o2::its
3636{
3737namespace
3838{
39+
3940template <TrackletMode Mode, bool EvalRun, int NLayers>
4041void trackleterKernelHost (
4142 const gsl::span<const Cluster>& clustersNextLayer, // 0 2
@@ -48,9 +49,9 @@ void trackleterKernelHost(
4849 const IndexTableUtils<NLayers>& utils,
4950 const TimeEstBC& timErr,
5051 gsl::span<int > rofFoundTrackletsOffsets,
51- const int globalOffsetNextLayer = 0 ,
52- const int globalOffsetCurrentLayer = 0 ,
53- const int maxTrackletsPerCluster = static_cast < int >( 2e3 ) )
52+ const int globalOffsetNextLayer,
53+ const int globalOffsetCurrentLayer,
54+ const int maxTrackletsPerCluster)
5455{
5556 const int PhiBins{utils.getNphiBins ()};
5657 const int ZBins{utils.getNzBins ()};
@@ -65,17 +66,17 @@ void trackleterKernelHost(
6566 phiBinsNum += PhiBins;
6667 }
6768 // loop on phi bins next layer
68- for (int iPhiBin{selectedBinsRect.y }, iPhiCount{0 }; iPhiCount < phiBinsNum; iPhiBin = ++iPhiBin == PhiBins ? 0 : iPhiBin, iPhiCount++) {
69+ for (int iPhiBin{selectedBinsRect.y }, iPhiCount{0 }; iPhiCount < phiBinsNum && storedTracklets < maxTrackletsPerCluster ; iPhiBin = ++iPhiBin == PhiBins ? 0 : iPhiBin, iPhiCount++) {
6970 const int firstBinIndex{utils.getBinIndex (selectedBinsRect.x , iPhiBin)};
7071 const int firstRowClusterIndex{indexTableNext[firstBinIndex]};
7172 const int maxRowClusterIndex{indexTableNext[firstBinIndex + ZBins]};
7273 // loop on clusters next layer
73- for (int iNextLayerClusterIndex{firstRowClusterIndex}; iNextLayerClusterIndex < maxRowClusterIndex && iNextLayerClusterIndex < static_cast <int >(clustersNextLayer.size ()); ++iNextLayerClusterIndex) {
74+ for (int iNextLayerClusterIndex{firstRowClusterIndex}; iNextLayerClusterIndex < maxRowClusterIndex && iNextLayerClusterIndex < static_cast <int >(clustersNextLayer.size ()) && storedTracklets < maxTrackletsPerCluster ; ++iNextLayerClusterIndex) {
7475 if (usedClustersNextLayer[iNextLayerClusterIndex]) {
7576 continue ;
7677 }
7778 const Cluster& nextCluster{clustersNextLayer[iNextLayerClusterIndex]};
78- if (o2::gpu::GPUCommonMath::Abs ( math_utils::smallestAngleDifference (currentCluster.phi , nextCluster.phi )) < phiCut) {
79+ if (math_utils::isPhiDifferenceBelow (currentCluster.phi , nextCluster.phi , phiCut) ) {
7980 if (storedTracklets < maxTrackletsPerCluster) {
8081 if constexpr (!EvalRun) {
8182 if constexpr (Mode == TrackletMode::Layer0Layer1) {
@@ -105,35 +106,39 @@ void trackletSelectionKernelHost(
105106 gsl::span<unsigned char > usedClusters2, // global layer 2 used clusters
106107 const gsl::span<const Tracklet>& tracklets01,
107108 const gsl::span<const Tracklet>& tracklets12,
108- bounded_vector<bool >& usedTracklets,
109+ bounded_vector<uint8_t >& usedTracklets,
109110 const gsl::span<int > foundTracklets01,
110111 const gsl::span<int > foundTracklets12,
111112 bounded_vector<Line>& lines,
112113 const gsl::span<const o2::MCCompLabel>& trackletLabels,
113114 bounded_vector<o2::MCCompLabel>& linesLabels,
114115 const int nLayer1Clusters,
115- const float tanLambdaCut = 0 . 025f ,
116- const float phiCut = 0 . 005f ,
117- const int maxTracklets = 100 )
116+ const float tanLambdaCut,
117+ const float phiCut,
118+ const int maxTracklets)
118119{
119120 int offset01{0 }, offset12{0 };
120121 for (int iCurrentLayerClusterIndex{0 }; iCurrentLayerClusterIndex < nLayer1Clusters; ++iCurrentLayerClusterIndex) {
121122 int validTracklets{0 };
122- for (int iTracklet12{offset12}; iTracklet12 < offset12 + foundTracklets12[iCurrentLayerClusterIndex]; ++iTracklet12) {
123- for (int iTracklet01{offset01}; iTracklet01 < offset01 + foundTracklets01[iCurrentLayerClusterIndex]; ++iTracklet01) {
123+ const int endTracklet01 = offset01 + foundTracklets01[iCurrentLayerClusterIndex];
124+ const int endTracklet12 = offset12 + foundTracklets12[iCurrentLayerClusterIndex];
125+ for (int iTracklet12{offset12}; iTracklet12 < endTracklet12 && validTracklets != maxTracklets; ++iTracklet12) {
126+ const auto & tracklet12{tracklets12[iTracklet12]};
127+ for (int iTracklet01{offset01}; iTracklet01 < endTracklet01 && validTracklets != maxTracklets; ++iTracklet01) {
124128 if (usedTracklets[iTracklet01]) {
125129 continue ;
126130 }
127131
128132 const auto & tracklet01{tracklets01[iTracklet01]};
129- const auto & tracklet12{tracklets12[iTracklet12]};
130133 if (!tracklet01.getTimeStamp ().isCompatible (tracklet12.getTimeStamp ())) {
131134 continue ;
132135 }
133136
134137 const float deltaTanLambda{o2::gpu::GPUCommonMath::Abs (tracklet01.tanLambda - tracklet12.tanLambda )};
135- const float deltaPhi{o2::gpu::GPUCommonMath::Abs (math_utils::smallestAngleDifference (tracklet01.phi , tracklet12.phi ))};
136- if (deltaTanLambda < tanLambdaCut && deltaPhi < phiCut && validTracklets != maxTracklets) {
138+ if (deltaTanLambda >= tanLambdaCut) {
139+ continue ;
140+ }
141+ if (math_utils::isPhiDifferenceBelow (tracklet01.phi , tracklet12.phi , phiCut) && validTracklets != maxTracklets) {
137142 usedClusters0[tracklet01.firstClusterIndex ] = 1 ;
138143 usedClusters2[tracklet12.secondClusterIndex ] = 1 ;
139144 usedTracklets[iTracklet01] = true ;
@@ -296,8 +301,8 @@ void VertexerTraits<NLayers>::computeTrackletMatching(const int iteration)
296301 if (mTimeFrame ->getFoundTracklets (pivotRofId, 0 ).empty () || skipROF (iteration, pivotRofId)) {
297302 continue ;
298303 }
299- mTimeFrame ->getLines (pivotRofId).reserve (mTimeFrame ->getNTrackletsCluster (pivotRofId, 0 ).size ());
300- bounded_vector<bool > usedTracklets (mTimeFrame ->getFoundTracklets (pivotRofId, 0 ).size (), false , mMemoryPool .get ());
304+ mTimeFrame ->getLines (pivotRofId).reserve (std::min ( mTimeFrame ->getFoundTracklets (pivotRofId, 0 ). size (), mTimeFrame -> getNTrackletsCluster (pivotRofId, 0 ).size () * constants::MaxSelectedTrackletsPerCluster ));
305+ bounded_vector<uint8_t > usedTracklets (mTimeFrame ->getFoundTracklets (pivotRofId, 0 ).size (), 0 , mMemoryPool .get ());
301306 trackletSelectionKernelHost (
302307 mTimeFrame ->getClusters ()[0 ].data (),
303308 mTimeFrame ->getClusters ()[1 ].data (),
@@ -313,7 +318,8 @@ void VertexerTraits<NLayers>::computeTrackletMatching(const int iteration)
313318 mTimeFrame ->getLinesLabel (pivotRofId),
314319 static_cast <int >(mTimeFrame ->getClustersOnLayer (pivotRofId, 1 ).size ()),
315320 mVrtParams [iteration].tanLambdaCut ,
316- mVrtParams [iteration].phiCut );
321+ mVrtParams [iteration].phiCut ,
322+ constants::MaxSelectedTrackletsPerCluster);
317323 totalLines.local () += mTimeFrame ->getLines (pivotRofId).size ();
318324 }
319325 });
0 commit comments