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  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  inline unsigned getField(const uint32_t u, const unsigned mask,
14  const unsigned offset)
15  {return (u >> offset) & mask;}
16 
17  inline void setBit(uint32_t* u, const unsigned bitnum, const bool b)
18  {if (b) {*u |= (1U << bitnum);} else {*u &= ~(1U << bitnum);}}
19 
20  inline void orBit(uint32_t* u, const unsigned bitnum, const bool b)
21  {if (b) {*u |= (1U << bitnum);}}
22 
23  inline void andBit(uint32_t* u, const unsigned bitnum, const bool b)
24  {if (!b) {*u &= ~(1U << bitnum);}}
25 
26  inline bool getBit(const uint32_t u, const unsigned bitnum)
27  {return u & (1U << bitnum);}
28 }
29 
30 #endif // DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
void orBit(uint32_t *u, const unsigned bitnum, const bool b)
unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
void setBit(uint32_t *u, const unsigned bitnum, const bool b)
void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
Definition: value.py:1
void andBit(uint32_t *u, const unsigned bitnum, const bool b)
double b
Definition: hdecay.h:120
bool getBit(const uint32_t u, const unsigned bitnum)