Project
Loading...
Searching...
No Matches
FeeLinkId.cxx
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
13#include <fmt/format.h>
14#include <iostream>
15
16namespace o2::mch::raw
17{
18FeeLinkId::FeeLinkId(uint16_t feeId, uint8_t linkId) : mFeeId{feeId},
19 mLinkId{linkId}
20{
21 if (mLinkId < 0 || (mLinkId > 11 && mLinkId != 15)) {
22 throw std::invalid_argument(fmt::format("LinkId should be between 0 and 11 or = 15 but is {}", linkId));
23 }
24}
25uint32_t encode(const FeeLinkId& id)
26{
27 return (id.feeId() << 16) | id.linkId();
28}
29
31{
32 uint16_t feeId = static_cast<uint16_t>((x & 0xFFFF0000) >> 16);
33 uint8_t linkId = static_cast<uint8_t>(x & 0xF);
34 return FeeLinkId(feeId, linkId);
35}
36
37std::ostream& operator<<(std::ostream& os, const FeeLinkId& id)
38{
39 os << fmt::format("FeeLinkId(FEE={:4d},LINK={:1d}) CODE={:8d}", id.feeId(), id.linkId(), encode(id));
40 return os;
41}
42
43std::string asString(const FeeLinkId& feeLinkId)
44{
45 return fmt::format("FEE{}-LINK{}", feeLinkId.feeId(), feeLinkId.linkId());
46}
47
48bool operator<(const FeeLinkId& f1, const FeeLinkId& f2)
49{
50 return encode(f1) < encode(f2);
51}
52} // namespace o2::mch::raw
uint8_t linkId() const
Definition FeeLinkId.h:27
FeeLinkId(uint16_t feeId, uint8_t linkId)
Definition FeeLinkId.cxx:18
uint16_t feeId() const
Definition FeeLinkId.h:26
GLint GLenum GLint x
Definition glcorearb.h:403
FeeLinkId decodeFeeLinkId(uint32_t code)
Definition FeeLinkId.cxx:30
std::string asString(const SampaCluster &sc)
uint32_t encode(const DsDetId &id)
Create an integer code for the given id.
Definition DsDetId.cxx:28
bool operator<(const observer_ptr< W1 > &p1, const observer_ptr< W2 > &p2)
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)