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_ZDC_CTF_HELPER_H
17#define O2_ZDC_CTF_HELPER_H
18
19#ifdef NDEBUG
20#undef NDEBUG
21#endif
22
23#include "DataFormatsZDC/CTF.h"
24#include <gsl/span>
25
26namespace o2
27{
28namespace zdc
29{
30
32{
33
34 public:
35 CTFHelper(const gsl::span<const BCData>& trgData,
36 const gsl::span<const ChannelData>& chanData,
37 const gsl::span<const OrbitData>& pedData)
38 : mTrigData(trgData), mChanData(chanData), mEOData(pedData) {}
39
41 {
42 CTFHeader h{o2::detectors::DetID::ZDC, 0, 1, 0, // dummy timestamp, version 1.0
43 uint32_t(mTrigData.size()), uint32_t(mChanData.size()), uint32_t(mEOData.size()), 0, 0, 0};
44 if (mTrigData.size()) {
45 h.firstOrbit = mTrigData[0].ir.orbit;
46 h.firstBC = mTrigData[0].ir.bc;
47 }
48 if (mEOData.size()) {
49 h.firstOrbitEOData = mEOData[0].ir.orbit;
50 h.firstScaler = mEOData[0].scaler; // then we store increments
51 }
52 return h;
53 }
54
55 size_t getSize() const { return mTrigData.size() * sizeof(BCData) + mChanData.size() * sizeof(ChannelData) + mEOData.size() * sizeof(OrbitData); }
56
57 //>>> =========================== ITERATORS ========================================
58
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, BCData, int16_t>
142 {
143 public:
144 using _Iter<Iter_bcIncTrig, BCData, int16_t>::_Iter;
146 {
147 if (mIndex) {
148 if (mData[mIndex].ir.orbit == mData[mIndex - 1].ir.orbit) {
149 return value_type(mData[mIndex].ir.bc - mData[mIndex - 1].ir.bc);
150 } else {
151 return value_type(mData[mIndex].ir.bc);
152 }
153 }
154 return 0;
155 }
157 {
158 size_t id = mIndex + i;
159 if (id) {
160 if (mData[id].ir.orbit == mData[id - 1].ir.orbit) {
161 return value_type(mData[id].ir.bc - mData[id - 1].ir.bc);
162 } else {
163 return value_type(mData[id].ir.bc);
164 }
165 }
166 return 0;
167 }
168 };
169
171 //_______________________________________________
172 // Orbit difference wrt previous. For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
173 class Iter_orbitIncTrig : public _Iter<Iter_orbitIncTrig, BCData, int32_t>
174 {
175 public:
177 value_type operator*() const { return value_type(mIndex ? mData[mIndex].ir.orbit - mData[mIndex - 1].ir.orbit : 0); }
179 {
180 size_t id = mIndex + i;
181 return value_type(id ? mData[id].ir.orbit - mData[id - 1].ir.orbit : 0);
182 }
183 };
184
185 //_______________________________________________
186 // Modules trigger words, NModules words per trigger, iterate over the BCData and its modules
187 class Iter_moduleTrig : public _Iter<Iter_moduleTrig, BCData, uint16_t, NModules>
188 {
189 public:
191 value_type operator*() const { return mData[mIndex / NModules].moduleTriggers[mIndex % NModules]; }
193 {
194 size_t id = mIndex + i;
195 return mData[id / NModules].moduleTriggers[id % NModules];
196 }
197 };
198
199 //_______________________________________________
200 // ZDC channels pattern word: 32b word is saved as 2 16 bit words
201 class Iter_channelsHL : public _Iter<Iter_channelsHL, BCData, uint16_t, 2>
202 {
203 public:
205 value_type operator*() const { return uint16_t(mIndex & 0x1 ? mData[mIndex / 2].channels : mData[mIndex / 2].channels >> 16); }
207 {
208 size_t id = mIndex + i;
209 return uint16_t(id & 0x1 ? mData[id / 2].channels : mData[id / 2].channels >> 16);
210 }
211 };
212
213 //_______________________________________________
214 // ZDC trigger word: 32b word is saved as 2 16 bit words
215 class Iter_triggersHL : public _Iter<Iter_triggersHL, BCData, uint16_t, 2>
216 {
217 public:
219 value_type operator*() const { return uint16_t(mIndex & 0x1 ? mData[mIndex / 2].triggers : mData[mIndex / 2].triggers >> 16); }
221 {
222 size_t id = mIndex + i;
223 return uint16_t(id & 0x1 ? mData[id / 2].triggers : mData[id / 2].triggers >> 16);
224 }
225 };
226
227 //_______________________________________________
228 // Alice external trigger word
229 class Iter_extTriggers : public _Iter<Iter_extTriggers, BCData, uint8_t>
230 {
231 public:
233 value_type operator*() const { return mData[mIndex].ext_triggers; }
234 value_type operator[](difference_type i) const { return mData[mIndex + i].ext_triggers; }
235 };
236
237 //_______________________________________________
238 // Number of channels for trigger
239 class Iter_nchanTrig : public _Iter<Iter_nchanTrig, BCData, uint16_t>
240 {
241 public:
243 value_type operator*() const { return mData[mIndex].ref.getEntries(); }
244 value_type operator[](difference_type i) const { return mData[mIndex + i].ref.getEntries(); }
245 };
246
248
249 //_______________________________________________
250 class Iter_chanID : public _Iter<Iter_chanID, ChannelData, uint8_t>
251 {
252 public:
254 value_type operator*() const { return mData[mIndex].id; }
256 };
257
258 //_______________________________________________
259 class Iter_chanData : public _Iter<Iter_chanData, ChannelData, uint16_t, NTimeBinsPerBC>
260 {
261 public:
265 {
266 size_t id = mIndex + i;
267 return mData[id / NTimeBinsPerBC].data[id % NTimeBinsPerBC];
268 }
269 };
270
272
273 //_______________________________________________
274 // Orbit difference wrt previous. For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
275 class Iter_orbitIncEOD : public _Iter<Iter_orbitIncEOD, OrbitData, int32_t>
276 {
277 public:
279 value_type operator*() const { return value_type(mIndex ? mData[mIndex].ir.orbit - mData[mIndex - 1].ir.orbit : 0); }
281 {
282 size_t id = mIndex + i;
283 return value_type(id ? mData[id].ir.orbit - mData[id - 1].ir.orbit : 0);
284 }
285 };
286
287 //_______________________________________________
288 class Iter_pedData : public _Iter<Iter_pedData, OrbitData, uint16_t, NChannels>
289 {
290 public:
294 {
295 size_t id = mIndex + i;
296 return mData[id / NChannels].data[id % NChannels];
297 }
298 };
299
300 //_______________________________________________
301 class Iter_sclInc : public _Iter<Iter_sclInc, OrbitData, int16_t, NChannels>
302 {
303 public:
306 {
307 // define with respect to previous orbit
308 int slot = mIndex / NChannels, chan = mIndex % NChannels;
309 return value_type(slot ? mData[slot].scaler[chan] - mData[slot - 1].scaler[chan] : 0);
310 }
312 {
313 size_t id = mIndex + i;
314 int slot = id / NChannels, chan = id % NChannels;
315 return value_type(slot ? mData[slot].scaler[chan] - mData[slot - 1].scaler[chan] : 0);
316 }
317 };
318
319 //<<< =========================== ITERATORS ========================================
320
321 Iter_bcIncTrig begin_bcIncTrig() const { return Iter_bcIncTrig(mTrigData, false); }
322 Iter_bcIncTrig end_bcIncTrig() const { return Iter_bcIncTrig(mTrigData, true); }
323
324 Iter_orbitIncTrig begin_orbitIncTrig() const { return Iter_orbitIncTrig(mTrigData, false); }
325 Iter_orbitIncTrig end_orbitIncTrig() const { return Iter_orbitIncTrig(mTrigData, true); }
326
327 Iter_moduleTrig begin_moduleTrig() const { return Iter_moduleTrig(mTrigData, false); }
328 Iter_moduleTrig end_moduleTrig() const { return Iter_moduleTrig(mTrigData, true); }
329
330 Iter_channelsHL begin_channelsHL() const { return Iter_channelsHL(mTrigData, false); }
331 Iter_channelsHL end_channelsHL() const { return Iter_channelsHL(mTrigData, true); }
332
333 Iter_triggersHL begin_triggersHL() const { return Iter_triggersHL(mTrigData, false); }
334 Iter_triggersHL end_triggersHL() const { return Iter_triggersHL(mTrigData, true); }
335
336 Iter_extTriggers begin_extTriggers() const { return Iter_extTriggers(mTrigData, false); }
337 Iter_extTriggers end_extTriggers() const { return Iter_extTriggers(mTrigData, true); }
338
339 Iter_nchanTrig begin_nchanTrig() const { return Iter_nchanTrig(mTrigData, false); }
340 Iter_nchanTrig end_nchanTrig() const { return Iter_nchanTrig(mTrigData, true); }
341
342 Iter_chanID begin_chanID() const { return Iter_chanID(mChanData, false); }
343 Iter_chanID end_chanID() const { return Iter_chanID(mChanData, true); }
344
345 Iter_chanData begin_chanData() const { return Iter_chanData(mChanData, false); }
346 Iter_chanData end_chanData() const { return Iter_chanData(mChanData, true); }
347
348 Iter_orbitIncEOD begin_orbitIncEOD() const { return Iter_orbitIncEOD(mEOData, false); }
349 Iter_orbitIncEOD end_orbitIncEOD() const { return Iter_orbitIncEOD(mEOData, true); }
350
351 Iter_pedData begin_pedData() const { return Iter_pedData(mEOData, false); }
352 Iter_pedData end_pedData() const { return Iter_pedData(mEOData, true); }
353
354 Iter_sclInc begin_sclInc() const { return Iter_sclInc(mEOData, false); }
355 Iter_sclInc end_sclInc() const { return Iter_sclInc(mEOData, true); }
356
357 private:
358 const gsl::span<const o2::zdc::BCData> mTrigData;
359 const gsl::span<const o2::zdc::ChannelData> mChanData;
360 const gsl::span<const o2::zdc::OrbitData> mEOData;
361};
362
363} // namespace zdc
364} // namespace o2
365
366#endif
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
uint32_t res
Definition RawData.h:0
Definitions for ZDC CTF data.
Class for time synchronization of RawReader instances.
value_type operator[](difference_type i) const
Definition CTFHelper.h:156
value_type operator[](difference_type i) const
Definition CTFHelper.h:264
value_type operator*() const
Definition CTFHelper.h:254
value_type operator[](difference_type i) const
Definition CTFHelper.h:255
value_type operator[](difference_type i) const
Definition CTFHelper.h:206
value_type operator[](difference_type i) const
Definition CTFHelper.h:234
value_type operator[](difference_type i) const
Definition CTFHelper.h:192
value_type operator[](difference_type i) const
Definition CTFHelper.h:244
value_type operator[](difference_type i) const
Definition CTFHelper.h:280
value_type operator[](difference_type i) const
Definition CTFHelper.h:178
value_type operator[](difference_type i) const
Definition CTFHelper.h:293
value_type operator*() const
Definition CTFHelper.h:292
value_type operator[](difference_type i) const
Definition CTFHelper.h:311
value_type operator*() const
Definition CTFHelper.h:305
value_type operator[](difference_type i) const
Definition CTFHelper.h:220
friend I operator+(difference_type i, const I &iter)
Definition CTFHelper.h:124
bool operator>=(const I &other) const noexcept
Definition CTFHelper.h:130
bool operator<(const I &other) const noexcept
Definition CTFHelper.h:129
difference_type operator-(const I &other) const noexcept
Definition CTFHelper.h:122
bool operator>(const I &other) const noexcept
Definition CTFHelper.h:128
I operator-(difference_type i) const
Definition CTFHelper.h:116
I & operator+=(difference_type i) noexcept
Definition CTFHelper.h:98
difference_type mIndex
Definition CTFHelper.h:135
bool operator!=(const I &other) const noexcept
Definition CTFHelper.h:126
I & operator++() noexcept
Definition CTFHelper.h:72
_Iter(const gsl::span< const D > &data, bool end=false)
Definition CTFHelper.h:69
bool operator==(const I &other) const noexcept
Definition CTFHelper.h:127
bool operator<=(const I &other) const noexcept
Definition CTFHelper.h:131
std::random_access_iterator_tag iterator_category
Definition CTFHelper.h:67
I & operator--() noexcept
Definition CTFHelper.h:85
gsl::span< const D > mData
Definition CTFHelper.h:134
I & operator-=(difference_type i) noexcept
Definition CTFHelper.h:110
std::ptrdiff_t difference_type
Definition CTFHelper.h:63
I operator+(difference_type i) const
Definition CTFHelper.h:104
Iter_sclInc end_sclInc() const
Definition CTFHelper.h:355
Iter_extTriggers end_extTriggers() const
Definition CTFHelper.h:337
Iter_bcIncTrig end_bcIncTrig() const
Definition CTFHelper.h:322
Iter_triggersHL end_triggersHL() const
Definition CTFHelper.h:334
Iter_chanID begin_chanID() const
Definition CTFHelper.h:342
CTFHeader createHeader()
Definition CTFHelper.h:40
CTFHelper(const gsl::span< const BCData > &trgData, const gsl::span< const ChannelData > &chanData, const gsl::span< const OrbitData > &pedData)
Definition CTFHelper.h:35
Iter_moduleTrig begin_moduleTrig() const
Definition CTFHelper.h:327
Iter_bcIncTrig begin_bcIncTrig() const
Definition CTFHelper.h:321
size_t getSize() const
Definition CTFHelper.h:55
Iter_pedData end_pedData() const
Definition CTFHelper.h:352
Iter_orbitIncEOD end_orbitIncEOD() const
Definition CTFHelper.h:349
Iter_moduleTrig end_moduleTrig() const
Definition CTFHelper.h:328
Iter_channelsHL end_channelsHL() const
Definition CTFHelper.h:331
Iter_orbitIncTrig begin_orbitIncTrig() const
Definition CTFHelper.h:324
Iter_orbitIncTrig end_orbitIncTrig() const
Definition CTFHelper.h:325
Iter_triggersHL begin_triggersHL() const
Definition CTFHelper.h:333
Iter_nchanTrig begin_nchanTrig() const
Definition CTFHelper.h:339
Iter_sclInc begin_sclInc() const
Definition CTFHelper.h:354
Iter_chanData end_chanData() const
Definition CTFHelper.h:346
Iter_orbitIncEOD begin_orbitIncEOD() const
Definition CTFHelper.h:348
Iter_pedData begin_pedData() const
Definition CTFHelper.h:351
Iter_channelsHL begin_channelsHL() const
Definition CTFHelper.h:330
Iter_chanID end_chanID() const
Definition CTFHelper.h:343
Iter_extTriggers begin_extTriggers() const
Definition CTFHelper.h:336
Iter_chanData begin_chanData() const
Definition CTFHelper.h:345
Iter_nchanTrig end_nchanTrig() const
Definition CTFHelper.h:340
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
struct o2::upgrades_utils::@482 zdc
structure to keep FT0 information
constexpr int NModules
Definition Constants.h:68
constexpr int NTimeBinsPerBC
Definition Constants.h:53
constexpr int NChannels
Definition Constants.h:65
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
uint32_t orbit
LHC orbit.
uint16_t bc
bunch crossing ID of interaction
Header for a single CTF.
Definition CTF.h:32
VectorOfTObjectPtrs other
o2::InteractionRecord ir(0, 0)
std::vector< ChannelData > channels