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_HMPID_CTF_HELPER_H
17#define O2_HMPID_CTF_HELPER_H
18
19#include "DataFormatsHMP/CTF.h"
22#include <gsl/span>
23
24namespace o2
25{
26namespace hmpid
27{
28
30{
31
32 public:
33 CTFHelper(const gsl::span<const Trigger>& trgRec,
34 const gsl::span<const Digit>& digData)
35 : mTrigRec(trgRec), mDigData(digData), mDigStart(digData.size())
36 {
37 // flag start of new trigger for digits
38 for (const auto& trg : mTrigRec) {
39 if (trg.getNumberOfObjects()) {
40 mDigStart[trg.getFirstEntry()] = true;
41 }
42 }
43 }
44
46 {
47 CTFHeader h{o2::detectors::DetID::HMP, 0, 1, 0, // dummy timestamp, version 1.0
48 uint32_t(mTrigRec.size()), uint32_t(mDigData.size()), 0, 0};
49 if (mTrigRec.size()) {
50 h.firstOrbit = mTrigRec[0].getOrbit();
51 h.firstBC = mTrigRec[0].getBc();
52 }
53 return h;
54 }
55
56 size_t getSize() const { return mTrigRec.size() * sizeof(Trigger) + mDigData.size() * sizeof(Digit); }
57
58 //>>> =========================== ITERATORS ========================================
59 template <typename I, typename D, typename T, int M = 1>
60 class _Iter
61 {
62 public:
63 using difference_type = std::ptrdiff_t;
64 using value_type = T;
65 using pointer = const T*;
66 using reference = const T&;
67 using iterator_category = std::random_access_iterator_tag;
68
69 _Iter(const gsl::span<const D>& data, bool end = false) : mData(data), mIndex(end ? M * data.size() : 0){};
70 _Iter() = default;
71
72 inline I& operator++() noexcept
73 {
74 ++mIndex;
75 return static_cast<I&>(*this);
76 }
77
78 inline I operator++(int)
79 {
80 I res = *(static_cast<I*>(this));
81 ++mIndex;
82 return res;
83 }
84
85 inline I& operator--() noexcept
86 {
87 mIndex--;
88 return static_cast<I&>(*this);
89 }
90
91 inline I operator--(int)
92 {
93 I res = *(static_cast<I*>(this));
94 --mIndex;
95 return res;
96 }
97
99 {
100 mIndex += i;
101 return static_cast<I&>(*this);
102 }
103
105 {
106 I res = *(const_cast<I*>(static_cast<const I*>(this)));
107 return res += i;
108 }
109
111 {
112 mIndex -= i;
113 return static_cast<I&>(*this);
114 }
115
117 {
118 I res = *(const_cast<I*>(static_cast<const I*>(this)));
119 return res -= i;
120 }
121
122 difference_type operator-(const I& other) const noexcept { return mIndex - other.mIndex; }
123
124 inline friend I operator+(difference_type i, const I& iter) { return iter + i; };
125
126 bool operator!=(const I& other) const noexcept { return mIndex != other.mIndex; }
127 bool operator==(const I& other) const noexcept { return mIndex == other.mIndex; }
128 bool operator>(const I& other) const noexcept { return mIndex > other.mIndex; }
129 bool operator<(const I& other) const noexcept { return mIndex < other.mIndex; }
130 bool operator>=(const I& other) const noexcept { return mIndex >= other.mIndex; }
131 bool operator<=(const I& other) const noexcept { return mIndex <= other.mIndex; }
132
133 protected:
134 gsl::span<const D> mData{};
136 };
137
138 //_______________________________________________
139 // BC difference wrt previous if in the same orbit, otherwise the abs.value.
140 // For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
141 class Iter_bcIncTrig : public _Iter<Iter_bcIncTrig, Trigger, int16_t>
142 {
143 public:
144 using _Iter<Iter_bcIncTrig, Trigger, int16_t>::_Iter;
146 {
147 if (mIndex) {
148 if (mData[mIndex].getOrbit() == mData[mIndex - 1].getOrbit()) {
149 return value_type(mData[mIndex].getBc() - mData[mIndex - 1].getBc());
150 } else {
151 return value_type(mData[mIndex].getBc());
152 }
153 }
154 return 0;
155 }
157 {
158 size_t id = mIndex + i;
159 if (id) {
160 if (mData[id].getOrbit() == mData[id - 1].getOrbit()) {
161 return value_type(mData[id].getBc() - mData[id - 1].getBc());
162 } else {
163 return value_type(mData[id].getBc());
164 }
165 }
166 return 0;
167 }
168 };
169
170 //_______________________________________________
171 // Orbit difference wrt previous. For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
172 class Iter_orbitIncTrig : public _Iter<Iter_orbitIncTrig, Trigger, int32_t>
173 {
174 public:
178 {
179 size_t id = mIndex + i;
180 return value_type(id ? mData[id].getOrbit() - mData[id - 1].getOrbit() : 0);
181 }
182 };
183
184 //_______________________________________________
185 // Number of digits for trigger
186 class Iter_entriesDig : public _Iter<Iter_entriesDig, Trigger, uint32_t>
187 {
188 public:
190 value_type operator*() const { return mData[mIndex].getNumberOfObjects(); }
191 value_type operator[](difference_type i) const { return mData[mIndex + i].getNumberOfObjects(); }
192 };
193
194 //_______________________________________________
195 class Iter_ChID : public _Iter<Iter_ChID, Digit, uint8_t>
196 {
197 private:
198 const std::vector<bool>* mTrigStart{nullptr};
199
200 public:
202 Iter_ChID(const std::vector<bool>* ts, const gsl::span<const Digit>& data, bool end) : mTrigStart(ts), _Iter(data, end) {}
203 Iter_ChID() = default;
204
205 // assume sorting in ChID: for the 1st digit of the trigger return the abs ChID, for the following ones: difference to previous ChID
207 {
208 return (*mTrigStart)[mIndex] ? mData[mIndex].getCh() : mData[mIndex].getCh() - mData[mIndex - 1].getCh();
209 }
211 {
212 size_t id = mIndex + i;
213 return (*mTrigStart)[id] ? mData[id].getCh() : mData[id].getCh() - mData[id - 1].getCh();
214 }
215 };
216
217 //_______________________________________________
218 class Iter_Q : public _Iter<Iter_Q, Digit, uint16_t>
219 {
220 public:
222 value_type operator*() const { return mData[mIndex].getQ(); }
223 value_type operator[](difference_type i) const { return mData[mIndex + i].getQ(); }
224 };
225
226 //_______________________________________________
227 class Iter_Ph : public _Iter<Iter_Ph, Digit, uint8_t>
228 {
229 public:
231 value_type operator*() const { return mData[mIndex].getPh(); }
232 value_type operator[](difference_type i) const { return mData[mIndex + i].getPh(); }
233 };
234
235 //_______________________________________________
236 class Iter_X : public _Iter<Iter_X, Digit, uint8_t>
237 {
238 public:
240 value_type operator*() const { return mData[mIndex].getX(); }
241 value_type operator[](difference_type i) const { return mData[mIndex + i].getX(); }
242 };
243
244 //_______________________________________________
245 class Iter_Y : public _Iter<Iter_Y, Digit, uint8_t>
246 {
247 public:
249 value_type operator*() const { return mData[mIndex].getY(); }
250 value_type operator[](difference_type i) const { return mData[mIndex + i].getY(); }
251 };
252
253 //<<< =========================== ITERATORS ========================================
254
255 Iter_bcIncTrig begin_bcIncTrig() const { return Iter_bcIncTrig(mTrigRec, false); }
256 Iter_bcIncTrig end_bcIncTrig() const { return Iter_bcIncTrig(mTrigRec, true); }
257
258 Iter_orbitIncTrig begin_orbitIncTrig() const { return Iter_orbitIncTrig(mTrigRec, false); }
259 Iter_orbitIncTrig end_orbitIncTrig() const { return Iter_orbitIncTrig(mTrigRec, true); }
260
261 Iter_entriesDig begin_entriesDig() const { return Iter_entriesDig(mTrigRec, false); }
262 Iter_entriesDig end_entriesDig() const { return Iter_entriesDig(mTrigRec, true); }
263
264 Iter_ChID begin_ChID() const { return Iter_ChID(&mDigStart, mDigData, false); }
265 Iter_ChID end_ChID() const { return Iter_ChID(&mDigStart, mDigData, true); }
266
267 Iter_Q begin_Q() const { return Iter_Q(mDigData, false); }
268 Iter_Q end_Q() const { return Iter_Q(mDigData, true); }
269
270 Iter_Ph begin_Ph() const { return Iter_Ph(mDigData, false); }
271 Iter_Ph end_Ph() const { return Iter_Ph(mDigData, true); }
272
273 Iter_X begin_X() const { return Iter_X(mDigData, false); }
274 Iter_X end_X() const { return Iter_X(mDigData, true); }
275
276 Iter_Y begin_Y() const { return Iter_Y(mDigData, false); }
277 Iter_Y end_Y() const { return Iter_Y(mDigData, true); }
278
279 private:
280 const gsl::span<const o2::hmpid::Trigger> mTrigRec;
281 const gsl::span<const o2::hmpid::Digit> mDigData;
282 std::vector<bool> mDigStart;
283};
284
285} // namespace hmpid
286} // namespace o2
287
288#endif
uint32_t getOrbit() const
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 HMPID CTF data.
uint32_t res
Definition RawData.h:0
Class for time synchronization of RawReader instances.
value_type operator*() const
Definition CTFHelper.h:206
Iter_ChID(const std::vector< bool > *ts, const gsl::span< const Digit > &data, bool end)
Definition CTFHelper.h:202
value_type operator[](difference_type i) const
Definition CTFHelper.h:210
value_type operator*() const
Definition CTFHelper.h:231
value_type operator[](difference_type i) const
Definition CTFHelper.h:232
value_type operator[](difference_type i) const
Definition CTFHelper.h:223
value_type operator*() const
Definition CTFHelper.h:222
value_type operator*() const
Definition CTFHelper.h:240
value_type operator[](difference_type i) const
Definition CTFHelper.h:241
value_type operator[](difference_type i) const
Definition CTFHelper.h:250
value_type operator*() const
Definition CTFHelper.h:249
value_type operator[](difference_type i) const
Definition CTFHelper.h:156
value_type operator[](difference_type i) const
Definition CTFHelper.h:191
value_type operator[](difference_type i) const
Definition CTFHelper.h:177
friend I operator+(difference_type i, const I &iter)
Definition CTFHelper.h:124
I operator-(difference_type i) const
Definition CTFHelper.h:116
I operator+(difference_type i) const
Definition CTFHelper.h:104
gsl::span< const D > mData
Definition CTFHelper.h:134
bool operator<(const I &other) const noexcept
Definition CTFHelper.h:129
std::random_access_iterator_tag iterator_category
Definition CTFHelper.h:67
I & operator++() noexcept
Definition CTFHelper.h:72
_Iter(const gsl::span< const D > &data, bool end=false)
Definition CTFHelper.h:69
I & operator-=(difference_type i) noexcept
Definition CTFHelper.h:110
difference_type operator-(const I &other) const noexcept
Definition CTFHelper.h:122
std::ptrdiff_t difference_type
Definition CTFHelper.h:63
bool operator<=(const I &other) const noexcept
Definition CTFHelper.h:131
I & operator+=(difference_type i) noexcept
Definition CTFHelper.h:98
bool operator==(const I &other) const noexcept
Definition CTFHelper.h:127
bool operator>(const I &other) const noexcept
Definition CTFHelper.h:128
bool operator!=(const I &other) const noexcept
Definition CTFHelper.h:126
I & operator--() noexcept
Definition CTFHelper.h:85
bool operator>=(const I &other) const noexcept
Definition CTFHelper.h:130
Iter_Q begin_Q() const
Definition CTFHelper.h:267
Iter_entriesDig end_entriesDig() const
Definition CTFHelper.h:262
CTFHelper(const gsl::span< const Trigger > &trgRec, const gsl::span< const Digit > &digData)
Definition CTFHelper.h:33
Iter_Y begin_Y() const
Definition CTFHelper.h:276
Iter_orbitIncTrig begin_orbitIncTrig() const
Definition CTFHelper.h:258
Iter_bcIncTrig end_bcIncTrig() const
Definition CTFHelper.h:256
Iter_Q end_Q() const
Definition CTFHelper.h:268
CTFHeader createHeader()
Definition CTFHelper.h:45
Iter_entriesDig begin_entriesDig() const
Definition CTFHelper.h:261
Iter_Y end_Y() const
Definition CTFHelper.h:277
Iter_X end_X() const
Definition CTFHelper.h:274
Iter_X begin_X() const
Definition CTFHelper.h:273
Iter_orbitIncTrig end_orbitIncTrig() const
Definition CTFHelper.h:259
Iter_ChID begin_ChID() const
Definition CTFHelper.h:264
Iter_bcIncTrig begin_bcIncTrig() const
Definition CTFHelper.h:255
Iter_Ph begin_Ph() const
Definition CTFHelper.h:270
Iter_ChID end_ChID() const
Definition CTFHelper.h:265
size_t getSize() const
Definition CTFHelper.h:56
Iter_Ph end_Ph() const
Definition CTFHelper.h:271
HMPID Digit declaration.
Definition Digit.h:36
HMPID Trigger declaration.
Definition Trigger.h:32
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
GLuint id
Definition glcorearb.h:650
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
Header for a single CTF.
Definition CTF.h:29
VectorOfTObjectPtrs other