1515#ifndef ALICEO2_RANGEREFERENCE_H
1616#define ALICEO2_RANGEREFERENCE_H
1717
18- #include < Rtypes.h >
18+ #include " GPUCommonRtypes.h "
1919
2020namespace o2
2121{
@@ -41,13 +41,57 @@ class RangeReference
4141 void setFirstEntry (FirstEntry ent) { mFirstEntry = ent; }
4242 void setEntries (NElem n) { mEntries = n; }
4343 void changeEntriesBy (NElem inc) { mEntries += inc; }
44+ bool operator ==(const RangeReference& other) const
45+ {
46+ return mFirstEntry == other.mFirstEntry && mEntries == other.mEntries ;
47+ }
4448
4549 private:
4650 FirstEntry mFirstEntry ; // /< 1st entry of the group
4751 NElem mEntries = 0 ; // /< number of entries
4852
4953 ClassDefNV (RangeReference, 1 );
5054};
55+
56+ // Compact (32bit long) range reference
57+ template <int NBitsN>
58+ class RangeRefComp
59+ {
60+ using Base = std::uint32_t ;
61+
62+ private:
63+ static constexpr int NBitsTotal = sizeof (Base) * 8 ;
64+ static constexpr Base MaskN = ((0x1 << NBitsN) - 1 );
65+ static constexpr Base MaskR = (~Base (0 )) & (~MaskN);
66+ Base mData = 0 ; // /< packed 1st entry reference + N entries
67+ void sanityCheck ()
68+ {
69+ static_assert (NBitsN < NBitsTotal, " NBitsN too large" );
70+ }
71+
72+ public:
73+ RangeRefComp (int ent, int n) { set (ent, n); }
74+ RangeRefComp () = default ;
75+ RangeRefComp (const RangeRefComp& src) = default ;
76+ void set (int ent, int n)
77+ {
78+ mData = (Base (ent) << NBitsN) + (Base (n) & MaskN);
79+ }
80+ static constexpr Base getMaxFirstEntry () { return MaskR >> NBitsN; }
81+ static constexpr Base getMaxEntries () { return MaskN; }
82+ int getFirstEntry () const { return mData >> NBitsN; }
83+ int getEntries () const { return mData & ((0x1 << NBitsN) - 1 ); }
84+ void setFirstEntry (int ent) { mData = (Base (ent) << NBitsN) | (mData & MaskN); }
85+ void setEntries (int n) { mData = (mData & MaskR) | (Base (n) & MaskN); }
86+ void changeEntriesBy (int inc) { setEntries (getEntries () + inc); }
87+ bool operator ==(const RangeRefComp& other) const
88+ {
89+ return mData == other.mData ;
90+ }
91+
92+ ClassDefNV (RangeRefComp, 1 );
93+ };
94+
5195} // namespace dataformats
5296} // namespace o2
5397
0 commit comments