From 4589c3d785d5151ab4b39e7e81a108c433c03176 Mon Sep 17 00:00:00 2001 From: Maximiliano Puccio Date: Mon, 5 Oct 2020 12:11:38 +0200 Subject: [PATCH] ITS tracking works on generic N layers --- Detectors/ITSMFT/ITS/tracking/CMakeLists.txt | 2 +- .../tracking/include/ITStracking/Cluster.h | 6 +- .../include/ITStracking/Configuration.h | 48 ++++--- .../tracking/include/ITStracking/Constants.h | 26 ---- .../tracking/include/ITStracking/IOUtils.h | 3 +- .../include/ITStracking/IndexTableUtils.h | 67 ++++++--- .../ITStracking/PrimaryVertexContext.h | 98 ++++--------- .../tracking/include/ITStracking/ROframe.h | 26 ++-- .../ITS/tracking/include/ITStracking/Road.h | 4 +- .../include/ITStracking/TrackerTraits.h | 19 +-- .../include/ITStracking/TrackerTraitsCPU.h | 2 +- .../include/ITStracking/VertexerTraits.h | 56 +++++--- Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx | 20 ++- Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx | 134 ++++-------------- .../ITS/tracking/src/PrimaryVertexContext.cxx | 49 ++++--- Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx | 6 +- Detectors/ITSMFT/ITS/tracking/src/Road.cxx | 4 +- Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx | 22 +-- .../ITS/tracking/src/TrackerTraitsCPU.cxx | 24 ++-- .../ITS/tracking/src/VertexerTraits.cxx | 51 ++++--- .../ITS/workflow/src/CookedTrackerSpec.cxx | 2 +- .../ITSMFT/ITS/workflow/src/TrackerSpec.cxx | 2 +- GPU/GPUTracking/Global/GPUChainITS.cxx | 8 +- GPU/GPUTracking/Global/GPUChainITS.h | 4 +- GPU/GPUTracking/ITS/GPUITSFitter.h | 11 +- GPU/GPUTracking/ITS/GPUITSFitterKernels.cxx | 8 +- macro/run_trac_ca_its.C | 12 +- 27 files changed, 314 insertions(+), 400 deletions(-) diff --git a/Detectors/ITSMFT/ITS/tracking/CMakeLists.txt b/Detectors/ITSMFT/ITS/tracking/CMakeLists.txt index 5465d25b3ab33..7315b166edf54 100644 --- a/Detectors/ITSMFT/ITS/tracking/CMakeLists.txt +++ b/Detectors/ITSMFT/ITS/tracking/CMakeLists.txt @@ -19,7 +19,7 @@ o2_add_library(ITStracking src/Label.cxx src/PrimaryVertexContext.cxx src/Road.cxx - src/StandaloneDebugger.cxx + # src/StandaloneDebugger.cxx src/Tracker.cxx src/TrackerTraitsCPU.cxx src/TrackingConfigParam.cxx diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cluster.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cluster.h index 68c09dc52f5a5..ca7167821c401 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cluster.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Cluster.h @@ -31,9 +31,9 @@ namespace its struct Cluster final { Cluster() = default; Cluster(const float x, const float y, const float z, const int idx); - Cluster(const int, const Cluster&); - Cluster(const int, const float3&, const Cluster&); - void Init(const int, const float3&, const Cluster&); + Cluster(const int, const IndexTableUtils& utils, const Cluster&); + Cluster(const int, const float3&, const IndexTableUtils& utils, const Cluster&); + void Init(const int, const float3&, const IndexTableUtils& utils, const Cluster&); float xCoordinate; // = -999.f; float yCoordinate; // = -999.f; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h index 866e3480cd69a..e7d046682ae07 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Configuration.h @@ -47,29 +47,37 @@ struct TrackingParameters { TrackingParameters& operator=(const TrackingParameters& t); int CellMinimumLevel(); + int CellsPerRoad() const { return NLayers - 2; } + int TrackletsPerRoad() const { return NLayers - 1; } + + int NLayers = 7; + 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}; + int ZBins{256}; + int PhiBins{128}; /// General parameters int ClusterSharing = 0; int MinTrackLength = 7; /// Trackleting cuts float TrackletMaxDeltaPhi = 0.3f; - float TrackletMaxDeltaZ[constants::its::TrackletsPerRoad] = {0.1f, 0.1f, 0.3f, 0.3f, 0.3f, 0.3f}; + std::vector TrackletMaxDeltaZ = {0.1f, 0.1f, 0.3f, 0.3f, 0.3f, 0.3f}; /// Cell finding cuts float CellMaxDeltaTanLambda = 0.025f; - float CellMaxDCA[constants::its::CellsPerRoad] = {0.05f, 0.04f, 0.05f, 0.2f, 0.4f}; + std::vector CellMaxDCA = {0.05f, 0.04f, 0.05f, 0.2f, 0.4f}; float CellMaxDeltaPhi = 0.14f; - float CellMaxDeltaZ[constants::its::CellsPerRoad] = {0.2f, 0.4f, 0.5f, 0.6f, 3.0f}; + std::vector CellMaxDeltaZ = {0.2f, 0.4f, 0.5f, 0.6f, 3.0f}; /// Neighbour finding cuts - float NeighbourMaxDeltaCurvature[constants::its::CellsPerRoad - 1] = {0.008f, 0.0025f, 0.003f, 0.0035f}; - float NeighbourMaxDeltaN[constants::its::CellsPerRoad - 1] = {0.002f, 0.0090f, 0.002f, 0.005f}; + std::vector NeighbourMaxDeltaCurvature = {0.008f, 0.0025f, 0.003f, 0.0035f}; + std::vector NeighbourMaxDeltaN = {0.002f, 0.0090f, 0.002f, 0.005f}; }; struct MemoryParameters { /// Memory coefficients MemoryParameters& operator=(const MemoryParameters& t); int MemoryOffset = 256; - float CellsMemoryCoefficients[constants::its::CellsPerRoad] = {2.3208e-08f, 2.104e-08f, 1.6432e-08f, 1.2412e-08f, 1.3543e-08f}; - float TrackletsMemoryCoefficients[constants::its::TrackletsPerRoad] = {0.0016353f, 0.0013627f, 0.000984f, 0.00078135f, 0.00057934f, 0.00052217f}; + std::vector CellsMemoryCoefficients = {2.3208e-08f, 2.104e-08f, 1.6432e-08f, 1.2412e-08f, 1.3543e-08f}; + std::vector TrackletsMemoryCoefficients = {0.0016353f, 0.0013627f, 0.000984f, 0.00078135f, 0.00057934f, 0.00052217f}; }; inline int TrackingParameters::CellMinimumLevel() @@ -83,34 +91,32 @@ inline TrackingParameters& TrackingParameters::operator=(const TrackingParameter this->MinTrackLength = t.MinTrackLength; /// Trackleting cuts this->TrackletMaxDeltaPhi = t.TrackletMaxDeltaPhi; - for (int iT = 0; iT < constants::its::TrackletsPerRoad; ++iT) - this->TrackletMaxDeltaZ[iT] = t.TrackletMaxDeltaZ[iT]; + this->TrackletMaxDeltaZ = t.TrackletMaxDeltaZ; /// Cell finding cuts this->CellMaxDeltaTanLambda = t.CellMaxDeltaTanLambda; this->CellMaxDeltaPhi = t.CellMaxDeltaPhi; - for (int iC = 0; iC < constants::its::CellsPerRoad; ++iC) { - this->CellMaxDCA[iC] = t.CellMaxDCA[iC]; - this->CellMaxDeltaZ[iC] = t.CellMaxDeltaZ[iC]; - } + this->CellMaxDCA = t.CellMaxDCA; + this->CellMaxDeltaZ = t.CellMaxDeltaZ; /// Neighbour finding cuts - for (int iC = 0; iC < constants::its::CellsPerRoad - 1; ++iC) { - this->NeighbourMaxDeltaCurvature[iC] = t.NeighbourMaxDeltaCurvature[iC]; - this->NeighbourMaxDeltaN[iC] = t.NeighbourMaxDeltaN[iC]; - } + this->NeighbourMaxDeltaCurvature = t.NeighbourMaxDeltaCurvature; + this->NeighbourMaxDeltaN = t.NeighbourMaxDeltaN; return *this; } inline MemoryParameters& MemoryParameters::operator=(const MemoryParameters& t) { this->MemoryOffset = t.MemoryOffset; - for (int iC = 0; iC < constants::its::CellsPerRoad; ++iC) - this->CellsMemoryCoefficients[iC] = t.CellsMemoryCoefficients[iC]; - for (int iT = 0; iT < constants::its::TrackletsPerRoad; ++iT) - this->TrackletsMemoryCoefficients[iT] = t.TrackletsMemoryCoefficients[iT]; + this->CellsMemoryCoefficients = t.CellsMemoryCoefficients; + this->TrackletsMemoryCoefficients = t.TrackletsMemoryCoefficients; return *this; } struct VertexingParameters { + 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}; + int ZBins{256}; + int PhiBins{128}; + float zCut = 0.002f; //0.002f float phiCut = 0.005f; //0.005f float pairCut = 0.04f; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Constants.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Constants.h index e6353c9cae8af..495dd8c47db12 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Constants.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Constants.h @@ -41,43 +41,17 @@ constexpr float FloatMinThreshold{1e-20f}; namespace its { -constexpr int LayersNumber{7}; constexpr int LayersNumberVertexer{3}; -constexpr int TrackletsPerRoad{LayersNumber - 1}; -constexpr int CellsPerRoad{LayersNumber - 2}; constexpr int ClustersPerCell{3}; constexpr int UnusedIndex{-1}; constexpr float Resolution{0.0005f}; -GPU_HOST_DEVICE constexpr GPUArray LayersZCoordinate() -{ - constexpr double s = 1.; // safety margin - return GPUArray{{16.333f + s, 16.333f + s, 16.333f + s, 42.140f + s, 42.140f + s, 73.745f + s, 73.745f + s}}; -} -GPU_HOST_DEVICE constexpr GPUArray LayersRCoordinate() -{ - return GPUArray{{2.33959f, 3.14076f, 3.91924f, 19.6213f, 24.5597f, 34.388f, 39.3329f}}; -} GPU_HOST_DEVICE constexpr GPUArray VertexerHistogramVolume() { return GPUArray{{1.98, 1.98, 40.f}}; } } // namespace its -namespace index_table -{ -constexpr int ZBins{256}; -constexpr int PhiBins{128}; -constexpr float InversePhiBinSize{constants::index_table::PhiBins / constants::math::TwoPi}; -GPU_HOST_DEVICE constexpr GPUArray InverseZBinSize() -{ - constexpr auto zSize = its::LayersZCoordinate(); - return GPUArray{{0.5f * ZBins / (zSize[0]), 0.5f * ZBins / (zSize[1]), 0.5f * ZBins / (zSize[2]), - 0.5f * ZBins / (zSize[3]), 0.5f * ZBins / (zSize[4]), 0.5f * ZBins / (zSize[5]), - 0.5f * ZBins / (zSize[6])}}; -} -} // namespace index_table - namespace pdgcodes { constexpr int PionCode{211}; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IOUtils.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IOUtils.h index 8afe8dbbe4b78..621052f088f91 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IOUtils.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IOUtils.h @@ -55,7 +55,6 @@ constexpr float DefClusErrorCol = o2::itsmft::SegmentationAlpide::PitchCol * 0.5 constexpr float DefClusError2Row = DefClusErrorRow * DefClusErrorRow; constexpr float DefClusError2Col = DefClusErrorCol * DefClusErrorCol; -void loadConfigurations(const std::string&); std::vector loadEventData(const std::string&); void loadEventData(ROframe& events, gsl::span clusters, gsl::span::iterator& pattIt, const itsmft::TopologyDictionary& dict, @@ -63,7 +62,7 @@ void loadEventData(ROframe& events, gsl::span clus int loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& events, gsl::span clusters, gsl::span::iterator& pattIt, const itsmft::TopologyDictionary& dict, const dataformats::MCTruthContainer* mClsLabels = nullptr); -void generateSimpleData(ROframe& event, const int phiDivs, const int zDivs); +// void generateSimpleData(ROframe& event, const int phiDivs, const int zDivs); void convertCompactClusters(gsl::span clusters, gsl::span::iterator& pattIt, diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IndexTableUtils.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IndexTableUtils.h index 228defce3b650..034994ca898f5 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IndexTableUtils.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/IndexTableUtils.h @@ -22,6 +22,7 @@ #endif #include "ITStracking/Constants.h" +#include "ITStracking/Configuration.h" #include "ITStracking/Definitions.h" #include "GPUCommonMath.h" #include "GPUCommonDef.h" @@ -31,42 +32,64 @@ namespace o2 namespace its { -namespace index_table_utils +class IndexTableUtils { -float getInverseZBinSize(const int); -GPUhdi() int getZBinIndex(const int, const float); -GPUhdi() int getPhiBinIndex(const float); -GPUhdi() int getBinIndex(const int, const int); -GPUhdi() int countRowSelectedBins( - const GPUArray&, const int, const int, - const int); -} // namespace index_table_utils + public: + template + void setTrackingParameters(const T& params); + float getInverseZCoordinate(const int layerIndex) const; + GPUhdi() int getZBinIndex(const int, const float) const; + GPUhdi() int getPhiBinIndex(const float) const; + GPUhdi() int getBinIndex(const int, const int) const; + GPUhdi() int countRowSelectedBins(const int*, const int, const int, const int) const; -inline float getInverseZCoordinate(const int layerIndex) + GPUhdi() int getNzBins() const { return mNzBins; } + GPUhdi() int getNphiBins() const { return mNphiBins; } + GPUhdi() float getLayerZ(int i) const { return mLayerZ[i]; } + + private: + int mNzBins = 0; + int mNphiBins = 0; + float mInversePhiBinSize = 0.f; + std::vector mLayerZ; + std::vector mInverseZBinSize; +}; + +template +inline void IndexTableUtils::setTrackingParameters(const T& params) +{ + mInversePhiBinSize = params.PhiBins / constants::math::TwoPi; + mInverseZBinSize.resize(params.LayerZ.size()); + mNzBins = params.ZBins; + mNphiBins = params.PhiBins; + mLayerZ = params.LayerZ; + for (unsigned int iL{0}; iL < mInverseZBinSize.size(); ++iL) { + mInverseZBinSize[iL] = 0.5f * params.ZBins / params.LayerZ[iL]; + } +} + +inline float IndexTableUtils::getInverseZCoordinate(const int layerIndex) const { - return 0.5f * constants::index_table::ZBins / constants::its::LayersZCoordinate()[layerIndex]; + return 0.5f * mNzBins / mLayerZ[layerIndex]; } -GPUhdi() int index_table_utils::getZBinIndex(const int layerIndex, const float zCoordinate) +GPUhdi() int IndexTableUtils::getZBinIndex(const int layerIndex, const float zCoordinate) const { - return (zCoordinate + constants::its::LayersZCoordinate()[layerIndex]) * - constants::index_table::InverseZBinSize()[layerIndex]; + return (zCoordinate + mLayerZ[layerIndex]) * mInverseZBinSize[layerIndex]; } -GPUhdi() int index_table_utils::getPhiBinIndex(const float currentPhi) +GPUhdi() int IndexTableUtils::getPhiBinIndex(const float currentPhi) const { - return (currentPhi * constants::index_table::InversePhiBinSize); + return (currentPhi * mInversePhiBinSize); } -GPUhdi() int index_table_utils::getBinIndex(const int zIndex, const int phiIndex) +GPUhdi() int IndexTableUtils::getBinIndex(const int zIndex, const int phiIndex) const { - return gpu::GPUCommonMath::Min(phiIndex * constants::index_table::ZBins + zIndex, - constants::index_table::ZBins * constants::index_table::PhiBins - 1); + return gpu::GPUCommonMath::Min(phiIndex * mNzBins + zIndex, mNzBins * mNphiBins - 1); } -GPUhdi() int index_table_utils::countRowSelectedBins( - const GPUArray& indexTable, - const int phiBinIndex, const int minZBinIndex, const int maxZBinIndex) +GPUhdi() int IndexTableUtils::countRowSelectedBins(const int* indexTable, const int phiBinIndex, + const int minZBinIndex, const int maxZBinIndex) const { const int firstBinIndex{getBinIndex(minZBinIndex, phiBinIndex)}; const int maxBinIndex{firstBinIndex + maxZBinIndex - minZBinIndex + 1}; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/PrimaryVertexContext.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/PrimaryVertexContext.h index 3c363c4d7219f..6da9ceb77a6b0 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/PrimaryVertexContext.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/PrimaryVertexContext.h @@ -24,6 +24,7 @@ #include "ITStracking/Configuration.h" #include "ITStracking/Constants.h" #include "ITStracking/Definitions.h" +#include "ITStracking/IndexTableUtils.h" #include "ITStracking/Road.h" #include "ITStracking/Tracklet.h" @@ -42,99 +43,56 @@ class PrimaryVertexContext PrimaryVertexContext(const PrimaryVertexContext&) = delete; PrimaryVertexContext& operator=(const PrimaryVertexContext&) = delete; - virtual void initialise(const MemoryParameters& memParam, const std::array, constants::its::LayersNumber>& cl, - const std::array& pv, const int iteration); - const float3& getPrimaryVertex() const; - std::array, constants::its::LayersNumber>& getClusters(); - std::array, constants::its::CellsPerRoad>& getCells(); - std::array, constants::its::CellsPerRoad - 1>& getCellsLookupTable(); - std::array>, constants::its::CellsPerRoad - 1>& getCellsNeighbours(); - std::vector& getRoads(); + virtual void initialise(const MemoryParameters& memParam, const TrackingParameters& trkParam, + const std::vector>& cl, const std::array& pv, const int iteration); + const float3& getPrimaryVertex() const { return mPrimaryVertex; } + auto& getClusters() { return mClusters; } + auto& getCells() { return mCells; } + auto& getCellsLookupTable() { return mCellsLookupTable; } + auto& getCellsNeighbours() { return mCellsNeighbours; } + auto& getRoads() { return mRoads; } float getMinR(int layer) { return mMinR[layer]; } float getMaxR(int layer) { return mMaxR[layer]; } - bool isClusterUsed(int layer, int clusterId) const; + bool isClusterUsed(int layer, int clusterId) const { return mUsedClusters[layer][clusterId]; } void markUsedCluster(int layer, int clusterId); - std::array, - constants::its::TrackletsPerRoad>& - getIndexTables(); - std::array, constants::its::TrackletsPerRoad>& getTracklets(); - std::array, constants::its::CellsPerRoad>& getTrackletsLookupTable(); + auto& getIndexTables() { return mIndexTables; } + auto& getTracklets() { return mTracklets; } + auto& getTrackletsLookupTable() { return mTrackletsLookupTable; } void initialiseRoadLabels(); void setRoadLabel(int i, const unsigned long long& lab, bool fake); const unsigned long long& getRoadLabel(int i) const; bool isRoadFake(int i) const; + IndexTableUtils mIndexTableUtils; + protected: float3 mPrimaryVertex; - std::array mMinR; - std::array mMaxR; - std::array, constants::its::LayersNumber> mUnsortedClusters; - std::array, constants::its::LayersNumber> mClusters; - std::array, constants::its::LayersNumber> mUsedClusters; - std::array, constants::its::CellsPerRoad> mCells; - std::array, constants::its::CellsPerRoad - 1> mCellsLookupTable; - std::array>, constants::its::CellsPerRoad - 1> mCellsNeighbours; + std::vector mMinR; + std::vector mMaxR; + std::vector> mUnsortedClusters; + std::vector> mClusters; + std::vector> mUsedClusters; + std::vector> mCells; + std::vector> mCellsLookupTable; + std::vector>> mCellsNeighbours; std::vector mRoads; - std::array, - constants::its::TrackletsPerRoad> - mIndexTables; - std::array, constants::its::TrackletsPerRoad> mTracklets; - std::array, constants::its::CellsPerRoad> mTrackletsLookupTable; + // std::array, + // constants::its::TrackletsPerRoad> + std::vector> mIndexTables; + std::vector> mTracklets; + std::vector> mTrackletsLookupTable; std::vector> mRoadLabels; }; -inline const float3& PrimaryVertexContext::getPrimaryVertex() const { return mPrimaryVertex; } - -inline std::array, constants::its::LayersNumber>& PrimaryVertexContext::getClusters() -{ - return mClusters; -} - -inline std::array, constants::its::CellsPerRoad>& PrimaryVertexContext::getCells() { return mCells; } - -inline std::array, constants::its::CellsPerRoad - 1>& PrimaryVertexContext::getCellsLookupTable() -{ - return mCellsLookupTable; -} - -inline std::array>, constants::its::CellsPerRoad - 1>& - PrimaryVertexContext::getCellsNeighbours() -{ - return mCellsNeighbours; -} - -inline std::vector& PrimaryVertexContext::getRoads() { return mRoads; } - -inline bool PrimaryVertexContext::isClusterUsed(int layer, int clusterId) const -{ - return mUsedClusters[layer][clusterId]; -} inline void PrimaryVertexContext::markUsedCluster(int layer, int clusterId) { mUsedClusters[layer][clusterId] = true; } -inline std::array, - constants::its::TrackletsPerRoad>& - PrimaryVertexContext::getIndexTables() -{ - return mIndexTables; -} - -inline std::array, constants::its::TrackletsPerRoad>& PrimaryVertexContext::getTracklets() -{ - return mTracklets; -} - -inline std::array, constants::its::CellsPerRoad>& PrimaryVertexContext::getTrackletsLookupTable() -{ - return mTrackletsLookupTable; -} - inline void PrimaryVertexContext::initialiseRoadLabels() { mRoadLabels.clear(); diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROframe.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROframe.h index 99c1578540e4d..45ba3e4498ce3 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROframe.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/ROframe.h @@ -38,7 +38,7 @@ using Vertex = o2::dataformats::Vertex>; class ROframe final { public: - ROframe(int ROframeId); + ROframe(int ROframeId, int nLayers); int getROFrameId() const; const float3& getPrimaryVertex(const int) const; int getPrimaryVerticesNum() const; @@ -49,10 +49,10 @@ class ROframe final int getTotalClusters() const; bool empty() const; - const std::array, constants::its::LayersNumber>& getClusters() const; + const auto& getClusters() const { return mClusters; } const std::vector& getClustersOnLayer(int layerId) const; const std::vector& getTrackingFrameInfoOnLayer(int layerId) const; - const std::array, constants::its::LayersNumber>& getTrackingFrameInfo() const; + const auto& getTrackingFrameInfo() const { return mTrackingFrameInfo; } const TrackingFrameInfo& getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const; const MCCompLabel& getClusterLabels(int layerId, const Cluster& cl) const; @@ -73,10 +73,10 @@ class ROframe final private: const int mROframeId; std::vector mPrimaryVertices; - std::array, constants::its::LayersNumber> mClusters; - std::array, constants::its::LayersNumber> mTrackingFrameInfo; - std::array, constants::its::LayersNumber> mClusterLabels; - std::array, constants::its::LayersNumber> mClusterExternalIndices; + std::vector> mClusters; + std::vector> mTrackingFrameInfo; + std::vector> mClusterLabels; + std::vector> mClusterExternalIndices; }; inline int ROframe::getROFrameId() const { return mROframeId; } @@ -87,11 +87,6 @@ inline int ROframe::getPrimaryVerticesNum() const { return mPrimaryVertices.size inline bool ROframe::empty() const { return getTotalClusters() == 0; } -inline const std::array, constants::its::LayersNumber>& ROframe::getClusters() const -{ - return mClusters; -} - inline const std::vector& ROframe::getClustersOnLayer(int layerId) const { return mClusters[layerId]; @@ -102,11 +97,6 @@ inline const std::vector& ROframe::getTrackingFrameInfoOnLaye return mTrackingFrameInfo[layerId]; } -inline const std::array, constants::its::LayersNumber>& ROframe::getTrackingFrameInfo() const -{ - return mTrackingFrameInfo; -} - inline const TrackingFrameInfo& ROframe::getClusterTrackingFrameInfo(int layerId, const Cluster& cl) const { return mTrackingFrameInfo[layerId][cl.clusterId]; @@ -157,7 +147,7 @@ inline void ROframe::addClusterExternalIndexToLayer(int layer, const int idx) inline void ROframe::clear() { - for (int iL = 0; iL < constants::its::LayersNumber; ++iL) { + for (unsigned int iL = 0; iL < mClusters.size(); ++iL) { mClusters[iL].clear(); mTrackingFrameInfo[iL].clear(); mClusterLabels[iL].clear(); diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Road.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Road.h index 9650eb9fa9ab7..04946fad243e7 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Road.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/Road.h @@ -43,8 +43,10 @@ class Road final void resetRoad(); void addCell(int, int); + static constexpr int mMaxRoadSize = 13; + private: - int mCellIds[constants::its::CellsPerRoad]; + int mCellIds[mMaxRoadSize]; int mRoadSize; int mLabel; bool mIsFakeRoad; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h index 65500276c3374..913cc5dc805ac 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraits.h @@ -41,7 +41,7 @@ namespace its { class TrackITSExt; -typedef std::function& roads, std::array, std::array, const std::array, 7>&, std::vector&)> FuncRunITSTrackFit_t; +typedef std::function& roads, std::vector&, std::vector&, const std::vector>&, std::vector&)> FuncRunITSTrackFit_t; class TrackerTraits { @@ -49,7 +49,7 @@ class TrackerTraits virtual ~TrackerTraits() = default; GPU_HOST_DEVICE static constexpr int4 getEmptyBinsRect() { return int4{0, 0, 0, 0}; } - GPU_DEVICE static const int4 getBinsRect(const Cluster&, const int, const float, const float, float maxdeltaz, float maxdeltaphi); + GPU_DEVICE const int4 getBinsRect(const Cluster&, const int, const float, const float, float maxdeltaz, float maxdeltaphi); void SetRecoChain(o2::gpu::GPUChainITS* chain, FuncRunITSTrackFit_t&& funcRunITSTrackFit) { @@ -59,7 +59,7 @@ class TrackerTraits virtual void computeLayerTracklets(){}; virtual void computeLayerCells(){}; - virtual void refitTracks(const std::array, 7>&, std::vector&){}; + virtual void refitTracks(const std::vector>&, std::vector&){}; void UpdateTrackingParameters(const TrackingParameters& trkPar); PrimaryVertexContext* getPrimaryVertexContext() { return mPrimaryVertexContext; } @@ -85,16 +85,17 @@ inline GPU_DEVICE const int4 TrackerTraits::getBinsRect(const Cluster& currentCl const float zRangeMax = gpu::GPUCommonMath::Max(z1, z2) + maxdeltaz; const float phiRangeMax = currentCluster.phiCoordinate + maxdeltaphi; - if (zRangeMax < -constants::its::LayersZCoordinate()[layerIndex + 1] || - zRangeMin > constants::its::LayersZCoordinate()[layerIndex + 1] || zRangeMin > zRangeMax) { + if (zRangeMax < -mTrkParams.LayerZ[layerIndex + 1] || + zRangeMin > mTrkParams.LayerZ[layerIndex + 1] || zRangeMin > zRangeMax) { return getEmptyBinsRect(); } - return int4{gpu::GPUCommonMath::Max(0, index_table_utils::getZBinIndex(layerIndex + 1, zRangeMin)), - index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMin)), - gpu::GPUCommonMath::Min(constants::index_table::ZBins - 1, index_table_utils::getZBinIndex(layerIndex + 1, zRangeMax)), - index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMax))}; + const IndexTableUtils& utils{mPrimaryVertexContext->mIndexTableUtils}; + return int4{gpu::GPUCommonMath::Max(0, utils.getZBinIndex(layerIndex + 1, zRangeMin)), + utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMin)), + gpu::GPUCommonMath::Min(mTrkParams.ZBins - 1, utils.getZBinIndex(layerIndex + 1, zRangeMax)), + utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMax))}; } } // namespace its } // namespace o2 diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraitsCPU.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraitsCPU.h index 865ae121abe04..a43fc44b28ef1 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraitsCPU.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/TrackerTraitsCPU.h @@ -44,7 +44,7 @@ class TrackerTraitsCPU : public TrackerTraits void computeLayerCells() final; void computeLayerTracklets() final; - void refitTracks(const std::array, 7>& tf, std::vector& tracks) final; + void refitTracks(const std::vector>& tf, std::vector& tracks) final; protected: std::vector> mTracklets; diff --git a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h index be341b69a39a3..e8d4192219465 100644 --- a/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h +++ b/Detectors/ITSMFT/ITS/tracking/include/ITStracking/VertexerTraits.h @@ -45,8 +45,6 @@ namespace its class ROframe; -using constants::index_table::PhiBins; -using constants::index_table::ZBins; using constants::its::LayersNumberVertexer; struct lightVertex { @@ -106,8 +104,11 @@ class VertexerTraits { return int4{0, 0, 0, 0}; } - GPUhd() static const int4 getBinsRect(const Cluster&, const int, const float, float maxdeltaz, float maxdeltaphi); - GPUhd() static const int2 getPhiBins(float phi, float deltaPhi); + GPUhd() const int4 getBinsRect(const Cluster&, const int, const float, float maxdeltaz, float maxdeltaphi); + GPUhd() const int2 getPhiBins(float phi, float deltaPhi); + + GPUhd() static const int4 getBinsRect(const Cluster&, const int, const float, float maxdeltaz, float maxdeltaphi, const IndexTableUtils&); + GPUhd() static const int2 getPhiBins(float phi, float deltaPhi, const IndexTableUtils&); // virtual vertexer interface virtual void reset(); @@ -128,8 +129,9 @@ class VertexerTraits void updateVertexingParameters(const VertexingParameters& vrtPar); VertexingParameters getVertexingParameters() const { return mVrtParams; } - static const std::vector> selectClusters(const std::array& indexTable, - const std::array& selectedBinsRect); + static const std::vector> selectClusters(const int* indexTable, + const std::array& selectedBinsRect, + const IndexTableUtils& utils); std::vector getVertices() const { return mVertices; } // utils @@ -160,7 +162,8 @@ class VertexerTraits #endif VertexingParameters mVrtParams; - std::array, LayersNumberVertexer> mIndexTables; + IndexTableUtils mIndexTableUtils; + std::array, LayersNumberVertexer> mIndexTables; std::vector mVertices; // Frame related quantities @@ -177,6 +180,8 @@ class VertexerTraits inline void VertexerTraits::initialise(ROframe* event) { reset(); + if (!mIndexTableUtils.getNzBins()) + updateVertexingParameters(mVrtParams); arrangeClusters(event); setIsGPU(false); } @@ -189,32 +194,51 @@ inline void VertexerTraits::setIsGPU(const unsigned char isgpu) inline void VertexerTraits::updateVertexingParameters(const VertexingParameters& vrtPar) { 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))); + for (auto& table : mIndexTables) { + table.resize(mIndexTableUtils.getNphiBins() * mIndexTableUtils.getNzBins() + 1, 0); + } } GPUhdi() const int2 VertexerTraits::getPhiBins(float phi, float dPhi) { - return int2{index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phi - dPhi)), - index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phi + dPhi))}; + return VertexerTraits::getPhiBins(phi, dPhi, mIndexTableUtils); +} + +GPUhdi() const int2 VertexerTraits::getPhiBins(float phi, float dPhi, const IndexTableUtils& utils) +{ + return int2{utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phi - dPhi)), + utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phi + dPhi))}; } GPUhdi() const int4 VertexerTraits::getBinsRect(const Cluster& currentCluster, const int layerIndex, - const float directionZIntersection, float maxdeltaz, float maxdeltaphi) + const float directionZIntersection, float maxdeltaz, float maxdeltaphi, + const IndexTableUtils& utils) { const float zRangeMin = directionZIntersection - 2 * maxdeltaz; const float phiRangeMin = currentCluster.phiCoordinate - maxdeltaphi; const float zRangeMax = directionZIntersection + 2 * maxdeltaz; const float phiRangeMax = currentCluster.phiCoordinate + maxdeltaphi; - if (zRangeMax < -constants::its::LayersZCoordinate()[layerIndex + 1] || - zRangeMin > constants::its::LayersZCoordinate()[layerIndex + 1] || zRangeMin > zRangeMax) { + if (zRangeMax < -utils.getLayerZ(layerIndex + 1) || + zRangeMin > utils.getLayerZ(layerIndex + 1) || zRangeMin > zRangeMax) { return getEmptyBinsRect(); } - return int4{gpu::GPUCommonMath::Max(0, index_table_utils::getZBinIndex(layerIndex + 1, zRangeMin)), - index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMin)), - gpu::GPUCommonMath::Min(constants::index_table::ZBins - 1, index_table_utils::getZBinIndex(layerIndex + 1, zRangeMax)), - index_table_utils::getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMax))}; + return int4{gpu::GPUCommonMath::Max(0, utils.getZBinIndex(layerIndex + 1, zRangeMin)), + utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMin)), + gpu::GPUCommonMath::Min(utils.getNzBins() - 1, utils.getZBinIndex(layerIndex + 1, zRangeMax)), + utils.getPhiBinIndex(math_utils::getNormalizedPhiCoordinate(phiRangeMax))}; +} + +GPUhdi() const int4 VertexerTraits::getBinsRect(const Cluster& currentCluster, const int layerIndex, + const float directionZIntersection, float maxdeltaz, float maxdeltaphi) +{ + return VertexerTraits::getBinsRect(currentCluster, layerIndex, directionZIntersection, maxdeltaz, maxdeltaphi, mIndexTableUtils); } // debug diff --git a/Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx b/Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx index ed96496fcfb6e..b6f1c4a0dede6 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Cluster.cxx @@ -13,8 +13,6 @@ /// #include "ITStracking/Cluster.h" - -#include "ITStracking/IndexTableUtils.h" #include "ITStracking/MathUtils.h" namespace o2 @@ -38,21 +36,21 @@ Cluster::Cluster(const float x, const float y, const float z, const int index) // Nothing to do } -Cluster::Cluster(const int layerIndex, const Cluster& other) +Cluster::Cluster(const int layerIndex, const IndexTableUtils& utils, const Cluster& other) : xCoordinate{other.xCoordinate}, yCoordinate{other.yCoordinate}, zCoordinate{other.zCoordinate}, phiCoordinate{getNormalizedPhiCoordinate(calculatePhiCoordinate(other.xCoordinate, other.yCoordinate))}, rCoordinate{calculateRCoordinate(other.xCoordinate, other.yCoordinate)}, clusterId{other.clusterId}, - indexTableBinIndex{index_table_utils::getBinIndex(index_table_utils::getZBinIndex(layerIndex, zCoordinate), - index_table_utils::getPhiBinIndex(phiCoordinate))} + indexTableBinIndex{utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate), + utils.getPhiBinIndex(phiCoordinate))} //, montecarloId{ other.montecarloId } { // Nothing to do } -Cluster::Cluster(const int layerIndex, const float3& primaryVertex, const Cluster& other) +Cluster::Cluster(const int layerIndex, const float3& primaryVertex, const IndexTableUtils& utils, const Cluster& other) : xCoordinate{other.xCoordinate}, yCoordinate{other.yCoordinate}, zCoordinate{other.zCoordinate}, @@ -60,13 +58,13 @@ Cluster::Cluster(const int layerIndex, const float3& primaryVertex, const Cluste calculatePhiCoordinate(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y))}, rCoordinate{calculateRCoordinate(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y)}, clusterId{other.clusterId}, - indexTableBinIndex{index_table_utils::getBinIndex(index_table_utils::getZBinIndex(layerIndex, zCoordinate), - index_table_utils::getPhiBinIndex(phiCoordinate))} + indexTableBinIndex{utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate), + utils.getPhiBinIndex(phiCoordinate))} { // Nothing to do } -void Cluster::Init(const int layerIndex, const float3& primaryVertex, const Cluster& other) +void Cluster::Init(const int layerIndex, const float3& primaryVertex, const IndexTableUtils& utils, const Cluster& other) { xCoordinate = other.xCoordinate; yCoordinate = other.yCoordinate; @@ -75,8 +73,8 @@ void Cluster::Init(const int layerIndex, const float3& primaryVertex, const Clus calculatePhiCoordinate(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y)); rCoordinate = calculateRCoordinate(xCoordinate - primaryVertex.x, yCoordinate - primaryVertex.y); clusterId = other.clusterId; - indexTableBinIndex = index_table_utils::getBinIndex(index_table_utils::getZBinIndex(layerIndex, zCoordinate), - index_table_utils::getPhiBinIndex(phiCoordinate)); + indexTableBinIndex = utils.getBinIndex(utils.getZBinIndex(layerIndex, zCoordinate), + utils.getPhiBinIndex(phiCoordinate)); } TrackingFrameInfo::TrackingFrameInfo(float x, float y, float z, float xTF, float alpha, GPUArray&& posTF, diff --git a/Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx b/Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx index 174100f3166c4..b91aac4736d4c 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/IOUtils.cxx @@ -38,9 +38,6 @@ constexpr int PrimaryVertexLayerId{-1}; constexpr int EventLabelsSeparator{-1}; } // namespace -using o2::its::constants::its::LayersRCoordinate; -using o2::its::constants::its::LayersZCoordinate; - namespace o2 { namespace its @@ -80,18 +77,6 @@ void ioutils::convertCompactClusters(gsl::span clu } } -void ioutils::loadConfigurations(const std::string& fileName) -{ - if (!fileName.empty()) { - std::ifstream inputStream; - inputStream.open(fileName); - nlohmann::json j; - inputStream >> j; - static_cast(Configuration::getInstance()) = j.at("TrackingParameters").get(); - //static_cast(Configuration::getInstance()) = j.at("IndexTableParameters").get(); - } -} - std::vector ioutils::loadEventData(const std::string& fileName) { std::vector events{}; @@ -114,7 +99,7 @@ std::vector ioutils::loadEventData(const std::string& fileName) if (layerId == PrimaryVertexLayerId) { if (clusterId != 0) { - events.emplace_back(events.size()); + events.emplace_back(events.size(), 7); } events.back().addPrimaryVertex(xCoordinate, yCoordinate, zCoordinate); @@ -244,33 +229,33 @@ int ioutils::loadROFrameData(const o2::itsmft::ROFRecord& rof, ROframe& event, g return clusters_in_frame.size(); } -void ioutils::generateSimpleData(ROframe& event, const int phiDivs, const int zDivs = 1) -{ - const float angleOffset = constants::math::TwoPi / static_cast(phiDivs); - // Maximum z allowed on innermost layer should be: ~9,75 - const float zOffsetFirstLayer = (zDivs == 1) ? 0 : 1.5 * (LayersZCoordinate()[6] * LayersRCoordinate()[0]) / (LayersRCoordinate()[6] * (static_cast(zDivs) - 1)); - std::vector x, y; - std::array, 7> z; - for (size_t j{0}; j < zDivs; ++j) { - for (size_t i{0}; i < phiDivs; ++i) { - x.emplace_back(cos(i * angleOffset + 0.001)); // put an epsilon to move from periods (e.g. 20 clusters vs 20 cells) - y.emplace_back(sin(i * angleOffset + 0.001)); - const float zFirstLayer{-static_cast((zDivs - 1.) / 2.) * zOffsetFirstLayer + zOffsetFirstLayer * static_cast(j)}; - z[0].emplace_back(zFirstLayer); - for (size_t iLayer{1}; iLayer < constants::its::LayersNumber; ++iLayer) { - z[iLayer].emplace_back(zFirstLayer * LayersRCoordinate()[iLayer] / LayersRCoordinate()[0]); - } - } - } - - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { - for (int i = 0; i < phiDivs * zDivs; i++) { - o2::MCCompLabel label{i, 0, 0, false}; - event.addClusterLabelToLayer(iLayer, label); //last argument : label, goes into mClustersLabel - event.addClusterToLayer(iLayer, LayersRCoordinate()[iLayer] * x[i], LayersRCoordinate()[iLayer] * y[i], z[iLayer][i], i); //uses 1st constructor for clusters - } - } -} +// void ioutils::generateSimpleData(ROframe& event, const int phiDivs, const int zDivs = 1) +// { +// const float angleOffset = constants::math::TwoPi / static_cast(phiDivs); +// // Maximum z allowed on innermost layer should be: ~9,75 +// const float zOffsetFirstLayer = (zDivs == 1) ? 0 : 1.5 * (LayersZCoordinate()[6] * LayersRCoordinate()[0]) / (LayersRCoordinate()[6] * (static_cast(zDivs) - 1)); +// std::vector x, y; +// std::array, 7> z; +// for (size_t j{0}; j < zDivs; ++j) { +// for (size_t i{0}; i < phiDivs; ++i) { +// x.emplace_back(cos(i * angleOffset + 0.001)); // put an epsilon to move from periods (e.g. 20 clusters vs 20 cells) +// y.emplace_back(sin(i * angleOffset + 0.001)); +// const float zFirstLayer{-static_cast((zDivs - 1.) / 2.) * zOffsetFirstLayer + zOffsetFirstLayer * static_cast(j)}; +// z[0].emplace_back(zFirstLayer); +// for (size_t iLayer{1}; iLayer < 7; ++iLayer) { +// z[iLayer].emplace_back(zFirstLayer * LayersRCoordinate()[iLayer] / LayersRCoordinate()[0]); +// } +// } +// } + +// for (int iLayer{0}; iLayer < 7; ++iLayer) { +// for (int i = 0; i < phiDivs * zDivs; i++) { +// o2::MCCompLabel label{i, 0, 0, false}; +// event.addClusterLabelToLayer(iLayer, label); //last argument : label, goes into mClustersLabel +// event.addClusterToLayer(iLayer, LayersRCoordinate()[iLayer] * x[i], LayersRCoordinate()[iLayer] * y[i], z[iLayer][i], i); //uses 1st constructor for clusters +// } +// } +// } std::vector> ioutils::loadLabels(const int eventsNum, const std::string& fileName) { @@ -364,70 +349,7 @@ void ioutils::writeRoadsReport(std::ofstream& correctRoadsOutputStream, std::ofs } } -void to_json(nlohmann::json& j, const TrackingParameters& par) -{ - std::array tmpTrackletMaxDeltaZ; - std::copy(par.TrackletMaxDeltaZ, par.TrackletMaxDeltaZ + tmpTrackletMaxDeltaZ.size(), tmpTrackletMaxDeltaZ.begin()); - std::array tmpCellMaxDCA; - std::copy(par.CellMaxDCA, par.CellMaxDCA + tmpCellMaxDCA.size(), tmpCellMaxDCA.begin()); - std::array tmpCellMaxDeltaZ; - std::copy(par.CellMaxDeltaZ, par.CellMaxDeltaZ + tmpCellMaxDeltaZ.size(), tmpCellMaxDeltaZ.begin()); - std::array tmpNeighbourMaxDeltaCurvature; - std::copy(par.NeighbourMaxDeltaCurvature, par.NeighbourMaxDeltaCurvature + tmpNeighbourMaxDeltaCurvature.size(), tmpNeighbourMaxDeltaCurvature.begin()); - std::array tmpNeighbourMaxDeltaN; - std::copy(par.NeighbourMaxDeltaN, par.NeighbourMaxDeltaN + tmpNeighbourMaxDeltaN.size(), tmpNeighbourMaxDeltaN.begin()); - j = nlohmann::json{ - {"ClusterSharing", par.ClusterSharing}, - {"MinTrackLength", par.MinTrackLength}, - {"TrackletMaxDeltaPhi", par.TrackletMaxDeltaPhi}, - {"TrackletMaxDeltaZ", tmpTrackletMaxDeltaZ}, - {"CellMaxDeltaTanLambda", par.CellMaxDeltaTanLambda}, - {"CellMaxDCA", tmpCellMaxDCA}, - {"CellMaxDeltaPhi", par.CellMaxDeltaPhi}, - {"CellMaxDeltaZ", tmpCellMaxDeltaZ}, - {"NeighbourMaxDeltaCurvature", tmpNeighbourMaxDeltaCurvature}, - {"NeighbourMaxDeltaN", tmpNeighbourMaxDeltaN}}; -} - -void from_json(const nlohmann::json& j, TrackingParameters& par) -{ - par.ClusterSharing = j.at("ClusterSharing").get(); - par.MinTrackLength = j.at("MinTrackLength").get(); - par.TrackletMaxDeltaPhi = j.at("TrackletMaxDeltaPhi").get(); - par.CellMaxDeltaTanLambda = j.at("CellMaxDeltaTanLambda").get(); - par.CellMaxDeltaPhi = j.at("CellMaxDeltaPhi").get(); - auto tmpTrackletMaxDeltaZ = j.at("TrackletMaxDeltaZ").get>(); - std::copy(tmpTrackletMaxDeltaZ.begin(), tmpTrackletMaxDeltaZ.end(), par.TrackletMaxDeltaZ); - auto tmpCellMaxDCA = j.at("CellMaxDCA").get>(); - std::copy(tmpCellMaxDCA.begin(), tmpCellMaxDCA.end(), par.CellMaxDCA); - auto tmpCellMaxDeltaZ = j.at("CellMaxDeltaZ").get>(); - std::copy(tmpCellMaxDCA.begin(), tmpCellMaxDeltaZ.end(), par.CellMaxDeltaZ); - auto tmpNeighbourMaxDeltaCurvature = j.at("NeighbourMaxDeltaCurvature").get>(); - std::copy(tmpNeighbourMaxDeltaCurvature.begin(), tmpNeighbourMaxDeltaCurvature.end(), par.NeighbourMaxDeltaCurvature); - auto tmpNeighbourMaxDeltaN = j.at("NeighbourMaxDeltaN").get>(); - std::copy(tmpNeighbourMaxDeltaN.begin(), tmpNeighbourMaxDeltaN.end(), par.NeighbourMaxDeltaN); -} -void to_json(nlohmann::json& j, const MemoryParameters& par) -{ - std::array tmpCellsMemoryCoefficients; - std::copy(par.CellsMemoryCoefficients, par.CellsMemoryCoefficients + tmpCellsMemoryCoefficients.size(), tmpCellsMemoryCoefficients.begin()); - std::array tmpTrackletsMemoryCoefficients; - std::copy(par.TrackletsMemoryCoefficients, par.TrackletsMemoryCoefficients + tmpTrackletsMemoryCoefficients.size(), tmpTrackletsMemoryCoefficients.begin()); - j = nlohmann::json{ - {"MemoryOffset", par.MemoryOffset}, - {"CellsMemoryCoefficients", tmpCellsMemoryCoefficients}, - {"TrackletsMemoryCoefficients", tmpTrackletsMemoryCoefficients}}; -} - -void from_json(const nlohmann::json& j, MemoryParameters& par) -{ - par.MemoryOffset = j.at("MemoryOffset").get(); - auto tmpCellsMemoryCoefficients = j.at("CellsMemoryCoefficients").get>(); - std::copy(tmpCellsMemoryCoefficients.begin(), tmpCellsMemoryCoefficients.end(), par.CellsMemoryCoefficients); - auto tmpTrackletsMemoryCoefficients = j.at("TrackletsMemoryCoefficients").get>(); - std::copy(tmpTrackletsMemoryCoefficients.begin(), tmpTrackletsMemoryCoefficients.end(), par.TrackletsMemoryCoefficients); -} } // namespace its } // namespace o2 diff --git a/Detectors/ITSMFT/ITS/tracking/src/PrimaryVertexContext.cxx b/Detectors/ITSMFT/ITS/tracking/src/PrimaryVertexContext.cxx index d4dcbe5f36fc9..45149e0a76b20 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/PrimaryVertexContext.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/PrimaryVertexContext.cxx @@ -21,8 +21,8 @@ namespace o2 namespace its { -void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const std::array, constants::its::LayersNumber>& cl, - const std::array& pVtx, const int iteration) +void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const TrackingParameters& trkParam, + const std::vector>& cl, const std::array& pVtx, const int iteration) { struct ClusterHelper { @@ -38,7 +38,20 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st std::vector cHelper; - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { + mMinR.resize(trkParam.LayerRadii.size(), 10000.); + mMaxR.resize(trkParam.LayerRadii.size(), -1.); + mUnsortedClusters.resize(trkParam.LayerRadii.size()); + mClusters.resize(trkParam.NLayers); + mUsedClusters.resize(trkParam.NLayers); + mCells.resize(trkParam.NLayers - 2); + mCellsLookupTable.resize(trkParam.NLayers - 3); + mCellsNeighbours.resize(trkParam.NLayers - 3); + mIndexTables.resize(trkParam.NLayers - 1, std::vector(trkParam.ZBins * trkParam.PhiBins + 1, 0)); + mTracklets.resize(trkParam.NLayers - 1); + mTrackletsLookupTable.resize(trkParam.NLayers - 2); + mIndexTableUtils.setTrackingParameters(trkParam); + + for (unsigned int iLayer{0}; iLayer < mClusters.size(); ++iLayer) { const auto& currentLayer{cl[iLayer]}; const int clustersNum{static_cast(currentLayer.size())}; @@ -48,11 +61,7 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st mUsedClusters[iLayer].clear(); mUsedClusters[iLayer].resize(clustersNum, false); - constexpr int _size = constants::index_table::PhiBins * constants::index_table::ZBins; - std::array clsPerBin; - for (int iB{0}; iB < _size; ++iB) { - clsPerBin[iB] = 0; - } + std::vector clsPerBin(trkParam.PhiBins * trkParam.ZBins, 0); cHelper.clear(); cHelper.resize(clustersNum); @@ -66,8 +75,8 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st float x = c.xCoordinate - mPrimaryVertex.x; float y = c.yCoordinate - mPrimaryVertex.y; float phi = math_utils::calculatePhiCoordinate(x, y); - int bin = index_table_utils::getBinIndex(index_table_utils::getZBinIndex(iLayer, c.zCoordinate), - index_table_utils::getPhiBinIndex(phi)); + int bin = mIndexTableUtils.getBinIndex(mIndexTableUtils.getZBinIndex(iLayer, c.zCoordinate), + mIndexTableUtils.getPhiBinIndex(phi)); h.phi = phi; h.r = math_utils::calculateRCoordinate(x, y); mMinR[iLayer] = gpu::GPUCommonMath::Min(h.r, mMinR[iLayer]); @@ -76,9 +85,9 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st h.ind = clsPerBin[bin]++; } - std::array lutPerBin; + std::vector lutPerBin(clsPerBin.size()); lutPerBin[0] = 0; - for (int iB{1}; iB < _size; ++iB) { + for (unsigned int iB{1}; iB < lutPerBin.size(); ++iB) { lutPerBin[iB] = lutPerBin[iB - 1] + clsPerBin[iB - 1]; } @@ -92,10 +101,10 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st } if (iLayer > 0) { - for (int iB{0}; iB < _size; ++iB) { + for (unsigned int iB{0}; iB < clsPerBin.size(); ++iB) { mIndexTables[iLayer - 1][iB] = lutPerBin[iB]; } - for (int iB{_size}; iB < (int)mIndexTables[iLayer - 1].size(); iB++) { + for (auto iB{clsPerBin.size()}; iB < (int)mIndexTables[iLayer - 1].size(); iB++) { mIndexTables[iLayer - 1][iB] = clustersNum; } } @@ -104,8 +113,8 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st mRoads.clear(); - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { - if (iLayer < constants::its::CellsPerRoad) { + for (unsigned int iLayer{0}; iLayer < mClusters.size(); ++iLayer) { + if (iLayer < mCells.size()) { mCells[iLayer].clear(); float cellsMemorySize = memParam.MemoryOffset + @@ -118,7 +127,7 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st } } - if (iLayer < constants::its::CellsPerRoad - 1) { + if (iLayer < mCells.size() - 1) { mCellsLookupTable[iLayer].clear(); mCellsLookupTable[iLayer].resize( std::max(cl[iLayer + 1].size(), cl[iLayer + 2].size()) + @@ -130,8 +139,8 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st } } - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { - if (iLayer < constants::its::TrackletsPerRoad) { + for (unsigned int iLayer{0}; iLayer < mClusters.size(); ++iLayer) { + if (iLayer < mTracklets.size()) { mTracklets[iLayer].clear(); float trackletsMemorySize = std::max(cl[iLayer].size(), cl[iLayer + 1].size()) + @@ -143,7 +152,7 @@ void PrimaryVertexContext::initialise(const MemoryParameters& memParam, const st } } - if (iLayer < constants::its::CellsPerRoad) { + if (iLayer < mCells.size()) { mTrackletsLookupTable[iLayer].clear(); mTrackletsLookupTable[iLayer].resize(cl[iLayer + 1].size(), constants::its::UnusedIndex); } diff --git a/Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx b/Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx index d2139bffc5102..093d6019f0b05 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/ROframe.cxx @@ -21,7 +21,11 @@ namespace o2 namespace its { -ROframe::ROframe(const int ROframeId) : mROframeId{ROframeId} +ROframe::ROframe(int ROframeId, int nLayers) : mROframeId{ROframeId}, + mClusters{nLayers}, + mTrackingFrameInfo{nLayers}, + mClusterLabels{nLayers}, + mClusterExternalIndices{nLayers} { } diff --git a/Detectors/ITSMFT/ITS/tracking/src/Road.cxx b/Detectors/ITSMFT/ITS/tracking/src/Road.cxx index da5748bbcd75a..facb1f43fa1e2 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Road.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Road.cxx @@ -13,6 +13,8 @@ /// #include "ITStracking/Road.h" +#include +#include namespace o2 { @@ -25,7 +27,7 @@ Road::Road(int cellLayer, int cellId) : Road() { addCell(cellLayer, cellId); } void Road::resetRoad() { - for (int i = 0; i < constants::its::CellsPerRoad; i++) { + for (int i = 0; i < mMaxRoadSize; i++) { mCellIds[i] = constants::its::UnusedIndex; } mRoadSize = 0; diff --git a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx index e58317517a189..dfc3ba585dca9 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/Tracker.cxx @@ -62,7 +62,7 @@ void Tracker::clustersToTracks(const ROframe& event, std::ostream& timeBenchmark int pass = iteration + iVertex; /// Do not reinitialise the context if we analyse pile-up events std::array pV = {event.getPrimaryVertex(iVertex).x, event.getPrimaryVertex(iVertex).y, event.getPrimaryVertex(iVertex).z}; total += evaluateTask(&Tracker::initialisePrimaryVertexContext, "Context initialisation", - timeBenchmarkOutputStream, mMemParams[iteration], event.getClusters(), pV, pass); + timeBenchmarkOutputStream, mMemParams[iteration], mTrkParams[iteration], event.getClusters(), pV, pass); total += evaluateTask(&Tracker::computeTracklets, "Tracklet finding", timeBenchmarkOutputStream); total += evaluateTask(&Tracker::computeCells, "Cell finding", timeBenchmarkOutputStream); total += evaluateTask(&Tracker::findCellsNeighbours, "Neighbour finding", timeBenchmarkOutputStream, iteration); @@ -93,7 +93,7 @@ void Tracker::computeCells() void Tracker::findCellsNeighbours(int& iteration) { - for (int iLayer{0}; iLayer < constants::its::CellsPerRoad - 1; ++iLayer) { + for (int iLayer{0}; iLayer < mTrkParams[iteration].CellsPerRoad() - 1; ++iLayer) { if (mPrimaryVertexContext->getCells()[iLayer + 1].empty() || mPrimaryVertexContext->getCellsLookupTable()[iLayer].empty()) { @@ -152,11 +152,11 @@ void Tracker::findCellsNeighbours(int& iteration) void Tracker::findRoads(int& iteration) { - for (int iLevel{constants::its::CellsPerRoad}; iLevel >= mTrkParams[iteration].CellMinimumLevel(); --iLevel) { + for (int iLevel{mTrkParams[iteration].CellsPerRoad()}; iLevel >= mTrkParams[iteration].CellMinimumLevel(); --iLevel) { CA_DEBUGGER(int nRoads = -mPrimaryVertexContext->getRoads().size()); const int minimumLevel{iLevel - 1}; - for (int iLayer{constants::its::CellsPerRoad - 1}; iLayer >= minimumLevel; --iLayer) { + for (int iLayer{mTrkParams[iteration].CellsPerRoad() - 1}; iLayer >= minimumLevel; --iLayer) { const int levelCellsNum{static_cast(mPrimaryVertexContext->getCells()[iLayer].size())}; @@ -230,7 +230,7 @@ void Tracker::findTracks(const ROframe& event) int lastCellLevel = constants::its::UnusedIndex; CA_DEBUGGER(int nClusters = 2); - for (int iCell{0}; iCell < constants::its::CellsPerRoad; ++iCell) { + for (int iCell{0}; iCell < mTrkParams[0].CellsPerRoad(); ++iCell) { const int cellIndex = road[iCell]; if (cellIndex == constants::its::UnusedIndex) { continue; @@ -270,18 +270,18 @@ void Tracker::findTracks(const ROframe& event) for (size_t iC = 0; iC < clusters.size(); ++iC) { temporaryTrack.setExternalClusterIndex(iC, clusters[iC], clusters[iC] != constants::its::UnusedIndex); } - bool fitSuccess = fitTrack(event, temporaryTrack, constants::its::LayersNumber - 4, -1, -1); + bool fitSuccess = fitTrack(event, temporaryTrack, mTrkParams[0].NLayers - 4, -1, -1); if (!fitSuccess) continue; CA_DEBUGGER(fitCounters[nClusters - 4]++); temporaryTrack.resetCovariance(); - fitSuccess = fitTrack(event, temporaryTrack, 0, constants::its::LayersNumber, 1); + fitSuccess = fitTrack(event, temporaryTrack, 0, mTrkParams[0].NLayers, 1); if (!fitSuccess) continue; CA_DEBUGGER(backpropagatedCounters[nClusters - 4]++); temporaryTrack.getParamOut() = temporaryTrack; temporaryTrack.resetCovariance(); - fitSuccess = fitTrack(event, temporaryTrack, constants::its::LayersNumber - 1, -1, -1); + fitSuccess = fitTrack(event, temporaryTrack, mTrkParams[0].NLayers - 1, -1, -1); if (!fitSuccess) continue; CA_DEBUGGER(refitCounters[nClusters - 4]++); @@ -306,7 +306,7 @@ void Tracker::findTracks(const ROframe& event) for (auto& track : tracks) { CA_DEBUGGER(int nClusters = 0); int nShared = 0; - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { + for (int iLayer{0}; iLayer < mTrkParams[0].NLayers; ++iLayer) { if (track.getClusterIndex(iLayer) == constants::its::UnusedIndex) { continue; } @@ -331,7 +331,7 @@ void Tracker::findTracks(const ROframe& event) prevNclusters = nClusters; #endif - for (int iLayer{0}; iLayer < constants::its::LayersNumber; ++iLayer) { + for (int iLayer{0}; iLayer < mTrkParams[0].NLayers; ++iLayer) { if (track.getClusterIndex(iLayer) == constants::its::UnusedIndex) { continue; } @@ -469,7 +469,7 @@ void Tracker::computeRoadsMClabels(const ROframe& event) bool isFakeRoad{false}; bool isFirstRoadCell{true}; - for (int iCell{0}; iCell < constants::its::CellsPerRoad; ++iCell) { + for (int iCell{0}; iCell < mTrkParams[0].CellsPerRoad(); ++iCell) { const int currentCellIndex{currentRoad[iCell]}; if (currentCellIndex == constants::its::UnusedIndex) { diff --git a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraitsCPU.cxx b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraitsCPU.cxx index 5925a66c7a204..98e6710ca5481 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/TrackerTraitsCPU.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/TrackerTraitsCPU.cxx @@ -34,7 +34,7 @@ namespace its void TrackerTraitsCPU::computeLayerTracklets() { PrimaryVertexContext* primaryVertexContext = mPrimaryVertexContext; - for (int iLayer{0}; iLayer < constants::its::TrackletsPerRoad; ++iLayer) { + for (int iLayer{0}; iLayer < mTrkParams.TrackletsPerRoad(); ++iLayer) { if (primaryVertexContext->getClusters()[iLayer].empty() || primaryVertexContext->getClusters()[iLayer + 1].empty()) { return; } @@ -67,12 +67,12 @@ void TrackerTraitsCPU::computeLayerTracklets() int phiBinsNum{selectedBinsRect.w - selectedBinsRect.y + 1}; if (phiBinsNum < 0) { - phiBinsNum += constants::index_table::PhiBins; + phiBinsNum += mTrkParams.PhiBins; } for (int iPhiBin{selectedBinsRect.y}, iPhiCount{0}; iPhiCount < phiBinsNum; - iPhiBin = ++iPhiBin == constants::index_table::PhiBins ? 0 : iPhiBin, iPhiCount++) { - const int firstBinIndex{index_table_utils::getBinIndex(selectedBinsRect.x, iPhiBin)}; + iPhiBin = ++iPhiBin == mTrkParams.PhiBins ? 0 : iPhiBin, iPhiCount++) { + const int firstBinIndex{primaryVertexContext->mIndexTableUtils.getBinIndex(selectedBinsRect.x, iPhiBin)}; const int maxBinIndex{firstBinIndex + selectedBinsRect.z - selectedBinsRect.x + 1}; const int firstRowClusterIndex = primaryVertexContext->getIndexTables()[iLayer][firstBinIndex]; const int maxRowClusterIndex = primaryVertexContext->getIndexTables()[iLayer][maxBinIndex]; @@ -113,7 +113,7 @@ void TrackerTraitsCPU::computeLayerTracklets() void TrackerTraitsCPU::computeLayerCells() { PrimaryVertexContext* primaryVertexContext = mPrimaryVertexContext; - for (int iLayer{0}; iLayer < constants::its::CellsPerRoad; ++iLayer) { + for (int iLayer{0}; iLayer < mTrkParams.CellsPerRoad(); ++iLayer) { if (primaryVertexContext->getTracklets()[iLayer + 1].empty() || primaryVertexContext->getTracklets()[iLayer].empty()) { @@ -231,15 +231,15 @@ void TrackerTraitsCPU::computeLayerCells() } } -void TrackerTraitsCPU::refitTracks(const std::array, 7>& tf, std::vector& tracks) +void TrackerTraitsCPU::refitTracks(const std::vector>& tf, std::vector& tracks) { - std::array cells; - for (int iLayer = 0; iLayer < 5; iLayer++) { - cells[iLayer] = mPrimaryVertexContext->getCells()[iLayer].data(); + std::vector cells; + for (int iLayer = 0; iLayer < mTrkParams.CellsPerRoad(); iLayer++) { + cells.push_back(mPrimaryVertexContext->getCells()[iLayer].data()); } - std::array clusters; - for (int iLayer = 0; iLayer < 7; iLayer++) { - clusters[iLayer] = mPrimaryVertexContext->getClusters()[iLayer].data(); + std::vector clusters; + for (int iLayer = 0; iLayer < mTrkParams.NLayers; iLayer++) { + clusters.push_back(mPrimaryVertexContext->getClusters()[iLayer].data()); } mChainRunITSTrackFit(*mChain, mPrimaryVertexContext->getRoads(), clusters, cells, tf, tracks); } diff --git a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx index c55fca3840077..9bc4b48336c93 100644 --- a/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx +++ b/Detectors/ITSMFT/ITS/tracking/src/VertexerTraits.cxx @@ -37,31 +37,30 @@ namespace o2 namespace its { using boost::histogram::indexed; -using constants::index_table::PhiBins; -using constants::index_table::ZBins; -using constants::its::LayersRCoordinate; -using constants::its::LayersZCoordinate; using constants::math::TwoPi; -using index_table_utils::getZBinIndex; void trackleterKernelSerial( const std::vector& clustersNextLayer, // 0 2 const std::vector& clustersCurrentLayer, // 1 1 - const std::array& indexTableNext, + const int* indexTableNext, const unsigned char pairOfLayers, const float phiCut, std::vector& Tracklets, std::vector& foundTracklets, + const IndexTableUtils& utils, // const ROframe* evt = nullptr, const int maxTrackletsPerCluster = static_cast(2e3)) { + const int PhiBins{utils.getNphiBins()}; + const int ZBins{utils.getNzBins()}; + foundTracklets.resize(clustersCurrentLayer.size(), 0); // loop on layer1 clusters for (unsigned int iCurrentLayerClusterIndex{0}; iCurrentLayerClusterIndex < clustersCurrentLayer.size(); ++iCurrentLayerClusterIndex) { int storedTracklets{0}; const Cluster currentCluster{clustersCurrentLayer[iCurrentLayerClusterIndex]}; const int layerIndex{pairOfLayers == LAYER0_TO_LAYER1 ? 0 : 2}; - const int4 selectedBinsRect{VertexerTraits::getBinsRect(currentCluster, layerIndex, 0.f, 50.f, phiCut / 2)}; + const int4 selectedBinsRect{VertexerTraits::getBinsRect(currentCluster, layerIndex, 0.f, 50.f, phiCut / 2, utils)}; if (selectedBinsRect.x != 0 || selectedBinsRect.y != 0 || selectedBinsRect.z != 0 || selectedBinsRect.w != 0) { int phiBinsNum{selectedBinsRect.w - selectedBinsRect.y + 1}; if (phiBinsNum < 0) { @@ -69,7 +68,7 @@ void trackleterKernelSerial( } // loop on phi bins next layer for (int iPhiBin{selectedBinsRect.y}, iPhiCount{0}; iPhiCount < phiBinsNum; iPhiBin = ++iPhiBin == PhiBins ? 0 : iPhiBin, iPhiCount++) { - const int firstBinIndex{index_table_utils::getBinIndex(selectedBinsRect.x, iPhiBin)}; + const int firstBinIndex{utils.getBinIndex(selectedBinsRect.x, iPhiBin)}; const int firstRowClusterIndex{indexTableNext[firstBinIndex]}; const int maxRowClusterIndex{indexTableNext[firstBinIndex + ZBins]}; // loop on clusters next layer @@ -150,9 +149,6 @@ VertexerTraits::VertexerTraits() : mAverageClustersRadii{std::array{0. VertexerTraits::VertexerTraits() : mAverageClustersRadii{std::array{0.f, 0.f, 0.f}}, mMaxDirectorCosine3{0.f} { - mVrtParams.phiSpan = static_cast(std::ceil(constants::index_table::PhiBins * mVrtParams.phiCut / - constants::math::TwoPi)); - mVrtParams.zSpan = static_cast(std::ceil(mVrtParams.zCut * constants::index_table::InverseZBinSize()[0])); } #endif @@ -169,7 +165,7 @@ void VertexerTraits::reset() { for (int iLayer{0}; iLayer < constants::its::LayersNumberVertexer; ++iLayer) { mClusters[iLayer].clear(); - mIndexTables[iLayer].fill(0); + std::fill(mIndexTables[iLayer].begin(), mIndexTables[iLayer].end(), 0); } mTracklets.clear(); @@ -193,6 +189,7 @@ std::vector VertexerTraits::getMClabelsLayer(const int layer) const void VertexerTraits::arrangeClusters(ROframe* event) { + const auto& LayersZCoordinate = mVrtParams.LayerZ; mEvent = event; for (int iLayer{0}; iLayer < constants::its::LayersNumberVertexer; ++iLayer) { const auto& currentLayer{event->getClustersOnLayer(iLayer)}; @@ -202,7 +199,7 @@ void VertexerTraits::arrangeClusters(ROframe* event) mClusters[iLayer].reserve(clustersNum); } for (unsigned int iCluster{0}; iCluster < clustersNum; ++iCluster) { - mClusters[iLayer].emplace_back(iLayer, currentLayer.at(iCluster)); + mClusters[iLayer].emplace_back(iLayer, mIndexTableUtils, currentLayer.at(iCluster)); mAverageClustersRadii[iLayer] += mClusters[iLayer].back().rCoordinate; } mAverageClustersRadii[iLayer] *= 1.f / clustersNum; @@ -221,7 +218,7 @@ void VertexerTraits::arrangeClusters(ROframe* event) previousBinIndex = currentBinIndex; } } - for (int iBin{previousBinIndex + 1}; iBin <= ZBins * PhiBins; iBin++) { + for (int iBin{previousBinIndex + 1}; iBin <= mIndexTableUtils.getNzBins() * mIndexTableUtils.getNphiBins(); iBin++) { mIndexTables[iLayer][iBin] = static_cast(clustersNum); } } @@ -229,24 +226,24 @@ void VertexerTraits::arrangeClusters(ROframe* event) mDeltaRadii10 = mAverageClustersRadii[1] - mAverageClustersRadii[0]; mDeltaRadii21 = mAverageClustersRadii[2] - mAverageClustersRadii[1]; mMaxDirectorCosine3 = - LayersZCoordinate()[2] / std::sqrt(LayersZCoordinate()[2] * LayersZCoordinate()[2] + - (mDeltaRadii10 + mDeltaRadii21) * (mDeltaRadii10 + mDeltaRadii21)); + LayersZCoordinate[2] / std::hypot(LayersZCoordinate[2], mDeltaRadii10 + mDeltaRadii21); } -const std::vector> VertexerTraits::selectClusters(const std::array& indexTable, - const std::array& selectedBinsRect) +const std::vector> VertexerTraits::selectClusters(const int* indexTable, + const std::array& selectedBinsRect, + const IndexTableUtils& utils) { std::vector> filteredBins{}; int phiBinsNum{selectedBinsRect[3] - selectedBinsRect[1] + 1}; if (phiBinsNum < 0) - phiBinsNum += PhiBins; + phiBinsNum += utils.getNphiBins(); filteredBins.reserve(phiBinsNum); for (int iPhiBin{selectedBinsRect[1]}, iPhiCount{0}; iPhiCount < phiBinsNum; - iPhiBin = ++iPhiBin == PhiBins ? 0 : iPhiBin, iPhiCount++) { - const int firstBinIndex{index_table_utils::getBinIndex(selectedBinsRect[0], iPhiBin)}; + iPhiBin = ++iPhiBin == utils.getNphiBins() ? 0 : iPhiBin, iPhiCount++) { + const int firstBinIndex{utils.getBinIndex(selectedBinsRect[0], iPhiBin)}; filteredBins.emplace_back( indexTable[firstBinIndex], - index_table_utils::countRowSelectedBins(indexTable, iPhiBin, selectedBinsRect[0], selectedBinsRect[2])); + utils.countRowSelectedBins(indexTable, iPhiBin, selectedBinsRect[0], selectedBinsRect[2])); } return filteredBins; } @@ -311,20 +308,22 @@ void VertexerTraits::computeTracklets() trackleterKernelSerial( mClusters[0], mClusters[1], - mIndexTables[0], + mIndexTables[0].data(), LAYER0_TO_LAYER1, mVrtParams.phiCut, mComb01, - mFoundTracklets01); + mFoundTracklets01, + mIndexTableUtils); trackleterKernelSerial( mClusters[2], mClusters[1], - mIndexTables[2], + mIndexTables[2].data(), LAYER1_TO_LAYER2, mVrtParams.phiCut, mComb12, - mFoundTracklets12); + mFoundTracklets12, + mIndexTableUtils); #ifdef _ALLOW_DEBUG_TREES_ITS_ if (isDebugFlag(VertexerDebug::CombinatoricsTreeAll)) { diff --git a/Detectors/ITSMFT/ITS/workflow/src/CookedTrackerSpec.cxx b/Detectors/ITSMFT/ITS/workflow/src/CookedTrackerSpec.cxx index 3ae9eb90fecfd..0b256de8e34fb 100644 --- a/Detectors/ITSMFT/ITS/workflow/src/CookedTrackerSpec.cxx +++ b/Detectors/ITSMFT/ITS/workflow/src/CookedTrackerSpec.cxx @@ -119,7 +119,7 @@ void CookedTrackerDPL::run(ProcessingContext& pc) o2::its::VertexerTraits vertexerTraits; o2::its::Vertexer vertexer(&vertexerTraits); - o2::its::ROframe event(0); + o2::its::ROframe event(0, 7); auto& vertROFvec = pc.outputs().make>(Output{"ITS", "VERTICESROF", 0, Lifetime::Timeframe}); auto& vertices = pc.outputs().make>(Output{"ITS", "VERTICES", 0, Lifetime::Timeframe}); diff --git a/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx b/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx index 83047fed62448..190da2a52d6d2 100644 --- a/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx +++ b/Detectors/ITSMFT/ITS/workflow/src/TrackerSpec.cxx @@ -130,7 +130,7 @@ void TrackerDPL::run(ProcessingContext& pc) auto& vertices = pc.outputs().make>(Output{"ITS", "VERTICES", 0, Lifetime::Timeframe}); std::uint32_t roFrame = 0; - ROframe event(0); + ROframe event(0, 7); bool continuous = mGRP->isDetContinuousReadOut("ITS"); LOG(INFO) << "ITSTracker RO: continuous=" << continuous; diff --git a/GPU/GPUTracking/Global/GPUChainITS.cxx b/GPU/GPUTracking/Global/GPUChainITS.cxx index c828884b69328..a6db94b02b007 100644 --- a/GPU/GPUTracking/Global/GPUChainITS.cxx +++ b/GPU/GPUTracking/Global/GPUChainITS.cxx @@ -70,13 +70,13 @@ int GPUChainITS::Finalize() { return 0; } int GPUChainITS::RunChain() { return 0; } -int GPUChainITS::PrepareAndRunITSTrackFit(std::vector& roads, std::array clusters, std::array cells, const std::array, 7>& tf, std::vector& tracks) +int GPUChainITS::PrepareAndRunITSTrackFit(std::vector& roads, std::vector& clusters, std::vector& cells, const std::vector>& tf, std::vector& tracks) { mRec->PrepareEvent(); return RunITSTrackFit(roads, clusters, cells, tf, tracks); } -int GPUChainITS::RunITSTrackFit(std::vector& roads, std::array clusters, std::array cells, const std::array, 7>& tf, std::vector& tracks) +int GPUChainITS::RunITSTrackFit(std::vector& roads, std::vector& clusters, std::vector& cells, const std::vector>& tf, std::vector& tracks) { auto threadContext = GetThreadContext(); bool doGPU = GetRecoStepsGPU() & RecoStep::ITSTracking; @@ -85,7 +85,7 @@ int GPUChainITS::RunITSTrackFit(std::vector& roads, std::arrayioPtrs); @@ -93,7 +93,7 @@ int GPUChainITS::RunITSTrackFit(std::vector& roads, std::array& roads, std::array clusters, std::array cells, const std::array, 7>& tf, std::vector& tracks); - int RunITSTrackFit(std::vector& roads, std::array clusters, std::array cells, const std::array, 7>& tf, std::vector& tracks); + int PrepareAndRunITSTrackFit(std::vector& roads, std::vector& clusters, std::vector& cells, const std::vector>& tf, std::vector& tracks); + int RunITSTrackFit(std::vector& roads, std::vector& clusters, std::vector& cells, const std::vector>& tf, std::vector& tracks); o2::its::TrackerTraits* GetITSTrackerTraits(); o2::its::VertexerTraits* GetITSVertexerTraits(); diff --git a/GPU/GPUTracking/ITS/GPUITSFitter.h b/GPU/GPUTracking/ITS/GPUITSFitter.h index c45efa0048adf..fc27cc985808a 100644 --- a/GPU/GPUTracking/ITS/GPUITSFitter.h +++ b/GPU/GPUTracking/ITS/GPUITSFitter.h @@ -56,6 +56,8 @@ class GPUITSFitter : public GPUProcessor { return mMemory->mNumberOfTracks; } + GPUd() void SetNumberOfLayers(int i) { mNumberOfLayers = i; } + GPUd() int NumberOfLayers() { return mNumberOfLayers; } GPUd() void SetNumberTF(int i, int v) { mNTF[i] = v; } GPUd() o2::its::TrackingFrameInfo** trackingFrame() { @@ -77,16 +79,17 @@ class GPUITSFitter : public GPUProcessor }; protected: + int mNumberOfLayers; int mNumberOfRoads = 0; int mNMaxTracks = 0; - int mNTF[7] = {}; + int* mNTF = nullptr; Memory* mMemory = nullptr; o2::its::Road* mRoads = nullptr; - o2::its::TrackingFrameInfo* mTF[7] = {}; + o2::its::TrackingFrameInfo** mTF = {nullptr}; GPUITSTrack* mTracks = nullptr; - const o2::its::Cluster* mClusterPtrs[7]; - const o2::its::Cell* mCellPtrs[5]; + const o2::its::Cluster** mClusterPtrs; + const o2::its::Cell** mCellPtrs; short mMemoryResInput = -1; short mMemoryResTracks = -1; diff --git a/GPU/GPUTracking/ITS/GPUITSFitterKernels.cxx b/GPU/GPUTracking/ITS/GPUITSFitterKernels.cxx index 9aa51d047b13f..3fa9c2b2aedc7 100644 --- a/GPU/GPUTracking/ITS/GPUITSFitterKernels.cxx +++ b/GPU/GPUTracking/ITS/GPUITSFitterKernels.cxx @@ -78,7 +78,7 @@ GPUdii() void GPUITSFitterKernel::Thread<0>(int nBlocks, int nThreads, int iBloc int lastCellLevel = o2::its::constants::its::UnusedIndex; CA_DEBUGGER(int nClusters = 2); - for (int iCell{0}; iCell < o2::its::constants::its::CellsPerRoad; ++iCell) { + for (int iCell{0}; iCell < Fitter.NumberOfLayers() - 2; ++iCell) { const int cellIndex = road[iCell]; if (cellIndex == o2::its::constants::its::UnusedIndex) { continue; @@ -164,13 +164,13 @@ GPUdii() void GPUITSFitterKernel::Thread<0>(int nBlocks, int nThreads, int iBloc for (size_t iC = 0; iC < 7; ++iC) { temporaryTrack.mClusters[iC] = clusters[iC]; } - bool fitSuccess = fitTrack(Fitter, prop, temporaryTrack, o2::its::constants::its::LayersNumber - 4, -1, -1); + bool fitSuccess = fitTrack(Fitter, prop, temporaryTrack, Fitter.NumberOfLayers() - 4, -1, -1); if (!fitSuccess) { continue; } CA_DEBUGGER(fitCounters[nClusters - 4]++); temporaryTrack.ResetCovariance(); - fitSuccess = fitTrack(Fitter, prop, temporaryTrack, 0, o2::its::constants::its::LayersNumber, 1); + fitSuccess = fitTrack(Fitter, prop, temporaryTrack, 0, Fitter.NumberOfLayers(), 1); if (!fitSuccess) { continue; } @@ -184,7 +184,7 @@ GPUdii() void GPUITSFitterKernel::Thread<0>(int nBlocks, int nThreads, int iBloc temporaryTrack.mOuterParam.X = temporaryTrack.X(); temporaryTrack.mOuterParam.alpha = prop.GetAlpha(); temporaryTrack.ResetCovariance(); - fitSuccess = fitTrack(Fitter, prop, temporaryTrack, o2::its::constants::its::LayersNumber - 1, -1, -1); + fitSuccess = fitTrack(Fitter, prop, temporaryTrack, Fitter.NumberOfLayers() - 1, -1, -1); if (!fitSuccess) { continue; } diff --git a/macro/run_trac_ca_its.C b/macro/run_trac_ca_its.C index c004c3dfd15a6..7de5057592c9a 100644 --- a/macro/run_trac_ca_its.C +++ b/macro/run_trac_ca_its.C @@ -63,13 +63,13 @@ void run_trac_ca_its(std::string path = "./", gSystem->Load("libO2ITStracking.so"); //std::unique_ptr rec(GPUReconstruction::CreateInstance()); - std::unique_ptr rec(GPUReconstruction::CreateInstance("CUDA", true)); // for GPU with CUDA - auto* chainITS = rec->AddChain(); - rec->Init(); + // std::unique_ptr rec(GPUReconstruction::CreateInstance("CUDA", true)); // for GPU with CUDA + // auto* chainITS = rec->AddChain(); + // rec->Init(); - o2::its::Tracker tracker(chainITS->GetITSTrackerTraits()); - //o2::its::Tracker tracker(new o2::its::TrackerTraitsCPU()); - o2::its::ROframe event(0); + // o2::its::Tracker tracker(chainITS->GetITSTrackerTraits()); + o2::its::Tracker tracker(new o2::its::TrackerTraitsCPU()); + o2::its::ROframe event(0, 7); if (path.back() != '/') { path += '/';