@@ -823,19 +823,12 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
823823 }
824824
825825 bounded_vector<TrackITSExt> tracks (mMemoryPool .get ());
826- tracks.reserve (trackSeeds.size ());
827826 mTaskArena .execute ([&] {
828- tbb::combinable<bounded_vector<TrackITSExt>> locTracksData ([&] {
829- return bounded_vector<TrackITSExt>(mMemoryPool .get ());
830- });
831-
827+ bounded_vector<int > perSeedCount (trackSeeds.size () + 1 , 0 , mMemoryPool .get ());
832828 tbb::parallel_for (
833829 tbb::blocked_range<int >(0 , (int )trackSeeds.size ()),
834830 [&](const tbb::blocked_range<int >& Seeds) {
835831 for (int iSeed = Seeds.begin (); iSeed < Seeds.end (); ++iSeed) {
836- auto & localTracks = locTracksData.local ();
837- localTracks.reserve (Seeds.size ());
838-
839832 const CellSeed& seed{trackSeeds[iSeed]};
840833 TrackITSExt temporaryTrack{seed};
841834 temporaryTrack.resetCovariance ();
@@ -855,14 +848,41 @@ void TrackerTraits<nLayers>::findRoads(const int iteration)
855848 if (!fitSuccess || temporaryTrack.getPt () < mTrkParams [iteration].MinPt [mTrkParams [iteration].NLayers - temporaryTrack.getNClusters ()]) {
856849 continue ;
857850 }
858- localTracks. push_back (temporaryTrack) ;
851+ ++perSeedCount[iSeed] ;
859852 }
860853 });
854+ std::exclusive_scan (perSeedCount.begin (), perSeedCount.end (), perSeedCount.begin (), 0 );
855+ auto totalTracks{perSeedCount.back ()};
856+ if (totalTracks == 0 ) {
857+ return ;
858+ }
859+ tracks.resize (totalTracks);
861860
862- locTracksData.combine_each ([&](const bounded_vector<TrackITSExt>& localTracks) {
863- tracks.insert (tracks.end (), localTracks.begin (), localTracks.end ());
864- });
865- tracks.shrink_to_fit ();
861+ tbb::parallel_for (
862+ tbb::blocked_range<int >(0 , (int )trackSeeds.size ()),
863+ [&](const tbb::blocked_range<int >& Seeds) {
864+ for (int iSeed = Seeds.begin (); iSeed < Seeds.end (); ++iSeed) {
865+ if (perSeedCount[iSeed] == perSeedCount[iSeed + 1 ]) {
866+ continue ;
867+ }
868+ const CellSeed& seed{trackSeeds[iSeed]};
869+ auto & trk = tracks[perSeedCount[iSeed]] = TrackITSExt (seed);
870+ trk.resetCovariance ();
871+ trk.setChi2 (0 );
872+ for (int iL{0 }; iL < 7 ; ++iL) {
873+ trk.setExternalClusterIndex (iL, seed.getCluster (iL), seed.getCluster (iL) != constants::its::UnusedIndex);
874+ }
875+
876+ bool fitSuccess = fitTrack (trk, 0 , mTrkParams [0 ].NLayers , 1 , mTrkParams [0 ].MaxChi2ClusterAttachment , mTrkParams [0 ].MaxChi2NDF );
877+ if (!fitSuccess) {
878+ continue ;
879+ }
880+ trk.getParamOut () = trk.getParamIn ();
881+ trk.resetCovariance ();
882+ trk.setChi2 (0 );
883+ fitTrack (trk, mTrkParams [0 ].NLayers - 1 , -1 , -1 , mTrkParams [0 ].MaxChi2ClusterAttachment , mTrkParams [0 ].MaxChi2NDF , 50 .f );
884+ }
885+ });
866886
867887 tbb::parallel_sort (tracks.begin (), tracks.end (), [](const auto & a, const auto & b) {
868888 return a.getChi2 () < b.getChi2 ();
0 commit comments