Project
Loading...
Searching...
No Matches
FECInfo.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
12#ifndef AliceO2_TPC_FECInfo_H
13#define AliceO2_TPC_FECInfo_H
14
15#include <iosfwd>
16
17namespace o2
18{
19namespace tpc
20{
21
23{
24 public:
25 static constexpr int ChannelsPerSAMPA = 32;
26 static constexpr int SAMPAsPerFEC = 5;
28 static constexpr int FECsPerSector = 91;
29 static constexpr int FECsTotal = FECsPerSector * 36;
30
31 FECInfo() = default;
32 FECInfo(unsigned char index,
33 // unsigned char connector,
34 // unsigned char channel,
35 unsigned char sampaChip,
36 unsigned char sampaChannel)
37 : mIndex(index), /*mConnector(connector), mChannel(channel),*/ mSampaChip(sampaChip), mSampaChannel(sampaChannel)
38 {
39 }
40
41 unsigned char getIndex() const { return mIndex; }
42 // const unsigned char getConnector() const { return mConnector; } // -> can be calculated from mSampaChannel and mSampaChip
43 unsigned char getFECChannel() const { return mSampaChip * ChannelsPerSAMPA + mSampaChannel; } // -> can be calculated from mSampaChannel and mSampaChip
44 unsigned char getSampaChip() const { return mSampaChip; }
45 unsigned char getSampaChannel() const { return mSampaChannel; }
46
48 bool operator==(const FECInfo& other) const
49 {
50 return mIndex == other.mIndex &&
51 (mSampaChip == other.mSampaChip && mSampaChannel == other.mSampaChannel);
52 //( (mConnector==other.mConnector && mChannel==other.mChannel)
53 //|| (mSampaChip==other.mSampaChip && mSampaChannel==other.mSampaChannel) );
54 }
55
56 static constexpr int globalSAMPAId(const int fecInSector, const int sampaOnFEC, const int channelOnSAMPA)
57 {
58 // channelOnSAMPA 0-31, 5 bits
59 // sampaOnFEC 0- 4, 3 bits
60 // fecInSector 0-90, 7 bits
61 return (fecInSector << 8) + (sampaOnFEC << 5) + channelOnSAMPA;
62 }
63
64 static constexpr int fecInSector(const int globalSAMPAId) { return globalSAMPAId >> 8; }
65 static constexpr int sampaOnFEC(const int globalSAMPAId) { return (globalSAMPAId >> 5) & 7; }
66 static constexpr int channelOnSAMPA(const int globalSAMPAId) { return globalSAMPAId & 31; }
67
69 static constexpr int sampaFromFECChannel(const int fecChannel) { return fecChannel / ChannelsPerSAMPA; }
70
72 static constexpr int channelFromFECChannel(const int fecChannel) { return fecChannel % ChannelsPerSAMPA; }
73
74 static void sampaInfo(const int globalSAMPAId, int& fecInSector, int& sampaOnFEC, int& channelOnSAMPA)
75 {
77 sampaOnFEC = (globalSAMPAId >> 5) & 7;
79 }
80
82 bool operator<(const FECInfo& other) const
83 {
84 if (mIndex < other.mIndex) {
85 return true;
86 }
87 if (mSampaChip < other.mSampaChip) {
88 return true;
89 }
90 if (mSampaChip == other.mSampaChip && mSampaChannel < other.mSampaChannel) {
91 return true;
92 }
93 return false;
94 }
95
96 private:
97 std::ostream& print(std::ostream& out) const;
98 friend std::ostream& operator<<(std::ostream& out, const FECInfo& fec);
99 unsigned char mIndex{0};
100 unsigned char mSampaChip{0};
101 unsigned char mSampaChannel{0};
102
103 // unsigned char mConnector {0}; ///< Connector on the FEC -> Can be deduced from mSampaChip and mSampaChannel
104 // unsigned char mChannel {0}; ///< Channel on the FEC -> Can be deduced from mSampaChip and mSampaChannel
105};
106
107} // namespace tpc
108} // namespace o2
109
110#endif
void print() const
static constexpr int FECsTotal
Definition FECInfo.h:29
static constexpr int ChannelsPerSAMPA
Definition FECInfo.h:25
static constexpr int channelFromFECChannel(const int fecChannel)
calculate the sampa channel number from the channel number on the FEC (0-159)
Definition FECInfo.h:72
static constexpr int FECsPerSector
Definition FECInfo.h:28
static constexpr int channelOnSAMPA(const int globalSAMPAId)
Definition FECInfo.h:66
static constexpr int SAMPAsPerFEC
Definition FECInfo.h:26
FECInfo(unsigned char index, unsigned char sampaChip, unsigned char sampaChannel)
Definition FECInfo.h:32
static constexpr int ChannelsPerFEC
Definition FECInfo.h:27
static void sampaInfo(const int globalSAMPAId, int &fecInSector, int &sampaOnFEC, int &channelOnSAMPA)
Definition FECInfo.h:74
static constexpr int sampaFromFECChannel(const int fecChannel)
calculate the sampa number from the channel number on the FEC (0-159)
Definition FECInfo.h:69
unsigned char getSampaChannel() const
Definition FECInfo.h:45
bool operator<(const FECInfo &other) const
smaller operator
Definition FECInfo.h:82
static constexpr int sampaOnFEC(const int globalSAMPAId)
Definition FECInfo.h:65
unsigned char getIndex() const
Definition FECInfo.h:41
unsigned char getFECChannel() const
Definition FECInfo.h:43
bool operator==(const FECInfo &other) const
equal operator
Definition FECInfo.h:48
static constexpr int fecInSector(const int globalSAMPAId)
Definition FECInfo.h:64
unsigned char getSampaChip() const
Definition FECInfo.h:44
friend std::ostream & operator<<(std::ostream &out, const FECInfo &fec)
Definition FECInfo.cxx:27
static constexpr int globalSAMPAId(const int fecInSector, const int sampaOnFEC, const int channelOnSAMPA)
Definition FECInfo.h:56
FECInfo()=default
GLuint index
Definition glcorearb.h:781
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
VectorOfTObjectPtrs other