Skip to content

Commit 29534b7

Browse files
martenoledavidrohr
authored andcommitted
Make Tracklet64 compatible with GPUTRDTracker
1 parent 5651740 commit 29534b7

6 files changed

Lines changed: 91 additions & 44 deletions

File tree

DataFormats/Detectors/TRD/include/DataFormatsTRD/Tracklet64.h

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
//
2727
////////////////////////////////////////////////////////////////////////////
2828

29-
#include "Rtypes.h" // for ClassDef
29+
#include "GPUCommonDef.h"
30+
#include "GPUCommonRtypes.h"
3031

3132
namespace o2
3233
{
@@ -45,11 +46,11 @@ class Tracklet64
4546
{
4647

4748
public:
48-
Tracklet64() = default;
49-
Tracklet64(uint64_t trackletword) { mtrackletWord = trackletword; }
50-
Tracklet64(const Tracklet64&) = default;
51-
Tracklet64(uint64_t format, uint64_t hcid, uint64_t padrow, uint64_t col, uint64_t position,
52-
uint64_t slope, uint64_t Q0, uint64_t Q1, uint64_t Q2)
49+
GPUdDefault() Tracklet64() = default;
50+
GPUd() Tracklet64(uint64_t trackletword) { mtrackletWord = trackletword; }
51+
GPUdDefault() Tracklet64(const Tracklet64&) = default;
52+
GPUd() Tracklet64(uint64_t format, uint64_t hcid, uint64_t padrow, uint64_t col, uint64_t position,
53+
uint64_t slope, uint64_t Q0, uint64_t Q1, uint64_t Q2)
5354
{
5455
mtrackletWord = ((format << formatbs) & formatmask) |
5556
((hcid << hcidbs) & hcidmask) |
@@ -62,66 +63,68 @@ class Tracklet64
6263
((Q0 << Q0bs) & Q0mask);
6364
}
6465

65-
~Tracklet64() = default;
66-
Tracklet64& operator=(const Tracklet64& rhs) = default;
66+
GPUdDefault() ~Tracklet64() = default;
67+
GPUdDefault() Tracklet64& operator=(const Tracklet64& rhs) = default;
6768

6869
// ----- Getters for contents of tracklet word -----
69-
uint64_t getHCID() const { return ((mtrackletWord & hcidmask) >> hcidbs); }; // no units 0..1077
70-
uint64_t getPadRow() const { return ((mtrackletWord & padrowmask) >> padrowbs); }; // pad row number [0..15]
71-
uint64_t getColumn() const { return ((mtrackletWord & colmask) >> colbs); }; // column refers to MCM position in column direction on readout board [0..3]
72-
uint64_t getPosition() const { return ((mtrackletWord & posmask) >> posbs); }; // in units of 1/80 pads, 11 bit granularity [-12.8..12.8] relative to MCM center
73-
uint64_t getSlope() const { return ((mtrackletWord & slopemask) >> slopebs); }; // in units of 1/1000 pads/timebin, 8 bit granularity [-0.128 to 0.128]
74-
uint64_t getPID() const { return ((mtrackletWord & PIDmask)); }; // no unit, all 3 charge windows combined
75-
uint64_t getQ0() const { return ((mtrackletWord & Q0mask) >> Q0bs); }; // no unit
76-
uint64_t getQ1() const { return ((mtrackletWord & Q1mask) >> Q1bs); }; // no unit
77-
uint64_t getQ2() const { return ((mtrackletWord & Q2mask) >> Q2bs); }; // no unit
78-
79-
void setTrackletWord(uint64_t trackletword) { mtrackletWord = trackletword; }
70+
GPUd() uint64_t getHCID() const { return ((mtrackletWord & hcidmask) >> hcidbs); }; // no units 0..1077
71+
GPUd() uint64_t getPadRow() const { return ((mtrackletWord & padrowmask) >> padrowbs); }; // pad row number [0..15]
72+
GPUd() uint64_t getColumn() const { return ((mtrackletWord & colmask) >> colbs); }; // column refers to MCM position in column direction on readout board [0..3]
73+
GPUd() uint64_t getPosition() const { return ((mtrackletWord & posmask) >> posbs); }; // in units of 1/80 pads, 11 bit granularity [-12.8..12.8] relative to MCM center
74+
GPUd() uint64_t getSlope() const { return ((mtrackletWord & slopemask) >> slopebs); }; // in units of 1/1000 pads/timebin, 8 bit granularity [-0.128 to 0.128]
75+
GPUd() uint64_t getPID() const { return ((mtrackletWord & PIDmask)); }; // no unit, all 3 charge windows combined
76+
GPUd() uint64_t getQ0() const { return ((mtrackletWord & Q0mask) >> Q0bs); }; // no unit
77+
GPUd() uint64_t getQ1() const { return ((mtrackletWord & Q1mask) >> Q1bs); }; // no unit
78+
GPUd() uint64_t getQ2() const { return ((mtrackletWord & Q2mask) >> Q2bs); }; // no unit
79+
80+
GPUd() void setTrackletWord(uint64_t trackletword) { mtrackletWord = trackletword; }
8081

8182
// ----- Getters for tracklet information -----
82-
int getMCM() const { return 4 * (getPadRow() % 4) + getColumn(); } // returns MCM position on ROB [0..15]
83-
int getROB() const { return (getHCID() % 2) ? (getPadRow() / 4) * 2 + 1 : (getPadRow() / 4) * 2; } // returns ROB number [0..5] for C0 chamber and [0..7] for C1 chamber
84-
float getUncalibratedY() const; // translate local position into global y (in cm) not taking into account calibrations (ExB, vDrift, t0)
85-
float getUncalibratedDy(float nTbDrift = 19.4f) const; // translate local slope into dy/dx with dx=3m (drift length) and default drift time in time bins (19.4 timebins / 3cm)
83+
GPUd() int getMCM() const { return 4 * (getPadRow() % 4) + getColumn(); } // returns MCM position on ROB [0..15]
84+
GPUd() int getROB() const { return (getHCID() % 2) ? (getPadRow() / 4) * 2 + 1 : (getPadRow() / 4) * 2; } // returns ROB number [0..5] for C0 chamber and [0..7] for C1 chamber
85+
GPUd() float getUncalibratedY() const; // translate local position into global y (in cm) not taking into account calibrations (ExB, vDrift, t0)
86+
GPUd() float getUncalibratedDy(float nTbDrift = 19.4f) const; // translate local slope into dy/dx with dx=3m (drift length) and default drift time in time bins (19.4 timebins / 3cm)
8687

8788
// ----- Getters for offline corresponding values -----
88-
int getDetector() const { return getHCID() / 2; }
89+
GPUd() int getDetector() const { return getHCID() / 2; }
8990

90-
uint64_t getTrackletWord() const { return mtrackletWord; }
91+
GPUd() uint64_t getTrackletWord() const { return mtrackletWord; }
9192

92-
void setQ0(int charge)
93+
GPUd() void setQ0(int charge)
9394
{
9495
mtrackletWord &= ~Q0mask;
9596
mtrackletWord |= ((charge << Q0bs) & Q0mask);
9697
}
97-
void setQ1(int charge)
98+
GPUd() void setQ1(int charge)
9899
{
99100
mtrackletWord &= ~Q1mask;
100101
mtrackletWord |= ((charge << Q1bs) & Q1mask);
101102
}
102-
void setQ2(int charge)
103+
GPUd() void setQ2(int charge)
103104
{
104105
mtrackletWord &= ~Q2mask;
105106
mtrackletWord |= ((charge << Q2bs) & Q2mask);
106107
}
107-
void setPID(uint64_t pid)
108+
GPUd() void setPID(uint64_t pid)
108109
{
109110
// set the entire pid area of the trackletword, all the 3 Q's
110111
mtrackletWord &= ~PIDmask;
111112
mtrackletWord |= ((pid << PIDbs) & PIDmask);
112113
}
113-
void setPosition(uint64_t position)
114+
GPUd() void setPosition(uint64_t position)
114115
{
115116
mtrackletWord &= ~posmask;
116117
mtrackletWord |= ((position << posbs) & posmask);
117118
}
118-
void setSlope(uint64_t slope)
119+
GPUd() void setSlope(uint64_t slope)
119120
{
120121
mtrackletWord &= ~slopemask;
121122
mtrackletWord |= ((slope << slopebs) & slopemask);
122123
}
123124

125+
#ifndef GPUCA_GPUCODE_DEVICE
124126
void printStream(std::ostream& stream) const;
127+
#endif // GPUCA_GPUCODE_DEVICE
125128

126129
// bit masks for the above raw data;
127130
static constexpr uint64_t formatmask = 0xf000000000000000;
@@ -152,7 +155,9 @@ class Tracklet64
152155
ClassDefNV(Tracklet64, 1);
153156
};
154157

158+
#ifndef GPUCA_GPUCODE_DEVICE
155159
std::ostream& operator<<(std::ostream& stream, const Tracklet64& trg);
160+
#endif // GPUCA_GPUCODE_DEVICE
156161

157162
} //namespace trd
158163
} //namespace o2

DataFormats/Detectors/TRD/src/Tracklet64.cxx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace trd
2222

2323
using namespace constants;
2424

25-
float Tracklet64::getUncalibratedY() const
25+
GPUd() float Tracklet64::getUncalibratedY() const
2626
{
2727
int padLocalBin = getPosition();
2828
int padLocal = 0;
@@ -37,7 +37,7 @@ float Tracklet64::getUncalibratedY() const
3737
return (offset + padLocal * GRANULARITYTRKLPOS) * padWidth;
3838
}
3939

40-
float Tracklet64::getUncalibratedDy(float nTbDrift) const
40+
GPUd() float Tracklet64::getUncalibratedDy(float nTbDrift) const
4141
{
4242
float dy;
4343
int dyLocalBin = getSlope();
@@ -51,6 +51,7 @@ float Tracklet64::getUncalibratedDy(float nTbDrift) const
5151
return dy * GRANULARITYTRKLSLOPE * padWidth * nTbDrift;
5252
}
5353

54+
#ifndef GPUCA_GPUCODE_DEVICE
5455
void Tracklet64::printStream(std::ostream& stream) const
5556
{
5657
stream << "Tracklet64 : 0x" << std::hex << getTrackletWord();
@@ -65,6 +66,7 @@ std::ostream& operator<<(std::ostream& stream, const Tracklet64& trg)
6566
trg.printStream(stream);
6667
return stream;
6768
}
69+
#endif // GPUCA_GPUCODE_DEVICE
6870

6971
} // namespace trd
7072
} // namespace o2

Detectors/TRD/workflow/src/TRDGlobalTrackingSpec.cxx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,8 @@ void TRDGlobalTracking::run(ProcessingContext& pc)
140140

141141
for (int iTrklt = 0; iTrklt < nTracklets; ++iTrklt) {
142142
auto trklt = trackletsTRD[iTrklt];
143-
unsigned int trkltWord = 0; // DUMMY
144-
GPUTRDTrackletWord trkltLoad;
143+
GPUTRDTrackletWord trkltLoad(trklt.getTrackletWord());
145144
trkltLoad.SetId(iTrklt);
146-
trkltLoad.SetHCId(trklt.getHCID());
147-
trkltLoad.SetTrackletWord(trkltWord);
148145
if (mTracker->LoadTracklet(trkltLoad) > 0) {
149146
LOG(WARNING) << "Could not load tracklet " << iTrklt;
150147
}

GPU/GPUTracking/Base/opencl-common/GPUReconstructionOCL.cl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define nullptr NULL
5757
#define NULL (0x0)
5858
#endif
59+
#define uint64_t unsigned long
5960
#define uint32_t unsigned int
6061
#define uint16_t unsigned short
6162
#define uint8_t unsigned char

GPU/GPUTracking/TRDTracking/GPUTRDTrackletWord.cxx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@
1313

1414
#include "GPUTRDTrackletWord.h"
1515
using namespace GPUCA_NAMESPACE::gpu;
16+
17+
#ifndef GPUCA_TPC_GEOMETRY_O2
18+
19+
#include "AliTRDtrackletWord.h"
20+
#include "AliTRDtrackletMCM.h"
21+
1622
#ifndef GPUCA_GPUCODE_DEVICE
1723
#include <new>
1824
#endif
1925

2026
GPUd() GPUTRDTrackletWord::GPUTRDTrackletWord(unsigned int trackletWord) : mId(-1), mHCId(-1), mTrackletWord(trackletWord)
2127
{
2228
}
23-
2429
GPUd() GPUTRDTrackletWord::GPUTRDTrackletWord(unsigned int trackletWord, int hcid, int id) : mId(id), mHCId(hcid), mTrackletWord(trackletWord) {}
2530

2631
#ifndef GPUCA_GPUCODE_DEVICE
27-
#ifdef GPUCA_ALIROOT_LIB
28-
#include "AliTRDtrackletWord.h"
29-
#include "AliTRDtrackletMCM.h"
30-
3132
GPUTRDTrackletWord::GPUTRDTrackletWord(const AliTRDtrackletWord& rhs) : mId(-1), mHCId(rhs.GetHCId()), mTrackletWord(rhs.GetTrackletWord())
3233
{
3334
}
34-
3535
GPUTRDTrackletWord::GPUTRDTrackletWord(const AliTRDtrackletMCM& rhs) : mId(-1), mHCId(rhs.GetHCId()), mTrackletWord(rhs.GetTrackletWord()) {}
3636

3737
GPUTRDTrackletWord& GPUTRDTrackletWord::operator=(const AliTRDtrackletMCM& rhs)
@@ -41,7 +41,6 @@ GPUTRDTrackletWord& GPUTRDTrackletWord::operator=(const AliTRDtrackletMCM& rhs)
4141
return *this;
4242
}
4343

44-
#endif // GPUCA_ALIROOT_LIB
4544
#endif // GPUCA_GPUCODE_DEVICE
4645

4746
GPUd() int GPUTRDTrackletWord::GetYbin() const
@@ -63,3 +62,5 @@ GPUd() int GPUTRDTrackletWord::GetdY() const
6362
return ((mTrackletWord >> 13) & 0x7f);
6463
}
6564
}
65+
66+
#endif // !GPUCA_TPC_GEOMETRY_O2

GPU/GPUTracking/TRDTracking/GPUTRDTrackletWord.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
#include "GPUDef.h"
2020

21+
#ifndef GPUCA_TPC_GEOMETRY_O2 // compatibility to Run 2 data types
22+
2123
class AliTRDtrackletWord;
2224
class AliTRDtrackletMCM;
2325

@@ -75,4 +77,43 @@ class GPUTRDTrackletWord
7577
} // namespace gpu
7678
} // namespace GPUCA_NAMESPACE
7779

80+
#else // compatibility with Run 3 data types
81+
82+
#include "DataFormatsTRD/Tracklet64.h"
83+
84+
namespace GPUCA_NAMESPACE
85+
{
86+
namespace gpu
87+
{
88+
89+
class GPUTRDTrackletWord : private o2::trd::Tracklet64
90+
{
91+
public:
92+
GPUd() GPUTRDTrackletWord(uint64_t trackletWord = 0) : o2::trd::Tracklet64(trackletWord){};
93+
GPUdDefault() GPUTRDTrackletWord(const GPUTRDTrackletWord& rhs) CON_DEFAULT;
94+
GPUdDefault() GPUTRDTrackletWord& operator=(const GPUTRDTrackletWord& rhs) CON_DEFAULT;
95+
GPUdDefault() ~GPUTRDTrackletWord() CON_DEFAULT;
96+
97+
// ----- Override operators < and > to enable tracklet sorting by HCId -----
98+
GPUd() bool operator<(const GPUTRDTrackletWord& t) const { return (getHCID() < t.getHCID()); }
99+
GPUd() bool operator>(const GPUTRDTrackletWord& t) const { return (getHCID() > t.getHCID()); }
100+
GPUd() bool operator<=(const GPUTRDTrackletWord& t) const { return (getHCID() < t.getHCID()) || (getHCID() == t.getHCID()); }
101+
102+
GPUd() int GetZbin() const { return getPadRow(); }
103+
GPUd() float GetY() const { return getUncalibratedY(); }
104+
GPUd() float GetdY() const { return getUncalibratedDy(); }
105+
GPUd() int GetDetector() const { return getDetector(); }
106+
GPUd() int GetId() const { return mId; }
107+
108+
GPUd() void SetId(int id) { mId = id; }
109+
110+
protected:
111+
int mId; // index in tracklet input block
112+
};
113+
114+
} // namespace gpu
115+
} // namespace GPUCA_NAMESPACE
116+
117+
#endif // GPUCA_TPC_GEOMETRY_O2
118+
78119
#endif // GPUTRDTRACKLETWORD_H

0 commit comments

Comments
 (0)