From 03a9a271bedce65a9fd03112a201fde23112b8aa Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Fri, 12 Jul 2024 14:28:21 +0200 Subject: [PATCH 01/11] Add iteration structure --- .../GPU/ITStrackingGPU/VertexerTraitsGPU.h | 10 +-- .../tracking/GPU/cuda/VertexerTraitsGPU.cu | 42 ++++----- .../include/ITStracking/Configuration.h | 2 + .../tracking/include/ITStracking/TimeFrame.h | 6 +- .../include/ITStracking/TrackingConfigParam.h | 2 + .../tracking/include/ITStracking/Vertexer.h | 30 +++++-- .../include/ITStracking/VertexerTraits.h | 22 ++--- .../ITSMFT/ITS/tracking/src/TimeFrame.cxx | 1 + .../ITS/tracking/src/TrackingInterface.cxx | 16 +++- .../ITSMFT/ITS/tracking/src/Vertexer.cxx | 65 +++++++------- .../ITS/tracking/src/VertexerTraits.cxx | 89 ++++++++++--------- 11 files changed, 164 insertions(+), 121 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h index fda67bb619d37..cbf2364738538 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h +++ b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h @@ -42,11 +42,11 @@ class VertexerTraitsGPU : public VertexerTraits public: VertexerTraitsGPU(); ~VertexerTraitsGPU() override; - void initialise(const TrackingParameters&) override; + void initialise(const TrackingParameters&, const int& iteration = 0) override; void adoptTimeFrame(TimeFrame*) override; - void computeTracklets() override; - void computeTrackletMatching() override; - void computeVertices() override; + void computeTracklets(const int& iteration = 0) override; + void computeTrackletMatching(const int& iteration = 0) override; + void computeVertices(const int& iteration = 0) override; // Hybrid void initialiseHybrid(const TrackingParameters& pars) override { VertexerTraits::initialise(pars); } @@ -55,7 +55,7 @@ class VertexerTraitsGPU : public VertexerTraits void computeTrackletMatchingHybrid() override { VertexerTraits::computeTrackletMatching(); } void computeVerticesHybrid() override { VertexerTraits::computeVertices(); } - void updateVertexingParameters(const VertexingParameters&, const TimeFrameGPUParameters&) override; + void updateVertexingParameters(const std::vector&, const TimeFrameGPUParameters&) override; void computeVerticesHist(); diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu index 9a1ed507ae5a4..abc19529b8ba7 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu +++ b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu @@ -95,7 +95,7 @@ VertexerTraitsGPU::~VertexerTraitsGPU() { } -void VertexerTraitsGPU::initialise(const TrackingParameters& trackingParams) +void VertexerTraitsGPU::initialise(const TrackingParameters& trackingParams, const int& iteration) { mTimeFrameGPU->initialise(0, trackingParams, 3, &mIndexTableUtils, &mTfGPUParams); } @@ -595,17 +595,19 @@ GPUg() void computeVertexKernel( } } // namespace gpu -void VertexerTraitsGPU::updateVertexingParameters(const VertexingParameters& vrtPar, const TimeFrameGPUParameters& tfPar) +void VertexerTraitsGPU::updateVertexingParameters(const std::vector& vrtPar, const TimeFrameGPUParameters& tfPar) { mVrtParams = vrtPar; mTfGPUParams = tfPar; - mIndexTableUtils.setTrackingParameters(vrtPar); - mVrtParams.phiSpan = static_cast(std::ceil(mIndexTableUtils.getNphiBins() * mVrtParams.phiCut / - constants::math::TwoPi)); - mVrtParams.zSpan = static_cast(std::ceil(mVrtParams.zCut * mIndexTableUtils.getInverseZCoordinate(0))); + mVrtParams = vrtPar; + mIndexTableUtils.setTrackingParameters(vrtPar[0]); + for (auto& par : mVrtParams) { + par.phiSpan = static_cast(std::ceil(mIndexTableUtils.getNphiBins() * par.phiCut / constants::math::TwoPi)); + par.zSpan = static_cast(std::ceil(par.zCut * mIndexTableUtils.getInverseZCoordinate(0))); + } } -void VertexerTraitsGPU::computeTracklets() +void VertexerTraitsGPU::computeTracklets(const int& iteration) { if (!mTimeFrameGPU->getClusters().size()) { return; @@ -635,8 +637,8 @@ void VertexerTraitsGPU::computeTracklets() mTimeFrameGPU->getDeviceIndexTableUtils(), // const IndexTableUtils* utils, offset, // const unsigned int startRofId, rofs, // const unsigned int rofSize, - mVrtParams.phiCut, // const float phiCut, - mVrtParams.maxTrackletsPerCluster); // const size_t maxTrackletsPerCluster = 1e2 + mVrtParams[iteration].phiCut, // const float phiCut, + mVrtParams[iteration].maxTrackletsPerCluster); // const size_t maxTrackletsPerCluster = 1e2 gpu::trackleterKernelMultipleRof<<getStream(chunkId).get()>>>( mTimeFrameGPU->getChunk(chunkId).getDeviceClusters(2), // const Cluster* clustersNextLayer, // 0 2 @@ -649,8 +651,8 @@ void VertexerTraitsGPU::computeTracklets() mTimeFrameGPU->getDeviceIndexTableUtils(), // const IndexTableUtils* utils, offset, // const unsigned int startRofId, rofs, // const unsigned int rofSize, - mVrtParams.phiCut, // const float phiCut, - mVrtParams.maxTrackletsPerCluster); // const size_t maxTrackletsPerCluster = 1e2 + mVrtParams[iteration].phiCut, // const float phiCut, + mVrtParams[iteration].maxTrackletsPerCluster); // const size_t maxTrackletsPerCluster = 1e2 gpu::trackletSelectionKernelMultipleRof<<getStream(chunkId).get()>>>( mTimeFrameGPU->getChunk(chunkId).getDeviceClusters(0), // const Cluster* clusters0, // Clusters on layer 0 @@ -667,9 +669,9 @@ void VertexerTraitsGPU::computeTracklets() mTimeFrameGPU->getChunk(chunkId).getDeviceNExclusiveFoundLines(), // int* nExclusiveFoundLines, // Number of found lines exclusive scan offset, // const unsigned int startRofId, // Starting ROF ID rofs, // const unsigned int rofSize, // Number of ROFs to consider - mVrtParams.maxTrackletsPerCluster, // const int maxTrackletsPerCluster = 1e2, // Maximum number of tracklets per cluster - mVrtParams.tanLambdaCut, // const float tanLambdaCut = 0.025f, // Cut on tan lambda - mVrtParams.phiCut); // const float phiCut = 0.002f) // Cut on phi + mVrtParams[iteration].maxTrackletsPerCluster, // const int maxTrackletsPerCluster = 1e2, // Maximum number of tracklets per cluster + mVrtParams[iteration].tanLambdaCut, // const float tanLambdaCut = 0.025f, // Cut on tan lambda + mVrtParams[iteration].phiCut); // const float phiCut = 0.002f) // Cut on phi discardResult(cub::DeviceScan::ExclusiveSum(mTimeFrameGPU->getChunk(chunkId).getDeviceCUBTmpBuffer(), mTimeFrameGPU->getChunk(chunkId).getTimeFrameGPUParameters()->tmpCUBBufferSize, @@ -681,7 +683,7 @@ void VertexerTraitsGPU::computeTracklets() // Reset used tracklets checkGPUError(cudaMemsetAsync(mTimeFrameGPU->getChunk(chunkId).getDeviceUsedTracklets(), false, - sizeof(unsigned char) * mVrtParams.maxTrackletsPerCluster * mTimeFrameGPU->getTotalClustersPerROFrange(offset, rofs, 1), + sizeof(unsigned char) * mVrtParams[iteration].maxTrackletsPerCluster * mTimeFrameGPU->getTotalClustersPerROFrange(offset, rofs, 1), mTimeFrameGPU->getStream(chunkId).get()), __FILE__, __LINE__); @@ -700,9 +702,9 @@ void VertexerTraitsGPU::computeTracklets() mTimeFrameGPU->getChunk(chunkId).getDeviceNExclusiveFoundLines(), // int* nExclusiveFoundLines, // Number of found lines exclusive scan offset, // const unsigned int startRofId, // Starting ROF ID rofs, // const unsigned int rofSize, // Number of ROFs to consider - mVrtParams.maxTrackletsPerCluster, // const int maxTrackletsPerCluster = 1e2, // Maximum number of tracklets per cluster - mVrtParams.tanLambdaCut, // const float tanLambdaCut = 0.025f, // Cut on tan lambda - mVrtParams.phiCut); // const float phiCut = 0.002f) // Cut on phi + mVrtParams[iteration].maxTrackletsPerCluster, // const int maxTrackletsPerCluster = 1e2, // Maximum number of tracklets per cluster + mVrtParams[iteration].tanLambdaCut, // const float tanLambdaCut = 0.025f, // Cut on tan lambda + mVrtParams[iteration].phiCut); // const float phiCut = 0.002f) // Cut on phi int nClusters = mTimeFrameGPU->getTotalClustersPerROFrange(offset, rofs, 1); int lastFoundLines; @@ -767,11 +769,11 @@ void VertexerTraitsGPU::computeTracklets() mTimeFrameGPU->wipe(3); } -void VertexerTraitsGPU::computeTrackletMatching() +void VertexerTraitsGPU::computeTrackletMatching(const int& iteration) { } -void VertexerTraitsGPU::computeVertices() +void VertexerTraitsGPU::computeVertices(const int& iteration) { } diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index a700dc1e806c0..13ed2a05eef29 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -106,6 +106,8 @@ inline int TrackingParameters::CellMinimumLevel() } struct VertexingParameters { + bool nIterations = 1; // Number of vertexing passes to perform + int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; std::vector LayerZ = {16.333f + 1, 16.333f + 1, 16.333f + 1, 42.140f + 1, 42.140f + 1, 73.745f + 1, 73.745f + 1}; std::vector LayerRadii = {2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f}; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index 5d222e58f2586..4dd0a40716a6a 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -195,6 +195,7 @@ class TimeFrame uint32_t getTotalTrackletsTF(const int iLayer) { return mTotalTracklets[iLayer]; } int getTotalClustersPerROFrange(int rofMin, int range, int layerId) const; std::array& getBeamXY() { return mBeamPos; } + unsigned int& getNoVertexROF() { return mNoVertexROF; } // \Vertexer void initialiseRoadLabels(); @@ -220,7 +221,7 @@ class TimeFrame } } - virtual void setDevicePropagator(const o2::base::PropagatorImpl*){}; + virtual void setDevicePropagator(const o2::base::PropagatorImpl*) {}; const o2::base::PropagatorImpl* getDevicePropagator() const { return mPropagatorDevice; } template @@ -233,6 +234,7 @@ class TimeFrame void setExtAllocator(bool ext) { mExtAllocator = ext; } bool getExtAllocator() const { return mExtAllocator; } + /// Debug and printing void checkTrackletLUTs(); void printROFoffsets(); @@ -283,6 +285,8 @@ class TimeFrame private: float mBz = 5.; + unsigned int mNTotalLowPtVertices = 0; + unsigned int mNoVertexROF = 0; int mBeamPosWeight = 0; std::array mBeamPos = {0.f, 0.f}; bool isBeamPositionOverridden = false; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h index 36a5fd63b12d1..0b36066ee1b82 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h @@ -22,6 +22,8 @@ namespace its struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper { + bool nIterations = 1; // Number of vertexing passes to perform + int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; // geometrical cuts diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h index eb46c60305bda..c6d53b8aa8b4a 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h @@ -53,7 +53,8 @@ class Vertexer Vertexer& operator=(const Vertexer&) = delete; void adoptTimeFrame(TimeFrame& tf); - VertexingParameters& getVertParameters() const; + std::vector& getVertParameters() const; + void setParameters(std::vector& vertParams); void getGlobalConfiguration(); std::vector exportVertices(); @@ -62,8 +63,6 @@ class Vertexer float clustersToVertices(std::function = [](std::string s) { std::cout << s << std::endl; }); float clustersToVerticesHybrid(std::function = [](std::string s) { std::cout << s << std::endl; }); void filterMCTracklets(); - void validateTracklets(); - void validateTrackletsHybrid(); template void findTracklets(T&&... args); @@ -71,7 +70,11 @@ class Vertexer void findTrackletsHybrid(T&&... args); void findTrivialMCTracklets(); - void findVertices(); + template + void validateTracklets(T&&... args); + void validateTrackletsHybrid(); + template + void findVertices(T&&... args); void findVerticesHybrid(); void findHistVertices(); @@ -95,6 +98,8 @@ class Vertexer VertexerTraits* mTraits = nullptr; /// Observer pointer, not owned by this class TimeFrame* mTimeFrame = nullptr; /// Observer pointer, not owned by this class + + std::vector mVertParams; }; template @@ -109,24 +114,31 @@ void Vertexer::findTracklets(T&&... args) mTraits->computeTracklets(std::forward(args)...); } -inline VertexingParameters& Vertexer::getVertParameters() const +inline std::vector& Vertexer::getVertParameters() const { return mTraits->getVertexingParameters(); } +inline void Vertexer::setParameters(std::vector& vertParams) +{ + mTraits->setVertexingParameters(vertParams); +} + inline void Vertexer::dumpTraits() { mTraits->dumpVertexerTraits(); } -inline void Vertexer::validateTracklets() +template +inline void Vertexer::validateTracklets(T&&... args) { - mTraits->computeTrackletMatching(); + mTraits->computeTrackletMatching(std::forward(args)...); } -inline void Vertexer::findVertices() +template +inline void Vertexer::findVertices(T&&... args) { - mTraits->computeVertices(); + mTraits->computeVertices(std::forward(args)...); } template diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h index 365a24cfaee62..e745e62974142 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h @@ -62,12 +62,12 @@ class VertexerTraits GPUhd() static const int2 getPhiBins(float phi, float deltaPhi, const IndexTableUtils&); // virtual vertexer interface - virtual void initialise(const TrackingParameters& trackingParams); - virtual void computeTracklets(); - virtual void computeTrackletMatching(); - virtual void computeVertices(); + virtual void initialise(const TrackingParameters& trackingParams, const int& iteration = 0); + virtual void computeTracklets(const int& iteration = 0); + virtual void computeTrackletMatching(const int& iteration = 0); + virtual void computeVertices(const int& iteration = 0); virtual void adoptTimeFrame(TimeFrame* tf); - virtual void updateVertexingParameters(const VertexingParameters& vrtPar, const TimeFrameGPUParameters& gpuTfPar); + virtual void updateVertexingParameters(const std::vector& vrtPar, const TimeFrameGPUParameters& gpuTfPar); // Hybrid virtual void initialiseHybrid(const TrackingParameters& trackingParams) { initialise(trackingParams); }; virtual void computeTrackletsHybrid() { computeTracklets(); }; @@ -83,16 +83,18 @@ class VertexerTraits std::vector&, std::vector&, TimeFrame*, - std::vector*); + std::vector*, + const int& iteration = 0); static const std::vector> selectClusters(const int* indexTable, const std::array& selectedBinsRect, const IndexTableUtils& utils); // utils - VertexingParameters& getVertexingParameters() { return mVrtParams; } - VertexingParameters getVertexingParameters() const { return mVrtParams; } + std::vector& getVertexingParameters() { return mVrtParams; } + std::vector getVertexingParameters() const { return mVrtParams; } void setIsGPU(const unsigned char isgpu) { mIsGPU = isgpu; }; + void setVertexingParameters(std::vector& vertParams) { mVrtParams = vertParams; } unsigned char getIsGPU() const { return mIsGPU; }; void dumpVertexerTraits(); void setNThreads(int n); @@ -102,7 +104,7 @@ class VertexerTraits unsigned char mIsGPU; int mNThreads = 1; - VertexingParameters mVrtParams; + std::vector mVrtParams; IndexTableUtils mIndexTableUtils; std::vector mVertices; @@ -110,7 +112,7 @@ class VertexerTraits TimeFrame* mTimeFrame = nullptr; }; -inline void VertexerTraits::initialise(const TrackingParameters& trackingParams) +inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int& iteration) { mTimeFrame->initialise(0, trackingParams, 3); setIsGPU(false); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index 6e7114d9ca54d..64d7a1f2f42a0 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -251,6 +251,7 @@ int TimeFrame::getTotalClusters() const void TimeFrame::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers) { if (iteration == 0) { + mNoVertexROF = 0; if (maxLayers < trkParam.NLayers) { resetRofPV(); } diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 492976d164227..5e00fcc1ba1ea 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -33,6 +33,7 @@ void ITSTrackingInterface::initialise() { mRunVertexer = true; mCosmicsProcessing = false; + std::vector vertParams; std::vector trackParams; if (mMode == TrackingMode::Unset) { mMode = (TrackingMode)(o2::its::TrackerParamConfig::Instance().trackingMode); @@ -51,13 +52,19 @@ void ITSTrackingInterface::initialise() trackParams[2].TrackletMinPt = 0.1f; trackParams[2].CellDeltaTanLambdaSigma *= 4.; trackParams[2].MinTrackLength = 4; - LOG(info) << "Initializing tracker in async. phase reconstruction with " << trackParams.size() << " passes"; + LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes", trackParams.size()); + vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice + vertParams[1].phiCut = 0.015f; + vertParams[1].tanLambdaCut = 0.015f; + vertParams[1].vertPerRofThreshold = 0; + } else if (mMode == TrackingMode::Sync) { trackParams.resize(1); trackParams[0].ZBins = 64; trackParams[0].PhiBins = 32; trackParams[0].MinTrackLength = 4; - LOG(info) << "Initializing tracker in sync. phase reconstruction with " << trackParams.size() << " passes"; + LOGP(info, "Initializing tracker in sync. phase reconstruction with {} passes", trackParams.size()); + vertParams.resize(1); } else if (mMode == TrackingMode::Cosmics) { mCosmicsProcessing = true; mRunVertexer = false; @@ -71,7 +78,7 @@ void ITSTrackingInterface::initialise() trackParams[0].MaxChi2NDF = 40.; trackParams[0].TrackletsPerClusterLimit = 100.; trackParams[0].CellsPerClusterLimit = 100.; - LOG(info) << "Initializing tracker in reconstruction for cosmics with " << trackParams.size() << " passes"; + LOGP(info, "Initializing tracker in reconstruction for cosmics with {} passes", trackParams.size()); } else { throw std::runtime_error(fmt::format("Unsupported ITS tracking mode {:s} ", asString(mMode))); @@ -81,6 +88,7 @@ void ITSTrackingInterface::initialise() params.CorrType = o2::base::PropagatorImpl::MatCorrType::USEMatCorrLUT; } mTracker->setParameters(trackParams); + mVertexer->setParameters(vertParams); } template @@ -212,7 +220,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) } } LOG(info) << fmt::format(" - rejected {}/{} ROFs: random/mult.sel:{} (seed {}), vtx.sel:{}", cutRandomMult + cutVertexMult, rofspan.size(), cutRandomMult, multEst.lastRandomSeed, cutVertexMult); - LOG(info) << fmt::format(" - Vertex seeding total elapsed time: {} ms for {} vertices found in {} ROFs", vertexerElapsedTime, mTimeFrame->getPrimaryVerticesNum(), rofspan.size()); + LOG(info) << fmt::format(" - Vertex seeding total elapsed time: {} ms for {} vertices found in {}/{} ROFs", vertexerElapsedTime, mTimeFrame->getPrimaryVerticesNum(), rofspan.size() - mTimeFrame->getNoVertexROF(), rofspan.size()); if (mOverrideBeamEstimation) { LOG(info) << fmt::format(" - Beam position set to: {}, {} from meanvertex object", mTimeFrame->getBeamX(), mTimeFrame->getBeamY()); diff --git a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx index acc59a66a7c2c..d49800882325c 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx @@ -33,6 +33,7 @@ Vertexer::Vertexer(VertexerTraits* traits) if (!traits) { LOG(fatal) << "nullptr passed to ITS vertexer construction."; } + mVertParams.resize(1); mTraits = traits; } @@ -40,12 +41,14 @@ float Vertexer::clustersToVertices(std::function logger) { float total{0.f}; TrackingParameters trkPars; - trkPars.PhiBins = mTraits->getVertexingParameters().PhiBins; - trkPars.ZBins = mTraits->getVertexingParameters().ZBins; - total += evaluateTask(&Vertexer::initialiseVertexer, "Vertexer initialisation", logger, trkPars); - total += evaluateTask(&Vertexer::findTracklets, "Vertexer tracklet finding", logger); - total += evaluateTask(&Vertexer::validateTracklets, "Vertexer adjacent tracklets validation", logger); - total += evaluateTask(&Vertexer::findVertices, "Vertexer vertex finding", logger); + for (int iteration = 0; iteration < (int)mVertParams.size(); ++iteration) { + trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins; + trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins; + total += evaluateTask(&Vertexer::initialiseVertexer, "Vertexer initialisation", logger, trkPars, iteration); + total += evaluateTask(&Vertexer::findTracklets, "Vertexer tracklet finding", logger, iteration); + total += evaluateTask(&Vertexer::validateTracklets, "Vertexer adjacent tracklets validation", logger, iteration); + total += evaluateTask(&Vertexer::findVertices, "Vertexer vertex finding", logger, iteration); + } printEpilog(logger, total); return total; } @@ -54,8 +57,8 @@ float Vertexer::clustersToVerticesHybrid(std::function logg { float total{0.f}; TrackingParameters trkPars; - trkPars.PhiBins = mTraits->getVertexingParameters().PhiBins; - trkPars.ZBins = mTraits->getVertexingParameters().ZBins; + trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins; + trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins; total += evaluateTask(&Vertexer::initialiseVertexerHybrid, "Hybrid Vertexer initialisation", logger, trkPars); total += evaluateTask(&Vertexer::findTrackletsHybrid, "Hybrid Vertexer tracklet finding", logger); total += evaluateTask(&Vertexer::validateTrackletsHybrid, "Hybrid Vertexer adjacent tracklets validation", logger); @@ -69,31 +72,29 @@ void Vertexer::getGlobalConfiguration() auto& vc = o2::its::VertexerParamConfig::Instance(); vc.printKeyValues(true, true); auto& grc = o2::its::GpuRecoParamConfig::Instance(); - - VertexingParameters verPar; - verPar.allowSingleContribClusters = vc.allowSingleContribClusters; - verPar.zCut = vc.zCut; - verPar.phiCut = vc.phiCut; - verPar.pairCut = vc.pairCut; - verPar.clusterCut = vc.clusterCut; - verPar.histPairCut = vc.histPairCut; - verPar.tanLambdaCut = vc.tanLambdaCut; - verPar.lowMultBeamDistCut = vc.lowMultBeamDistCut; - verPar.vertNsigmaCut = vc.vertNsigmaCut; - verPar.vertRadiusSigma = vc.vertRadiusSigma; - verPar.trackletSigma = vc.trackletSigma; - verPar.maxZPositionAllowed = vc.maxZPositionAllowed; - verPar.clusterContributorsCut = vc.clusterContributorsCut; - verPar.maxTrackletsPerCluster = vc.maxTrackletsPerCluster; - verPar.phiSpan = vc.phiSpan; - verPar.nThreads = vc.nThreads; - verPar.ZBins = vc.ZBins; - verPar.PhiBins = vc.PhiBins; - + LOGP(info, "size of mVertParams: {}", mVertParams.size()); + for (auto& verPar : mVertParams) { + verPar.allowSingleContribClusters = vc.allowSingleContribClusters; + verPar.zCut = vc.zCut; + verPar.phiCut = vc.phiCut; + verPar.pairCut = vc.pairCut; + verPar.clusterCut = vc.clusterCut; + verPar.histPairCut = vc.histPairCut; + verPar.tanLambdaCut = vc.tanLambdaCut; + verPar.lowMultBeamDistCut = vc.lowMultBeamDistCut; + verPar.vertNsigmaCut = vc.vertNsigmaCut; + verPar.vertRadiusSigma = vc.vertRadiusSigma; + verPar.trackletSigma = vc.trackletSigma; + verPar.maxZPositionAllowed = vc.maxZPositionAllowed; + verPar.clusterContributorsCut = vc.clusterContributorsCut; + verPar.maxTrackletsPerCluster = vc.maxTrackletsPerCluster; + verPar.phiSpan = vc.phiSpan; + verPar.nThreads = vc.nThreads; + verPar.ZBins = vc.ZBins; + verPar.PhiBins = vc.PhiBins; + } TimeFrameGPUParameters tfGPUpar; - // tfGPUpar.nROFsPerChunk = grc.nROFsPerChunk; - - mTraits->updateVertexingParameters(verPar, tfGPUpar); + mTraits->updateVertexingParameters(mVertParams, tfGPUpar); } void Vertexer::adoptTimeFrame(TimeFrame& tf) diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index ceb5e4d0d44b7..ee7d414549139 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -158,17 +158,22 @@ const std::vector> VertexerTraits::selectClusters(const int* return filteredBins; } -void VertexerTraits::updateVertexingParameters(const VertexingParameters& vrtPar, const TimeFrameGPUParameters& tfPar) +void VertexerTraits::updateVertexingParameters(const std::vector& vrtPar, const TimeFrameGPUParameters& tfPar) { mVrtParams = vrtPar; - mIndexTableUtils.setTrackingParameters(vrtPar); - mVrtParams.phiSpan = static_cast(std::ceil(mIndexTableUtils.getNphiBins() * mVrtParams.phiCut / - constants::math::TwoPi)); - mVrtParams.zSpan = static_cast(std::ceil(mVrtParams.zCut * mIndexTableUtils.getInverseZCoordinate(0))); - setNThreads(mVrtParams.nThreads); + LOGP(info, "here1"); + mIndexTableUtils.setTrackingParameters(vrtPar[0]); + LOGP(info, "here2"); + for (auto& par : mVrtParams) { + par.phiSpan = static_cast(std::ceil(mIndexTableUtils.getNphiBins() * par.phiCut / constants::math::TwoPi)); + par.zSpan = static_cast(std::ceil(par.zCut * mIndexTableUtils.getInverseZCoordinate(0))); + } + LOGP(info, "here3"); + setNThreads(vrtPar[0].nThreads); + LOGP(info, "here4"); } -void VertexerTraits::computeTracklets() +void VertexerTraits::computeTracklets(const int& iteration) { #pragma omp parallel num_threads(mNThreads) { @@ -178,24 +183,24 @@ void VertexerTraits::computeTracklets() mTimeFrame->getClustersOnLayer(rofId, 0), mTimeFrame->getClustersOnLayer(rofId, 1), mTimeFrame->getIndexTable(rofId, 0).data(), - mVrtParams.phiCut, + mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[0], mTimeFrame->getNTrackletsCluster(rofId, 0), mIndexTableUtils, rofId, 0, - mVrtParams.maxTrackletsPerCluster); + mVrtParams[iteration].maxTrackletsPerCluster); trackleterKernelHost( mTimeFrame->getClustersOnLayer(rofId, 2), mTimeFrame->getClustersOnLayer(rofId, 1), mTimeFrame->getIndexTable(rofId, 2).data(), - mVrtParams.phiCut, + mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[1], mTimeFrame->getNTrackletsCluster(rofId, 1), mIndexTableUtils, rofId, 0, - mVrtParams.maxTrackletsPerCluster); + mVrtParams[iteration].maxTrackletsPerCluster); mTimeFrame->getNTrackletsROf(rofId, 0) = std::accumulate(mTimeFrame->getNTrackletsCluster(rofId, 0).begin(), mTimeFrame->getNTrackletsCluster(rofId, 0).end(), 0); mTimeFrame->getNTrackletsROf(rofId, 1) = std::accumulate(mTimeFrame->getNTrackletsCluster(rofId, 1).begin(), mTimeFrame->getNTrackletsCluster(rofId, 1).end(), 0); } @@ -212,24 +217,24 @@ void VertexerTraits::computeTracklets() mTimeFrame->getClustersOnLayer(rofId, 0), mTimeFrame->getClustersOnLayer(rofId, 1), mTimeFrame->getIndexTable(rofId, 0).data(), - mVrtParams.phiCut, + mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[0], mTimeFrame->getNTrackletsCluster(rofId, 0), mIndexTableUtils, rofId, mTimeFrame->getNTrackletsROf(rofId, 0), - mVrtParams.maxTrackletsPerCluster); + mVrtParams[iteration].maxTrackletsPerCluster); trackleterKernelHost( mTimeFrame->getClustersOnLayer(rofId, 2), mTimeFrame->getClustersOnLayer(rofId, 1), mTimeFrame->getIndexTable(rofId, 2).data(), - mVrtParams.phiCut, + mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[1], mTimeFrame->getNTrackletsCluster(rofId, 1), mIndexTableUtils, rofId, mTimeFrame->getNTrackletsROf(rofId, 1), - mVrtParams.maxTrackletsPerCluster); + mVrtParams[iteration].maxTrackletsPerCluster); } } @@ -292,7 +297,7 @@ void VertexerTraits::computeTracklets() #endif } // namespace its -void VertexerTraits::computeTrackletMatching() +void VertexerTraits::computeTrackletMatching(const int& iteration) { #pragma omp parallel for num_threads(mNThreads) schedule(dynamic) for (int rofId = 0; rofId < mTimeFrame->getNrof(); ++rofId) { @@ -307,8 +312,8 @@ void VertexerTraits::computeTrackletMatching() mTimeFrame->getLines(rofId), mTimeFrame->getLabelsFoundTracklets(rofId, 0), mTimeFrame->getLinesLabel(rofId), - mVrtParams.tanLambdaCut, - mVrtParams.phiCut); + mVrtParams[iteration].tanLambdaCut, + mVrtParams[iteration].phiCut); } #ifdef VTX_DEBUG @@ -342,10 +347,10 @@ void VertexerTraits::computeTrackletMatching() #endif } -void VertexerTraits::computeVertices() +void VertexerTraits::computeVertices(const int& iteration) { - auto nsigmaCut{std::min(mVrtParams.vertNsigmaCut * mVrtParams.vertNsigmaCut * (mVrtParams.vertRadiusSigma * mVrtParams.vertRadiusSigma + mVrtParams.trackletSigma * mVrtParams.trackletSigma), 1.98f)}; + auto nsigmaCut{std::min(mVrtParams[iteration].vertNsigmaCut * mVrtParams[iteration].vertNsigmaCut * (mVrtParams[iteration].vertRadiusSigma * mVrtParams[iteration].vertRadiusSigma + mVrtParams[iteration].trackletSigma * mVrtParams[iteration].trackletSigma), 1.98f)}; std::vector vertices; #ifdef VTX_DEBUG std::vector> dbg_clusLines(mTimeFrame->getNrof()); @@ -364,7 +369,7 @@ void VertexerTraits::computeVertices() continue; } auto dca{Line::getDCA(mTimeFrame->getLines(rofId)[line1], mTimeFrame->getLines(rofId)[line2])}; - if (dca < mVrtParams.pairCut) { + if (dca < mVrtParams[iteration].pairCut) { mTimeFrame->getTrackletClusters(rofId).emplace_back(line1, mTimeFrame->getLines(rofId)[line1], line2, mTimeFrame->getLines(rofId)[line2]); std::array tmpVertex{mTimeFrame->getTrackletClusters(rofId).back().getVertex()}; if (tmpVertex[0] * tmpVertex[0] + tmpVertex[1] * tmpVertex[1] > 4.f) { @@ -377,7 +382,7 @@ void VertexerTraits::computeVertices() if (usedTracklets[tracklet3]) { continue; } - if (Line::getDistanceFromPoint(mTimeFrame->getLines(rofId)[tracklet3], tmpVertex) < mVrtParams.pairCut) { + if (Line::getDistanceFromPoint(mTimeFrame->getLines(rofId)[tracklet3], tmpVertex) < mVrtParams[iteration].pairCut) { mTimeFrame->getTrackletClusters(rofId).back().add(tracklet3, mTimeFrame->getLines(rofId)[tracklet3]); usedTracklets[tracklet3] = true; tmpVertex = mTimeFrame->getTrackletClusters(rofId).back().getVertex(); @@ -387,12 +392,12 @@ void VertexerTraits::computeVertices() } } } - if (mVrtParams.allowSingleContribClusters) { + if (mVrtParams[iteration].allowSingleContribClusters) { auto beamLine = Line{{mTimeFrame->getBeamX(), mTimeFrame->getBeamY(), -50.f}, {mTimeFrame->getBeamX(), mTimeFrame->getBeamY(), 50.f}}; // use beam position as contributor for (size_t iLine{0}; iLine < numTracklets; ++iLine) { if (!usedTracklets[iLine]) { auto dca = Line::getDCA(mTimeFrame->getLines(rofId)[iLine], beamLine); - if (dca < mVrtParams.pairCut) { + if (dca < mVrtParams[iteration].pairCut) { mTimeFrame->getTrackletClusters(rofId).emplace_back(iLine, mTimeFrame->getLines(rofId)[iLine], -1, beamLine); // beamline must be passed as second line argument } } @@ -408,11 +413,11 @@ void VertexerTraits::computeVertices() std::array vertex2{}; for (int iCluster2{iCluster1 + 1}; iCluster2 < noClustersVec[rofId]; ++iCluster2) { vertex2 = mTimeFrame->getTrackletClusters(rofId)[iCluster2].getVertex(); - if (std::abs(vertex1[2] - vertex2[2]) < mVrtParams.clusterCut) { + if (std::abs(vertex1[2] - vertex2[2]) < mVrtParams[iteration].clusterCut) { float distance{(vertex1[0] - vertex2[0]) * (vertex1[0] - vertex2[0]) + (vertex1[1] - vertex2[1]) * (vertex1[1] - vertex2[1]) + (vertex1[2] - vertex2[2]) * (vertex1[2] - vertex2[2])}; - if (distance < mVrtParams.pairCut * mVrtParams.pairCut) { + if (distance < mVrtParams[iteration].pairCut * mVrtParams[iteration].pairCut) { for (auto label : mTimeFrame->getTrackletClusters(rofId)[iCluster2].getLabels()) { mTimeFrame->getTrackletClusters(rofId)[iCluster1].add(label, mTimeFrame->getLines(rofId)[label]); vertex1 = mTimeFrame->getTrackletClusters(rofId)[iCluster1].getVertex(); @@ -439,8 +444,8 @@ void VertexerTraits::computeVertices() bool lowMultCandidate{false}; double beamDistance2{(mTimeFrame->getBeamX() - mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[0]) * (mTimeFrame->getBeamX() - mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[0]) + (mTimeFrame->getBeamY() - mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[1]) * (mTimeFrame->getBeamY() - mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[1])}; - if (atLeastOneFound && (lowMultCandidate = mTimeFrame->getTrackletClusters(rofId)[iCluster].getSize() < mVrtParams.clusterContributorsCut)) { // We might have pile up with nContr > cut. - lowMultCandidate &= (beamDistance2 < mVrtParams.lowMultBeamDistCut * mVrtParams.lowMultBeamDistCut); + if (atLeastOneFound && (lowMultCandidate = mTimeFrame->getTrackletClusters(rofId)[iCluster].getSize() < mVrtParams[iteration].clusterContributorsCut)) { // We might have pile up with nContr > cut. + lowMultCandidate &= (beamDistance2 < mVrtParams[iteration].lowMultBeamDistCut * mVrtParams[iteration].lowMultBeamDistCut); if (!lowMultCandidate) { // Not the first cluster and not a low multiplicity candidate, we can remove it mTimeFrame->getTrackletClusters(rofId).erase(mTimeFrame->getTrackletClusters(rofId).begin() + iCluster); noClustersVec[rofId]--; @@ -448,7 +453,7 @@ void VertexerTraits::computeVertices() } } - if (beamDistance2 < nsigmaCut && std::abs(mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[2]) < mVrtParams.maxZPositionAllowed) { + if (beamDistance2 < nsigmaCut && std::abs(mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[2]) < mVrtParams[iteration].maxZPositionAllowed) { atLeastOneFound = true; vertices.emplace_back(o2::math_utils::Point3D(mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[0], mTimeFrame->getTrackletClusters(rofId)[iCluster].getVertex()[1], @@ -468,6 +473,9 @@ void VertexerTraits::computeVertices() } } mTimeFrame->addPrimaryVertices(vertices); + if (!vertices.size()) { + mTimeFrame->getNoVertexROF()++; + } } #ifdef VTX_DEBUG TFile* dbg_file = TFile::Open("artefacts_tf.root", "update"); @@ -511,10 +519,11 @@ void VertexerTraits::computeVerticesInRof(int rofId, std::vector& vertices, std::vector& verticesInRof, TimeFrame* tf, - std::vector* labels) + std::vector* labels, + const int& iteration) { int foundVertices{0}; - auto nsigmaCut{std::min(mVrtParams.vertNsigmaCut * mVrtParams.vertNsigmaCut * (mVrtParams.vertRadiusSigma * mVrtParams.vertRadiusSigma + mVrtParams.trackletSigma * mVrtParams.trackletSigma), 1.98f)}; + auto nsigmaCut{std::min(mVrtParams[iteration].vertNsigmaCut * mVrtParams[iteration].vertNsigmaCut * (mVrtParams[iteration].vertRadiusSigma * mVrtParams[iteration].vertRadiusSigma + mVrtParams[iteration].trackletSigma * mVrtParams[iteration].trackletSigma), 1.98f)}; const int numTracklets{static_cast(lines.size())}; for (int line1{0}; line1 < numTracklets; ++line1) { if (usedLines[line1]) { @@ -525,7 +534,7 @@ void VertexerTraits::computeVerticesInRof(int rofId, continue; } auto dca{Line::getDCA(lines[line1], lines[line2])}; - if (dca < mVrtParams.pairCut) { + if (dca < mVrtParams[iteration].pairCut) { clusterLines.emplace_back(line1, lines[line1], line2, lines[line2]); std::array tmpVertex{clusterLines.back().getVertex()}; if (tmpVertex[0] * tmpVertex[0] + tmpVertex[1] * tmpVertex[1] > 4.f) { @@ -538,7 +547,7 @@ void VertexerTraits::computeVerticesInRof(int rofId, if (usedLines[tracklet3]) { continue; } - if (Line::getDistanceFromPoint(lines[tracklet3], tmpVertex) < mVrtParams.pairCut) { + if (Line::getDistanceFromPoint(lines[tracklet3], tmpVertex) < mVrtParams[iteration].pairCut) { clusterLines.back().add(tracklet3, lines[tracklet3]); usedLines[tracklet3] = true; tmpVertex = clusterLines.back().getVertex(); @@ -549,12 +558,12 @@ void VertexerTraits::computeVerticesInRof(int rofId, } } - if (mVrtParams.allowSingleContribClusters) { + if (mVrtParams[iteration].allowSingleContribClusters) { auto beamLine = Line{{tf->getBeamX(), tf->getBeamY(), -50.f}, {tf->getBeamX(), tf->getBeamY(), 50.f}}; // use beam position as contributor for (size_t iLine{0}; iLine < numTracklets; ++iLine) { if (!usedLines[iLine]) { auto dca = Line::getDCA(lines[iLine], beamLine); - if (dca < mVrtParams.pairCut) { + if (dca < mVrtParams[iteration].pairCut) { clusterLines.emplace_back(iLine, lines[iLine], -1, beamLine); // beamline must be passed as second line argument } } @@ -569,11 +578,11 @@ void VertexerTraits::computeVerticesInRof(int rofId, std::array vertex2{}; for (int iCluster2{iCluster1 + 1}; iCluster2 < nClusters; ++iCluster2) { vertex2 = clusterLines[iCluster2].getVertex(); - if (std::abs(vertex1[2] - vertex2[2]) < mVrtParams.clusterCut) { + if (std::abs(vertex1[2] - vertex2[2]) < mVrtParams[iteration].clusterCut) { float distance{(vertex1[0] - vertex2[0]) * (vertex1[0] - vertex2[0]) + (vertex1[1] - vertex2[1]) * (vertex1[1] - vertex2[1]) + (vertex1[2] - vertex2[2]) * (vertex1[2] - vertex2[2])}; - if (distance < mVrtParams.pairCut * mVrtParams.pairCut) { + if (distance < mVrtParams[iteration].pairCut * mVrtParams[iteration].pairCut) { for (auto label : clusterLines[iCluster2].getLabels()) { clusterLines[iCluster1].add(label, lines[label]); vertex1 = clusterLines[iCluster1].getVertex(); @@ -594,15 +603,15 @@ void VertexerTraits::computeVerticesInRof(int rofId, double beamDistance2{(tf->getBeamX() - clusterLines[iCluster].getVertex()[0]) * (tf->getBeamX() - clusterLines[iCluster].getVertex()[0]) + (tf->getBeamY() - clusterLines[iCluster].getVertex()[1]) * (tf->getBeamY() - clusterLines[iCluster].getVertex()[1])}; - if (atLeastOneFound && (lowMultCandidate = clusterLines[iCluster].getSize() < mVrtParams.clusterContributorsCut)) { // We might have pile up with nContr > cut. - lowMultCandidate &= (beamDistance2 < mVrtParams.lowMultBeamDistCut * mVrtParams.lowMultBeamDistCut); + if (atLeastOneFound && (lowMultCandidate = clusterLines[iCluster].getSize() < mVrtParams[iteration].clusterContributorsCut)) { // We might have pile up with nContr > cut. + lowMultCandidate &= (beamDistance2 < mVrtParams[iteration].lowMultBeamDistCut * mVrtParams[iteration].lowMultBeamDistCut); if (!lowMultCandidate) { // Not the first cluster and not a low multiplicity candidate, we can remove it clusterLines.erase(clusterLines.begin() + iCluster); nClusters--; continue; } } - if (beamDistance2 < nsigmaCut && std::abs(clusterLines[iCluster].getVertex()[2]) < mVrtParams.maxZPositionAllowed) { + if (beamDistance2 < nsigmaCut && std::abs(clusterLines[iCluster].getVertex()[2]) < mVrtParams[iteration].maxZPositionAllowed) { atLeastOneFound = true; ++foundVertices; vertices.emplace_back(o2::math_utils::Point3D(clusterLines[iCluster].getVertex()[0], From 43904777fa10d41481bc455b4eb7ffbe3f5ae0a5 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Fri, 12 Jul 2024 18:39:33 +0200 Subject: [PATCH 02/11] Overrule size of vector param with specific config value, for pp/PbPb --- .../ITS/tracking/include/ITStracking/Configuration.h | 2 +- .../ITS/tracking/include/ITStracking/TrackerTraits.h | 1 + .../tracking/include/ITStracking/TrackingConfigParam.h | 2 +- .../ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h | 2 +- Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 1 + Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx | 5 ++--- Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx | 8 ++++---- Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx | 4 ---- 8 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index 13ed2a05eef29..0e072bb632046 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -106,7 +106,7 @@ inline int TrackingParameters::CellMinimumLevel() } struct VertexingParameters { - bool nIterations = 1; // Number of vertexing passes to perform + int nIterations = 1; // Number of vertexing passes to perform int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; std::vector LayerZ = {16.333f + 1, 16.333f + 1, 16.333f + 1, 42.140f + 1, 42.140f + 1, 73.745f + 1, 73.745f + 1}; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h index 1930bc8761c66..3f811e8f9f776 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h @@ -120,6 +120,7 @@ inline float TrackerTraits::getBz() const inline void TrackerTraits::UpdateTrackingParameters(const std::vector& trkPars) { mTrkParams = trkPars; + LOGP(info, "TrackerTraits::updateTrackingParameters size of pars is {}", mTrkParams.size()); } inline const int4 TrackerTraits::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z, float maxdeltaz) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h index 0b36066ee1b82..b83e56de3c12c 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h @@ -22,7 +22,7 @@ namespace its struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper { - bool nIterations = 1; // Number of vertexing passes to perform + int nIterations = 1; // Number of vertexing passes to perform int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h index c6d53b8aa8b4a..f9f817d3de220 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Vertexer.h @@ -121,7 +121,7 @@ inline std::vector& Vertexer::getVertParameters() const inline void Vertexer::setParameters(std::vector& vertParams) { - mTraits->setVertexingParameters(vertParams); + mVertParams = vertParams; } inline void Vertexer::dumpTraits() diff --git a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx index 42df15b24f052..4ccc53b1bdbfe 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx @@ -454,6 +454,7 @@ void Tracker::rectifyClusterIndices() void Tracker::getGlobalConfiguration() { + LOGP(info, "tracker::getGlobalConfiguration size of pars is {}", mTrkParams.size()); auto& tc = o2::its::TrackerParamConfig::Instance(); tc.printKeyValues(true, true); if (tc.useMatCorrTGeo) { diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 5e00fcc1ba1ea..4049fd1f57e59 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -41,6 +41,7 @@ void ITSTrackingInterface::initialise() } if (mMode == TrackingMode::Async) { trackParams.resize(3); + vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice for (auto& param : trackParams) { param.ZBins = 64; param.PhiBins = 32; @@ -52,12 +53,10 @@ void ITSTrackingInterface::initialise() trackParams[2].TrackletMinPt = 0.1f; trackParams[2].CellDeltaTanLambdaSigma *= 4.; trackParams[2].MinTrackLength = 4; - LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes", trackParams.size()); - vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice + LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(), vertParams[0].nIterations, vertParams.size()); vertParams[1].phiCut = 0.015f; vertParams[1].tanLambdaCut = 0.015f; vertParams[1].vertPerRofThreshold = 0; - } else if (mMode == TrackingMode::Sync) { trackParams.resize(1); trackParams[0].ZBins = 64; diff --git a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx index d49800882325c..19240a38a0e8b 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx @@ -41,7 +41,10 @@ float Vertexer::clustersToVertices(std::function logger) { float total{0.f}; TrackingParameters trkPars; - for (int iteration = 0; iteration < (int)mVertParams.size(); ++iteration) { + TimeFrameGPUParameters tfGPUpar; + mTraits->updateVertexingParameters(mVertParams, tfGPUpar); + for (int iteration = 0; iteration < std::min(mVertParams[0].nIterations, (int)mVertParams.size()); ++iteration) { + logger(fmt::format("ITS Seeding vertexer iteration {} summary:", iteration)); trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins; trkPars.ZBins = mTraits->getVertexingParameters()[0].ZBins; total += evaluateTask(&Vertexer::initialiseVertexer, "Vertexer initialisation", logger, trkPars, iteration); @@ -72,7 +75,6 @@ void Vertexer::getGlobalConfiguration() auto& vc = o2::its::VertexerParamConfig::Instance(); vc.printKeyValues(true, true); auto& grc = o2::its::GpuRecoParamConfig::Instance(); - LOGP(info, "size of mVertParams: {}", mVertParams.size()); for (auto& verPar : mVertParams) { verPar.allowSingleContribClusters = vc.allowSingleContribClusters; verPar.zCut = vc.zCut; @@ -93,8 +95,6 @@ void Vertexer::getGlobalConfiguration() verPar.ZBins = vc.ZBins; verPar.PhiBins = vc.PhiBins; } - TimeFrameGPUParameters tfGPUpar; - mTraits->updateVertexingParameters(mVertParams, tfGPUpar); } void Vertexer::adoptTimeFrame(TimeFrame& tf) diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index ee7d414549139..4a101f8427ba7 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -161,16 +161,12 @@ const std::vector> VertexerTraits::selectClusters(const int* void VertexerTraits::updateVertexingParameters(const std::vector& vrtPar, const TimeFrameGPUParameters& tfPar) { mVrtParams = vrtPar; - LOGP(info, "here1"); mIndexTableUtils.setTrackingParameters(vrtPar[0]); - LOGP(info, "here2"); for (auto& par : mVrtParams) { par.phiSpan = static_cast(std::ceil(mIndexTableUtils.getNphiBins() * par.phiCut / constants::math::TwoPi)); par.zSpan = static_cast(std::ceil(par.zCut * mIndexTableUtils.getInverseZCoordinate(0))); } - LOGP(info, "here3"); setNThreads(vrtPar[0].nThreads); - LOGP(info, "here4"); } void VertexerTraits::computeTracklets(const int& iteration) From 0d689dda9a857e552e0747500f56d787c0fe797e Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Tue, 16 Jul 2024 10:49:02 +0200 Subject: [PATCH 03/11] Propagate CKVals only to the first iteration --- .../include/ITStracking/TrackerTraits.h | 1 - .../ITS/tracking/src/TrackingInterface.cxx | 2 +- .../ITSMFT/ITS/tracking/src/Vertexer.cxx | 43 ++++++++++--------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h index 3f811e8f9f776..1930bc8761c66 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h @@ -120,7 +120,6 @@ inline float TrackerTraits::getBz() const inline void TrackerTraits::UpdateTrackingParameters(const std::vector& trkPars) { mTrkParams = trkPars; - LOGP(info, "TrackerTraits::updateTrackingParameters size of pars is {}", mTrkParams.size()); } inline const int4 TrackerTraits::getBinsRect(const int layerIndex, float phi, float maxdeltaphi, float z, float maxdeltaz) diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 4049fd1f57e59..9bcd55f89e8ac 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -53,7 +53,7 @@ void ITSTrackingInterface::initialise() trackParams[2].TrackletMinPt = 0.1f; trackParams[2].CellDeltaTanLambdaSigma *= 4.; trackParams[2].MinTrackLength = 4; - LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(), vertParams[0].nIterations, vertParams.size()); + LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(), o2::its::VertexerParamConfig::Instance().nIterations, vertParams.size()); vertParams[1].phiCut = 0.015f; vertParams[1].tanLambdaCut = 0.015f; vertParams[1].vertPerRofThreshold = 0; diff --git a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx index 19240a38a0e8b..89cd74454c5d5 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx @@ -43,6 +43,7 @@ float Vertexer::clustersToVertices(std::function logger) TrackingParameters trkPars; TimeFrameGPUParameters tfGPUpar; mTraits->updateVertexingParameters(mVertParams, tfGPUpar); + LOGP(info, "[1].phiCut {} [1].tanLambdaCut {}", mVertParams[1].phiCut, mVertParams[1].tanLambdaCut); for (int iteration = 0; iteration < std::min(mVertParams[0].nIterations, (int)mVertParams.size()); ++iteration) { logger(fmt::format("ITS Seeding vertexer iteration {} summary:", iteration)); trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins; @@ -75,26 +76,28 @@ void Vertexer::getGlobalConfiguration() auto& vc = o2::its::VertexerParamConfig::Instance(); vc.printKeyValues(true, true); auto& grc = o2::its::GpuRecoParamConfig::Instance(); - for (auto& verPar : mVertParams) { - verPar.allowSingleContribClusters = vc.allowSingleContribClusters; - verPar.zCut = vc.zCut; - verPar.phiCut = vc.phiCut; - verPar.pairCut = vc.pairCut; - verPar.clusterCut = vc.clusterCut; - verPar.histPairCut = vc.histPairCut; - verPar.tanLambdaCut = vc.tanLambdaCut; - verPar.lowMultBeamDistCut = vc.lowMultBeamDistCut; - verPar.vertNsigmaCut = vc.vertNsigmaCut; - verPar.vertRadiusSigma = vc.vertRadiusSigma; - verPar.trackletSigma = vc.trackletSigma; - verPar.maxZPositionAllowed = vc.maxZPositionAllowed; - verPar.clusterContributorsCut = vc.clusterContributorsCut; - verPar.maxTrackletsPerCluster = vc.maxTrackletsPerCluster; - verPar.phiSpan = vc.phiSpan; - verPar.nThreads = vc.nThreads; - verPar.ZBins = vc.ZBins; - verPar.PhiBins = vc.PhiBins; - } + + // This is odd: we override only the parameters for the first iteration. + // Variations for the next iterations are set in the trackingInterfrace. + mVertParams[0].nIterations = vc.nIterations; + mVertParams[0].allowSingleContribClusters = vc.allowSingleContribClusters; + mVertParams[0].zCut = vc.zCut; + mVertParams[0].phiCut = vc.phiCut; + mVertParams[0].pairCut = vc.pairCut; + mVertParams[0].clusterCut = vc.clusterCut; + mVertParams[0].histPairCut = vc.histPairCut; + mVertParams[0].tanLambdaCut = vc.tanLambdaCut; + mVertParams[0].lowMultBeamDistCut = vc.lowMultBeamDistCut; + mVertParams[0].vertNsigmaCut = vc.vertNsigmaCut; + mVertParams[0].vertRadiusSigma = vc.vertRadiusSigma; + mVertParams[0].trackletSigma = vc.trackletSigma; + mVertParams[0].maxZPositionAllowed = vc.maxZPositionAllowed; + mVertParams[0].clusterContributorsCut = vc.clusterContributorsCut; + mVertParams[0].maxTrackletsPerCluster = vc.maxTrackletsPerCluster; + mVertParams[0].phiSpan = vc.phiSpan; + mVertParams[0].nThreads = vc.nThreads; + mVertParams[0].ZBins = vc.ZBins; + mVertParams[0].PhiBins = vc.PhiBins; } void Vertexer::adoptTimeFrame(TimeFrame& tf) From 4f7ff9bf4000cd98226f6543337fb70303916ddc Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 17 Jul 2024 12:02:31 +0200 Subject: [PATCH 04/11] Add UPC vertices to the output --- .../tracking/include/ITStracking/TimeFrame.h | 3 +- .../include/ITStracking/VertexerTraits.h | 2 +- .../ITSMFT/ITS/tracking/src/TimeFrame.cxx | 16 +++++++-- .../ITSMFT/ITS/tracking/src/Vertexer.cxx | 1 - .../ITS/tracking/src/VertexerTraits.cxx | 35 +++++++++++++------ 5 files changed, 41 insertions(+), 16 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index 4dd0a40716a6a..cc549d8ff5728 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -87,6 +87,7 @@ class TimeFrame void addPrimaryVertices(const std::vector& vertices); void addPrimaryVertices(const gsl::span& vertices); void addPrimaryVertices(const std::vector&); + void addPrimaryVerticesInROF(const std::vector& vertices, const int& rofId); void removePrimaryVerticesInROf(const int rofId); int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span clusters, const dataformats::MCTruthContainer* mcLabels = nullptr); @@ -143,7 +144,7 @@ class TimeFrame std::vector& getCellsLabel(int layer) { return mCellLabels[layer]; } bool hasMCinformation() const; - void initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers = 7); + void initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers = 7, bool resetVertices = true); void resetRofPV() { mPrimaryVertices.clear(); diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h index e745e62974142..23731a49b1593 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h @@ -114,7 +114,7 @@ class VertexerTraits inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int& iteration) { - mTimeFrame->initialise(0, trackingParams, 3); + mTimeFrame->initialise(0, trackingParams, 3, (bool)(!iteration)); // iteration for initialisation must be 0 for correctly resetting the frame, we need to pass the non-reset flag for vertices as well, tho. setIsGPU(false); } diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index 64d7a1f2f42a0..f81ede131b660 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -92,6 +92,14 @@ void TimeFrame::addPrimaryVertices(const std::vector& vertices) mROframesPV.push_back(mPrimaryVertices.size()); } +void TimeFrame::addPrimaryVerticesInROF(const std::vector& vertices, const int& rofId) +{ + mPrimaryVertices.insert(mPrimaryVertices.begin() + mROframesPV[rofId], vertices.begin(), vertices.end()); + for (int i = rofId + 1; i < mROframesPV.size(); ++i) { + mROframesPV[i] += vertices.size(); + } +} + void TimeFrame::addPrimaryVertices(const gsl::span& vertices) { for (const auto& vertex : vertices) { @@ -248,17 +256,19 @@ int TimeFrame::getTotalClusters() const return int(totalClusters); } -void TimeFrame::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers) +void TimeFrame::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers, bool resetVertices) { if (iteration == 0) { mNoVertexROF = 0; - if (maxLayers < trkParam.NLayers) { + if (maxLayers < trkParam.NLayers && resetVertices) { resetRofPV(); } deepVectorClear(mTracks); deepVectorClear(mTracksLabel); deepVectorClear(mLinesLabels); - deepVectorClear(mVerticesLabels); + if (resetVertices) { + deepVectorClear(mVerticesLabels); + } mTracks.resize(mNrof); mTracksLabel.resize(mNrof); mLinesLabels.resize(mNrof); diff --git a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx index 89cd74454c5d5..8bfe04e87edaf 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Vertexer.cxx @@ -43,7 +43,6 @@ float Vertexer::clustersToVertices(std::function logger) TrackingParameters trkPars; TimeFrameGPUParameters tfGPUpar; mTraits->updateVertexingParameters(mVertParams, tfGPUpar); - LOGP(info, "[1].phiCut {} [1].tanLambdaCut {}", mVertParams[1].phiCut, mVertParams[1].tanLambdaCut); for (int iteration = 0; iteration < std::min(mVertParams[0].nIterations, (int)mVertParams.size()); ++iteration) { logger(fmt::format("ITS Seeding vertexer iteration {} summary:", iteration)); trkPars.PhiBins = mTraits->getVertexingParameters()[0].PhiBins; diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index 4a101f8427ba7..63d19fd7bcd62 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -175,9 +175,10 @@ void VertexerTraits::computeTracklets(const int& iteration) { #pragma omp for schedule(dynamic) for (int rofId = 0; rofId < mTimeFrame->getNrof(); ++rofId) { + bool skipROF = iteration && (int)mTimeFrame->getPrimaryVertices(rofId).size() > mVrtParams[iteration].vertPerRofThreshold; trackleterKernelHost( - mTimeFrame->getClustersOnLayer(rofId, 0), - mTimeFrame->getClustersOnLayer(rofId, 1), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 0) : gsl::span(), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 1) : gsl::span(), mTimeFrame->getIndexTable(rofId, 0).data(), mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[0], @@ -187,8 +188,8 @@ void VertexerTraits::computeTracklets(const int& iteration) 0, mVrtParams[iteration].maxTrackletsPerCluster); trackleterKernelHost( - mTimeFrame->getClustersOnLayer(rofId, 2), - mTimeFrame->getClustersOnLayer(rofId, 1), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 2) : gsl::span(), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 1) : gsl::span(), mTimeFrame->getIndexTable(rofId, 2).data(), mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[1], @@ -209,9 +210,10 @@ void VertexerTraits::computeTracklets(const int& iteration) #pragma omp for schedule(dynamic) for (int rofId = 0; rofId < mTimeFrame->getNrof(); ++rofId) { + bool skipROF = iteration && (int)mTimeFrame->getPrimaryVertices(rofId).size() > mVrtParams[iteration].vertPerRofThreshold; trackleterKernelHost( - mTimeFrame->getClustersOnLayer(rofId, 0), - mTimeFrame->getClustersOnLayer(rofId, 1), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 0) : gsl::span(), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 1) : gsl::span(), mTimeFrame->getIndexTable(rofId, 0).data(), mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[0], @@ -221,8 +223,8 @@ void VertexerTraits::computeTracklets(const int& iteration) mTimeFrame->getNTrackletsROf(rofId, 0), mVrtParams[iteration].maxTrackletsPerCluster); trackleterKernelHost( - mTimeFrame->getClustersOnLayer(rofId, 2), - mTimeFrame->getClustersOnLayer(rofId, 1), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 2) : gsl::span(), + !skipROF ? mTimeFrame->getClustersOnLayer(rofId, 1) : gsl::span(), mTimeFrame->getIndexTable(rofId, 2).data(), mVrtParams[iteration].phiCut, mTimeFrame->getTracklets()[1], @@ -297,6 +299,9 @@ void VertexerTraits::computeTrackletMatching(const int& iteration) { #pragma omp parallel for num_threads(mNThreads) schedule(dynamic) for (int rofId = 0; rofId < mTimeFrame->getNrof(); ++rofId) { + if (iteration && (int)mTimeFrame->getPrimaryVertices(rofId).size() > mVrtParams[iteration].vertPerRofThreshold) { + continue; + } mTimeFrame->getLines(rofId).reserve(mTimeFrame->getNTrackletsCluster(rofId, 0).size()); trackletSelectionKernelHost( mTimeFrame->getClustersOnLayer(rofId, 0), @@ -353,6 +358,9 @@ void VertexerTraits::computeVertices(const int& iteration) #endif std::vector noClustersVec(mTimeFrame->getNrof(), 0); for (int rofId{0}; rofId < mTimeFrame->getNrof(); ++rofId) { + if (iteration && (int)mTimeFrame->getPrimaryVertices(rofId).size() > mVrtParams[iteration].vertPerRofThreshold) { + continue; + } const int numTracklets{static_cast(mTimeFrame->getLines(rofId).size())}; std::vector usedTracklets(numTracklets, false); @@ -426,6 +434,7 @@ void VertexerTraits::computeVertices(const int& iteration) } } } + int tmpTotVerts{0}; for (int rofId{0}; rofId < mTimeFrame->getNrof(); ++rofId) { vertices.clear(); std::sort(mTimeFrame->getTrackletClusters(rofId).begin(), mTimeFrame->getTrackletClusters(rofId).end(), @@ -468,11 +477,17 @@ void VertexerTraits::computeVertices(const int& iteration) } } } - mTimeFrame->addPrimaryVertices(vertices); - if (!vertices.size()) { + if (!iteration) { + mTimeFrame->addPrimaryVertices(vertices); + } else { + mTimeFrame->addPrimaryVerticesInROF(vertices, rofId); + } + tmpTotVerts += vertices.size(); + if (!vertices.size() && !iteration) { mTimeFrame->getNoVertexROF()++; } } + LOGP(info, "=> Total vertices found in iteration {}: {}", iteration, tmpTotVerts); #ifdef VTX_DEBUG TFile* dbg_file = TFile::Open("artefacts_tf.root", "update"); TTree* ln_clus_lines_tree = new TTree("clusterlines", "tf"); From 23126959e2a29b7e9362a1d1b3fb2380dfcfe2c3 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 17 Jul 2024 15:52:08 +0200 Subject: [PATCH 05/11] MC: assign a single flag to each vertex + purity --- .../ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu | 2 +- .../ITS/tracking/include/ITStracking/TimeFrame.h | 12 +++++++----- .../tracking/include/ITStracking/VertexerTraits.h | 15 +++++++++++++++ Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx | 12 +++++++++++- .../ITSMFT/ITS/tracking/src/TrackingInterface.cxx | 12 +++++++++--- .../ITSMFT/ITS/tracking/src/VertexerTraits.cxx | 13 +++++++++++-- .../ITSMFT/ITS/workflow/src/TrackWriterSpec.cxx | 5 ++++- Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx | 1 + .../ITS3/workflow/src/TrackWriterSpec.cxx | 2 ++ .../Upgrades/ITS3/workflow/src/TrackerSpec.cxx | 10 ++++++++-- 10 files changed, 69 insertions(+), 15 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu index abc19529b8ba7..6b9f375a61b6d 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu +++ b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu @@ -760,7 +760,7 @@ void VertexerTraitsGPU::computeTracklets(const int& iteration) gsl::span rofVerts{mTimeFrameGPU->getVerticesInChunks()[chunkId].data() + start, static_cast::size_type>(mTimeFrameGPU->getNVerticesInChunks()[chunkId][rofId])}; mTimeFrameGPU->addPrimaryVertices(rofVerts); if (mTimeFrameGPU->hasMCinformation()) { - mTimeFrameGPU->getVerticesLabels().emplace_back(); + // mTimeFrameGPU->getVerticesLabels().emplace_back(); // TODO: add MC labels } start += mTimeFrameGPU->getNVerticesInChunks()[chunkId][rofId]; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index cc549d8ff5728..d2e05e310cb98 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -80,14 +80,16 @@ class TimeFrame const Vertex& getPrimaryVertex(const int) const; gsl::span getPrimaryVertices(int tf) const; gsl::span getPrimaryVertices(int romin, int romax) const; - gsl::span> getPrimaryVerticesLabels(const int rof) const; + gsl::span> getPrimaryVerticesMCRecInfo(const int rof) const; gsl::span> getPrimaryVerticesXAlpha(int tf) const; void fillPrimaryVerticesXandAlpha(); int getPrimaryVerticesNum(int rofID = -1) const; void addPrimaryVertices(const std::vector& vertices); + void addPrimaryVerticesLabels(std::vector>& labels); void addPrimaryVertices(const gsl::span& vertices); void addPrimaryVertices(const std::vector&); void addPrimaryVerticesInROF(const std::vector& vertices, const int& rofId); + void addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int& rofId); void removePrimaryVerticesInROf(const int rofId); int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span clusters, const dataformats::MCTruthContainer* mcLabels = nullptr); @@ -169,7 +171,7 @@ class TimeFrame std::vector& getTracks(int rof) { return mTracks[rof]; } std::vector& getTracksLabel(const int rof) { return mTracksLabel[rof]; } std::vector& getLinesLabel(const int rof) { return mLinesLabels[rof]; } - std::vector>& getVerticesLabels() { return mVerticesLabels; } + std::vector>& getVerticesMCRecInfo() { return mVerticesMCRecInfo; } int getNumberOfClusters() const; int getNumberOfCells() const; @@ -316,7 +318,7 @@ class TimeFrame std::vector> mTrackletClusters; std::vector> mTrackletsIndexROf; std::vector> mLinesLabels; - std::vector> mVerticesLabels; + std::vector> mVerticesMCRecInfo; std::array mTotalTracklets = {0, 0}; // \Vertexer }; @@ -331,12 +333,12 @@ inline gsl::span TimeFrame::getPrimaryVertices(int rof) const return {&mPrimaryVertices[start], static_cast::size_type>(delta)}; } -inline gsl::span> TimeFrame::getPrimaryVerticesLabels(const int rof) const +inline gsl::span> TimeFrame::getPrimaryVerticesMCRecInfo(const int rof) const { const int start = mROframesPV[rof]; const int stop_idx = rof >= mNrof - 1 ? mNrof : rof + 1; int delta = mMultiplicityCutMask[rof] ? mROframesPV[stop_idx] - start : 0; // return empty span if Rof is excluded - return {&mVerticesLabels[start], static_cast::size_type>(delta)}; + return {&(mVerticesMCRecInfo[start]), static_cast>::size_type>(delta)}; } inline gsl::span TimeFrame::getPrimaryVertices(int romin, int romax) const diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h index 23731a49b1593..7a6f43adab554 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h @@ -100,6 +100,21 @@ class VertexerTraits void setNThreads(int n); int getNThreads() const { return mNThreads; } + template + static std::pair computeMain(const std::vector& elements) + { + T elem; + size_t maxCount = 0; + for (auto& element : elements) { + size_t count = std::count(elements.begin(), elements.end(), element); + if (count > maxCount) { + maxCount = count; + elem = element; + } + } + return std::make_pair(elem, static_cast(maxCount) / elements.size()); + } + protected: unsigned char mIsGPU; int mNThreads = 1; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index f81ede131b660..7511fd3d494b4 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -92,6 +92,11 @@ void TimeFrame::addPrimaryVertices(const std::vector& vertices) mROframesPV.push_back(mPrimaryVertices.size()); } +void TimeFrame::addPrimaryVerticesLabels(std::vector>& labels) +{ + mVerticesMCRecInfo.insert(mVerticesMCRecInfo.end(), labels.begin(), labels.end()); +} + void TimeFrame::addPrimaryVerticesInROF(const std::vector& vertices, const int& rofId) { mPrimaryVertices.insert(mPrimaryVertices.begin() + mROframesPV[rofId], vertices.begin(), vertices.end()); @@ -100,6 +105,11 @@ void TimeFrame::addPrimaryVerticesInROF(const std::vector& vertices, con } } +void TimeFrame::addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int& rofId) +{ + mVerticesMCRecInfo.insert(mVerticesMCRecInfo.begin() + mROframesPV[rofId], labels.begin(), labels.end()); +} + void TimeFrame::addPrimaryVertices(const gsl::span& vertices) { for (const auto& vertex : vertices) { @@ -267,7 +277,7 @@ void TimeFrame::initialise(const int iteration, const TrackingParameters& trkPar deepVectorClear(mTracksLabel); deepVectorClear(mLinesLabels); if (resetVertices) { - deepVectorClear(mVerticesLabels); + deepVectorClear(mVerticesMCRecInfo); } mTracks.resize(mNrof); mTracksLabel.resize(mNrof); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 9bcd55f89e8ac..1e02c2df714df 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -137,8 +137,10 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) // MC static pmr::vector dummyMCLabTracks, dummyMCLabVerts; + static pmr::vector dummyMCPurVerts; auto& allTrackLabels = mIsMC ? pc.outputs().make>(Output{"ITS", "TRACKSMCTR", 0}) : dummyMCLabTracks; auto& allVerticesLabels = mIsMC ? pc.outputs().make>(Output{"ITS", "VERTICESMCTR", 0}) : dummyMCLabVerts; + auto& allVerticesPurities = mIsMC ? pc.outputs().make>(Output{"ITS", "VERTICESMCPUR", 0}) : dummyMCPurVerts; std::uint32_t roFrame = 0; @@ -182,12 +184,16 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) mTimeFrame->resetRofPV(); } const auto& multEstConf = FastMultEstConfig::Instance(); // parameters for mult estimation and cuts + gsl::span> vMCRecInfo; for (auto iRof{0}; iRof < rofspan.size(); ++iRof) { std::vector vtxVecLoc; auto& vtxROF = vertROFvec.emplace_back(rofspan[iRof]); vtxROF.setFirstEntry(vertices.size()); if (mRunVertexer) { auto vtxSpan = mTimeFrame->getPrimaryVertices(iRof); + if (mIsMC) { + vMCRecInfo = mTimeFrame->getPrimaryVerticesMCRecInfo(iRof); + } vtxROF.setNEntries(vtxSpan.size()); bool selROF = vtxSpan.size() == 0; for (auto iV{0}; iV < vtxSpan.size(); ++iV) { @@ -198,9 +204,8 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) selROF = true; vertices.push_back(v); if (mIsMC) { - auto vLabels = mTimeFrame->getPrimaryVerticesLabels(iRof)[iV]; - allVerticesLabels.reserve(allVerticesLabels.size() + vLabels.size()); - std::copy(vLabels.begin(), vLabels.end(), std::back_inserter(allVerticesLabels)); + allVerticesLabels.push_back(vMCRecInfo[iV].first); + allVerticesPurities.push_back(vMCRecInfo[iV].second); } } if (processingMask[iRof] && !selROF) { // passed selection in clusters and not in vertex multiplicity @@ -288,6 +293,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) if (mIsMC) { LOGP(info, "ITSTracker pushed {} track labels", allTrackLabels.size()); LOGP(info, "ITSTracker pushed {} vertex labels", allVerticesLabels.size()); + LOGP(info, "ITSTracker pushed {} vertex purities", allVerticesPurities.size()); } } } diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index 63d19fd7bcd62..5fe9d798daec9 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -169,6 +169,7 @@ void VertexerTraits::updateVertexingParameters(const std::vector vertices; + std::vector> polls; #ifdef VTX_DEBUG std::vector> dbg_clusLines(mTimeFrame->getNrof()); #endif @@ -470,17 +472,24 @@ void VertexerTraits::computeVertices(const int& iteration) vertices.back().setTimeStamp(rofId); if (mTimeFrame->hasMCinformation()) { - mTimeFrame->getVerticesLabels().emplace_back(); + std::vector labels; for (auto& index : mTimeFrame->getTrackletClusters(rofId)[iCluster].getLabels()) { - mTimeFrame->getVerticesLabels().back().push_back(mTimeFrame->getLinesLabel(rofId)[index]); // then we can use nContributors from vertices to get the labels + labels.push_back(mTimeFrame->getLinesLabel(rofId)[index]); // then we can use nContributors from vertices to get the labels } + polls.push_back(computeMain(labels)); } } } if (!iteration) { mTimeFrame->addPrimaryVertices(vertices); + if (mTimeFrame->hasMCinformation()) { + mTimeFrame->addPrimaryVerticesLabels(polls); + } } else { mTimeFrame->addPrimaryVerticesInROF(vertices, rofId); + if (mTimeFrame->hasMCinformation()) { + mTimeFrame->addPrimaryVerticesLabelsInROF(polls, rofId); + } } tmpTotVerts += vertices.size(); if (!vertices.size() && !iteration) { diff --git a/Detectors/ITSMFT/ITS/workflow/src/TrackWriterSpec.cxx b/Detectors/ITSMFT/ITS/workflow/src/TrackWriterSpec.cxx index 02632cd4e3d3d..5cb6aa199ab64 100644 --- a/Detectors/ITSMFT/ITS/workflow/src/TrackWriterSpec.cxx +++ b/Detectors/ITSMFT/ITS/workflow/src/TrackWriterSpec.cxx @@ -72,7 +72,10 @@ DataProcessorSpec getTrackWriterSpec(bool useMC) BranchDefinition{InputSpec{"MC2ROframes", "ITS", "ITSTrackMC2ROF", 0}, "ITSTracksMC2ROF", (useMC ? 1 : 0), // one branch if mc labels enabled - ""})(); + ""}, + BranchDefinition>{InputSpec{"purityVertices", "ITS", "VERTICESMCPUR", 0}, + "ITSVertexMCPurity", (useMC ? 1 : 0), // one branch if mc labels enabled + ""})(); } } // namespace its diff --git a/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx b/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx index 367fa8673cc70..ec0b0d26f873c 100644 --- a/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx +++ b/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx @@ -114,6 +114,7 @@ DataProcessorSpec getTrackerSpec(bool useMC, bool useGeom, int trgType, const st inputs.emplace_back("itsmclabels", "ITS", "CLUSTERSMCTR", 0, Lifetime::Timeframe); inputs.emplace_back("ITSMC2ROframes", "ITS", "CLUSTERSMC2ROF", 0, Lifetime::Timeframe); outputs.emplace_back("ITS", "VERTICESMCTR", 0, Lifetime::Timeframe); + outputs.emplace_back("ITS", "VERTICESMCPUR", 0, Lifetime::Timeframe); outputs.emplace_back("ITS", "TRACKSMCTR", 0, Lifetime::Timeframe); outputs.emplace_back("ITS", "ITSTrackMC2ROF", 0, Lifetime::Timeframe); } diff --git a/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx index a0b879e7e4d99..24400e26eb2e2 100644 --- a/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx +++ b/Detectors/Upgrades/ITS3/workflow/src/TrackWriterSpec.cxx @@ -69,6 +69,8 @@ DataProcessorSpec getTrackWriterSpec(bool useMC) "ITSVertexMCTruth", (useMC ? 1 : 0), // one branch if mc labels enabled ""}, + BranchDefinition>{InputSpec{"purityVertices", "ITS", "VERTICESMCPUR", 0}, + "ITSVertexMCPurity", (useMC ? 1 : 0), ""}, BranchDefinition{InputSpec{"MC2ROframes", "ITS", "ITSTrackMC2ROF", 0}, "ITSTracksMC2ROF", (useMC ? 1 : 0), // one branch if mc labels enabled diff --git a/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx index 62212031691b2..5e6612d13b73f 100644 --- a/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx +++ b/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx @@ -182,6 +182,7 @@ void TrackerDPL::run(ProcessingContext& pc) auto& allTracks = pc.outputs().make>(Output{orig, "TRACKS", 0}); std::vector allTrackLabels; std::vector allVerticesLabels; + std::vector allVerticesPurities; auto& vertROFvec = pc.outputs().make>(Output{orig, "VERTICESROF", 0}); auto& vertices = pc.outputs().make>(Output{orig, "VERTICES", 0}); @@ -212,12 +213,16 @@ void TrackerDPL::run(ProcessingContext& pc) vertexerElapsedTime = mVertexer->clustersToVertices(logger); } const auto& multEstConf = FastMultEstConfig::Instance(); // parameters for mult estimation and cuts + gsl::span> vMCRecInfo; for (size_t iRof{0}; iRof < rofspan.size(); ++iRof) { std::vector vtxVecLoc; auto& vtxROF = vertROFvec.emplace_back(rofspan[iRof]); vtxROF.setFirstEntry(vertices.size()); if (mRunVertexer) { auto vtxSpan = timeFrame->getPrimaryVertices(iRof); + if (mIsMC) { + vMCRecInfo = timeFrame->getPrimaryVerticesMCRecInfo(iRof); + } vtxROF.setNEntries(vtxSpan.size()); bool selROF = vtxSpan.size() == 0; for (size_t iV{0}; iV < vtxSpan.size(); ++iV) { @@ -228,8 +233,8 @@ void TrackerDPL::run(ProcessingContext& pc) selROF = true; vertices.push_back(v); if (mIsMC) { - auto vLabels = timeFrame->getPrimaryVerticesLabels(iRof)[iV]; - std::copy(vLabels.begin(), vLabels.end(), std::back_inserter(allVerticesLabels)); + allVerticesLabels.push_back(vMCRecInfo[iV].first); + allVerticesPurities.push_back(vMCRecInfo[iV].second); } } if (processingMask[iRof] && !selROF) { // passed selection in clusters and not in vertex multiplicity @@ -303,6 +308,7 @@ void TrackerDPL::run(ProcessingContext& pc) pc.outputs().snapshot(Output{orig, "TRACKSMCTR", 0}, allTrackLabels); pc.outputs().snapshot(Output{orig, "VERTICESMCTR", 0}, allVerticesLabels); + pc.outputs().snapshot(Output{orig, "VERTICESMCPUR", 0}, allVerticesPurities); pc.outputs().snapshot(Output{orig, "ITSTrackMC2ROF", 0}, mc2rofs); } } From 2f572d07ddf55739c47a26474ebae0dc4a4dc0b6 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 17 Jul 2024 16:49:02 +0200 Subject: [PATCH 06/11] Improve logging --- .../ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h | 4 +++- Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx | 5 +++-- Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx | 8 +++++++- Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx | 7 ++----- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index d2e05e310cb98..e4468e112c0bf 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -101,6 +101,7 @@ class TimeFrame const dataformats::MCTruthContainer* mcLabels = nullptr); int getTotalClusters() const; + std::vector& getTotVertIteration() { return mTotVertPerIteration; } bool empty() const; bool isGPU() const { return mIsGPU; } int getSortedIndex(int rof, int layer, int i) const; @@ -289,7 +290,6 @@ class TimeFrame private: float mBz = 5.; unsigned int mNTotalLowPtVertices = 0; - unsigned int mNoVertexROF = 0; int mBeamPosWeight = 0; std::array mBeamPos = {0.f, 0.f}; bool isBeamPositionOverridden = false; @@ -320,6 +320,8 @@ class TimeFrame std::vector> mLinesLabels; std::vector> mVerticesMCRecInfo; std::array mTotalTracklets = {0, 0}; + unsigned int mNoVertexROF = 0; + std::vector mTotVertPerIteration; // \Vertexer }; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index 7511fd3d494b4..15c2ca26c6d09 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -269,9 +269,9 @@ int TimeFrame::getTotalClusters() const void TimeFrame::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers, bool resetVertices) { if (iteration == 0) { - mNoVertexROF = 0; if (maxLayers < trkParam.NLayers && resetVertices) { resetRofPV(); + deepVectorClear(mTotVertPerIteration); } deepVectorClear(mTracks); deepVectorClear(mTracksLabel); @@ -386,7 +386,8 @@ void TimeFrame::initialise(const int iteration, const TrackingParameters& trkPar } } } - + mTotVertPerIteration.resize(1 + iteration); + mNoVertexROF = 0; deepVectorClear(mRoads); deepVectorClear(mRoadLabels); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 1e02c2df714df..829f4b0b5eeac 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -224,7 +224,13 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) } } LOG(info) << fmt::format(" - rejected {}/{} ROFs: random/mult.sel:{} (seed {}), vtx.sel:{}", cutRandomMult + cutVertexMult, rofspan.size(), cutRandomMult, multEst.lastRandomSeed, cutVertexMult); - LOG(info) << fmt::format(" - Vertex seeding total elapsed time: {} ms for {} vertices found in {}/{} ROFs", vertexerElapsedTime, mTimeFrame->getPrimaryVerticesNum(), rofspan.size() - mTimeFrame->getNoVertexROF(), rofspan.size()); + LOG(info) << fmt::format(" - Vertex seeding total elapsed time: {} ms for {} ({} + {}) vertices found in {}/{} ROFs", + vertexerElapsedTime, + mTimeFrame->getPrimaryVerticesNum(), + mTimeFrame->getTotVertIteration()[0], + o2::its::VertexerParamConfig::Instance().nIterations > 1 ? mTimeFrame->getTotVertIteration()[1] : 0, + rofspan.size() - mTimeFrame->getNoVertexROF(), + rofspan.size()); if (mOverrideBeamEstimation) { LOG(info) << fmt::format(" - Beam position set to: {}, {} from meanvertex object", mTimeFrame->getBeamX(), mTimeFrame->getBeamY()); diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index 5fe9d798daec9..a21ff31e3d194 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -351,7 +351,6 @@ void VertexerTraits::computeTrackletMatching(const int& iteration) void VertexerTraits::computeVertices(const int& iteration) { - auto nsigmaCut{std::min(mVrtParams[iteration].vertNsigmaCut * mVrtParams[iteration].vertNsigmaCut * (mVrtParams[iteration].vertRadiusSigma * mVrtParams[iteration].vertRadiusSigma + mVrtParams[iteration].trackletSigma * mVrtParams[iteration].trackletSigma), 1.98f)}; std::vector vertices; std::vector> polls; @@ -436,7 +435,6 @@ void VertexerTraits::computeVertices(const int& iteration) } } } - int tmpTotVerts{0}; for (int rofId{0}; rofId < mTimeFrame->getNrof(); ++rofId) { vertices.clear(); std::sort(mTimeFrame->getTrackletClusters(rofId).begin(), mTimeFrame->getTrackletClusters(rofId).end(), @@ -491,12 +489,11 @@ void VertexerTraits::computeVertices(const int& iteration) mTimeFrame->addPrimaryVerticesLabelsInROF(polls, rofId); } } - tmpTotVerts += vertices.size(); - if (!vertices.size() && !iteration) { + mTimeFrame->getTotVertIteration()[iteration] += vertices.size(); + if (!vertices.size() && !(iteration && (int)mTimeFrame->getPrimaryVertices(rofId).size() > mVrtParams[iteration].vertPerRofThreshold)) { mTimeFrame->getNoVertexROF()++; } } - LOGP(info, "=> Total vertices found in iteration {}: {}", iteration, tmpTotVerts); #ifdef VTX_DEBUG TFile* dbg_file = TFile::Open("artefacts_tf.root", "update"); TTree* ln_clus_lines_tree = new TTree("clusterlines", "tf"); From 889a9b339d85d4a3213018a0090b97d35f8aeea4 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 17 Jul 2024 17:32:15 +0200 Subject: [PATCH 07/11] Tag vertices with iteration --- Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index a21ff31e3d194..29f3f19cef2c7 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -469,6 +469,7 @@ void VertexerTraits::computeVertices(const int& iteration) mTimeFrame->getTrackletClusters(rofId)[iCluster].getAvgDistance2()); // In place of chi2 vertices.back().setTimeStamp(rofId); + vertices.back().setFlags(iteration); if (mTimeFrame->hasMCinformation()) { std::vector labels; for (auto& index : mTimeFrame->getTrackletClusters(rofId)[iCluster].getLabels()) { From f4ec6a6be8075b6e3063200a61d3de7c88566358 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Wed, 17 Jul 2024 19:30:00 +0200 Subject: [PATCH 08/11] Add DeltaROF skipping to the tracker --- .../include/ReconstructionDataFormats/Vertex.h | 2 +- .../tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h | 8 ++++---- .../ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu | 8 ++++---- .../ITS/tracking/include/ITStracking/Configuration.h | 3 ++- .../ITS/tracking/include/ITStracking/TimeFrame.h | 6 +++--- .../include/ITStracking/TrackingConfigParam.h | 5 +++-- .../tracking/include/ITStracking/VertexerTraits.h | 12 ++++++------ Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx | 4 ++-- Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 1 + Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx | 4 ++-- Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx | 8 ++++---- Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx | 4 ++-- 12 files changed, 34 insertions(+), 31 deletions(-) diff --git a/DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h b/DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h index bbc2c01359276..24ae636db560e 100644 --- a/DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h +++ b/DataFormats/Reconstruction/include/ReconstructionDataFormats/Vertex.h @@ -141,7 +141,7 @@ class Vertex : public VertexBase GPUd() ushort getFlags() const { return mBits; } GPUd() bool isFlagSet(uint f) const { return mBits & (FlagsMask & f); } GPUd() void setFlags(ushort f) { mBits |= FlagsMask & f; } - GPUd() void resetFrags(ushort f = FlagsMask) { mBits &= ~(FlagsMask & f); } + GPUd() void resetFlags(ushort f = FlagsMask) { mBits &= ~(FlagsMask & f); } GPUd() void setChi2(float v) { mChi2 = v; } GPUd() float getChi2() const { return mChi2; } diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h index cbf2364738538..6b7e79a187745 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h +++ b/Detectors/ITSMFT/ITS/tracking/GPU/ITStrackingGPU/VertexerTraitsGPU.h @@ -42,11 +42,11 @@ class VertexerTraitsGPU : public VertexerTraits public: VertexerTraitsGPU(); ~VertexerTraitsGPU() override; - void initialise(const TrackingParameters&, const int& iteration = 0) override; + void initialise(const TrackingParameters&, const int iteration = 0) override; void adoptTimeFrame(TimeFrame*) override; - void computeTracklets(const int& iteration = 0) override; - void computeTrackletMatching(const int& iteration = 0) override; - void computeVertices(const int& iteration = 0) override; + void computeTracklets(const int iteration = 0) override; + void computeTrackletMatching(const int iteration = 0) override; + void computeVertices(const int iteration = 0) override; // Hybrid void initialiseHybrid(const TrackingParameters& pars) override { VertexerTraits::initialise(pars); } diff --git a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu index 6b9f375a61b6d..d18f9ecc0b7cb 100644 --- a/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu +++ b/Detectors/ITSMFT/ITS/tracking/GPU/cuda/VertexerTraitsGPU.cu @@ -95,7 +95,7 @@ VertexerTraitsGPU::~VertexerTraitsGPU() { } -void VertexerTraitsGPU::initialise(const TrackingParameters& trackingParams, const int& iteration) +void VertexerTraitsGPU::initialise(const TrackingParameters& trackingParams, const int iteration) { mTimeFrameGPU->initialise(0, trackingParams, 3, &mIndexTableUtils, &mTfGPUParams); } @@ -607,7 +607,7 @@ void VertexerTraitsGPU::updateVertexingParameters(const std::vectorgetClusters().size()) { return; @@ -769,11 +769,11 @@ void VertexerTraitsGPU::computeTracklets(const int& iteration) mTimeFrameGPU->wipe(3); } -void VertexerTraitsGPU::computeTrackletMatching(const int& iteration) +void VertexerTraitsGPU::computeTrackletMatching(const int iteration) { } -void VertexerTraitsGPU::computeVertices(const int& iteration) +void VertexerTraitsGPU::computeVertices(const int iteration) { } diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index 0e072bb632046..619f96b72626c 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -98,6 +98,7 @@ struct TrackingParameters { bool FindShortTracks = false; bool PerPrimaryVertexProcessing = false; bool SaveTimeBenchmarks = false; + bool skipSecondIterationVerticesInDeltaRof = false; }; inline int TrackingParameters::CellMinimumLevel() @@ -106,7 +107,7 @@ inline int TrackingParameters::CellMinimumLevel() } struct VertexingParameters { - int nIterations = 1; // Number of vertexing passes to perform + int nIterations = 1; // Number of vertexing passes to perform int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; std::vector LayerZ = {16.333f + 1, 16.333f + 1, 16.333f + 1, 42.140f + 1, 42.140f + 1, 73.745f + 1, 73.745f + 1}; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index e4468e112c0bf..f30e2e423bb65 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -88,8 +88,8 @@ class TimeFrame void addPrimaryVerticesLabels(std::vector>& labels); void addPrimaryVertices(const gsl::span& vertices); void addPrimaryVertices(const std::vector&); - void addPrimaryVerticesInROF(const std::vector& vertices, const int& rofId); - void addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int& rofId); + void addPrimaryVerticesInROF(const std::vector& vertices, const int rofId); + void addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int rofId); void removePrimaryVerticesInROf(const int rofId); int loadROFrameData(const o2::itsmft::ROFRecord& rof, gsl::span clusters, const dataformats::MCTruthContainer* mcLabels = nullptr); @@ -225,7 +225,7 @@ class TimeFrame } } - virtual void setDevicePropagator(const o2::base::PropagatorImpl*) {}; + virtual void setDevicePropagator(const o2::base::PropagatorImpl*){}; const o2::base::PropagatorImpl* getDevicePropagator() const { return mPropagatorDevice; } template diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h index b83e56de3c12c..c20b1a3b153d7 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h @@ -22,8 +22,8 @@ namespace its struct VertexerParamConfig : public o2::conf::ConfigurableParamHelper { - int nIterations = 1; // Number of vertexing passes to perform - int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round + int nIterations = 1; // Number of vertexing passes to perform + int vertPerRofThreshold = 0; // Maximum number of vertices per ROF to trigger second a round bool allowSingleContribClusters = false; // geometrical cuts @@ -82,6 +82,7 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper& vrtPar, const TimeFrameGPUParameters& gpuTfPar); // Hybrid @@ -84,7 +84,7 @@ class VertexerTraits std::vector&, TimeFrame*, std::vector*, - const int& iteration = 0); + const int iteration = 0); static const std::vector> selectClusters(const int* indexTable, const std::array& selectedBinsRect, @@ -127,7 +127,7 @@ class VertexerTraits TimeFrame* mTimeFrame = nullptr; }; -inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int& iteration) +inline void VertexerTraits::initialise(const TrackingParameters& trackingParams, const int iteration) { mTimeFrame->initialise(0, trackingParams, 3, (bool)(!iteration)); // iteration for initialisation must be 0 for correctly resetting the frame, we need to pass the non-reset flag for vertices as well, tho. setIsGPU(false); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index 15c2ca26c6d09..be0d8f5bf3d55 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -97,7 +97,7 @@ void TimeFrame::addPrimaryVerticesLabels(std::vector& vertices, const int& rofId) +void TimeFrame::addPrimaryVerticesInROF(const std::vector& vertices, const int rofId) { mPrimaryVertices.insert(mPrimaryVertices.begin() + mROframesPV[rofId], vertices.begin(), vertices.end()); for (int i = rofId + 1; i < mROframesPV.size(); ++i) { @@ -105,7 +105,7 @@ void TimeFrame::addPrimaryVerticesInROF(const std::vector& vertices, con } } -void TimeFrame::addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int& rofId) +void TimeFrame::addPrimaryVerticesLabelsInROF(const std::vector>& labels, const int rofId) { mVerticesMCRecInfo.insert(mVerticesMCRecInfo.begin() + mROframesPV[rofId], labels.begin(), labels.end()); } diff --git a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx index 4ccc53b1bdbfe..7f7f52417f432 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx @@ -477,6 +477,7 @@ void Tracker::getGlobalConfiguration() } } params.DeltaROF = tc.deltaRof; + params.skipSecondIterationVerticesInDeltaRof = tc.skipSecondIterationVerticesInDeltaRof; params.MaxChi2ClusterAttachment = tc.maxChi2ClusterAttachment > 0 ? tc.maxChi2ClusterAttachment : params.MaxChi2ClusterAttachment; params.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : params.MaxChi2NDF; params.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : params.PhiBins; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx index 672e7370035e0..a11320364b49b 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx @@ -70,8 +70,8 @@ void TrackerTraits::computeLayerTracklets(const int iteration, int iROFslice, in const Vertex diamondVert({mTrkParams[iteration].Diamond[0], mTrkParams[iteration].Diamond[1], mTrkParams[iteration].Diamond[2]}, {25.e-6f, 0.f, 0.f, 25.e-6f, 0.f, 36.f}, 1, 1.f); gsl::span diamondSpan(&diamondVert, 1); - int startROF{mTrkParams[iteration].nROFsPerIterations > 0 ? std::max(iROFslice * mTrkParams[iteration].nROFsPerIterations - mTrkParams[iteration].DeltaROF, 0) : 0}; - int endROF{mTrkParams[iteration].nROFsPerIterations > 0 ? std::min((iROFslice + 1) * mTrkParams[iteration].nROFsPerIterations + mTrkParams[iteration].DeltaROF, tf->getNrof()) : tf->getNrof()}; + int startROF{mTrkParams[iteration].nROFsPerIterations > 0 ? iROFslice * mTrkParams[iteration].nROFsPerIterations : 0}; + int endROF{mTrkParams[iteration].nROFsPerIterations > 0 ? (iROFslice + 1) * mTrkParams[iteration].nROFsPerIterations + mTrkParams[iteration].DeltaROF : tf->getNrof()}; for (int rof0{startROF}; rof0 < endROF; ++rof0) { gsl::span primaryVertices = mTrkParams[iteration].UseDiamond ? diamondSpan : tf->getPrimaryVertices(rof0); const int startVtx{iVertex >= 0 ? iVertex : 0}; diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index 29f3f19cef2c7..2196e04752484 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -170,7 +170,7 @@ void VertexerTraits::updateVertexingParameters(const std::vectorgetNrof(); ++rofId) { @@ -349,7 +349,7 @@ void VertexerTraits::computeTrackletMatching(const int& iteration) #endif } -void VertexerTraits::computeVertices(const int& iteration) +void VertexerTraits::computeVertices(const int iteration) { auto nsigmaCut{std::min(mVrtParams[iteration].vertNsigmaCut * mVrtParams[iteration].vertNsigmaCut * (mVrtParams[iteration].vertRadiusSigma * mVrtParams[iteration].vertRadiusSigma + mVrtParams[iteration].trackletSigma * mVrtParams[iteration].trackletSigma), 1.98f)}; std::vector vertices; @@ -538,7 +538,7 @@ void VertexerTraits::computeVerticesInRof(int rofId, std::vector& verticesInRof, TimeFrame* tf, std::vector* labels, - const int& iteration) + const int iteration) { int foundVertices{0}; auto nsigmaCut{std::min(mVrtParams[iteration].vertNsigmaCut * mVrtParams[iteration].vertNsigmaCut * (mVrtParams[iteration].vertRadiusSigma * mVrtParams[iteration].vertRadiusSigma + mVrtParams[iteration].trackletSigma * mVrtParams[iteration].trackletSigma), 1.98f)}; diff --git a/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx b/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx index 5e6612d13b73f..a6d01b2ba8710 100644 --- a/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx +++ b/Detectors/Upgrades/ITS3/workflow/src/TrackerSpec.cxx @@ -213,14 +213,14 @@ void TrackerDPL::run(ProcessingContext& pc) vertexerElapsedTime = mVertexer->clustersToVertices(logger); } const auto& multEstConf = FastMultEstConfig::Instance(); // parameters for mult estimation and cuts - gsl::span> vMCRecInfo; + gsl::span> vMCRecInfo; for (size_t iRof{0}; iRof < rofspan.size(); ++iRof) { std::vector vtxVecLoc; auto& vtxROF = vertROFvec.emplace_back(rofspan[iRof]); vtxROF.setFirstEntry(vertices.size()); if (mRunVertexer) { auto vtxSpan = timeFrame->getPrimaryVertices(iRof); - if (mIsMC) { + if (mIsMC) { vMCRecInfo = timeFrame->getPrimaryVerticesMCRecInfo(iRof); } vtxROF.setNEntries(vtxSpan.size()); From 65bbf5ecf8b5189ed959a4b0440f1fa5bf5bc3f7 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 18 Jul 2024 15:09:13 +0200 Subject: [PATCH 09/11] Add in-iteration deltaRof filtering --- .../ITSMFT/ITS/tracking/include/ITStracking/Configuration.h | 3 ++- .../ITS/tracking/include/ITStracking/TrackingConfigParam.h | 3 ++- Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 3 ++- Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx | 6 ++++++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index 619f96b72626c..6c8d4317bee38 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -98,7 +98,8 @@ struct TrackingParameters { bool FindShortTracks = false; bool PerPrimaryVertexProcessing = false; bool SaveTimeBenchmarks = false; - bool skipSecondIterationVerticesInDeltaRof = false; + bool SkipDeltaRofIfsecondIterationVtx = false; + bool DoUPCIteration = false; }; inline int TrackingParameters::CellMinimumLevel() diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h index c20b1a3b153d7..b8b473bcf7e73 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h @@ -82,7 +82,8 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper 0 ? tc.maxChi2ClusterAttachment : params.MaxChi2ClusterAttachment; params.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : params.MaxChi2NDF; params.PhiBins = tc.LUTbinsPhi > 0 ? tc.LUTbinsPhi : params.PhiBins; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx index a11320364b49b..65af84b141eac 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx @@ -98,6 +98,12 @@ void TrackerTraits::computeLayerTracklets(const int iteration, int iROFslice, in for (int iV{startVtx}; iV < endVtx; ++iV) { auto& primaryVertex{primaryVertices[iV]}; + if (mTrkParams[iteration].SkipDeltaRofIfsecondIterationVtx) { + if (primaryVertex.isFlagSet(1)) { + minRof = std::max(startROF, rof0); // same logic but setting like deltaRof=0 + maxRof = std::min(endROF - 1, rof0); + } + } const float resolution = o2::gpu::CAMath::Sqrt(Sq(mTrkParams[iteration].PVres) / primaryVertex.getNContributors() + Sq(tf->getPositionResolution(iLayer))); const float tanLambda{(currentCluster.zCoordinate - primaryVertex.getZ()) * inverseR0}; From ff2dd467cb5d955e8cb9df850b337dd54a44459a Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 18 Jul 2024 16:48:21 +0200 Subject: [PATCH 10/11] Add 4th iteration for UPCs --- .../tracking/include/ITStracking/TimeFrame.h | 7 +- .../ITSMFT/ITS/tracking/src/TimeFrame.cxx | 136 +++++++++--------- Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 4 +- .../ITS/tracking/src/TrackingInterface.cxx | 27 ++-- 4 files changed, 99 insertions(+), 75 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index f30e2e423bb65..db01b28264225 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -208,6 +208,7 @@ class TimeFrame bool isRoadFake(int i) const; void setMultiplicityCutMask(const std::vector& cutMask) { mMultiplicityCutMask = cutMask; } + void flipMultiplicityCutMask() { mMultiplicityCutMask.flip(); } int hasBogusClusters() const { return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); } @@ -225,7 +226,10 @@ class TimeFrame } } - virtual void setDevicePropagator(const o2::base::PropagatorImpl*){}; + virtual void setDevicePropagator(const o2::base::PropagatorImpl*) + { + return; + }; const o2::base::PropagatorImpl* getDevicePropagator() const { return mPropagatorDevice; } template @@ -288,6 +292,7 @@ class TimeFrame } private: + void prepareClusters(const TrackingParameters& trkParam, const int maxLayers); float mBz = 5.; unsigned int mNTotalLowPtVertices = 0; int mBeamPosWeight = 0; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx index be0d8f5bf3d55..ab846197677a2 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TimeFrame.cxx @@ -266,6 +266,73 @@ int TimeFrame::getTotalClusters() const return int(totalClusters); } +void TimeFrame::prepareClusters(const TrackingParameters& trkParam, const int maxLayers) +{ + std::vector cHelper; + std::vector clsPerBin(trkParam.PhiBins * trkParam.ZBins, 0); + for (int rof{0}; rof < mNrof; ++rof) { + if ((int)mMultiplicityCutMask.size() == mNrof && !mMultiplicityCutMask[rof]) { + continue; + } + for (int iLayer{0}; iLayer < std::min(trkParam.NLayers, maxLayers); ++iLayer) { + std::fill(clsPerBin.begin(), clsPerBin.end(), 0); + const auto unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)}; + const int clustersNum{static_cast(unsortedClusters.size())}; + + deepVectorClear(cHelper); + cHelper.resize(clustersNum); + + for (int iCluster{0}; iCluster < clustersNum; ++iCluster) { + + const Cluster& c = unsortedClusters[iCluster]; + ClusterHelper& h = cHelper[iCluster]; + float x = c.xCoordinate - mBeamPos[0]; + float y = c.yCoordinate - mBeamPos[1]; + const float& z = c.zCoordinate; + float phi = math_utils::computePhi(x, y); + int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)}; + if (zBin < 0) { + zBin = 0; + mBogusClusters[iLayer]++; + } else if (zBin >= trkParam.ZBins) { + zBin = trkParam.ZBins - 1; + mBogusClusters[iLayer]++; + } + int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi)); + h.phi = phi; + h.r = math_utils::hypot(x, y); + mMinR[iLayer] = o2::gpu::GPUCommonMath::Min(h.r, mMinR[iLayer]); + mMaxR[iLayer] = o2::gpu::GPUCommonMath::Max(h.r, mMaxR[iLayer]); + h.bin = bin; + h.ind = clsPerBin[bin]++; + } + std::vector lutPerBin(clsPerBin.size()); + lutPerBin[0] = 0; + for (unsigned int iB{1}; iB < lutPerBin.size(); ++iB) { + lutPerBin[iB] = lutPerBin[iB - 1] + clsPerBin[iB - 1]; + } + + auto clusters2beSorted{getClustersOnLayer(rof, iLayer)}; + for (int iCluster{0}; iCluster < clustersNum; ++iCluster) { + const ClusterHelper& h = cHelper[iCluster]; + + Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind]; + c = unsortedClusters[iCluster]; + c.phi = h.phi; + c.radius = h.r; + c.indexTableBinIndex = h.bin; + } + + for (unsigned int iB{0}; iB < clsPerBin.size(); ++iB) { + mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = lutPerBin[iB]; + } + for (auto iB{clsPerBin.size()}; iB < (trkParam.ZBins * trkParam.PhiBins + 1); iB++) { + mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = clustersNum; + } + } + } +} + void TimeFrame::initialise(const int iteration, const TrackingParameters& trkParam, const int maxLayers, bool resetVertices) { if (iteration == 0) { @@ -311,9 +378,6 @@ void TimeFrame::initialise(const int iteration, const TrackingParameters& trkPar v = std::vector(mNrof + 1, 0); } - std::vector cHelper; - std::vector clsPerBin(trkParam.PhiBins * trkParam.ZBins, 0); - for (int iLayer{0}; iLayer < trkParam.NLayers; ++iLayer) { if (trkParam.SystErrorY2[iLayer] > 0.f || trkParam.SystErrorZ2[iLayer] > 0.f) { for (auto& tfInfo : mTrackingFrameInfo[iLayer]) { @@ -323,69 +387,11 @@ void TimeFrame::initialise(const int iteration, const TrackingParameters& trkPar } } } - - for (int rof{0}; rof < mNrof; ++rof) { - if ((int)mMultiplicityCutMask.size() == mNrof && !mMultiplicityCutMask[rof]) { - continue; - } - for (int iLayer{0}; iLayer < std::min(trkParam.NLayers, maxLayers); ++iLayer) { - std::fill(clsPerBin.begin(), clsPerBin.end(), 0); - const auto unsortedClusters{getUnsortedClustersOnLayer(rof, iLayer)}; - const int clustersNum{static_cast(unsortedClusters.size())}; - - deepVectorClear(cHelper); - cHelper.resize(clustersNum); - - for (int iCluster{0}; iCluster < clustersNum; ++iCluster) { - - const Cluster& c = unsortedClusters[iCluster]; - ClusterHelper& h = cHelper[iCluster]; - float x = c.xCoordinate - mBeamPos[0]; - float y = c.yCoordinate - mBeamPos[1]; - const float& z = c.zCoordinate; - float phi = math_utils::computePhi(x, y); - int zBin{mIndexTableUtils.getZBinIndex(iLayer, z)}; - if (zBin < 0) { - zBin = 0; - mBogusClusters[iLayer]++; - } else if (zBin >= trkParam.ZBins) { - zBin = trkParam.ZBins - 1; - mBogusClusters[iLayer]++; - } - int bin = mIndexTableUtils.getBinIndex(zBin, mIndexTableUtils.getPhiBinIndex(phi)); - h.phi = phi; - h.r = math_utils::hypot(x, y); - mMinR[iLayer] = o2::gpu::GPUCommonMath::Min(h.r, mMinR[iLayer]); - mMaxR[iLayer] = o2::gpu::GPUCommonMath::Max(h.r, mMaxR[iLayer]); - h.bin = bin; - h.ind = clsPerBin[bin]++; - } - std::vector lutPerBin(clsPerBin.size()); - lutPerBin[0] = 0; - for (unsigned int iB{1}; iB < lutPerBin.size(); ++iB) { - lutPerBin[iB] = lutPerBin[iB - 1] + clsPerBin[iB - 1]; - } - - auto clusters2beSorted{getClustersOnLayer(rof, iLayer)}; - for (int iCluster{0}; iCluster < clustersNum; ++iCluster) { - const ClusterHelper& h = cHelper[iCluster]; - - Cluster& c = clusters2beSorted[lutPerBin[h.bin] + h.ind]; - c = unsortedClusters[iCluster]; - c.phi = h.phi; - c.radius = h.r; - c.indexTableBinIndex = h.bin; - } - - for (unsigned int iB{0}; iB < clsPerBin.size(); ++iB) { - mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = lutPerBin[iB]; - } - for (auto iB{clsPerBin.size()}; iB < (trkParam.ZBins * trkParam.PhiBins + 1); iB++) { - mIndexTables[iLayer][rof * (trkParam.ZBins * trkParam.PhiBins + 1) + iB] = clustersNum; - } - } - } } + if (iteration == 0 || iteration == 3) { + prepareClusters(trkParam, maxLayers); + } + mTotVertPerIteration.resize(1 + iteration); mNoVertexROF = 0; deepVectorClear(mRoads); diff --git a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx index 15e2ccbe35950..bd166c0d9fcdf 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx @@ -57,7 +57,9 @@ void Tracker::clustersToTracks(std::function logger, std::f } for (int iteration = 0; iteration < (int)mTrkParams.size(); ++iteration) { - + if (iteration == 3 && mTrkParams[0].DoUPCIteration) { + mTimeFrame->flipMultiplicityCutMask(); + } logger(fmt::format("ITS Tracking iteration {} summary:", iteration)); double timeTracklets{0.}, timeCells{0.}, timeNeighbours{0.}, timeRoads{0.}; int nTracklets{0}, nCells{0}, nNeighbours{0}, nTracks{-static_cast(mTimeFrame->getNumberOfTracks())}; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 829f4b0b5eeac..0defb5c752e45 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -40,19 +40,25 @@ void ITSTrackingInterface::initialise() LOGP(info, "Tracking mode not set, trying to fetch it from configurable params to: {}", asString(mMode)); } if (mMode == TrackingMode::Async) { - trackParams.resize(3); + trackParams.resize(o2::its::TrackerParamConfig::Instance().doUPCIteration ? 4 : 3); vertParams.resize(2); // The number of actual iterations will be set as a configKeyVal to allow for pp/PbPb choice + trackParams[1].TrackletMinPt = 0.2f; + trackParams[1].CellDeltaTanLambdaSigma *= 2.; + trackParams[2].TrackletMinPt = 0.1f; + trackParams[2].CellDeltaTanLambdaSigma *= 4.; + trackParams[2].MinTrackLength = 4; + if (o2::its::TrackerParamConfig::Instance().doUPCIteration) { + trackParams[3].TrackletMinPt = 0.1f; + trackParams[3].CellDeltaTanLambdaSigma *= 4.; + trackParams[3].MinTrackLength = 4; + trackParams[3].DeltaROF = 0; // UPC specific setting + } for (auto& param : trackParams) { param.ZBins = 64; param.PhiBins = 32; param.CellsPerClusterLimit = 1.e3f; param.TrackletsPerClusterLimit = 1.e3f; } - trackParams[1].TrackletMinPt = 0.2f; - trackParams[1].CellDeltaTanLambdaSigma *= 2.; - trackParams[2].TrackletMinPt = 0.1f; - trackParams[2].CellDeltaTanLambdaSigma *= 4.; - trackParams[2].MinTrackLength = 4; LOGP(info, "Initializing tracker in async. phase reconstruction with {} passes for tracking and {}/{} for vertexing", trackParams.size(), o2::its::VertexerParamConfig::Instance().nIterations, vertParams.size()); vertParams[1].phiCut = 0.015f; vertParams[1].tanLambdaCut = 0.015f; @@ -169,7 +175,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) FastMultEst multEst; // mult estimator std::vector processingMask; - int cutVertexMult{0}, cutRandomMult = int(rofs.size()) - multEst.selectROFs(rofs, compClusters, physTriggers, processingMask); + int cutVertexMult{0}, cutUPCVertex{0}, cutRandomMult = int(rofs.size()) - multEst.selectROFs(rofs, compClusters, physTriggers, processingMask); mTimeFrame->setMultiplicityCutMask(processingMask); float vertexerElapsedTime{0.f}; if (mRunVertexer) { @@ -194,6 +200,11 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) if (mIsMC) { vMCRecInfo = mTimeFrame->getPrimaryVerticesMCRecInfo(iRof); } + if (o2::its::TrackerParamConfig::Instance().doUPCIteration && (vtxSpan.size() && vtxSpan[0].getFlags() == 1)) { // at least one vertex in this ROF and it is from second vertex iteration + LOGP(debug, "ROF {} rejected as vertices are from the UPC iteration", iRof); + processingMask[iRof] = false; + cutUPCVertex++; + } vtxROF.setNEntries(vtxSpan.size()); bool selROF = vtxSpan.size() == 0; for (auto iV{0}; iV < vtxSpan.size(); ++iV) { @@ -223,7 +234,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) mTimeFrame->addPrimaryVertices(vtxVecLoc); } } - LOG(info) << fmt::format(" - rejected {}/{} ROFs: random/mult.sel:{} (seed {}), vtx.sel:{}", cutRandomMult + cutVertexMult, rofspan.size(), cutRandomMult, multEst.lastRandomSeed, cutVertexMult); + LOG(info) << fmt::format(" - rejected {}/{} ROFs: random/mult.sel:{} (seed {}), vtx.sel:{}, upc.sel:{}", cutRandomMult + cutVertexMult + cutUPCVertex, rofspan.size(), cutRandomMult, multEst.lastRandomSeed, cutVertexMult, cutUPCVertex); LOG(info) << fmt::format(" - Vertex seeding total elapsed time: {} ms for {} ({} + {}) vertices found in {}/{} ROFs", vertexerElapsedTime, mTimeFrame->getPrimaryVerticesNum(), From dc0ca6cebfe2b83eac4218517cdc57bcc8cf9461 Mon Sep 17 00:00:00 2001 From: Matteo Concas Date: Thu, 18 Jul 2024 19:01:36 +0200 Subject: [PATCH 11/11] Skip second iteration vertices in first three iterations of the tracking --- .../ITS/tracking/include/ITStracking/Configuration.h | 1 - .../ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h | 4 +++- .../ITS/tracking/include/ITStracking/TrackingConfigParam.h | 1 - Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 3 +-- Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx | 7 ++----- Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx | 6 ++++-- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index 6c8d4317bee38..17844e8338067 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -98,7 +98,6 @@ struct TrackingParameters { bool FindShortTracks = false; bool PerPrimaryVertexProcessing = false; bool SaveTimeBenchmarks = false; - bool SkipDeltaRofIfsecondIterationVtx = false; bool DoUPCIteration = false; }; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h index db01b28264225..de83d37d6c430 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TimeFrame.h @@ -208,7 +208,8 @@ class TimeFrame bool isRoadFake(int i) const; void setMultiplicityCutMask(const std::vector& cutMask) { mMultiplicityCutMask = cutMask; } - void flipMultiplicityCutMask() { mMultiplicityCutMask.flip(); } + void setROFMask(const std::vector& rofMask) { mROFMask = rofMask; } + void swapMasks() { mMultiplicityCutMask.swap(mROFMask); } int hasBogusClusters() const { return std::accumulate(mBogusClusters.begin(), mBogusClusters.end(), 0); } @@ -305,6 +306,7 @@ class TimeFrame std::vector mPositionResolution; std::vector mClusterSize; std::vector mMultiplicityCutMask; + std::vector mROFMask; std::vector> mPValphaX; /// PV x and alpha for track propagation std::vector> mTrackletLabels; std::vector> mCellLabels; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h index b8b473bcf7e73..e76c77008120f 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackingConfigParam.h @@ -82,7 +82,6 @@ struct TrackerParamConfig : public o2::conf::ConfigurableParamHelper logger, std::f for (int iteration = 0; iteration < (int)mTrkParams.size(); ++iteration) { if (iteration == 3 && mTrkParams[0].DoUPCIteration) { - mTimeFrame->flipMultiplicityCutMask(); + mTimeFrame->swapMasks(); } logger(fmt::format("ITS Tracking iteration {} summary:", iteration)); double timeTracklets{0.}, timeCells{0.}, timeNeighbours{0.}, timeRoads{0.}; @@ -479,7 +479,6 @@ void Tracker::getGlobalConfiguration() } } params.DeltaROF = tc.deltaRof; - params.SkipDeltaRofIfsecondIterationVtx = tc.skipDeltaRofIfsecondIterationVtx; params.DoUPCIteration = tc.doUPCIteration; params.MaxChi2ClusterAttachment = tc.maxChi2ClusterAttachment > 0 ? tc.maxChi2ClusterAttachment : params.MaxChi2ClusterAttachment; params.MaxChi2NDF = tc.maxChi2NDF > 0 ? tc.maxChi2NDF : params.MaxChi2NDF; diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx index 65af84b141eac..1722c05ecb4f6 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraits.cxx @@ -98,11 +98,8 @@ void TrackerTraits::computeLayerTracklets(const int iteration, int iROFslice, in for (int iV{startVtx}; iV < endVtx; ++iV) { auto& primaryVertex{primaryVertices[iV]}; - if (mTrkParams[iteration].SkipDeltaRofIfsecondIterationVtx) { - if (primaryVertex.isFlagSet(1)) { - minRof = std::max(startROF, rof0); // same logic but setting like deltaRof=0 - maxRof = std::min(endROF - 1, rof0); - } + if (primaryVertex.isFlagSet(1) && iteration != 3) { + continue; } const float resolution = o2::gpu::CAMath::Sqrt(Sq(mTrkParams[iteration].PVres) / primaryVertex.getNContributors() + Sq(tf->getPositionResolution(iLayer))); diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx index 0defb5c752e45..fd4c5bdc56486 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackingInterface.cxx @@ -174,8 +174,9 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) auto errorLogger = [&](std::string s) { LOG(error) << s; }; FastMultEst multEst; // mult estimator - std::vector processingMask; + std::vector processingMask, processUPCMask; int cutVertexMult{0}, cutUPCVertex{0}, cutRandomMult = int(rofs.size()) - multEst.selectROFs(rofs, compClusters, physTriggers, processingMask); + processUPCMask.resize(processingMask.size(), false); mTimeFrame->setMultiplicityCutMask(processingMask); float vertexerElapsedTime{0.f}; if (mRunVertexer) { @@ -202,7 +203,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) } if (o2::its::TrackerParamConfig::Instance().doUPCIteration && (vtxSpan.size() && vtxSpan[0].getFlags() == 1)) { // at least one vertex in this ROF and it is from second vertex iteration LOGP(debug, "ROF {} rejected as vertices are from the UPC iteration", iRof); - processingMask[iRof] = false; + processUPCMask[iRof] = true; cutUPCVertex++; } vtxROF.setNEntries(vtxSpan.size()); @@ -253,6 +254,7 @@ void ITSTrackingInterface::run(framework::ProcessingContext& pc) } else { mTimeFrame->setMultiplicityCutMask(processingMask); + mTimeFrame->setROFMask(processUPCMask); // Run CA tracker if constexpr (isGPU) { if (mMode == o2::its::TrackingMode::Async) {