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_CTP_CTF_HELPER_H
17#define O2_CTP_CTF_HELPER_H
18
19#include "DataFormatsCTP/CTF.h"
22#include <gsl/span>
23
24namespace o2
25{
26namespace ctp
27{
28
30{
31
32 public:
33 CTFHelper(const gsl::span<const CTPDigit>& data) : mData(data) {}
34
35 static constexpr int CTPInpNBytes = CTP_NINPUTS / 8 + (CTP_NINPUTS % 8 > 0);
36 static constexpr int CTPClsNBytes = CTP_NCLASSES / 8 + (CTP_NCLASSES % 8 > 0);
37
39 {
40 CTFHeader h{o2::detectors::DetID::CTP, 0, 1, 0, // dummy timestamp, version 1.0
41 lumi.counts, lumi.countsFV0, lumi.nHBFCounted, lumi.nHBFCountedFV0, lumi.orbit,
42 uint32_t(mData.size()), 0, 0, uint16_t(lumi.inp1), uint16_t(lumi.inp2)};
43 if (mData.size()) {
44 h.firstOrbit = mData[0].intRecord.orbit;
45 h.firstBC = mData[0].intRecord.bc;
46 }
47 return h;
48 }
49
50 size_t getSize() const { return mData.size() * sizeof(CTPDigit); }
51
52 //>>> =========================== ITERATORS ========================================
53
54 template <typename I, typename D, typename T, int M = 1>
55 class _Iter
56 {
57 public:
58 using difference_type = std::ptrdiff_t;
59 using value_type = T;
60 using pointer = const T*;
61 using reference = const T&;
62 using iterator_category = std::random_access_iterator_tag;
63
64 _Iter(const gsl::span<const D>& data, bool end = false) : mData(data), mIndex(end ? M * data.size() : 0){};
65 _Iter() = default;
66
67 inline I& operator++() noexcept
68 {
69 ++mIndex;
70 return static_cast<I&>(*this);
71 }
72
73 inline I operator++(int)
74 {
75 I res = *(static_cast<I*>(this));
76 ++mIndex;
77 return res;
78 }
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
94 {
95 mIndex += i;
96 return static_cast<I&>(*this);
97 }
98
100 {
101 I res = *(const_cast<I*>(static_cast<const I*>(this)));
102 return res += i;
103 }
104
106 {
107 mIndex -= i;
108 return static_cast<I&>(*this);
109 }
110
112 {
113 I res = *(const_cast<I*>(static_cast<const I*>(this)));
114 return res -= i;
115 }
116
117 difference_type operator-(const I& other) const noexcept { return mIndex - other.mIndex; }
118
119 inline friend I operator+(difference_type i, const I& iter) { return iter + i; };
120
121 bool operator!=(const I& other) const noexcept { return mIndex != other.mIndex; }
122 bool operator==(const I& other) const noexcept { return mIndex == other.mIndex; }
123 bool operator>(const I& other) const noexcept { return mIndex > other.mIndex; }
124 bool operator<(const I& other) const noexcept { return mIndex < other.mIndex; }
125 bool operator>=(const I& other) const noexcept { return mIndex >= other.mIndex; }
126 bool operator<=(const I& other) const noexcept { return mIndex <= other.mIndex; }
127
128 protected:
129 gsl::span<const D> mData{};
131 };
132
133 //_______________________________________________
134 // BC difference wrt previous if in the same orbit, otherwise the abs.value.
135 // For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
136 class Iter_bcIncTrig : public _Iter<Iter_bcIncTrig, CTPDigit, int16_t>
137 {
138 public:
139 using _Iter<Iter_bcIncTrig, CTPDigit, int16_t>::_Iter;
141 {
142 if (mIndex) {
143 if (mData[mIndex].intRecord.orbit == mData[mIndex - 1].intRecord.orbit) {
144 return value_type(mData[mIndex].intRecord.bc - mData[mIndex - 1].intRecord.bc);
145 } else {
146 return value_type(mData[mIndex].intRecord.bc);
147 }
148 }
149 return 0;
150 }
152 {
153 size_t id = mIndex + i;
154 if (id) {
155 if (mData[id].intRecord.orbit == mData[id - 1].intRecord.orbit) {
156 return value_type(mData[id].intRecord.bc - mData[id - 1].intRecord.bc);
157 } else {
158 return value_type(mData[id].intRecord.bc);
159 }
160 }
161 return 0;
162 }
163 };
164
165 //_______________________________________________
166 // Orbit difference wrt previous. For the very 1st entry return 0 (diff wrt 1st BC in the CTF header)
167 class Iter_orbitIncTrig : public _Iter<Iter_orbitIncTrig, CTPDigit, int32_t>
168 {
169 public:
171 value_type operator*() const { return value_type(mIndex ? mData[mIndex].intRecord.orbit - mData[mIndex - 1].intRecord.orbit : 0); }
173 {
174 size_t id = mIndex + i;
175 return value_type(id ? mData[id].intRecord.orbit - mData[id - 1].intRecord.orbit : 0);
176 }
177 };
178
179 //_______________________________________________
180 class Iter_bytesInput : public _Iter<Iter_bytesInput, CTPDigit, uint8_t, CTPInpNBytes>
181 {
182 public:
185 {
186 return static_cast<uint8_t>(((mData[mIndex / CTPInpNBytes].CTPInputMask.to_ullong()) >> (8 * (mIndex % CTPInpNBytes))) & 0xff);
187 }
189 {
190 size_t id = mIndex + i;
191 return static_cast<uint8_t>(((mData[id / CTPInpNBytes].CTPInputMask.to_ullong()) >> (8 * (id % CTPInpNBytes))) & 0xff);
192 }
193 };
194
195 //_______________________________________________
196 class Iter_bytesClass : public _Iter<Iter_bytesClass, CTPDigit, uint8_t, CTPClsNBytes>
197 {
198 public:
201 {
202 return static_cast<uint8_t>(((mData[mIndex / CTPClsNBytes].CTPClassMask.to_ullong()) >> (8 * (mIndex % CTPClsNBytes))) & 0xff);
203 }
205 {
206 size_t id = mIndex + i;
207 return static_cast<uint8_t>(((mData[id / CTPClsNBytes].CTPClassMask.to_ullong()) >> (8 * (id % CTPClsNBytes))) & 0xff);
208 }
209 };
210
211 //<<< =========================== ITERATORS ========================================
212
213 Iter_bcIncTrig begin_bcIncTrig() const { return Iter_bcIncTrig(mData, false); }
214 Iter_bcIncTrig end_bcIncTrig() const { return Iter_bcIncTrig(mData, true); }
215
217 Iter_orbitIncTrig end_orbitIncTrig() const { return Iter_orbitIncTrig(mData, true); }
218
219 Iter_bytesInput begin_bytesInput() const { return Iter_bytesInput(mData, false); }
220 Iter_bytesInput end_bytesInput() const { return Iter_bytesInput(mData, true); }
221
222 Iter_bytesClass begin_bytesClass() const { return Iter_bytesClass(mData, false); }
223 Iter_bytesClass end_bytesClass() const { return Iter_bytesClass(mData, true); }
224
225 private:
226 const gsl::span<const o2::ctp::CTPDigit> mData;
227};
228
229} // namespace ctp
230} // namespace o2
231
232#endif
Definitions for CTP CTF data.
definition of CTPDigit, CTPInputDigit
unsigned char uint8_t
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
Class for time synchronization of RawReader instances.
value_type operator[](difference_type i) const
Definition CTFHelper.h:151
value_type operator[](difference_type i) const
Definition CTFHelper.h:204
value_type operator[](difference_type i) const
Definition CTFHelper.h:188
value_type operator[](difference_type i) const
Definition CTFHelper.h:172
I & operator++() noexcept
Definition CTFHelper.h:67
friend I operator+(difference_type i, const I &iter)
Definition CTFHelper.h:119
std::ptrdiff_t difference_type
Definition CTFHelper.h:58
difference_type mIndex
Definition CTFHelper.h:130
I operator-(difference_type i) const
Definition CTFHelper.h:111
bool operator==(const I &other) const noexcept
Definition CTFHelper.h:122
bool operator>(const I &other) const noexcept
Definition CTFHelper.h:123
I & operator-=(difference_type i) noexcept
Definition CTFHelper.h:105
difference_type operator-(const I &other) const noexcept
Definition CTFHelper.h:117
bool operator<=(const I &other) const noexcept
Definition CTFHelper.h:126
I & operator--() noexcept
Definition CTFHelper.h:80
gsl::span< const D > mData
Definition CTFHelper.h:129
bool operator!=(const I &other) const noexcept
Definition CTFHelper.h:121
I operator+(difference_type i) const
Definition CTFHelper.h:99
bool operator<(const I &other) const noexcept
Definition CTFHelper.h:124
bool operator>=(const I &other) const noexcept
Definition CTFHelper.h:125
_Iter(const gsl::span< const D > &data, bool end=false)
Definition CTFHelper.h:64
std::random_access_iterator_tag iterator_category
Definition CTFHelper.h:62
I & operator+=(difference_type i) noexcept
Definition CTFHelper.h:93
Iter_bytesClass begin_bytesClass() const
Definition CTFHelper.h:222
Iter_bcIncTrig end_bcIncTrig() const
Definition CTFHelper.h:214
static constexpr int CTPClsNBytes
Definition CTFHelper.h:36
Iter_bcIncTrig begin_bcIncTrig() const
Definition CTFHelper.h:213
Iter_bytesInput begin_bytesInput() const
Definition CTFHelper.h:219
CTFHelper(const gsl::span< const CTPDigit > &data)
Definition CTFHelper.h:33
Iter_orbitIncTrig begin_orbitIncTrig() const
Definition CTFHelper.h:216
static constexpr int CTPInpNBytes
Definition CTFHelper.h:35
CTFHeader createHeader(const LumiInfo &lumi)
Definition CTFHelper.h:38
size_t getSize() const
Definition CTFHelper.h:50
Iter_bytesClass end_bytesClass() const
Definition CTFHelper.h:223
Iter_bytesInput end_bytesInput() const
Definition CTFHelper.h:220
Iter_orbitIncTrig end_orbitIncTrig() const
Definition CTFHelper.h:217
GLsizeiptr size
Definition glcorearb.h:659
GLuint GLuint end
Definition glcorearb.h:469
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
LumiInfo lumi