diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index 436ce25336ca7..b324092624a6d 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -90,12 +90,14 @@ struct TimeFrame { int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span clusters, const dataformats::MCTruthContainer* mcLabels = nullptr); - int loadROFrameData(gsl::span rofs, + int loadROFrameData(gsl::span rofs, gsl::span clusters, gsl::span::iterator& pattIt, const itsmft::TopologyDictionary* dict, const dataformats::MCTruthContainer* mcLabels = nullptr); void resetROFrameData(size_t nROFs); + void prepareROFrameData(gsl::span rofs, + gsl::span clusters); int getTotalClusters() const; auto& getTotVertIteration() { return mTotVertPerIteration; } diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingInterface.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingInterface.h index 787f299e15888..491d2df4697ac 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingInterface.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingInterface.h @@ -78,7 +78,7 @@ class ITSTrackingInterface TimeFrameN* mTimeFrame = nullptr; protected: - virtual void loadROF(gsl::span& trackROFspan, + virtual void loadROF(gsl::span& trackROFspan, gsl::span clusters, gsl::span::iterator& pattIt, const dataformats::MCTruthContainer* mcLabels); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index 4ea0bedaced5f..ca28ee227df56 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -103,28 +103,17 @@ void TimeFrame::addPrimaryVerticesContributorLabelsInROF(const bounded_ } template -int TimeFrame::loadROFrameData(gsl::span rofs, +int TimeFrame::loadROFrameData(gsl::span rofs, gsl::span clusters, gsl::span::iterator& pattIt, const itsmft::TopologyDictionary* dict, const dataformats::MCTruthContainer* mcLabels) { - resetROFrameData(rofs.size()); - GeometryTGeo* geom = GeometryTGeo::Instance(); geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G)); - mNrof = rofs.size(); - clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get()); - std::array clusterCountPerLayer{}; - for (const auto& clus : clusters) { - ++clusterCountPerLayer[geom->getLayer(clus.getSensorID())]; - } - for (int iLayer{0}; iLayer < nLayers; ++iLayer) { - mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]); - mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]); - mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]); - } + resetROFrameData(rofs.size()); + prepareROFrameData(rofs, clusters); for (size_t iRof{0}; iRof < rofs.size(); ++iRof) { const auto& rof = rofs[iRof]; @@ -182,7 +171,7 @@ int TimeFrame::loadROFrameData(gsl::span rofs, } return mNrof; -} // namespace o2::its +} template void TimeFrame::resetROFrameData(size_t nRofs) @@ -201,6 +190,24 @@ void TimeFrame::resetROFrameData(size_t nRofs) } } +template +void TimeFrame::prepareROFrameData(gsl::span rofs, + gsl::span clusters) +{ + GeometryTGeo* geom = GeometryTGeo::Instance(); + mNrof = rofs.size(); + clearResizeBoundedVector(mClusterSize, clusters.size(), mMemoryPool.get()); + std::array clusterCountPerLayer{}; + for (const auto& clus : clusters) { + ++clusterCountPerLayer[geom->getLayer(clus.getSensorID())]; + } + for (int iLayer{0}; iLayer < nLayers; ++iLayer) { + mUnsortedClusters[iLayer].reserve(clusterCountPerLayer[iLayer]); + mTrackingFrameInfo[iLayer].reserve(clusterCountPerLayer[iLayer]); + mClusterExternalIndices[iLayer].reserve(clusterCountPerLayer[iLayer]); + } +} + template void TimeFrame::prepareClusters(const TrackingParameters& trkParam, const int maxLayers) { diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index f673d8f446350..d5f13cd9d25ea 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -139,11 +139,10 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) mTracker->setBz(o2::base::Propagator::Instance()->getNominalBz()); gsl::span::iterator pattIt = patterns.begin(); - - gsl::span trackROFspan(trackROFvec); + gsl::span trackROFspan(trackROFvec); loadROF(trackROFspan, compClusters, pattIt, labels); pattIt = patterns.begin(); - std::vector savedROF; + auto logger = [&](const std::string& s) { LOG(info) << s; }; auto fatalLogger = [&](const std::string& s) { LOG(fatal) << s; }; auto errorLogger = [&](const std::string& s) { LOG(error) << s; }; @@ -406,7 +405,7 @@ void ITSTrackingInterface::setTraitsFromProvider(VertexerTraitsN* vertexerTraits mVertexer->setMemoryPool(mMemoryPool); } -void ITSTrackingInterface::loadROF(gsl::span& trackROFspan, +void ITSTrackingInterface::loadROF(gsl::span& trackROFspan, gsl::span clusters, gsl::span::iterator& pattIt, const dataformats::MCTruthContainer* mcLabels) diff --git a/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h b/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h index 771b13539b759..fa15e73118524 100644 --- a/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h +++ b/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/IOUtils.h @@ -72,7 +72,7 @@ void convertCompactClusters(gsl::span clusters, const its3::TopologyDictionary* dict); int loadROFrameDataITS3(its::TimeFrame<7>* tf, - gsl::span rofs, + gsl::span rofs, gsl::span clusters, gsl::span::iterator& pattIt, const its3::TopologyDictionary* dict, diff --git a/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h b/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h index ab2ff0086200b..931628f2cf876 100644 --- a/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h +++ b/Detectors/Upgrades/ITS3/reconstruction/include/ITS3Reconstruction/TrackingInterface.h @@ -28,7 +28,7 @@ class ITS3TrackingInterface final : public its::ITSTrackingInterface void finaliseCCDB(framework::ConcreteDataMatcher& matcher, void* obj) final; protected: - void loadROF(gsl::span& trackROFspan, + void loadROF(gsl::span& trackROFspan, gsl::span clusters, gsl::span::iterator& pattIt, const dataformats::MCTruthContainer* mcLabels) final; diff --git a/Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx b/Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx index 2fced813efc93..8bfc7eedf2d6f 100644 --- a/Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx +++ b/Detectors/Upgrades/ITS3/reconstruction/src/IOUtils.cxx @@ -58,22 +58,22 @@ void convertCompactClusters(gsl::span clusters, } int loadROFrameDataITS3(its::TimeFrame<7>* tf, - gsl::span rofs, + gsl::span rofs, gsl::span clusters, gsl::span::iterator& pattIt, const its3::TopologyDictionary* dict, const dataformats::MCTruthContainer* mcLabels) { - tf->resetROFrameData(rofs.size()); - auto geom = its::GeometryTGeo::Instance(); geom->fillMatrixCache(o2::math_utils::bit2Mask(o2::math_utils::TransformType::T2L, o2::math_utils::TransformType::L2G)); - tf->mNrof = 0; + tf->resetROFrameData(rofs.size()); + tf->prepareROFrameData(rofs, clusters); its::bounded_vector clusterSizeVec(clusters.size(), tf->getMemoryPool().get()); - for (auto& rof : rofs) { + for (size_t iRof{0}; iRof < rofs.size(); ++iRof) { + const auto& rof = rofs[iRof]; for (int clusterId{rof.getFirstEntry()}; clusterId < rof.getFirstEntry() + rof.getNEntries(); ++clusterId) { auto& c = clusters[clusterId]; auto sensorID = c.getSensorID(); @@ -108,9 +108,8 @@ int loadROFrameDataITS3(its::TimeFrame<7>* tf, tf->addClusterExternalIndexToLayer(layer, clusterId); } for (unsigned int iL{0}; iL < tf->getUnsortedClusters().size(); ++iL) { - tf->mROFramesClusters[iL].push_back(tf->getUnsortedClusters()[iL].size()); + tf->mROFramesClusters[iL][iRof + 1] = tf->getUnsortedClusters()[iL].size(); } - tf->mNrof++; } tf->setClusterSize(clusterSizeVec); diff --git a/Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx b/Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx index 3d18ab267bd46..0f5c66a7f9663 100644 --- a/Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx +++ b/Detectors/Upgrades/ITS3/reconstruction/src/TrackingInterface.cxx @@ -74,7 +74,7 @@ void ITS3TrackingInterface::finaliseCCDB(framework::ConcreteDataMatcher& matcher } } -void ITS3TrackingInterface::loadROF(gsl::span& trackROFspan, +void ITS3TrackingInterface::loadROF(gsl::span& trackROFspan, gsl::span clusters, gsl::span::iterator& pattIt, const dataformats::MCTruthContainer* mcLabels)