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_
CaloRecHitAuxSetter::setField
constexpr void setField(uint32_t *u, const unsigned mask, const unsigned offset, const unsigned value)
Definition: CaloRecHitAuxSetter.h:8
CaloRecHitAuxSetter::setBit
constexpr void setBit(uint32_t *u, const unsigned bitnum, const bool b)
Definition: CaloRecHitAuxSetter.h:17
CaloRecHitAuxSetter::orBit
constexpr void orBit(uint32_t *u, const unsigned bitnum, const bool b)
Definition: CaloRecHitAuxSetter.h:25
CaloRecHitAuxSetter::andBit
constexpr void andBit(uint32_t *u, const unsigned bitnum, const bool b)
Definition: CaloRecHitAuxSetter.h:31
b
double b
Definition: hdecay.h:118
CaloRecHitAuxSetter::getField
constexpr unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset)
Definition: CaloRecHitAuxSetter.h:13
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
value
Definition: value.py:1
CaloRecHitAuxSetter::getBit
constexpr bool getBit(const uint32_t u, const unsigned bitnum)
Definition: CaloRecHitAuxSetter.h:37
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
CaloRecHitAuxSetter
Definition: CaloRecHitAuxSetter.h:7