CMS 3D CMS Logo

DTCELinkId.h
Go to the documentation of this file.
1 #ifndef CondFormats_Phase2TrackerDTC_DTCELinkId_h
2 #define CondFormats_Phase2TrackerDTC_DTCELinkId_h
3 
4 // -*- C++ -*-
5 //
6 // Package: CondFormats/Phase2TrackerDTC
7 // Class: DTCELinkId
8 //
16 //
17 // Original Author: Luigi Calligaris, SPRACE, Sao Paulo, BR
18 // Created : Wed, 27 Feb 2019 21:41:13 GMT
19 //
20 //
21 
22 #include <cstdint>
23 #include <limits>
24 
26 
28 {
29 public:
36 
37  // Constructs a DTCELinkId addressed by (dtc_id, gbtlink_id, elink_id)
38  DTCELinkId(uint16_t,uint8_t,uint8_t) noexcept;
39 
40  inline auto elink_id() const noexcept {return elink_id_ ;}
41  inline auto gbtlink_id() const noexcept {return gbtlink_id_;}
42  inline auto dtc_id() const noexcept {return dtc_id_ ;}
43 
44 private:
45  // In order to keep the payload small, we use the C standard integers, optimizing them for size.
46  // The lpGBT has at most 7 ePorts, therefore they can be addressed by an 8-bit number.
47  // The DTC should host at most 72 GBT links, therefore an 8-bit number should be enough to address it.
48  // The C++ memory alignment and padding rules impose that this class will have at least 32 bits size,
49  // i.e. 8+8+8 bits and 8+8+16 would be the same, so we choose the latter.
50  uint8_t elink_id_ ;
51  uint8_t gbtlink_id_;
52  uint16_t dtc_id_ ;
53 
55 };
56 
57 namespace std
58 {
59  template <>
60  struct hash<DTCELinkId>
61  {
62  size_t operator()(const DTCELinkId& k) const noexcept
63  {
64  // With
65  constexpr const size_t shift_gbtlink_id = numeric_limits< decltype( k.elink_id() ) >::max() + 1u;
66  constexpr const size_t shift_dtc_id = (numeric_limits< decltype( k.gbtlink_id() ) >::max() + 1u) * shift_gbtlink_id;
67 
68  return k.elink_id() + k.gbtlink_id() * shift_gbtlink_id + k.dtc_id() * shift_dtc_id;
69  }
70  };
71 }
72 
73 inline bool operator< (DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() < rhs.dtc_id() || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() < rhs.gbtlink_id()) || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() < rhs.elink_id());}
74 inline bool operator> (DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() > rhs.dtc_id() || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() > rhs.gbtlink_id()) || (lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() > rhs.elink_id());}
75 inline bool operator==(DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() == rhs.dtc_id() && lhs.gbtlink_id() == rhs.gbtlink_id() && lhs.elink_id() == rhs.elink_id();}
76 inline bool operator!=(DTCELinkId const& lhs, DTCELinkId const& rhs) {return lhs.dtc_id() != rhs.dtc_id() || lhs.gbtlink_id() != rhs.gbtlink_id() || lhs.elink_id() != rhs.elink_id();}
77 
78 
79 #endif // end DataFormats_Phase2TrackerDTC_DTCELinkId_h
auto gbtlink_id() const noexcept
Definition: DTCELinkId.h:41
bool operator==(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:75
bool operator>(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:74
size_t operator()(const DTCELinkId &k) const noexcept
Definition: DTCELinkId.h:62
~DTCELinkId() noexcept
Definition: DTCELinkId.cc:43
DTCELinkId & operator=(DTCELinkId const &) noexcept
Definition: DTCELinkId.cc:25
auto dtc_id() const noexcept
Definition: DTCELinkId.h:42
uint8_t elink_id_
Definition: DTCELinkId.h:50
uint16_t dtc_id_
Definition: DTCELinkId.h:52
int k[5][pyjets_maxn]
#define noexcept
bool operator!=(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:76
uint8_t gbtlink_id_
Definition: DTCELinkId.h:51
#define COND_SERIALIZABLE
Definition: Serializable.h:38
bool operator<(DTCELinkId const &lhs, DTCELinkId const &rhs)
Definition: DTCELinkId.h:73
DTCELinkId() noexcept
Definition: DTCELinkId.cc:7
auto elink_id() const noexcept
Definition: DTCELinkId.h:40
#define constexpr