forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompCluster.h
More file actions
131 lines (108 loc) · 3.87 KB
/
CompCluster.h
File metadata and controls
131 lines (108 loc) · 3.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
/// \file CompCluster.h
/// \brief Definition of the ITSMFT compact cluster
#ifndef ALICEO2_ITSMFT_COMPCLUSTER_H
#define ALICEO2_ITSMFT_COMPCLUSTER_H
#include <Rtypes.h>
#include <iosfwd>
namespace o2
{
namespace itsmft
{
/// This is a version of the ALPIDE cluster represented by the pattern ID and the address of the
/// top-left (min row,col) pixel of the topololy bounding box
class CompCluster
{
public:
static constexpr int NBitsRow = 9; // number of bits for the row
static constexpr int NBitsCol = 10; // number of bits for the column
static constexpr int NBitsPattID = 11; // number of bits for the pattern ID
private:
static constexpr UInt_t RowMask = (0x1 << NBitsRow) - 1;
static constexpr UInt_t ColMask = (0x1 << NBitsCol) - 1;
static constexpr UInt_t PattIDMask = (0x1 << NBitsPattID) - 1;
static constexpr UInt_t FlagBit = 0x1 << (NBitsRow + NBitsCol + NBitsPattID);
//
///< compactified data: bits [0:8] - row, [9-18] - col, [19-30] - pattern ID, bit 31 - special flag
UInt_t mData;
void sanityCheck();
public:
static constexpr unsigned short InvalidPatternID = (0x1 << NBitsPattID) - 1; // All 11 bits of pattern ID are 1
CompCluster(UShort_t row = 0, UShort_t col = 0, UShort_t patt = 0)
{
set(row, col, patt);
}
void set(UShort_t row, UShort_t col, UShort_t patt)
{
mData = (row & RowMask) | ((col & ColMask) << NBitsRow) | ((patt & PattIDMask) << (NBitsRow + NBitsCol));
}
UShort_t getRow() const { return mData & RowMask; }
UShort_t getCol() const { return (mData >> NBitsRow) & ColMask; }
UShort_t getPatternID() const { return (mData >> (NBitsRow + NBitsCol)) & PattIDMask; }
bool getFlag() const { return (mData & FlagBit) == FlagBit; }
void setRow(UShort_t r)
{
mData &= ~RowMask;
mData |= (r & RowMask);
}
void setCol(UShort_t c)
{
mData &= ~(ColMask << NBitsRow);
mData |= (c & ColMask) << NBitsRow;
};
void setPatternID(UShort_t p)
{
mData &= ~(PattIDMask << (NBitsRow + NBitsCol));
mData |= (p & PattIDMask) << (NBitsRow + NBitsCol);
}
void setFlag(bool v)
{
mData &= ~FlagBit;
if (v) {
mData |= FlagBit;
}
}
bool operator==(const CompCluster& cl) const
{
return mData == cl.mData;
}
void print() const;
std::string asString() const;
ClassDefNV(CompCluster, 2);
};
/// Extension of the compact cluster, augmented by the chipID
/// This is a TEMPORARY class, until we converge to more economical container
class CompClusterExt : public CompCluster
{
private:
UShort_t mChipID; ///< chip id
public:
CompClusterExt(UShort_t row = 0, UShort_t col = 0, UShort_t patt = 0, UShort_t chipID = 0) : CompCluster(row, col, patt), mChipID(chipID)
{
}
void set(UShort_t row, UShort_t col, UShort_t patt, UShort_t chipID)
{
CompCluster::set(row, col, patt);
mChipID = chipID;
}
UShort_t getChipID() const { return mChipID; }
UShort_t getSensorID() const { return mChipID; } // to have the same signature as BaseCluster
void setChipID(UShort_t c) { mChipID = c; }
void print() const;
std::string asString() const;
ClassDefNV(CompClusterExt, 1);
};
} // namespace itsmft
} // namespace o2
std::ostream& operator<<(std::ostream& stream, const o2::itsmft::CompCluster& cl);
std::ostream& operator<<(std::ostream& stream, const o2::itsmft::CompClusterExt& cl);
#endif /* ALICEO2_ITSMFT_COMPACTCLUSTER_H */