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
8 {
9  constexpr inline void setField(uint32_t* u, const unsigned mask,
10  const unsigned offset, const unsigned value)
11  {*u &= ~(mask << offset); *u |= ((value & mask) << offset);}
12 
13  constexpr inline unsigned getField(const uint32_t u, const unsigned mask,
14  const unsigned offset)
15  {return (u >> offset) & mask;}
16 
17  constexpr inline void setBit(uint32_t* u, const unsigned bitnum, const bool b)
18  {if (b) {*u |= (1U << bitnum);} else {*u &= ~(1U << bitnum);}}
19 
20  constexpr inline void orBit(uint32_t* u, const unsigned bitnum, const bool b)
21  {if (b) {*u |= (1U << bitnum);}}
22 
23  constexpr inline void andBit(uint32_t* u, const unsigned bitnum, const bool b)
24  {if (!b) {*u &= ~(1U << bitnum);}}
25 
26  constexpr inline bool getBit(const uint32_t u, const unsigned bitnum)
27  {return u & (1U << bitnum);}
28 }
29 
30 #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 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:120
#define constexpr