Project
Loading...
Searching...
No Matches
GPUTRDTrackletWord.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
14
16
17#ifndef GPUTRDTRACKLETWORD_H
18#define GPUTRDTRACKLETWORD_H
19
20#include "GPUDef.h"
21
22#ifndef GPUCA_TPC_GEOMETRY_O2 // compatibility to Run 2 data types
23
24class AliTRDtrackletWord;
25class AliTRDtrackletMCM;
26
27namespace o2::gpu
28{
29
31{
32 public:
33 GPUd() GPUTRDTrackletWord(uint32_t trackletWord = 0);
34 GPUd() GPUTRDTrackletWord(uint32_t trackletWord, int32_t hcid);
36 GPUdDefault() GPUTRDTrackletWord& operator=(const GPUTRDTrackletWord& rhs) = default;
38#ifndef GPUCA_GPUCODE_DEVICE
39 GPUTRDTrackletWord(const AliTRDtrackletWord& rhs);
40 GPUTRDTrackletWord(const AliTRDtrackletMCM& rhs);
41 GPUTRDTrackletWord& operator=(const AliTRDtrackletMCM& rhs);
42#endif
43
44 // ----- Override operators < and > to enable tracklet sorting by HCId -----
45 GPUd() bool operator<(const GPUTRDTrackletWord& t) const { return (GetHCId() < t.GetHCId()); }
46 GPUd() bool operator>(const GPUTRDTrackletWord& t) const { return (GetHCId() > t.GetHCId()); }
47 GPUd() bool operator<=(const GPUTRDTrackletWord& t) const { return (GetHCId() < t.GetHCId()) || (GetHCId() == t.GetHCId()); }
48
49 // ----- Getters for contents of tracklet word -----
50 GPUd() int32_t GetYbin() const;
51 GPUd() int32_t GetdYbin() const;
52 GPUd() int32_t GetZbin() const { return ((mTrackletWord >> 20) & 0xf); }
53 GPUd() int32_t GetPID() const { return ((mTrackletWord >> 24) & 0xff); }
54
55 // ----- Getters for offline corresponding values -----
56 GPUd() double GetPID(int32_t /* is */) const { return (double)GetPID() / 256.f; }
57 GPUd() int32_t GetDetector() const { return mHCId / 2; }
58 GPUd() int32_t GetHCId() const { return mHCId; }
59 GPUd() float GetdYdX() const { return (GetdYbin() * 140e-4f / 3.f); }
60 GPUd() float GetdY() const { return GetdYbin() * 140e-4f; }
61 GPUd() float GetY() const { return (GetYbin() * 160e-4f); }
62 GPUd() uint32_t GetTrackletWord() const { return mTrackletWord; }
63
64 GPUd() void SetTrackletWord(uint32_t trackletWord) { mTrackletWord = trackletWord; }
65 GPUd() void SetDetector(int32_t id) { mHCId = 2 * id + (GetYbin() < 0 ? 0 : 1); }
66 GPUd() void SetHCId(int32_t id) { mHCId = id; }
67
68 protected:
69 int32_t mHCId; // half-chamber ID
70 uint32_t mTrackletWord; // tracklet word: PID | Z | deflection length | Y
71 // bits: 8 4 7 13
72};
73} // namespace o2::gpu
74
75#else // compatibility with Run 3 data types
76
78
79namespace o2::gpu
80{
81
82class GPUTRDTrackletWord : private o2::trd::Tracklet64
83{
84 public:
85 GPUd() GPUTRDTrackletWord(uint64_t trackletWord = 0) : o2::trd::Tracklet64(trackletWord){};
86 GPUdDefault() GPUTRDTrackletWord(const GPUTRDTrackletWord& rhs) = default;
87 GPUdDefault() GPUTRDTrackletWord& operator=(const GPUTRDTrackletWord& rhs) = default;
88 GPUdDefault() ~GPUTRDTrackletWord() = default;
89
90 // ----- Override operators < and > to enable tracklet sorting by HCId -----
91 GPUd() bool operator<(const GPUTRDTrackletWord& t) const { return (getHCID() < t.getHCID()); }
92 GPUd() bool operator>(const GPUTRDTrackletWord& t) const { return (getHCID() > t.getHCID()); }
93 GPUd() bool operator<=(const GPUTRDTrackletWord& t) const { return (getHCID() < t.getHCID()) || (getHCID() == t.getHCID()); }
94
95 GPUd() int32_t GetZbin() const { return getPadRow(); }
96 GPUd() float GetY() const { return getUncalibratedY(); }
97 GPUd() float GetdY() const { return getUncalibratedDy(); }
98 GPUd() int32_t GetDetector() const { return getDetector(); }
99 GPUd() int32_t GetHCId() const { return getHCID(); }
100
101 // IMPORTANT: Do not add members, this class must keep the same memory layout as o2::trd::Tracklet64
102};
103
104static_assert(sizeof(GPUTRDTrackletWord) == sizeof(o2::trd::Tracklet64), "Incorrect memory layout");
105
106} // namespace o2::gpu
107
108#endif // GPUCA_TPC_GEOMETRY_O2
109
110#endif // GPUTRDTRACKLETWORD_H
GPUd() void SetTrackletWord(uint32_t trackletWord)
GPUd() void SetHCId(int32_t id)
GPUd() bool operator>(const GPUTRDTrackletWord &t) const
GPUTRDTrackletWord(const AliTRDtrackletWord &rhs)
GPUd() int32_t GetPID() const
GPUd() double GetPID(int32_t) const
GPUd() float GetdYdX() const
GPUd() void SetDetector(int32_t id)
GPUTRDTrackletWord(const AliTRDtrackletMCM &rhs)
GPUTRDTrackletWord & operator=(const AliTRDtrackletMCM &rhs)
GPUd() uint32_t GetTrackletWord() const
GPUd() int32_t GetDetector() const
GPUd() int32_t GetHCId() const
GPUd() bool operator<(const GPUTRDTrackletWord &t) const
GPUd() GPUTRDTrackletWord(uint32_t trackletWord=0)
GPUdDefault() ~GPUTRDTrackletWord()=default
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
GLuint id
Definition glcorearb.h:650