16#ifndef ALICEO2_ITSMFT_TRACKING_IOUTILS_H_
17#define ALICEO2_ITSMFT_TRACKING_IOUTILS_H_
80template <
typename T =
float>
83 gsl::span<const unsigned char>::iterator& patterns,
87 if (dict ==
nullptr) {
88 throw std::runtime_error(
"Cluster dictionary is not available");
91 const auto pattID =
c.getPatternID();
93 if (pattID >= dict->
getSize()) {
94 throw std::runtime_error(
"Cluster pattern ID is outside the topology dictionary");
106 result.nPixels =
static_cast<uint32_t
>(
pattern.getNPixels());
121 gsl::span<const o2::itsmft::CompClusterExt>
clusters{};
123 gsl::span<const o2::itsmft::ROFRecord>
rofs{};
136 std::vector<std::vector<uint32_t>>* externalIndicesBySurface =
nullptr,
137 std::vector<std::vector<uint32_t>>* clusterSizesBySurface =
nullptr);
141void prepareSources(TimeFrame&,
const SurfaceCatalogView&, gsl::span<const ClusterSourceInput>,
142 std::vector<std::vector<uint32_t>>*, std::vector<std::vector<uint32_t>>*,
bool requireCompleteMapping =
false);
144void appendCluster(TimeFrame&,
const SurfaceCatalogView&,
const ClusterSourceInput&,
const DecodedCluster&,
145 uint32_t, uint32_t, std::vector<std::vector<uint32_t>>&, std::vector<std::vector<uint32_t>>&);
150template <
typename Decode>
152 const Decode&
decode, std::vector<std::vector<uint32_t>>& externalIndices,
153 std::vector<std::vector<uint32_t>>& clusterSizes)
155 std::vector<std::vector<int>> boundaries(
src.layerToSurface.size(), std::vector<int>(
src.rofs.size() + 1, 0));
156 auto patterns =
src.patterns.begin();
157 for (uint32_t
r = 0;
r <
src.rofs.size(); ++
r) {
158 const auto& rof =
src.rofs[
r];
159 const auto firstEntry = rof.getFirstEntry();
160 const auto nEntries = rof.getNEntries();
161 for (int32_t clusterId = firstEntry; clusterId < firstEntry + nEntries; ++clusterId) {
162 const auto& cluster =
src.clusters[clusterId];
163 const auto externalIndex =
static_cast<uint32_t
>(clusterId);
166 decoded =
decode(cluster, patterns);
167 }
catch (
const std::runtime_error& error) {
168 throw std::runtime_error(std::format(
"Cluster decoding failed: source={} rof={} clusterIndex={}: {}",
169 src.id.value(),
r, externalIndex, error.what()));
171 appendCluster(frame, catalog,
src, decoded,
r, externalIndex, externalIndices, clusterSizes);
174 boundaries[
layer][
r + 1] =
static_cast<int>(externalIndices[
src.layerToSurface[
layer].value()].size());
177 if (patterns !=
src.patterns.end()) {
178 throw std::runtime_error(std::format(
"Trailing cluster pattern data source={} rof={} clusterIndex={}",
src.id.value(),
static_cast<uint32_t
>(
src.rofs.size()),
static_cast<uint32_t
>(
src.clusters.size())));
Definition of the ITSMFT compact cluster.
Shared CA tracking configuration for ITS and MFT.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the SegmentationAlpide class.
int ID
Detector identifiers: continuous, starting from 0.
static constexpr unsigned short InvalidPatternID
static constexpr float PitchCol
static constexpr float PitchRow
math_utils::Point3D< T > getClusterCoordinates(const CompCluster &cl) const
int getSize() const
Returns the number of elements in the dicionary;.
float getErr2X(int n) const
Returns the error^2 on the x position of the COG for the n_th element.
int getNpixels(int n) const
Returns the number of fired pixels of the n_th element.
bool isGroup(int n) const
Returns true if the element corresponds to a group of rare topologies.
float getErr2Z(int n) const
Returns the error^2 on the z position of the COG for the n_th element.
GLenum GLuint GLint GLint layer
constexpr float DefClusErrorRow
constexpr float DefClusErrorCol
constexpr float DefClusError2Col
ClusterData< T > extractClusterData(const CompClusterExt &c, gsl::span< const unsigned char >::iterator &patterns, const TopologyDictionary *dict)
constexpr float DefClusError2Row
void loadDecodedSource(TimeFrame &frame, const SurfaceCatalogView &catalog, const ClusterSourceInput &src, const Decode &decode, std::vector< std::vector< uint32_t > > &externalIndices, std::vector< std::vector< uint32_t > > &clusterSizes)
void validateClusterRanges(const ClusterSourceInput &)
void storeSourceROFClusters(TimeFrame &, const ClusterSourceInput &, const std::vector< std::vector< int > > &)
void appendCluster(TimeFrame &, const SurfaceCatalogView &, const ClusterSourceInput &, const DecodedCluster &, uint32_t, uint32_t, std::vector< std::vector< uint32_t > > &, std::vector< std::vector< uint32_t > > &)
void prepareSources(TimeFrame &, const SurfaceCatalogView &, gsl::span< const ClusterSourceInput >, std::vector< std::vector< uint32_t > > *, std::vector< std::vector< uint32_t > > *, bool requireCompleteMapping=false)
void loadTimeFrameSources(TimeFrame &, gsl::span< const ClusterSourceInput >, SurfaceCatalogView, std::vector< std::vector< uint32_t > > *externalIndicesBySurface=nullptr, std::vector< std::vector< uint32_t > > *clusterSizesBySurface=nullptr)
o2::math_utils::Point3D< T > coordinates
SurfaceCovariance2F rowColumnCovariance
SurfaceFramePoint cylinderFrame
coder decode(ctfImage, triggersD, clustersD)
std::array< uint16_t, 5 > pattern