@@ -73,6 +73,9 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
7373
7474 mTaskArena ->execute ([&] {
7575 auto forTracklets = [&](auto Tag, int iLayer, int pivotROF, int base, int & offset) -> int {
76+ if (!mTimeFrame ->mMultiplicityCutMask [pivotROF]) {
77+ return 0 ;
78+ }
7679 int minROF = o2::gpu::CAMath::Max (startROF, pivotROF - mTrkParams [iteration].DeltaROF );
7780 int maxROF = o2::gpu::CAMath::Min (endROF - 1 , pivotROF + mTrkParams [iteration].DeltaROF );
7881 gsl::span<const Vertex> primaryVertices = mTrkParams [iteration].UseDiamond ? diamondSpan : mTimeFrame ->getPrimaryVertices (minROF, maxROF);
@@ -87,103 +90,98 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
8790
8891 int localCount = 0 ;
8992 auto & tracklets = mTimeFrame ->getTracklets ()[iLayer];
90- for (int targetROF0{minROF}; targetROF0 <= maxROF; ++targetROF0) {
91- if (!mTimeFrame ->mMultiplicityCutMask [targetROF0]) {
92- continue ;
93- }
94- auto layer0 = mTimeFrame ->getClustersOnLayer (targetROF0, iLayer);
95- if (layer0.empty ()) {
93+ auto layer0 = mTimeFrame ->getClustersOnLayer (pivotROF, iLayer);
94+ if (layer0.empty ()) {
95+ return 0 ;
96+ }
97+
98+ const float meanDeltaR = mTrkParams [iteration].LayerRadii [iLayer + 1 ] - mTrkParams [iteration].LayerRadii [iLayer];
99+
100+ for (int iCluster = 0 ; iCluster < int (layer0.size ()); ++iCluster) {
101+ const Cluster& currentCluster = layer0[iCluster];
102+ const int currentSortedIndex = mTimeFrame ->getSortedIndex (pivotROF, iLayer, iCluster);
103+ if (mTimeFrame ->isClusterUsed (iLayer, currentCluster.clusterId )) {
96104 continue ;
97105 }
98- const float meanDeltaR = mTrkParams [iteration]. LayerRadii [iLayer + 1 ] - mTrkParams [iteration]. LayerRadii [iLayer] ;
106+ const float inverseR0 = 1 . f / currentCluster. radius ;
99107
100- for (int iCluster = 0 ; iCluster < int (layer0.size ()); ++iCluster) {
101- const Cluster& currentCluster = layer0[iCluster];
102- const int currentSortedIndex = mTimeFrame ->getSortedIndex (targetROF0, iLayer, iCluster);
103- if (mTimeFrame ->isClusterUsed (iLayer, currentCluster.clusterId )) {
108+ for (int iV = startVtx; iV < endVtx; ++iV) {
109+ const auto & pv = primaryVertices[iV];
110+ if ((pv.isFlagSet (Vertex::Flags::UPCMode) && iteration != 3 ) || (iteration == 3 && !pv.isFlagSet (Vertex::Flags::UPCMode))) {
104111 continue ;
105112 }
106- const float inverseR0 = 1 .f / currentCluster.radius ;
107113
108- for (int iV = startVtx; iV < endVtx; ++iV) {
109- const auto & pv = primaryVertices[iV];
110- if ((pv.isFlagSet (Vertex::Flags::UPCMode) && iteration != 3 ) || (iteration == 3 && !pv.isFlagSet (Vertex::Flags::UPCMode))) {
111- continue ;
112- }
114+ const float resolution = o2::gpu::CAMath::Sqrt (math_utils::Sq (mTimeFrame ->getPositionResolution (iLayer)) + math_utils::Sq (mTrkParams [iteration].PVres ) / float (pv.getNContributors ()));
115+ const float tanLambda = (currentCluster.zCoordinate - pv.getZ ()) * inverseR0;
116+ const float zAtRmin = tanLambda * (mTimeFrame ->getMinR (iLayer + 1 ) - currentCluster.radius ) + currentCluster.zCoordinate ;
117+ const float zAtRmax = tanLambda * (mTimeFrame ->getMaxR (iLayer + 1 ) - currentCluster.radius ) + currentCluster.zCoordinate ;
118+ const float sqInvDeltaZ0 = 1 .f / (math_utils::Sq (currentCluster.zCoordinate - pv.getZ ()) + constants::Tolerance);
119+ const float sigmaZ = o2::gpu::CAMath::Sqrt (
120+ math_utils::Sq (resolution) * math_utils::Sq (tanLambda) * ((math_utils::Sq (inverseR0) + sqInvDeltaZ0) * math_utils::Sq (meanDeltaR) + 1 .f ) + math_utils::Sq (meanDeltaR * mTimeFrame ->getMSangle (iLayer)));
113121
114- const float resolution = o2::gpu::CAMath::Sqrt (math_utils::Sq (mTimeFrame ->getPositionResolution (iLayer)) + math_utils::Sq (mTrkParams [iteration].PVres ) / float (pv.getNContributors ()));
115- const float tanLambda = (currentCluster.zCoordinate - pv.getZ ()) * inverseR0;
116- const float zAtRmin = tanLambda * (mTimeFrame ->getMinR (iLayer + 1 ) - currentCluster.radius ) + currentCluster.zCoordinate ;
117- const float zAtRmax = tanLambda * (mTimeFrame ->getMaxR (iLayer + 1 ) - currentCluster.radius ) + currentCluster.zCoordinate ;
118- const float sqInvDeltaZ0 = 1 .f / (math_utils::Sq (currentCluster.zCoordinate - pv.getZ ()) + constants::Tolerance);
119- const float sigmaZ = o2::gpu::CAMath::Sqrt (
120- math_utils::Sq (resolution) * math_utils::Sq (tanLambda) * ((math_utils::Sq (inverseR0) + sqInvDeltaZ0) * math_utils::Sq (meanDeltaR) + 1 .f ) + math_utils::Sq (meanDeltaR * mTimeFrame ->getMSangle (iLayer)));
122+ auto bins = getBinsRect (currentCluster, iLayer + 1 , zAtRmin, zAtRmax, sigmaZ * mTrkParams [iteration].NSigmaCut , mTimeFrame ->getPhiCut (iLayer));
123+ if (bins.x == 0 && bins.y == 0 && bins.z == 0 && bins.w == 0 ) {
124+ continue ;
125+ }
126+ int phiBinsNum = bins.w - bins.y + 1 ;
127+ if (phiBinsNum < 0 ) {
128+ phiBinsNum += mTrkParams [iteration].PhiBins ;
129+ }
121130
122- auto bins = getBinsRect (currentCluster, iLayer + 1 , zAtRmin, zAtRmax, sigmaZ * mTrkParams [iteration]. NSigmaCut , mTimeFrame -> getPhiCut (iLayer));
123- if (bins. x == 0 && bins. y == 0 && bins. z == 0 && bins. w == 0 ) {
131+ for ( int targetROF{minROF}; targetROF <= maxROF; ++targetROF) {
132+ if (! mTimeFrame -> mMultiplicityCutMask [targetROF] ) {
124133 continue ;
125134 }
126- int phiBinsNum = bins. w - bins. y + 1 ;
127- if (phiBinsNum < 0 ) {
128- phiBinsNum += mTrkParams [iteration]. PhiBins ;
135+ auto layer1 = mTimeFrame -> getClustersOnLayer (targetROF, iLayer + 1 ) ;
136+ if (layer1. empty () ) {
137+ continue ;
129138 }
130-
131- for (int targetROF1{minROF}; targetROF1 <= maxROF; ++targetROF1) {
132- if (!mTimeFrame ->mMultiplicityCutMask [targetROF1] || std::abs (targetROF0 - targetROF1) > mTrkParams [iteration].DeltaROF ) {
133- continue ;
134- }
135- auto layer1 = mTimeFrame ->getClustersOnLayer (targetROF1, iLayer + 1 );
136- if (layer1.empty ()) {
137- continue ;
138- }
139- for (int iPhi = 0 ; iPhi < phiBinsNum; ++iPhi) {
140- int iPhiBin = (bins.y + iPhi) % mTrkParams [iteration].PhiBins ;
141- int firstBinIdx = mTimeFrame ->mIndexTableUtils .getBinIndex (bins.x , iPhiBin);
142- int maxBinIdx = firstBinIdx + (bins.z - bins.x ) + 1 ;
143- int firstRow = mTimeFrame ->getIndexTable (targetROF1, iLayer + 1 )[firstBinIdx];
144- int lastRow = mTimeFrame ->getIndexTable (targetROF1, iLayer + 1 )[maxBinIdx];
145- for (int iNext = firstRow; iNext < lastRow; ++iNext) {
146- if (iNext >= int (layer1.size ())) {
147- break ;
148- }
149- const Cluster& nextCluster = layer1[iNext];
150- if (mTimeFrame ->isClusterUsed (iLayer + 1 , nextCluster.clusterId )) {
151- continue ;
152- }
153- float deltaPhi = o2::gpu::GPUCommonMath::Abs (currentCluster.phi - nextCluster.phi );
154- float deltaZ = o2::gpu::GPUCommonMath::Abs ((tanLambda * (nextCluster.radius - currentCluster.radius )) + currentCluster.zCoordinate - nextCluster.zCoordinate );
139+ for (int iPhi = 0 ; iPhi < phiBinsNum; ++iPhi) {
140+ const int iPhiBin = (bins.y + iPhi) % mTrkParams [iteration].PhiBins ;
141+ const int firstBinIdx = mTimeFrame ->mIndexTableUtils .getBinIndex (bins.x , iPhiBin);
142+ const int maxBinIdx = firstBinIdx + (bins.z - bins.x ) + 1 ;
143+ const int firstRow = mTimeFrame ->getIndexTable (targetROF, iLayer + 1 )[firstBinIdx];
144+ const int lastRow = mTimeFrame ->getIndexTable (targetROF, iLayer + 1 )[maxBinIdx];
145+ for (int iNext = firstRow; iNext < lastRow; ++iNext) {
146+ if (iNext >= int (layer1.size ())) {
147+ break ;
148+ }
149+ const Cluster& nextCluster = layer1[iNext];
150+ if (mTimeFrame ->isClusterUsed (iLayer + 1 , nextCluster.clusterId )) {
151+ continue ;
152+ }
153+ float deltaPhi = o2::gpu::GPUCommonMath::Abs (currentCluster.phi - nextCluster.phi );
154+ float deltaZ = o2::gpu::GPUCommonMath::Abs ((tanLambda * (nextCluster.radius - currentCluster.radius )) + currentCluster.zCoordinate - nextCluster.zCoordinate );
155155
156156#ifdef OPTIMISATION_OUTPUT
157- MCCompLabel label;
158- int currentId{currentCluster.clusterId };
159- int nextId{nextCluster.clusterId };
160- for (auto & lab1 : mTimeFrame ->getClusterLabels (iLayer, currentId)) {
161- for (auto & lab2 : mTimeFrame ->getClusterLabels (iLayer + 1 , nextId)) {
162- if (lab1 == lab2 && lab1.isValid ()) {
163- label = lab1;
164- break ;
165- }
166- }
167- if (label.isValid ()) {
157+ MCCompLabel label;
158+ int currentId{currentCluster.clusterId };
159+ int nextId{nextCluster.clusterId };
160+ for (auto & lab1 : mTimeFrame ->getClusterLabels (iLayer, currentId)) {
161+ for (auto & lab2 : mTimeFrame ->getClusterLabels (iLayer + 1 , nextId)) {
162+ if (lab1 == lab2 && lab1.isValid ()) {
163+ label = lab1;
168164 break ;
169165 }
170166 }
171- off << std::format (" {}\t {:d}\t {}\t {}\t {}\t {}" , iLayer, label.isValid (), (tanLambda * (nextCluster.radius - currentCluster.radius ) + currentCluster.zCoordinate - nextCluster.zCoordinate ) / sigmaZ, tanLambda, resolution, sigmaZ) << std::endl;
167+ if (label.isValid ()) {
168+ break ;
169+ }
170+ }
171+ off << std::format (" {}\t {:d}\t {}\t {}\t {}\t {}" , iLayer, label.isValid (), (tanLambda * (nextCluster.radius - currentCluster.radius ) + currentCluster.zCoordinate - nextCluster.zCoordinate ) / sigmaZ, tanLambda, resolution, sigmaZ) << std::endl;
172172#endif
173173
174- if (deltaZ / sigmaZ < mTrkParams [iteration].NSigmaCut &&
175- (deltaPhi < mTimeFrame ->getPhiCut (iLayer) ||
176- o2::gpu::GPUCommonMath::Abs (deltaPhi - o2::constants::math::TwoPI) < mTimeFrame ->getPhiCut (iLayer))) {
177- float phi = o2::gpu::GPUCommonMath::ATan2 (currentCluster.yCoordinate - nextCluster.yCoordinate , currentCluster.xCoordinate - nextCluster.xCoordinate );
178- float tanL = (currentCluster.zCoordinate - nextCluster.zCoordinate ) / (currentCluster.radius - nextCluster.radius );
179- if constexpr (decltype (Tag)::value == PassMode::OnePass::value) {
180- tracklets.emplace_back (currentSortedIndex, mTimeFrame ->getSortedIndex (targetROF1, iLayer + 1 , iNext), tanL, phi, targetROF0, targetROF1);
181- } else if constexpr (decltype (Tag)::value == PassMode::TwoPassCount::value) {
182- ++localCount;
183- } else if constexpr (decltype (Tag)::value == PassMode::TwoPassInsert::value) {
184- const int idx = base + offset++;
185- tracklets[idx] = Tracklet (currentSortedIndex, mTimeFrame ->getSortedIndex (targetROF1, iLayer + 1 , iNext), tanL, phi, targetROF0, targetROF1);
186- }
174+ if (deltaZ / sigmaZ < mTrkParams [iteration].NSigmaCut &&
175+ ((deltaPhi < mTimeFrame ->getPhiCut (iLayer) || o2::gpu::GPUCommonMath::Abs (deltaPhi - o2::constants::math::TwoPI) < mTimeFrame ->getPhiCut (iLayer)))) {
176+ const float phi{o2::gpu::CAMath::ATan2 (currentCluster.yCoordinate - nextCluster.yCoordinate , currentCluster.xCoordinate - nextCluster.xCoordinate )};
177+ const float tanL = (currentCluster.zCoordinate - nextCluster.zCoordinate ) / (currentCluster.radius - nextCluster.radius );
178+ if constexpr (decltype (Tag)::value == PassMode::OnePass::value) {
179+ tracklets.emplace_back (currentSortedIndex, mTimeFrame ->getSortedIndex (targetROF, iLayer + 1 , iNext), tanL, phi, pivotROF, targetROF);
180+ } else if constexpr (decltype (Tag)::value == PassMode::TwoPassCount::value) {
181+ ++localCount;
182+ } else if constexpr (decltype (Tag)::value == PassMode::TwoPassInsert::value) {
183+ const int idx = base + offset++;
184+ tracklets[idx] = Tracklet (currentSortedIndex, mTimeFrame ->getSortedIndex (targetROF, iLayer + 1 , iNext), tanL, phi, pivotROF, targetROF);
187185 }
188186 }
189187 }
@@ -250,7 +248,10 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
250248 // / Sort tracklets
251249 auto & trkl{mTimeFrame ->getTracklets ()[iLayer]};
252250 tbb::parallel_sort (trkl.begin (), trkl.end (), [](const Tracklet& a, const Tracklet& b) -> bool {
253- return a.firstClusterIndex < b.firstClusterIndex || (a.firstClusterIndex == b.firstClusterIndex && a.secondClusterIndex < b.secondClusterIndex );
251+ if (a.firstClusterIndex != b.firstClusterIndex ) {
252+ return a.firstClusterIndex < b.firstClusterIndex ;
253+ }
254+ return a.secondClusterIndex < b.secondClusterIndex ;
254255 });
255256 // / Remove duplicates
256257 trkl.erase (std::unique (trkl.begin (), trkl.end (), [](const Tracklet& a, const Tracklet& b) -> bool {
@@ -297,7 +298,7 @@ void TrackerTraits<nLayers>::computeLayerTracklets(const int iteration, int iROF
297298 });
298299 }
299300 });
300- }
301+ } // namespace o2::its
301302
302303template <int nLayers>
303304void TrackerTraits<nLayers>::computeLayerCells(const int iteration)
@@ -327,7 +328,6 @@ void TrackerTraits<nLayers>::computeLayerCells(const int iteration)
327328 for (int iNextTracklet{nextLayerFirstTrackletIndex}; iNextTracklet < nextLayerLastTrackletIndex; ++iNextTracklet) {
328329 const Tracklet& nextTracklet{mTimeFrame ->getTracklets ()[iLayer + 1 ][iNextTracklet]};
329330 const auto & nextLbl = mTimeFrame ->getTrackletsLabel (iLayer + 1 )[iNextTracklet];
330- bool print = false ;
331331 if (mTimeFrame ->getTracklets ()[iLayer + 1 ][iNextTracklet].firstClusterIndex != nextLayerClusterIndex) {
332332 break ;
333333 }
@@ -509,7 +509,8 @@ void TrackerTraits<nLayers>::findCellsNeighbours(const int iteration)
509509 const auto & trkl01 = mTimeFrame ->getTracklets ()[iLayer + 1 ][currentCellSeed.getSecondTrackletIndex ()];
510510 const auto & trkl10 = mTimeFrame ->getTracklets ()[iLayer + 1 ][nextCellSeed.getFirstTrackletIndex ()];
511511 const auto & trkl11 = mTimeFrame ->getTracklets ()[iLayer + 2 ][nextCellSeed.getSecondTrackletIndex ()];
512- if ((std::max ({trkl00.getMaxRof (), trkl01.getMaxRof (), trkl10.getMaxRof (), trkl11.getMaxRof ()}) - std::min ({trkl00.getMinRof (), trkl01.getMinRof (), trkl10.getMinRof (), trkl10.getMinRof ()})) > mTrkParams [0 ].DeltaROF ) {
512+ if ((std::max ({trkl00.getMaxRof (), trkl01.getMaxRof (), trkl10.getMaxRof (), trkl11.getMaxRof ()}) -
513+ std::min ({trkl00.getMinRof (), trkl01.getMinRof (), trkl10.getMinRof (), trkl11.getMinRof ()})) > mTrkParams [0 ].DeltaROF ) {
513514 continue ;
514515 }
515516 }
@@ -657,20 +658,6 @@ void TrackerTraits<nLayers>::processNeighbours(int iLayer, int iLevel, const bou
657658 CA_DEBUGGER (failed[0 ]++);
658659 continue ;
659660 }
660- if (mTrkParams [0 ].DeltaROF ) { // TODO this has to be improved for the staggering
661- const auto & trklNeigh = mTimeFrame ->getTracklets ()[iLayer - 1 ][neighbourCell.getFirstTrackletIndex ()];
662- short minRof{std::numeric_limits<short >::max ()}, maxRof{std::numeric_limits<short >::min ()};
663- for (int iLayer{0 }; iLayer < mTrkParams [0 ].NLayers ; ++iLayer) {
664- if (const auto clsId = currentCell.getCluster (iLayer); clsId != constants::UnusedIndex) {
665- const short clsROF = mTimeFrame ->getClusterROF (iLayer, clsId);
666- minRof = std::min (minRof, clsROF);
667- maxRof = std::max (maxRof, clsROF);
668- }
669- }
670- if ((std::max (trklNeigh.getMaxRof (), maxRof) - std::min (trklNeigh.getMinRof (), minRof)) > mTrkParams [0 ].DeltaROF ) {
671- continue ;
672- }
673- }
674661
675662 // / Let's start the fitting procedure
676663 CellSeed seed{currentCell};
0 commit comments