CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHitAuxSetter.h
Go to the documentation of this file.
1 #ifndef RecoLocalCalo_HcalRecAlgos_CaloRecHitAuxSetter_h_
2 #define RecoLocalCalo_HcalRecAlgos_CaloRecHitAuxSetter_h_
3 
4 #include <cstdint>
5 
6 // Useful helpers for uint32_t fields
7 namespace CaloRecHitAuxSetter
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 bool getBit(const uint32_t u, const unsigned bitnum)
21  {return u & (1U << bitnum);}
22 }
23 
24 #endif // RecoLocalCalo_HcalRecAlgos_CaloRecHitAuxSetter_h_
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)
double b
Definition: hdecay.h:120
bool getBit(const uint32_t u, const unsigned bitnum)