Project
Loading...
Searching...
No Matches
IOUtils.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.
15
16#ifndef ALICEO2_ITSMFT_TRACKING_IOUTILS_H_
17#define ALICEO2_ITSMFT_TRACKING_IOUTILS_H_
18
19#include <cstddef>
20#include <cstdint>
21
22#ifndef GPUCA_GPUCODE
23#include <format>
24#include <stdexcept>
25#include <string>
26#endif
27
28#include <gsl/gsl>
29
40#include "MathUtils/Cartesian.h"
42
44{
45
46// Host-side facts produced by compact-cluster and geometry decoding.
49 // ITS geometry supplies its cylindrical tracking frame here. Disk
50 // projection uses global coordinates directly.
52 // Intrinsic ALPIDE local row/column covariance, without alignment systematics.
53 // The shared loader adds configured systematics before detector projection.
56 int layer{-1};
57};
58
59} // namespace o2::itsmft::tracking
60
62{
63
68
69template <typename T>
76
77// Decode using dictionary coordinates, errors and pixel counts. Grouped and
78// explicit patterns require their actual bitmap; the group entry is representative.
79// As in ITS tracking, the explicit-pattern stream is assumed to be valid.
80template <typename T = float>
82 const CompClusterExt& c,
83 gsl::span<const unsigned char>::iterator& patterns,
84 const TopologyDictionary* dict)
85{
87 if (dict == nullptr) {
88 throw std::runtime_error("Cluster dictionary is not available");
89 }
90
91 const auto pattID = c.getPatternID();
92 if (pattID != CompCluster::InvalidPatternID) {
93 if (pattID >= dict->getSize()) {
94 throw std::runtime_error("Cluster pattern ID is outside the topology dictionary");
95 }
96 result.sig2Row = dict->getErr2X(pattID);
97 result.sig2Col = dict->getErr2Z(pattID);
98 if (!dict->isGroup(pattID)) {
99 result.nPixels = static_cast<uint32_t>(dict->getNpixels(pattID));
100 result.coordinates = dict->getClusterCoordinates<T>(c);
101 return result;
102 }
103 }
104
105 const o2::itsmft::ClusterPattern pattern{patterns};
106 result.nPixels = static_cast<uint32_t>(pattern.getNPixels());
107 result.coordinates = TopologyDictionary::getClusterCoordinates<T>(c, pattern, pattID != CompCluster::InvalidPatternID);
108 return result;
109}
110
111} // namespace o2::itsmft::ioutils
112
113namespace o2::itsmft::tracking
114{
115
116class TimeFrame;
117
120 o2::detectors::DetID::ID detector{o2::detectors::DetID::ITS};
121 gsl::span<const o2::itsmft::CompClusterExt> clusters{};
122 gsl::span<const unsigned char> patterns{};
123 gsl::span<const o2::itsmft::ROFRecord> rofs{};
126 gsl::span<const LayerId> layerToSurface{};
127};
128
134void loadTimeFrameSources(TimeFrame&, gsl::span<const ClusterSourceInput>,
135 SurfaceCatalogView,
136 std::vector<std::vector<uint32_t>>* externalIndicesBySurface = nullptr,
137 std::vector<std::vector<uint32_t>>* clusterSizesBySurface = nullptr);
138
139namespace detail
140{
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);
143void validateClusterRanges(const ClusterSourceInput&);
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>>&);
146void storeSourceROFClusters(TimeFrame&, const ClusterSourceInput&, const std::vector<std::vector<int>>&);
147
148// Internal loading loop; geometry decoding and synthetic fixtures share the
149// same stream consumption, diagnostics and measurement insertion.
150template <typename Decode>
152 const Decode& decode, std::vector<std::vector<uint32_t>>& externalIndices,
153 std::vector<std::vector<uint32_t>>& clusterSizes)
154{
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);
164 DecodedCluster decoded;
165 try {
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()));
170 }
171 appendCluster(frame, catalog, src, decoded, r, externalIndex, externalIndices, clusterSizes);
172 }
173 for (size_t layer = 0; layer < src.layerToSurface.size(); ++layer) {
174 boundaries[layer][r + 1] = static_cast<int>(externalIndices[src.layerToSurface[layer].value()].size());
175 }
176 }
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())));
179 }
180 storeSourceROFClusters(frame, src, boundaries);
181}
182} // namespace detail
183
184} // namespace o2::itsmft::tracking
185
186#endif /* ALICEO2_ITSMFT_TRACKING_IOUTILS_H_ */
Definition of the ITSMFT compact cluster.
Definition of the ClusterTopology class.
Shared CA tracking configuration for ITS and MFT.
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
char error[CURL_ERROR_SIZE]
Definition of the ITSMFT ROFrame (trigger) record.
Definition of a container to keep Monte Carlo truth external to simulation objects.
int32_t nEntries
Definition Objects.cxx:40
uint32_t c
Definition RawData.h:2
Definition of the SegmentationAlpide class.
A container to hold and manage MC truth information/labels.
int ID
Detector identifiers: continuous, starting from 0.
Definition DetID.h:63
static constexpr unsigned short InvalidPatternID
Definition CompCluster.h:46
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.
GLuint64EXT * result
Definition glcorearb.h:5662
GLenum GLuint GLint GLint layer
Definition glcorearb.h:1310
GLboolean r
Definition glcorearb.h:1233
constexpr float DefClusErrorRow
Definition IOUtils.h:64
constexpr float DefClusErrorCol
Definition IOUtils.h:65
constexpr float DefClusError2Col
Definition IOUtils.h:67
ClusterData< T > extractClusterData(const CompClusterExt &c, gsl::span< const unsigned char >::iterator &patterns, const TopologyDictionary *dict)
Definition IOUtils.h:81
constexpr float DefClusError2Row
Definition IOUtils.h:66
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)
Definition IOUtils.h:151
void validateClusterRanges(const ClusterSourceInput &)
Definition IOUtils.cxx:266
void storeSourceROFClusters(TimeFrame &, const ClusterSourceInput &, const std::vector< std::vector< int > > &)
Definition IOUtils.cxx:328
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 > > &)
Definition IOUtils.cxx:285
void prepareSources(TimeFrame &, const SurfaceCatalogView &, gsl::span< const ClusterSourceInput >, std::vector< std::vector< uint32_t > > *, std::vector< std::vector< uint32_t > > *, bool requireCompleteMapping=false)
Definition IOUtils.cxx:203
void loadTimeFrameSources(TimeFrame &, gsl::span< const ClusterSourceInput >, SurfaceCatalogView, std::vector< std::vector< uint32_t > > *externalIndicesBySurface=nullptr, std::vector< std::vector< uint32_t > > *clusterSizesBySurface=nullptr)
Definition IOUtils.cxx:337
o2::math_utils::Point3D< T > coordinates
Definition IOUtils.h:71
const o2::itsmft::TopologyDictionary * dictionary
Definition IOUtils.h:124
const o2::dataformats::MCTruthContainer< o2::MCCompLabel > * labels
Definition IOUtils.h:125
gsl::span< const o2::itsmft::CompClusterExt > clusters
Definition IOUtils.h:121
gsl::span< const unsigned char > patterns
Definition IOUtils.h:122
o2::detectors::DetID::ID detector
Definition IOUtils.h:120
gsl::span< const o2::itsmft::ROFRecord > rofs
Definition IOUtils.h:123
gsl::span< const LayerId > layerToSurface
Definition IOUtils.h:126
SurfaceCovariance2F rowColumnCovariance
Definition IOUtils.h:54
SurfaceFramePoint cylinderFrame
Definition IOUtils.h:51
coder decode(ctfImage, triggersD, clustersD)
std::array< uint16_t, 5 > pattern