Project
Loading...
Searching...
No Matches
TimeFrame.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
18
19#ifndef ALICEO2_ITSMFT_TRACKING_TIMEFRAME_H_
20#define ALICEO2_ITSMFT_TRACKING_TIMEFRAME_H_
21
22#include <memory>
23#include <array>
24#include <cstddef>
25#include <optional>
26#include <vector>
27
28#include <gsl/gsl>
29
43
45{
46
49
50struct TimeFrame {
51 TimeFrame() = default;
52 TimeFrame(const TimeFrame&) = delete;
53 TimeFrame& operator=(const TimeFrame&) = delete;
54 virtual ~TimeFrame() = default;
55
56 const Vertex& getPrimaryVertex(const int ivtx) const { return mPrimaryVertices[ivtx]; }
57 auto& getPrimaryVertices() { return mPrimaryVertices; };
58 auto getPrimaryVerticesNum() { return mPrimaryVertices.size(); };
59 const auto& getPrimaryVertices() const { return mPrimaryVertices; };
60 auto& getPrimaryVerticesLabels() { return mPrimaryVerticesLabels; };
61 void addPrimaryVertex(const Vertex& vertex);
62 void addPrimaryVertexLabel(const VertexLabel& label) { mPrimaryVerticesLabels.push_back(label); }
63
64 void resetBeamXY(const float x, const float y, const float w = 0);
65 void setBeamPosition(const float x, const float y, const float s2, const float base = 50.f, const float systematic = 0.f)
66 {
67 isBeamPositionOverridden = true;
68 resetBeamXY(x, y, s2 / o2::gpu::CAMath::Sqrt((base * base) + systematic));
69 mBeamPositionVariance = s2;
70 }
71
72 float getBeamX() const { return mBeamPos[0]; }
73 float getBeamY() const { return mBeamPos[1]; }
74 float getBeamPositionVariance() const { return mBeamPositionVariance; }
75 std::array<float, 2>& getBeamXY() { return mBeamPos; }
76
77 void setBz(float bz) { mBz = bz; }
78 float getBz() const { return mBz; }
79
80 gsl::span<const GlobalMeasurement> getGlobalMeasurements(LayerId surface) const;
81 gsl::span<GlobalMeasurement> getGlobalMeasurements(LayerId surface);
82 void addMeasurement(LayerId surface, GlobalMeasurement global,
83 const SurfaceMeasurement& measurement);
84 void addMeasurement(LayerId surface, GlobalMeasurement global,
85 const SurfaceMeasurement& measurement,
86 gsl::span<const o2::MCCompLabel> labels);
87 void setHasMCInformation(bool value) noexcept { mHasMCInformation = value; }
88 const SurfaceMeasurement* getSurfaceMeasurement(LayerId layer, uint32_t clusterId) const noexcept;
89 gsl::span<const o2::MCCompLabel> getLabels(LayerId layer, uint32_t clusterId) const;
90 uint32_t getNMeasurementSurfaces() const noexcept { return static_cast<uint32_t>(mLayerGlobalMeasurements.size()); }
91 std::size_t getTotalMeasurements() const noexcept;
92
93 int getTotalClusters() const { return static_cast<int>(getTotalMeasurements()); }
94 bool empty() const { return getTotalMeasurements() == 0; }
95 int getSortedIndex(int rofId, int layer, int idx) const { return mROFramesClusters[layer][rofId] + idx; }
96 int getSortedStartIndex(int rofId, int layer) const { return mROFramesClusters[layer][rofId]; }
97 int getNrof(int layer) const
98 {
99 return mROFramesClusters[layer].empty() ? 0 : static_cast<int>(mROFramesClusters[layer].size()) - 1;
100 }
101 gsl::span<GlobalMeasurement> getClustersOnLayer(int rofId, int layer);
102 gsl::span<const GlobalMeasurement> getClustersOnLayer(int rofId, int layer) const;
103 auto& getClusters() noexcept { return mLayerGlobalMeasurements; }
104 const auto& getClusters() const noexcept { return mLayerGlobalMeasurements; }
105 gsl::span<const GlobalMeasurement> getClustersPerROFrange(int rofMin, int range, int layer) const;
106 gsl::span<const int> getROFramesClustersPerROFrange(int rofMin, int range, int layer) const;
107 gsl::span<const int> getROFrameClusters(int layer) const;
108 gsl::span<int> getIndexTable(int rofId, int layer);
109 int getClusterROF(int layer, int cluster) const;
110 int getTotalClustersPerROFrange(int rofMin, int range, int layer) const;
111
112 bool isClusterUsed(int layer, uint32_t clusterId) const;
113 void markUsedCluster(int layer, uint32_t clusterId);
114 gsl::span<unsigned char> getUsedClusters(int layer);
115 std::size_t getNumberOfClusters() const;
116 std::size_t getNumberOfUsedClusters() const;
117
118 float getMinR(int layer) const { return mMinR[layer]; }
119 float getMaxR(int layer) const { return mMaxR[layer]; }
120 float getMinZ(int layer) const { return mMinZ[layer]; }
121 float getMaxZ(int layer) const { return mMaxZ[layer]; }
122 const auto& getIndexTableUtils() const { return mIndexTableUtils[0]; }
123 const auto& getIndexTableUtils(int layer) const { return mIndexTableUtils[layer]; }
124
125 void setROFViews(RuntimeROFViews views) noexcept;
126 void setROFViews(std::size_t position, RuntimeROFViews views, uint16_t localLayer);
127 void setROFClusters(std::size_t position, gsl::span<const int> boundaries);
128 const RuntimeROFViews& getROFViews() const noexcept { return mROFViews; }
129 const RuntimeROFViews& getROFViews(int layer) const noexcept { return mROFViewsBySurface.empty() ? mROFViews : mROFViewsBySurface[layer]; }
130 int getROFLocalLayer(int layer) const noexcept { return mROFLocalLayerBySurface.empty() ? layer : mROFLocalLayerBySurface[layer]; }
131 const ROFTimingLayer& getROFTiming(int layer) const noexcept { return getROFViews(layer).overlap.getLayer(getROFLocalLayer(layer)); }
132 const RuntimeROFTableEntry& getROFOverlap(int fromLayer, int toLayer, int rof) const noexcept;
133 bool isROFEnabled(int layer, int rof) const noexcept;
134 bool isVertexCompatible(int layer, int rof, const Vertex& vertex) const noexcept;
135 o2::its::TimeEstBC getROFTimeStamp(int fromLayer, int fromROF, int toLayer, int toROF) const noexcept;
136 int getMaxVerticesPerROF() const noexcept;
137 const RuntimeROFOverlapView& getROFOverlapView() const noexcept { return mROFViews.overlap; }
139 const RuntimeROFMaskView& getROFMaskView() const noexcept { return mUseUPC ? mROFViews.upcMask : mROFViews.mask; }
140 void useUPCMask() noexcept { mUseUPC = true; }
141 gsl::span<const Vertex> getPrimaryVertices(int layer, int rofId) const;
142
143 bool hasMCinformation() const noexcept;
144 gsl::span<const MCCompLabel> getClusterLabels(int layer, int cluster) const;
145
146 // Clear TimeFrame data while preserving configuration and allocator identity.
148
150 const TimeFrameScratch& getScratch() const;
151 CapacityEstimator& getCapacityEstimator() noexcept { return mCapacityEstimator; }
152 const CapacityEstimator& getCapacityEstimator() const noexcept { return mCapacityEstimator; }
153
154 bool configure(DetectorConfiguration&& layout, std::size_t maxEdges, std::size_t maxCells,
155 std::shared_ptr<BoundedMemoryResource> memoryPool);
156 bool isConfigured() const noexcept { return mConfigurationValid; }
157 const DetectorConfiguration& getDetectorConfiguration() const noexcept { return mDetectorConfiguration; }
158
159 // Results are valid only with this TimeFrame's measurements.
160 auto& getGenericTracks() { return mGenericTracks; }
161 const auto& getGenericTracks() const { return mGenericTracks; }
162 auto& getTrackLabels() { return mTrackLabels; }
163 const auto& getTrackLabels() const { return mTrackLabels; }
164 // Flat inner-to-outer references; IDs are stable pre-sort positions in the
165 // TimeFrame-owned per-surface arrays.
166 auto& getTrackClusterIndices() { return mTrackClusterIndices; }
167 const auto& getTrackClusterIndices() const { return mTrackClusterIndices; }
168
170 void setMemoryPool(std::shared_ptr<BoundedMemoryResource> pool);
171 auto& getMemoryPool() const noexcept { return mMemoryPool; }
172
173 private:
174 // Must outlive containers allocated from it (reverse destruction order).
175 std::shared_ptr<BoundedMemoryResource> mMemoryPool;
176
177 // TimeFrame and cross-iteration tracking state.
178 std::vector<std::vector<int>> mROFramesClusters;
179 std::vector<bounded_vector<int>> mIndexTables;
180 std::vector<std::vector<uint8_t>> mLayerUsedClusters;
181 IndexTableConfigurationSet mIndexTableUtils;
182 std::vector<float> mMinR;
183 std::vector<float> mMaxR;
184 std::vector<float> mMinZ;
185 std::vector<float> mMaxZ;
186
187 RuntimeROFViews mROFViews{};
188 std::vector<RuntimeROFViews> mROFViewsBySurface;
189 std::vector<uint16_t> mROFLocalLayerBySurface;
190 bool mUseUPC{false};
191
192 float mBz = 5.;
193 unsigned int mNTotalLowPtVertices = 0;
194 int mBeamPosWeight = 0;
195 std::array<float, 2> mBeamPos = {0.f, 0.f};
196 float mBeamPositionVariance = 0.f;
197 bool isBeamPositionOverridden = false;
198
199 bounded_vector<Vertex> mPrimaryVertices;
200 bounded_vector<VertexLabel> mPrimaryVerticesLabels;
201
202 bounded_vector<GenericTrack> mGenericTracks;
203 bounded_vector<MCCompLabel> mTrackLabels;
204 bounded_vector<TrackClusterReference> mTrackClusterIndices;
205
206 std::vector<std::vector<GlobalMeasurement>> mLayerGlobalMeasurements;
207 std::vector<std::vector<SurfaceMeasurement>> mLayerSurfaceMeasurements;
208 std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>> mLayerClusterLabels;
209 bool mHasMCInformation{false};
210
211 bool mConfigurationValid = false;
212 DetectorConfiguration mDetectorConfiguration;
213 TimeFrameScratch mScratch;
214 CapacityEstimator mCapacityEstimator;
215 void prepareIndexTables(const IndexTableConfigurationSet& indexTableConfigs);
216 void prepareClusters(int maxLayers);
217 friend class Tracker;
218};
219
220} // namespace o2::itsmft::tracking
221
222#endif /* ALICEO2_ITSMFT_TRACKING_TIMEFRAME_H_ */
Cross-timeframe output-size prediction.
uint64_t vertex
Definition RawEventData.h:9
std::vector< o2::MCCompLabel > labels
Definition of a container to keep Monte Carlo truth external to simulation objects.
Runtime-plan-owned, detector-neutral CA workspace.
GLint GLenum GLint x
Definition glcorearb.h:403
GLenum GLint * range
Definition glcorearb.h:1899
GLint y
Definition glcorearb.h:270
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
std::pair< o2::MCCompLabel, float > VertexLabel
Definition Vertex.h:27
o2::dataformats::Vertex< o2::its::TimeEstBC > Vertex
Definition Vertex.h:26
o2::its::VertexLabel VertexLabel
Definition TimeFrame.h:48
uint32_t trackClusterIndicesSize noexcept
RuntimeROFVertexLookupView vertexLookup
Definition ROFViews.h:375
RuntimeROFOverlapView overlap
Definition ROFViews.h:374
TimeFrame(const TimeFrame &)=delete
const auto & getPrimaryVertices() const
Definition TimeFrame.h:59
float getBeamPositionVariance() const
Definition TimeFrame.h:74
gsl::span< const MCCompLabel > getClusterLabels(int layer, int cluster) const
TimeFrame & operator=(const TimeFrame &)=delete
void setROFClusters(std::size_t position, gsl::span< const int > boundaries)
gsl::span< const int > getROFrameClusters(int layer) const
bool hasMCinformation() const noexcept
void markUsedCluster(int layer, uint32_t clusterId)
float getMinZ(int layer) const
Definition TimeFrame.h:120
const auto & getGenericTracks() const
Definition TimeFrame.h:161
void addPrimaryVertexLabel(const VertexLabel &label)
Definition TimeFrame.h:62
const RuntimeROFTableEntry & getROFOverlap(int fromLayer, int toLayer, int rof) const noexcept
const auto & getIndexTableUtils(int layer) const
Definition TimeFrame.h:123
int getSortedStartIndex(int rofId, int layer) const
Definition TimeFrame.h:96
const RuntimeROFMaskView & getROFMaskView() const noexcept
Definition TimeFrame.h:139
void addPrimaryVertex(const Vertex &vertex)
Definition TimeFrame.cxx:28
void setBeamPosition(const float x, const float y, const float s2, const float base=50.f, const float systematic=0.f)
Definition TimeFrame.h:65
void setHasMCInformation(bool value) noexcept
Definition TimeFrame.h:87
auto & getClusters() noexcept
Definition TimeFrame.h:103
const DetectorConfiguration & getDetectorConfiguration() const noexcept
Definition TimeFrame.h:157
void addMeasurement(LayerId surface, GlobalMeasurement global, const SurfaceMeasurement &measurement)
Definition TimeFrame.cxx:56
int getNrof(int layer) const
Definition TimeFrame.h:97
const RuntimeROFViews & getROFViews() const noexcept
Definition TimeFrame.h:128
TimeFrameScratch & getScratch()
void setROFViews(RuntimeROFViews views) noexcept
int getSortedIndex(int rofId, int layer, int idx) const
Definition TimeFrame.h:95
std::size_t getTotalMeasurements() const noexcept
Definition TimeFrame.cxx:96
bool isConfigured() const noexcept
Definition TimeFrame.h:156
gsl::span< const o2::MCCompLabel > getLabels(LayerId layer, uint32_t clusterId) const
Definition TimeFrame.cxx:88
CapacityEstimator & getCapacityEstimator() noexcept
Definition TimeFrame.h:151
o2::its::TimeEstBC getROFTimeStamp(int fromLayer, int fromROF, int toLayer, int toROF) const noexcept
const auto & getIndexTableUtils() const
Definition TimeFrame.h:122
const CapacityEstimator & getCapacityEstimator() const noexcept
Definition TimeFrame.h:152
bool isClusterUsed(int layer, uint32_t clusterId) const
uint32_t getNMeasurementSurfaces() const noexcept
Definition TimeFrame.h:90
gsl::span< int > getIndexTable(int rofId, int layer)
int getROFLocalLayer(int layer) const noexcept
Definition TimeFrame.h:130
const SurfaceMeasurement * getSurfaceMeasurement(LayerId layer, uint32_t clusterId) const noexcept
Definition TimeFrame.cxx:79
float getMaxR(int layer) const
Definition TimeFrame.h:119
const RuntimeROFVertexLookupView & getROFVertexLookupView() const noexcept
Definition TimeFrame.h:138
gsl::span< const int > getROFramesClustersPerROFrange(int rofMin, int range, int layer) const
void resetBeamXY(const float x, const float y, const float w=0)
Definition TimeFrame.cxx:39
const auto & getTrackLabels() const
Definition TimeFrame.h:163
void setMemoryPool(std::shared_ptr< BoundedMemoryResource > pool)
memory management
const auto & getClusters() const noexcept
Definition TimeFrame.h:104
int getMaxVerticesPerROF() const noexcept
const ROFTimingLayer & getROFTiming(int layer) const noexcept
Definition TimeFrame.h:131
const RuntimeROFViews & getROFViews(int layer) const noexcept
Definition TimeFrame.h:129
int getTotalClustersPerROFrange(int rofMin, int range, int layer) const
std::array< float, 2 > & getBeamXY()
Definition TimeFrame.h:75
std::size_t getNumberOfClusters() const
gsl::span< const GlobalMeasurement > getGlobalMeasurements(LayerId surface) const
Definition TimeFrame.cxx:46
float getMaxZ(int layer) const
Definition TimeFrame.h:121
float getMinR(int layer) const
Definition TimeFrame.h:118
int getClusterROF(int layer, int cluster) const
bool isROFEnabled(int layer, int rof) const noexcept
gsl::span< unsigned char > getUsedClusters(int layer)
const auto & getTrackClusterIndices() const
Definition TimeFrame.h:167
std::size_t getNumberOfUsedClusters() const
gsl::span< GlobalMeasurement > getClustersOnLayer(int rofId, int layer)
auto & getMemoryPool() const noexcept
Definition TimeFrame.h:171
const Vertex & getPrimaryVertex(const int ivtx) const
Definition TimeFrame.h:56
gsl::span< const GlobalMeasurement > getClustersPerROFrange(int rofMin, int range, int layer) const
const RuntimeROFOverlapView & getROFOverlapView() const noexcept
Definition TimeFrame.h:137
bool configure(DetectorConfiguration &&layout, std::size_t maxEdges, std::size_t maxCells, std::shared_ptr< BoundedMemoryResource > memoryPool)
bool isVertexCompatible(int layer, int rof, const Vertex &vertex) const noexcept