1212// / \brief
1313// /
1414
15+ #include < cassert>
1516#include " ITStracking/VertexerTraits.h"
1617#include " ITStracking/ROframe.h"
1718#include " ITStracking/ClusterLines.h"
1819#include " ITStracking/Tracklet.h"
19- #include < iostream>
2020
2121#define LAYER0_TO_LAYER1 0
2222#define LAYER1_TO_LAYER2 1
@@ -42,10 +42,12 @@ void trackleterKernelSerial(
4242 std::vector<Tracklet>& Tracklets,
4343 std::vector<int >& foundTracklets,
4444 const char isMc,
45- const std::vector<int >& nextLayerMClabels,
46- const std::vector<int >& currentLayerMClabels,
45+ const ROframe* evt = nullptr ,
4746 const int maxTrackletsPerCluster = static_cast <int >(2e3 ))
4847{
48+ if (isMc) {
49+ assert (evt != nullptr );
50+ }
4951 foundTracklets.resize (clustersCurrentLayer.size (), 0 );
5052 // loop on layer1 clusters
5153 for (unsigned int iCurrentLayerClusterIndex{ 0 }; iCurrentLayerClusterIndex < clustersCurrentLayer.size (); ++iCurrentLayerClusterIndex) {
@@ -66,7 +68,9 @@ void trackleterKernelSerial(
6668 // loop on clusters next layer
6769 for (int iNextLayerClusterIndex{ firstRowClusterIndex }; iNextLayerClusterIndex < maxRowClusterIndex && iNextLayerClusterIndex < (int )clustersNextLayer.size (); ++iNextLayerClusterIndex) {
6870 const Cluster& nextCluster{ clustersNextLayer[iNextLayerClusterIndex] };
69- const char testMC{ !isMc || (nextLayerMClabels[iNextLayerClusterIndex] == currentLayerMClabels[iCurrentLayerClusterIndex] && nextLayerMClabels[iNextLayerClusterIndex] != -1 ) };
71+ const auto & lblNext = evt->getClusterLabels (layerIndex, nextCluster.clusterId );
72+ const auto & lblCurr = evt->getClusterLabels (1 , currentCluster.clusterId );
73+ const unsigned char testMC{ !isMc || (lblNext.getTrackID () == lblCurr.getTrackID () && lblCurr.isValid ()) };
7074 if (gpu::GPUCommonMath::Abs (currentCluster.phiCoordinate - nextCluster.phiCoordinate ) < phiCut && testMC) {
7175 if (storedTracklets < maxTrackletsPerCluster) {
7276 if (layerOrder == LAYER0_TO_LAYER1 ) {
@@ -228,42 +232,46 @@ const std::vector<std::pair<int, int>> VertexerTraits::selectClusters(const std:
228232
229233void VertexerTraits::computeTrackletsPureMontecarlo ()
230234{
231-
232- std::cout << " Running in Montecarlo trivial mode\n " ;
235+ assert (mEvent != nullptr );
233236
234237 std::vector<int > foundTracklets01;
235238 std::vector<int > foundTracklets12;
236239
237- std::vector<int > labelsMC0 = getMClabelsLayer (0 );
238- std::vector<int > labelsMC1 = getMClabelsLayer (1 );
239- std::vector<int > labelsMC2 = getMClabelsLayer (2 );
240-
241240 for (unsigned int iCurrentLayerClusterIndex{ 0 }; iCurrentLayerClusterIndex < mClusters [0 ].size (); ++iCurrentLayerClusterIndex) {
242- auto & cluster { mClusters [0 ][iCurrentLayerClusterIndex] };
241+ auto & currentCluster { mClusters [0 ][iCurrentLayerClusterIndex] };
243242 for (unsigned int iNextLayerClusterIndex = 0 ; iNextLayerClusterIndex < mClusters [1 ].size (); iNextLayerClusterIndex++) {
244243 const Cluster& nextCluster{ mClusters [1 ][iNextLayerClusterIndex] };
245- if (labelsMC1[iNextLayerClusterIndex] == labelsMC0[iCurrentLayerClusterIndex] && labelsMC1[iNextLayerClusterIndex] != -1 )
246- mComb01 .emplace_back (iCurrentLayerClusterIndex, iNextLayerClusterIndex, cluster, nextCluster);
244+ const auto & lblNext = mEvent ->getClusterLabels (1 , nextCluster.clusterId );
245+ const auto & lblCurr = mEvent ->getClusterLabels (0 , currentCluster.clusterId );
246+ if (lblNext.getTrackID () == lblCurr.getTrackID () && lblCurr.isValid ()) {
247+ mComb01 .emplace_back (iCurrentLayerClusterIndex, iNextLayerClusterIndex, currentCluster, nextCluster);
248+ }
247249 }
248250 }
249251
250252 for (unsigned int iCurrentLayerClusterIndex{ 0 }; iCurrentLayerClusterIndex < mClusters [2 ].size (); ++iCurrentLayerClusterIndex) {
251- auto & cluster { mClusters [2 ][iCurrentLayerClusterIndex] };
253+ auto & currentCluster { mClusters [2 ][iCurrentLayerClusterIndex] };
252254 for (unsigned int iNextLayerClusterIndex = 0 ; iNextLayerClusterIndex < mClusters [1 ].size (); iNextLayerClusterIndex++) {
253255 const Cluster& nextCluster{ mClusters [1 ][iNextLayerClusterIndex] };
254- if (labelsMC1[iNextLayerClusterIndex] == labelsMC2[iCurrentLayerClusterIndex] && labelsMC1[iNextLayerClusterIndex] != -1 )
255- mComb12 .emplace_back (iNextLayerClusterIndex, iCurrentLayerClusterIndex, nextCluster, cluster);
256+ const auto & lblNext = mEvent ->getClusterLabels (1 , nextCluster.clusterId );
257+ const auto & lblCurr = mEvent ->getClusterLabels (2 , currentCluster.clusterId );
258+ if (lblNext.getTrackID () == lblCurr.getTrackID () && lblCurr.isValid ()) {
259+ mComb12 .emplace_back (iNextLayerClusterIndex, iCurrentLayerClusterIndex, nextCluster, currentCluster);
260+ }
256261 }
257262 }
258263
259264 for (auto & trklet01 : mComb01 ) {
260265 for (auto & trklet12 : mComb12 ) {
261266 if (trklet01.secondClusterIndex == trklet12.firstClusterIndex ) {
262267 const float deltaTanLambda{ gpu::GPUCommonMath::Abs (trklet01.tanLambda - trklet12.tanLambda ) };
263- mDeltaTanlambdas .push_back (std::array<float , 7 >{ deltaTanLambda,
268+ #if defined(__VERTEXER_ITS_DEBUG)
269+ mDeltaTanlambdas .push_back (std::array<float , 8 >{ deltaTanLambda,
264270 mClusters [0 ][trklet01.firstClusterIndex ].zCoordinate , mClusters [0 ][trklet01.firstClusterIndex ].rCoordinate ,
265271 mClusters [1 ][trklet01.secondClusterIndex ].zCoordinate , mClusters [1 ][trklet01.secondClusterIndex ].rCoordinate ,
266- mClusters [2 ][trklet12.secondClusterIndex ].zCoordinate , mClusters [2 ][trklet12.secondClusterIndex ].rCoordinate });
272+ mClusters [2 ][trklet12.secondClusterIndex ].zCoordinate , mClusters [2 ][trklet12.secondClusterIndex ].rCoordinate ,
273+ true });
274+ #endif
267275 }
268276 }
269277 }
@@ -275,18 +283,12 @@ void VertexerTraits::computeTrackletsPureMontecarlo()
275283
276284void VertexerTraits::computeTracklets (const bool useMCLabel)
277285{
278- // computeTrackletsPureMontecarlo();
279286 if (useMCLabel)
280287 std::cout << " Running in Montecarlo check mode\n " ;
281288
282289 std::vector<int > foundTracklets01;
283290 std::vector<int > foundTracklets12;
284291
285- // /TODO: Ugly hack!! The labels should be optionals in the trackleter kernel
286- std::vector<int > labelsMC0 = useMCLabel ? getMClabelsLayer (0 ) : std::vector<int >();
287- std::vector<int > labelsMC1 = useMCLabel ? getMClabelsLayer (1 ) : std::vector<int >();
288- std::vector<int > labelsMC2 = useMCLabel ? getMClabelsLayer (2 ) : std::vector<int >();
289-
290292 trackleterKernelSerial (
291293 mClusters [0 ],
292294 mClusters [1 ],
@@ -296,8 +298,7 @@ void VertexerTraits::computeTracklets(const bool useMCLabel)
296298 mComb01 ,
297299 foundTracklets01,
298300 useMCLabel,
299- labelsMC0,
300- labelsMC1);
301+ mEvent );
301302
302303 trackleterKernelSerial (
303304 mClusters [2 ],
@@ -308,8 +309,7 @@ void VertexerTraits::computeTracklets(const bool useMCLabel)
308309 mComb12 ,
309310 foundTracklets12,
310311 useMCLabel,
311- labelsMC2,
312- labelsMC1);
312+ mEvent );
313313
314314 trackletSelectionKernelSerial (
315315 mClusters [0 ],
0 commit comments