CMS 3D CMS Logo

CaloRecHitAuxSetter.h
Go to the documentation of this file.
1 #ifndef DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
2 #define DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
3 
4 #include <cstdint>
5 
6 // Useful helpers for uint32_t fields
7 namespace CaloRecHitAuxSetter {
8  constexpr inline void setField(uint32_t* u, const unsigned mask, const unsigned offset, const unsigned value) {
9  *u &= ~(mask << offset);
10  *u |= ((value & mask) << offset);
11  }
12 
13  constexpr inline unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset) {
14  return (u >> offset) & mask;
15  }
16 
17  constexpr inline void setBit(uint32_t* u, const unsigned bitnum, const bool b) {
18  if (b) {
19  *u |= (1U << bitnum);
20  } else {
21  *u &= ~(1U << bitnum);
22  }
23  }
24 
25  constexpr inline void orBit(uint32_t* u, const unsigned bitnum, const bool b) {
26  if (b) {
27  *u |= (1U << bitnum);
28  }
29  }
30 
31  constexpr inline void andBit(uint32_t* u, const unsigned bitnum, const bool b) {
32  if (!b) {
33  *u &= ~(1U << bitnum);
34  }
35  }
36 
37  constexpr inline bool getBit(const uint32_t u, const unsigned bitnum) { return u & (1U << bitnum); }
38 } // namespace CaloRecHitAuxSetter
39 
40 #endif // DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
constexpr void setBit(uint32_t *u, const unsigned bitnum, const bool b)
constexpr void orBit(uint32_t *u, const unsigned bitnum, const bool b)
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
constexpr void andBit(uint32_t *u, const unsigned bitnum, const bool b)
constexpr uint32_t mask
Definition: gpuClustering.h:24
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
Definition: value.py:1
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
double b
Definition: hdecay.h:118