Project
Loading...
Searching...
No Matches
CTFHelper.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.
11
15
16#ifndef O2_MID_CTF_HELPER_H
17#define O2_MID_CTF_HELPER_H
18
21#include "DataFormatsMID/CTF.h"
23#include <gsl/span>
24
25namespace o2
26{
27namespace utils
28{
29class IRFrameSelector;
30}
31namespace mid
32{
33
35{
36
37 public:
38 using OrderRef = o2::dataformats::AbstractRef<29, 2, 1>; // 29 bits for index in event type span, 2 bits for event type, 1 bit flag
39 struct TFData {
40 std::vector<OrderRef> colDataRefs{};
41 std::vector<OrderRef> rofDataRefs{};
42 std::array<gsl::span<const o2::mid::ColumnData>, NEvTypes> colData{};
43 std::array<gsl::span<const o2::mid::ROFRecord>, NEvTypes> rofData{};
45 };
46
47 CTFHelper(const TFData& data) : mTFData(data) {}
48 CTFHelper() = delete;
49
51 {
52 CTFHeader h{o2::detectors::DetID::MID, 0, 1, 0, // dummy timestamp, version 1.0
53 uint32_t(mTFData.rofDataRefs.size()), uint32_t(mTFData.colDataRefs.size()), 0, 0};
54 if (h.nROFs) {
55 auto id0 = mTFData.rofDataRefs.front();
56 const auto& rof = mTFData.rofData[id0.getSource()][id0.getIndex()];
57 h.firstOrbit = rof.interactionRecord.orbit;
58 h.firstBC = rof.interactionRecord.bc;
59 }
60 return h;
61 }
62
63 size_t getSize() const { return mTFData.rofDataRefs.size() * sizeof(o2::mid::ROFRecord) + mTFData.colDataRefs.size() * sizeof(o2::mid::ColumnData); }
64
65 //>>> =========================== ITERATORS ========================================
66
67 template <typename I, typename D, typename T, int M = 1>
68 class _Iter
69 {
70 public:
71 using difference_type = std::ptrdiff_t;
72 using value_type = T;
73 using pointer = const T*;
74 using reference = const T&;
75 using iterator_category = std::random_access_iterator_tag;
76
77 _Iter(const std::vector<OrderRef>& ord, const std::array<gsl::span<const D>, NEvTypes>& data, bool end = false) : mOrder(ord), mData(&data), mIndex(end ? M * ord.size() : 0) {}
78 _Iter() = default;
79
80 inline I& operator++() noexcept
81 {
82 ++mIndex;
83 return static_cast<I&>(*this);
84 }
85
86 inline I operator++(int)
87 {
88 I res = *(static_cast<I*>(this));
89 ++mIndex;
90 return res;
91 }
92
93 inline I& operator--() noexcept
94 {
95 mIndex--;
96 return static_cast<I&>(*this);
97 }
98
99 inline I operator--(int)
100 {
101 I res = *(static_cast<I*>(this));
102 --mIndex;
103 return res;
104 }
105
107 {
108 mIndex += i;
109 return static_cast<I&>(*this);
110 }
111
113 {
114 I res = *(const_cast<I*>(static_cast<const I*>(this)));
115 return res += i;
116 }
117
119 {
120 mIndex -= i;
121 return static_cast<I&>(*this);
122 }
123
125 {
126 I res = *(const_cast<I*>(static_cast<const I*>(this)));
127 return res -= i;
128 }
129
130 difference_type operator-(const I& other) const noexcept { return mIndex - other.mIndex; }
131
132 inline friend I operator+(difference_type i, const I& iter) { return iter + i; };
133
134 bool operator!=(const I& other) const noexcept { return mIndex != other.mIndex; }
135 bool operator==(const I& other) const noexcept { return mIndex == other.mIndex; }
136 bool operator>(const I& other) const noexcept { return mIndex > other.mIndex; }
137 bool operator<(const I& other) const noexcept { return mIndex < other.mIndex; }
138 bool operator>=(const I& other) const noexcept { return mIndex >= other.mIndex; }
139 bool operator<=(const I& other) const noexcept { return mIndex <= other.mIndex; }
140
141 protected:
142 gsl::span<const OrderRef> mOrder{};
143 const std::array<gsl::span<const D>, NEvTypes>* mData{};
145 };
146
147 //_______________________________________________
148 // BC difference wrt previous if in the same orbit, otherwise the abs.value.
149 // For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
150 class Iter_bcIncROF : public _Iter<Iter_bcIncROF, ROFRecord, int16_t>
151 {
152 public:
153 using _Iter<Iter_bcIncROF, ROFRecord, int16_t>::_Iter;
155 {
156 const auto ir = (*mData)[mOrder[mIndex].getSource()][mOrder[mIndex].getIndex()].interactionRecord;
157 if (mIndex) {
158 const auto irP = (*mData)[mOrder[mIndex - 1].getSource()][mOrder[mIndex - 1].getIndex()].interactionRecord;
159 if (ir.orbit == irP.orbit) {
160 return value_type(ir.bc - irP.bc);
161 } else {
162 return value_type(ir.bc);
163 }
164 }
165 return 0;
166 }
168 {
169 size_t id = mIndex + i;
170 const auto ir = (*mData)[mOrder[id].getSource()][mOrder[id].getIndex()].interactionRecord;
171 if (id) {
172 const auto irP = (*mData)[mOrder[id - 1].getSource()][mOrder[id - 1].getIndex()].interactionRecord;
173 if (ir.orbit == irP.orbit) {
174 return value_type(ir.bc - irP.bc);
175 } else {
176 return value_type(ir.bc);
177 }
178 }
179 return 0;
180 }
181 };
182
183 //_______________________________________________
184 // Orbit difference wrt previous. For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
185 class Iter_orbitIncROF : public _Iter<Iter_orbitIncROF, ROFRecord, int32_t>
186 {
187 public:
190 {
191 if (mIndex) {
192 const auto ir = (*mData)[mOrder[mIndex].getSource()][mOrder[mIndex].getIndex()].interactionRecord;
193 const auto irP = (*mData)[mOrder[mIndex - 1].getSource()][mOrder[mIndex - 1].getIndex()].interactionRecord;
194 return value_type(ir.orbit - irP.orbit);
195 }
196 return 0;
197 }
199 {
200 size_t id = mIndex + i;
201 if (id) {
202 const auto ir = (*mData)[mOrder[id].getSource()][mOrder[id].getIndex()].interactionRecord;
203 const auto irP = (*mData)[mOrder[id - 1].getSource()][mOrder[id - 1].getIndex()].interactionRecord;
204 return value_type(ir.orbit - irP.orbit);
205 }
206 return 0;
207 }
208 };
209
210 //_______________________________________________
211 // Number of entries in the ROF
212 class Iter_entriesROF : public _Iter<Iter_entriesROF, ROFRecord, uint16_t>
213 {
214 public:
216 value_type operator*() const { return (*mData)[mOrder[mIndex].getSource()][mOrder[mIndex].getIndex()].nEntries; }
218 {
219 size_t id = mIndex + i;
220 return (*mData)[mOrder[id].getSource()][mOrder[id].getIndex()].nEntries;
221 }
222 };
223
224 //_______________________________________________
225 // Event type for the ROF
226 class Iter_evtypeROF : public _Iter<Iter_evtypeROF, ROFRecord, uint8_t>
227 {
228 public:
230 value_type operator*() const { return value_type((*mData)[mOrder[mIndex].getSource()][mOrder[mIndex].getIndex()].eventType); }
232 {
233 size_t id = mIndex + i;
234 return value_type((*mData)[mOrder[id].getSource()][mOrder[id].getIndex()].eventType);
235 }
236 };
237
238 //_______________________________________________
239 class Iter_pattern : public _Iter<Iter_pattern, ColumnData, uint16_t, 5>
240 {
241 public:
244 {
245 auto idx = mOrder[mIndex / 5];
246 return (*mData)[idx.getSource()][idx.getIndex()].patterns[mIndex % 5];
247 }
249 {
250 size_t id = mIndex + i;
251 auto idx = mOrder[id / 5];
252 return (*mData)[idx.getSource()][idx.getIndex()].patterns[id % 5];
253 }
254 };
255
256 //_______________________________________________
257 class Iter_deId : public _Iter<Iter_deId, ColumnData, uint8_t>
258 {
259 public:
262 {
263 auto idx = mOrder[mIndex];
264 return (*mData)[idx.getSource()][idx.getIndex()].deId;
265 }
267 {
268 auto idx = mOrder[mIndex + i];
269 return (*mData)[idx.getSource()][idx.getIndex()].deId;
270 }
271 };
272
273 //_______________________________________________
274 class Iter_colId : public _Iter<Iter_colId, ColumnData, uint8_t>
275 {
276 public:
279 {
280 auto idx = mOrder[mIndex];
281 return (*mData)[idx.getSource()][idx.getIndex()].columnId;
282 }
284 {
285 auto idx = mOrder[mIndex + i];
286 return (*mData)[idx.getSource()][idx.getIndex()].columnId;
287 }
288 };
289
290 //<<< =========================== ITERATORS ========================================
291
292 Iter_bcIncROF begin_bcIncROF() const { return Iter_bcIncROF(mTFData.rofDataRefs, mTFData.rofData, false); }
293 Iter_bcIncROF end_bcIncROF() const { return Iter_bcIncROF(mTFData.rofDataRefs, mTFData.rofData, true); }
294
295 Iter_orbitIncROF begin_orbitIncROF() const { return Iter_orbitIncROF(mTFData.rofDataRefs, mTFData.rofData, false); }
296 Iter_orbitIncROF end_orbitIncROF() const { return Iter_orbitIncROF(mTFData.rofDataRefs, mTFData.rofData, true); }
297
298 Iter_entriesROF begin_entriesROF() const { return Iter_entriesROF(mTFData.rofDataRefs, mTFData.rofData, false); }
299 Iter_entriesROF end_entriesROF() const { return Iter_entriesROF(mTFData.rofDataRefs, mTFData.rofData, true); }
300
301 Iter_evtypeROF begin_evtypeROF() const { return Iter_evtypeROF(mTFData.rofDataRefs, mTFData.rofData, false); }
302 Iter_evtypeROF end_evtypeROF() const { return Iter_evtypeROF(mTFData.rofDataRefs, mTFData.rofData, true); }
303
304 Iter_pattern begin_pattern() const { return Iter_pattern(mTFData.colDataRefs, mTFData.colData, false); }
305 Iter_pattern end_pattern() const { return Iter_pattern(mTFData.colDataRefs, mTFData.colData, true); }
306
307 Iter_deId begin_deId() const { return Iter_deId(mTFData.colDataRefs, mTFData.colData, false); }
308 Iter_deId end_deId() const { return Iter_deId(mTFData.colDataRefs, mTFData.colData, true); }
309
310 Iter_colId begin_colId() const { return Iter_colId(mTFData.colDataRefs, mTFData.colData, false); }
311 Iter_colId end_colId() const { return Iter_colId(mTFData.colDataRefs, mTFData.colData, true); }
312
313 private:
314 const TFData& mTFData;
315};
316
317} // namespace mid
318} // namespace o2
319
320#endif
Class to refer to object indicating its Indec, Source and status flags.
Strip pattern (aka digits)
unsigned short int uint16_t
unsigned int uint32_t
int32_t i
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
Definitions for MID CTF data.
Definition of the MID event record.
uint32_t res
Definition RawData.h:0
Class for time synchronization of RawReader instances.
value_type operator[](difference_type i) const
Definition CTFHelper.h:167
value_type operator*() const
Definition CTFHelper.h:278
value_type operator[](difference_type i) const
Definition CTFHelper.h:283
value_type operator*() const
Definition CTFHelper.h:261
value_type operator[](difference_type i) const
Definition CTFHelper.h:266
value_type operator[](difference_type i) const
Definition CTFHelper.h:217
value_type operator[](difference_type i) const
Definition CTFHelper.h:231
value_type operator[](difference_type i) const
Definition CTFHelper.h:198
value_type operator[](difference_type i) const
Definition CTFHelper.h:248
value_type operator*() const
Definition CTFHelper.h:243
I & operator+=(difference_type i) noexcept
Definition CTFHelper.h:106
friend I operator+(difference_type i, const I &iter)
Definition CTFHelper.h:132
I operator+(difference_type i) const
Definition CTFHelper.h:112
difference_type operator-(const I &other) const noexcept
Definition CTFHelper.h:130
I operator-(difference_type i) const
Definition CTFHelper.h:124
bool operator<=(const I &other) const noexcept
Definition CTFHelper.h:139
const std::array< gsl::span< const D >, NEvTypes > * mData
Definition CTFHelper.h:143
_Iter(const std::vector< OrderRef > &ord, const std::array< gsl::span< const D >, NEvTypes > &data, bool end=false)
Definition CTFHelper.h:77
I & operator-=(difference_type i) noexcept
Definition CTFHelper.h:118
bool operator>=(const I &other) const noexcept
Definition CTFHelper.h:138
bool operator==(const I &other) const noexcept
Definition CTFHelper.h:135
bool operator>(const I &other) const noexcept
Definition CTFHelper.h:136
std::ptrdiff_t difference_type
Definition CTFHelper.h:71
I & operator--() noexcept
Definition CTFHelper.h:93
bool operator!=(const I &other) const noexcept
Definition CTFHelper.h:134
bool operator<(const I &other) const noexcept
Definition CTFHelper.h:137
difference_type mIndex
Definition CTFHelper.h:144
std::random_access_iterator_tag iterator_category
Definition CTFHelper.h:75
gsl::span< const OrderRef > mOrder
Definition CTFHelper.h:142
I & operator++() noexcept
Definition CTFHelper.h:80
Iter_orbitIncROF begin_orbitIncROF() const
Definition CTFHelper.h:295
size_t getSize() const
Definition CTFHelper.h:63
Iter_pattern end_pattern() const
Definition CTFHelper.h:305
Iter_deId end_deId() const
Definition CTFHelper.h:308
Iter_evtypeROF end_evtypeROF() const
Definition CTFHelper.h:302
Iter_deId begin_deId() const
Definition CTFHelper.h:307
Iter_pattern begin_pattern() const
Definition CTFHelper.h:304
Iter_evtypeROF begin_evtypeROF() const
Definition CTFHelper.h:301
Iter_orbitIncROF end_orbitIncROF() const
Definition CTFHelper.h:296
Iter_entriesROF end_entriesROF() const
Definition CTFHelper.h:299
Iter_bcIncROF begin_bcIncROF() const
Definition CTFHelper.h:292
Iter_bcIncROF end_bcIncROF() const
Definition CTFHelper.h:293
CTFHeader createHeader()
Definition CTFHelper.h:50
Iter_entriesROF begin_entriesROF() const
Definition CTFHelper.h:298
CTFHelper(const TFData &data)
Definition CTFHelper.h:47
Iter_colId end_colId() const
Definition CTFHelper.h:311
Iter_colId begin_colId() const
Definition CTFHelper.h:310
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
GLuint id
Definition glcorearb.h:650
constexpr uint32_t NEvTypes
Definition ROFRecord.h:37
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Common utility functions.
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
Header for a single CTF.
Definition CTF.h:31
std::vector< OrderRef > rofDataRefs
Definition CTFHelper.h:41
std::array< gsl::span< const o2::mid::ROFRecord >, NEvTypes > rofData
Definition CTFHelper.h:43
std::array< gsl::span< const o2::mid::ColumnData >, NEvTypes > colData
Definition CTFHelper.h:42
void buildReferences(o2::utils::IRFrameSelector &irSelector)
Definition CTFHelper.cxx:21
std::vector< OrderRef > colDataRefs
Definition CTFHelper.h:40
Column data structure for MID.
Definition ColumnData.h:29
VectorOfTObjectPtrs other
o2::InteractionRecord ir(0, 0)
o2::utils::IRFrameSelector irSelector