Project
Loading...
Searching...
No Matches
Tracklet64.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
12// #include "TRDBase/GeometryBase.h"
13// #include "DetectorsCommonDataFormats/DetMatrixCache.h"
14// #include "DetectorsCommonDataFormats/DetID.h"
15
16#ifndef O2_TRD_TRACKLET64_H
17#define O2_TRD_TRACKLET64_H
18
20// //
21// TRD Raw tracklet //
22// class for TRD tracklets //
23// loosely based on the old TrackletMCM //
24// It still returns the old TrackletWord of run2, rebuilt on calling. //
25// Authors //
26// Sean Murray (murrays@cern.ch) //
27//
29
30#ifndef GPUCA_GPUCODE_DEVICE
31#include <cstdint>
32#endif
33#include "GPUCommonDef.h"
34#include "GPUCommonRtypes.h"
35#include "GPUCommonMath.h"
37
38namespace o2
39{
40namespace trd
41{
42/* |63|62|61|60|59|58|57|56|55|54|53|52|51|50|49|48|47|46|45|44|43|42|41|40|39|38|37|36|35|34|33|32|
43 -------------------------------------------------------------------------------------------------
44Word 0 | Format | HCID | padrow | col | position |
45 -------------------------------------------------------------------------------------------------
46 |31|30|29|28|27|26|25|24|23|22|21|20|19|18|17|16|15|14|13|12|11|10|09|08|07|06|05|04|03|02|01|00|
47 -------------------------------------------------------------------------------------------------
48Word 0 | slope | Q2 | Q1 | Q0 |
49 -------------------------------------------------------------------------------------------------
50
51 Note: In the tracklet word wich is sent from the FEE both the position and the slope have one bit inverted.
52 This avoids the mis-interpretation of the word as tracklet end marker. The raw reader flips these bits
53 back so that the position and slope stored in the Tracklet64 can be used without requiring to invert
54 any bit.
55*/
57{
58
59 public:
60 GPUdDefault() Tracklet64() = default;
61 GPUd() Tracklet64(uint64_t trackletword) { mtrackletWord = trackletword; }
62 GPUdDefault() Tracklet64(const Tracklet64&) = default;
63 GPUd() Tracklet64(uint64_t format, uint64_t hcid, uint64_t padrow, uint64_t col, uint64_t position,
64 uint64_t slope, uint64_t Q0, uint64_t Q1, uint64_t Q2)
65 {
66 mtrackletWord = ((format << formatbs) & formatmask) |
67 ((hcid << hcidbs) & hcidmask) |
68 ((padrow << padrowbs) & padrowmask) |
69 ((col << colbs) & colmask) |
70 ((position << posbs) & posmask) |
71 ((slope << slopebs) & slopemask) |
72 ((Q2 << Q2bs) & Q2mask) |
73 ((Q1 << Q1bs) & Q1mask) |
74 ((Q0 << Q0bs) & Q0mask);
75 }
76
77 Tracklet64(uint64_t format, uint64_t hcid, uint64_t padrow, uint64_t col, uint64_t position,
78 uint64_t slope, uint64_t pid)
79 {
80 mtrackletWord = ((format << formatbs) & formatmask) |
81 ((hcid << hcidbs) & hcidmask) |
82 ((padrow << padrowbs) & padrowmask) |
83 ((col << colbs) & colmask) |
84 ((position << posbs) & posmask) |
85 ((slope << slopebs) & slopemask) |
86 (pid & PIDmask);
87 }
88
89 GPUdDefault() ~Tracklet64() = default;
90 GPUdDefault() Tracklet64& operator=(const Tracklet64& rhs) = default;
91 GPUd() bool operator==(const Tracklet64& o) const { return mtrackletWord == o.mtrackletWord; }
92
93 // ----- Getters -----
94 GPUd() uint64_t getTrackletWord() const { return mtrackletWord; }
95
96 // position / direction information
97
98 // half-chamber number [0..1079]
99 GPUd() int getHCID() const { return ((mtrackletWord & hcidmask) >> hcidbs); };
100
101 // chamber number [0..539]
102 GPUd() int getDetector() const { return getHCID() / 2; }
103
104 // pad row number on ROB [0..15]
105 GPUd() int getPadRow() const { return ((mtrackletWord & padrowmask) >> padrowbs); };
106
107 // MCM position in column direction on ROB [0..3]
108 GPUd() int getColumn() const { return ((mtrackletWord & colmask) >> colbs); };
109
110 // in units of 1/40 pads, 11 bit granularity (MSP is used to indicate sign)
111 GPUd() int getPosition() const { return ((mtrackletWord & posmask) >> posbs); };
112
113 // applies two's complement to getPosition() to obtain signed value
114 GPUd() int getPositionBinSigned() const;
115
116 // the position as float in unit of pads relative to MCM center
117 GPUd() float getPositionFloat() const { return getPositionBinSigned() * constants::GRANULARITYTRKLPOS; }
118
119 // in units of 1/128 pads/timebin, 8 bit granularity (MSP is used to indicate sign)
120 GPUd() int getSlope() const { return ((mtrackletWord & slopemask) >> slopebs); };
121
122 // applies two's complement to getSlope() to obtain signed value
123 GPUd() int getSlopeBinSigned() const;
124
125 // as float in units of pads per time bin
126 GPUd() float getSlopeFloat() const { return getSlopeBinSigned() * constants::GRANULARITYTRKLSLOPE / constants::ADDBITSHIFTSLOPE; }
127
128 // MCM position on ROB [0..15]
129 GPUd() int getMCM() const { return constants::NMCMROBINROW * (getPadRow() % constants::NMCMROBINCOL) + getColumn(); }
130
131 // ROB number [0..5] for C0 chamber and [0..7] for C1 chamber
132 GPUd() int getROB() const { return (getHCID() % 2) ? (getPadRow() / constants::NMCMROBINROW) * 2 + 1 : (getPadRow() / constants::NMCMROBINROW) * 2; }
133
134 // MCM number in pad column direction [0..7]
135 GPUd() int getMCMCol() const { return (getMCM() % constants::NMCMROBINCOL) + constants::NMCMROBINCOL * (getROB() % 2); }
136
137 // pad width in cm required for transformation from pad coordinates to tracking coordinates
138 GPUd() float getPadWidth() const { return 0.635f + 0.03f * (getDetector() % constants::NLAYER); }
139
140 // pad column number inside pad row as float
141 // FIXME: understand why the offset seems to be 8 pads and not nChannels / 2 = 10.5
142 // Due to wrong pad shift included in alignment we need to optionally shift the tracklets by one pad
143 // in case we are not using the ideal alignment
144 GPUd() float getPadColFloat(bool applyShift) const { return getPositionFloat() + getMCMCol() * constants::NCOLMCM + 8.f + (applyShift ? 1.f : 0.f); }
145
146 // pad column number inside pad row as int can be off by +-1 pad (same function name as for TRD digit)
147 GPUd() int getPadCol(bool applyShift = false) const { return o2::gpu::CAMath::Float2IntRn(getPadColFloat(applyShift)); }
148
149 // translate local position into global y (in cm) not taking into account calibrations (ExB, vDrift, t0)
150 GPUd() float getUncalibratedY(bool applyShift = false) const { return (getPadColFloat(applyShift) - (constants::NCOLUMN / 2.f)) * getPadWidth(); }
151
152 // translate local slope into dy/dx with dx=3m (drift length) and default drift time in time bins (19.4 timebins / 3cm)
153 GPUd() float getUncalibratedDy(float nTbDrift = 19.4f) const { return getSlopeFloat() * getPadWidth() * nTbDrift; }
154
155 // PID related getters
156 GPUd() int getFormat() const { return ((mtrackletWord & formatmask) >> formatbs); };
157 GPUd() int getPID() const { return ((mtrackletWord & PIDmask)); };
158 GPUd() int getDynamicCharge(unsigned int charge) const
159 {
160 int shift = (charge >> 6) & 0x3;
161 if (shift == 0) {
162 shift = 8;
163 } else {
164 shift = shift << 1;
165 }
166 charge = charge << shift;
167 return charge;
168 }; // no unit
169 GPUd() int getQ0() const
170 {
171 if ((getFormat() & 0x1) == 0) {
172 return ((mtrackletWord & Q0mask) >> Q0bs);
173 } else {
174 return getDynamicCharge((mtrackletWord & Q0mask) >> Q0bs);
175 }
176 }; // no unit
177 GPUd() int getQ1() const
178 {
179 if ((getFormat() & 0x1) == 0) {
180 return ((mtrackletWord & Q1mask) >> Q1bs);
181 } else {
182 return getDynamicCharge((mtrackletWord & Q1mask) >> Q1bs);
183 }
184 }; // no unit
185 GPUd() int getQ2() const
186 {
187 if ((getFormat() & 0x1) == 0) {
188 return ((mtrackletWord & Q2mask) >> Q2bs);
189 } else {
190 return getDynamicCharge((mtrackletWord & Q2mask) >> Q2bs);
191 }
192 }; // no unit
193
194 // ----- Setters for tracklet word manipulation -----
195 GPUd() void setTrackletWord(uint64_t trackletword) { mtrackletWord = trackletword; }
196 GPUd() void setQ0(int charge) { mtrackletWord = (mtrackletWord & ~Q0mask) | ((charge & Q0mask) << Q0bs); }
197 GPUd() void setQ1(int charge) { mtrackletWord = (mtrackletWord & ~Q1mask) | ((charge & Q1mask) << Q1bs); }
198 GPUd() void setQ2(int charge) { mtrackletWord = (mtrackletWord & ~Q2mask) | ((charge & Q2mask) << Q2bs); }
199 GPUd() void setPID(int pid) { mtrackletWord = (mtrackletWord & ~PIDmask) | ((pid & PIDmask) << PIDbs); }
200 GPUd() void setPosition(int position) { mtrackletWord = (mtrackletWord & ~posmask) | ((position & posmask) << posbs); }
201 GPUd() void setSlope(int slope) { mtrackletWord = (mtrackletWord & ~slopemask) | ((slope & slopemask) << slopebs); }
202
203 GPUd() void print() const;
204#ifndef GPUCA_GPUCODE_DEVICE
205 void printStream(std::ostream& stream) const;
206#endif // GPUCA_GPUCODE_DEVICE
207
208 // bit masks for the above raw data;
209 static GPUglobalconstexpr() uint64_t formatmask = 0xf000000000000000;
210 static GPUglobalconstexpr() uint64_t hcidmask = 0x0ffe000000000000;
211 static GPUglobalconstexpr() uint64_t padrowmask = 0x0001e00000000000;
212 static GPUglobalconstexpr() uint64_t colmask = 0x0000180000000000;
213 static GPUglobalconstexpr() uint64_t posmask = 0x000007ff00000000;
214 static GPUglobalconstexpr() uint64_t slopemask = 0x00000000ff000000;
215 static GPUglobalconstexpr() uint64_t Q2mask = 0x0000000000ff0000;
216 static GPUglobalconstexpr() uint64_t Q1mask = 0x000000000000ff00;
217 static GPUglobalconstexpr() uint64_t Q0mask = 0x00000000000000ff;
218 static GPUglobalconstexpr() uint64_t PIDmask = 0x0000000000ffffff;
219 // bit shifts for the above raw data
220 static GPUglobalconstexpr() uint64_t formatbs = 60;
221 static GPUglobalconstexpr() uint64_t hcidbs = 49;
222 static GPUglobalconstexpr() uint64_t padrowbs = 45;
223 static GPUglobalconstexpr() uint64_t colbs = 43;
224 static GPUglobalconstexpr() uint64_t posbs = 32;
225 static GPUglobalconstexpr() uint64_t slopebs = 24;
226 static GPUglobalconstexpr() uint64_t PIDbs = 0;
227 static GPUglobalconstexpr() uint64_t Q2bs = 16;
228 static GPUglobalconstexpr() uint64_t Q1bs = 8;
229 static GPUglobalconstexpr() uint64_t Q0bs = 0;
230
231 protected:
232 uint64_t mtrackletWord; // the 64 bit word holding all the tracklet information for run3.
233 private:
234 ClassDefNV(Tracklet64, 2);
235};
236
237GPUdi() int Tracklet64::getPositionBinSigned() const
238{
239 int padLocalBin = getPosition();
240 int padLocal = 0;
241 if (padLocalBin & (1 << (constants::NBITSTRKLPOS - 1))) {
242 padLocal = -((~(padLocalBin - 1)) & ((1 << constants::NBITSTRKLPOS) - 1));
243 } else {
244 padLocal = padLocalBin & ((1 << constants::NBITSTRKLPOS) - 1);
245 }
246 return padLocal;
247}
248
249GPUdi() int Tracklet64::getSlopeBinSigned() const
250{
251 int slopeBin = getSlope();
252 int slope = 0;
253 if (slopeBin & (1 << (constants::NBITSTRKLSLOPE - 1))) {
254 slope = -((~(slopeBin - 1)) & ((1 << constants::NBITSTRKLSLOPE) - 1));
255 } else {
256 slope = slopeBin & ((1 << constants::NBITSTRKLSLOPE) - 1);
257 }
258 return -slope;
259}
260
261#ifndef GPUCA_GPUCODE_DEVICE
262std::ostream& operator<<(std::ostream& stream, const Tracklet64& trg);
263#endif // GPUCA_GPUCODE_DEVICE
264
265} // namespace trd
266} // namespace o2
267
268#endif
Global TRD definitions and constants.
int16_t charge
Definition RawEventData.h:5
void print() const
#define GPUdi()
#define protected
uint16_t pid
Definition RawData.h:2
o2::mid::ColumnData & getColumn(std::vector< o2::mid::ColumnData > &patterns, uint8_t icolumn, uint8_t deId)
GPUd() int getROB() const
Definition Tracklet64.h:132
GPUd() int getPositionBinSigned() const
GPUd() float getPadWidth() const
Definition Tracklet64.h:138
GPUd() void setTrackletWord(uint64_t trackletword)
Definition Tracklet64.h:195
GPUd() void print() const
GPUd() void setQ0(int charge)
Definition Tracklet64.h:196
GPUdDefault() Tracklet64 &operator
GPUd() void setPID(int pid)
Definition Tracklet64.h:199
GPUd() int getMCM() const
Definition Tracklet64.h:129
uint64_t uint64_t uint64_t uint64_t uint64_t slope
Definition Tracklet64.h:64
GPUd() void setQ1(int charge)
Definition Tracklet64.h:197
GPUd() int getPadCol(bool applyShift
uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t Q2
Definition Tracklet64.h:65
GPUd() int getSlope() const
Definition Tracklet64.h:120
uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t Q0
Definition Tracklet64.h:64
GPUd() void setSlope(int slope)
Definition Tracklet64.h:201
GPUd() int getMCMCol() const
Definition Tracklet64.h:135
Tracklet64(uint64_t format, uint64_t hcid, uint64_t padrow, uint64_t col, uint64_t position, uint64_t slope, uint64_t pid)
Definition Tracklet64.h:77
void printStream(std::ostream &stream) const
GPUd() void setQ2(int charge)
Definition Tracklet64.h:198
GPUd() int getSlopeBinSigned() const
GPUdDefault() Tracklet64()=default
uint64_t uint64_t uint64_t col
Definition Tracklet64.h:63
GPUd() void setPosition(int position)
Definition Tracklet64.h:200
GPUd() int getDetector() const
Definition Tracklet64.h:102
uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t uint64_t Q1
Definition Tracklet64.h:64
GPUd() int getPID() const
Definition Tracklet64.h:157
GPUdDefault() Tracklet64(const Tracklet64 &)=default
GPUdDefault() ~Tracklet64()=default
uint64_t uint64_t uint64_t uint64_t position
Definition Tracklet64.h:63
GPUd() int getPosition() const
Definition Tracklet64.h:111
GPUd() int getColumn() const
Definition Tracklet64.h:108
static GPUglobalconstexpr() uint64_t formatmask=0xf000000000000000
GPUd() int getQ1() const
Definition Tracklet64.h:177
GPUd() int getDynamicCharge(unsigned int charge) const
Definition Tracklet64.h:158
GPUd() Tracklet64(uint64_t trackletword)
Definition Tracklet64.h:61
GPUd() int getQ2() const
Definition Tracklet64.h:185
GPUd() int getQ0() const
Definition Tracklet64.h:169
uint64_t uint64_t padrow
Definition Tracklet64.h:63
GPUd() float getPadColFloat(bool applyShift) const
Definition Tracklet64.h:144
GPUd() int getPadRow() const
Definition Tracklet64.h:105
GLdouble f
Definition glcorearb.h:310
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint GLuint stream
Definition glcorearb.h:1806
GLint GLint GLsizei GLint GLenum format
Definition glcorearb.h:275
std::ostream & operator<<(std::ostream &stream, const Digit &d)
Definition Digit.cxx:85
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...