-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathFECInfo.h
More file actions
110 lines (93 loc) · 4.1 KB
/
FECInfo.h
File metadata and controls
110 lines (93 loc) · 4.1 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
// 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.
#ifndef AliceO2_TPC_FECInfo_H
#define AliceO2_TPC_FECInfo_H
#include <iosfwd>
namespace o2
{
namespace tpc
{
class FECInfo
{
public:
static constexpr int ChannelsPerSAMPA = 32;
static constexpr int SAMPAsPerFEC = 5;
static constexpr int ChannelsPerFEC = ChannelsPerSAMPA * SAMPAsPerFEC;
static constexpr int FECsPerSector = 91;
static constexpr int FECsTotal = FECsPerSector * 36;
FECInfo() = default;
FECInfo(unsigned char index,
// unsigned char connector,
// unsigned char channel,
unsigned char sampaChip,
unsigned char sampaChannel)
: mIndex(index), /*mConnector(connector), mChannel(channel),*/ mSampaChip(sampaChip), mSampaChannel(sampaChannel)
{
}
unsigned char getIndex() const { return mIndex; }
// const unsigned char getConnector() const { return mConnector; } // -> can be calculated from mSampaChannel and mSampaChip
unsigned char getFECChannel() const { return mSampaChip * ChannelsPerSAMPA + mSampaChannel; } // -> can be calculated from mSampaChannel and mSampaChip
unsigned char getSampaChip() const { return mSampaChip; }
unsigned char getSampaChannel() const { return mSampaChannel; }
/// equal operator
bool operator==(const FECInfo& other) const
{
return mIndex == other.mIndex &&
(mSampaChip == other.mSampaChip && mSampaChannel == other.mSampaChannel);
//( (mConnector==other.mConnector && mChannel==other.mChannel)
//|| (mSampaChip==other.mSampaChip && mSampaChannel==other.mSampaChannel) );
}
static constexpr int globalSAMPAId(const int fecInSector, const int sampaOnFEC, const int channelOnSAMPA)
{
// channelOnSAMPA 0-31, 5 bits
// sampaOnFEC 0- 4, 3 bits
// fecInSector 0-90, 7 bits
return (fecInSector << 8) + (sampaOnFEC << 5) + channelOnSAMPA;
}
static constexpr int fecInSector(const int globalSAMPAId) { return globalSAMPAId >> 8; }
static constexpr int sampaOnFEC(const int globalSAMPAId) { return (globalSAMPAId >> 5) & 7; }
static constexpr int channelOnSAMPA(const int globalSAMPAId) { return globalSAMPAId & 31; }
/// calculate the sampa number from the channel number on the FEC (0-159)
static constexpr int sampaFromFECChannel(const int fecChannel) { return fecChannel / ChannelsPerSAMPA; }
/// calculate the sampa channel number from the channel number on the FEC (0-159)
static constexpr int channelFromFECChannel(const int fecChannel) { return fecChannel % ChannelsPerSAMPA; }
static void sampaInfo(const int globalSAMPAId, int& fecInSector, int& sampaOnFEC, int& channelOnSAMPA)
{
fecInSector = (globalSAMPAId >> 8);
sampaOnFEC = (globalSAMPAId >> 5) & 7;
channelOnSAMPA = (globalSAMPAId & 31);
}
/// smaller operator
bool operator<(const FECInfo& other) const
{
if (mIndex < other.mIndex) {
return true;
}
if (mSampaChip < other.mSampaChip) {
return true;
}
if (mSampaChip == other.mSampaChip && mSampaChannel < other.mSampaChannel) {
return true;
}
return false;
}
private:
std::ostream& print(std::ostream& out) const;
friend std::ostream& operator<<(std::ostream& out, const FECInfo& fec);
unsigned char mIndex{0}; ///< FEC number in the sector
unsigned char mSampaChip{0}; ///< SAMPA chip on the FEC
unsigned char mSampaChannel{0}; ///< Cannel on the SAMPA chip
// unsigned char mConnector {0}; ///< Connector on the FEC -> Can be deduced from mSampaChip and mSampaChannel
// unsigned char mChannel {0}; ///< Channel on the FEC -> Can be deduced from mSampaChip and mSampaChannel
};
} // namespace tpc
} // namespace o2
#endif