File indexing completed on 2021-02-14 12:53:38
0001 #ifndef DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
0002 #define DataFormats_HcalRecHit_CaloRecHitAuxSetter_h_
0003
0004 #include <cstdint>
0005
0006
0007 namespace CaloRecHitAuxSetter {
0008 constexpr inline void setField(uint32_t* u, const unsigned mask, const unsigned offset, const unsigned value) {
0009 *u &= ~(mask << offset);
0010 *u |= ((value & mask) << offset);
0011 }
0012
0013 constexpr inline unsigned getField(const uint32_t u, const unsigned mask, const unsigned offset) {
0014 return (u >> offset) & mask;
0015 }
0016
0017 constexpr inline void setBit(uint32_t* u, const unsigned bitnum, const bool b) {
0018 if (b) {
0019 *u |= (1U << bitnum);
0020 } else {
0021 *u &= ~(1U << bitnum);
0022 }
0023 }
0024
0025 constexpr inline void orBit(uint32_t* u, const unsigned bitnum, const bool b) {
0026 if (b) {
0027 *u |= (1U << bitnum);
0028 }
0029 }
0030
0031 constexpr inline void andBit(uint32_t* u, const unsigned bitnum, const bool b) {
0032 if (!b) {
0033 *u &= ~(1U << bitnum);
0034 }
0035 }
0036
0037 constexpr inline bool getBit(const uint32_t u, const unsigned bitnum) { return u & (1U << bitnum); }
0038 }
0039
0040 #endif