Project
Loading...
Searching...
No Matches
DsChannelId.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 O2_DATAFORMATS_MCH_DS_CHANNEL_ID_H_
13#define O2_DATAFORMATS_MCH_DS_CHANNEL_ID_H_
14
15#include <cstdint>
16#include <string>
17#include "Rtypes.h"
18
19namespace o2::mch
20{
26{
27 public:
28 DsChannelId() = default;
29 DsChannelId(uint32_t channelId) : mChannelId(channelId) {}
30 DsChannelId(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
31 {
32 set(solarId, eLinkId, channel);
33 }
34
35 static uint32_t make(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
36 {
37 uint32_t id = (static_cast<uint32_t>(solarId) << 16) +
38 (static_cast<uint32_t>(eLinkId) << 8) + channel;
39 return id;
40 }
41
42 void set(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
43 {
44 mChannelId = DsChannelId::make(solarId, eLinkId, channel);
45 }
46
47 uint16_t getSolarId() const { return static_cast<uint16_t>((mChannelId >> 16) & 0xFFFF); }
48 uint8_t getElinkId() const { return static_cast<uint8_t>((mChannelId >> 8) & 0xFF); }
49
50 [[deprecated("use getElinkId instead which better reflects what it is and avoid confusion with dsId from DsDetId")]] uint8_t getDsId() const { return getElinkId(); }
51 uint8_t getChannel() const { return static_cast<uint8_t>(mChannelId & 0xFF); }
52
53 std::string asString() const;
54
55 uint32_t value() const { return mChannelId; }
56
57 bool isValid() const { return (mChannelId != 0); }
58
59 private:
60 uint32_t mChannelId{0};
61
62 ClassDefNV(DsChannelId, 1); // class for MCH readout channel
63};
64
65inline bool operator==(const DsChannelId& a, const DsChannelId& b) { return a.value() == b.value(); }
66inline bool operator!=(const DsChannelId& a, const DsChannelId& b) { return !(a == b); }
67inline bool operator<(const DsChannelId& a, const DsChannelId& b) { return a.value() < b.value(); }
68inline bool operator>(const DsChannelId& a, const DsChannelId& b) { return b < a; }
69inline bool operator<=(const DsChannelId& a, const DsChannelId& b) { return !(a > b); }
70inline bool operator>=(const DsChannelId& a, const DsChannelId& b) { return !(a < b); }
71
72} // namespace o2::mch
73#endif
uint8_t getDsId() const
Definition DsChannelId.h:50
std::string asString() const
DsChannelId(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
Definition DsChannelId.h:30
DsChannelId(uint32_t channelId)
Definition DsChannelId.h:29
uint8_t getElinkId() const
Definition DsChannelId.h:48
static uint32_t make(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
Definition DsChannelId.h:35
void set(uint16_t solarId, uint8_t eLinkId, uint8_t channel)
Definition DsChannelId.h:42
uint16_t getSolarId() const
Definition DsChannelId.h:47
uint8_t getChannel() const
Definition DsChannelId.h:51
bool isValid() const
Definition DsChannelId.h:57
uint32_t value() const
Definition DsChannelId.h:55
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLboolean GLboolean GLboolean GLboolean a
Definition glcorearb.h:1233
GLuint id
Definition glcorearb.h:650
bool operator==(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:65
bool operator>=(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:70
bool operator>(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:68
bool operator<(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:67
bool operator!=(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:66
bool operator<=(const DsChannelId &a, const DsChannelId &b)
Definition DsChannelId.h:69