CMS 3D CMS Logo

CaloRecHit.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_CALORECHIT_CALORECHIT_H
2 #define DATAFORMATS_CALORECHIT_CALORECHIT_H 1
3 
5 #include <ostream>
6 
7 #ifdef __CUDA_ARCH__
8 __constant__
9 #else
11 #endif
12  uint32_t calo_rechit_masks[] = {0x00000000u, 0x00000001u, 0x00000003u, 0x00000007u, 0x0000000fu, 0x0000001fu,
13  0x0000003fu, 0x0000007fu, 0x000000ffu, 0x000001ffu, 0x000003ffu, 0x000007ffu,
14  0x00000fffu, 0x00001fffu, 0x00003fffu, 0x00007fffu, 0x0000ffffu, 0x0001ffffu,
15  0x0003ffffu, 0x0007ffffu, 0x000fffffu, 0x001fffffu, 0x003fffffu, 0x007fffffu,
16  0x00ffffffu, 0x01ffffffu, 0x03ffffffu, 0x07ffffffu, 0x0fffffffu, 0x1fffffffu,
17  0x3fffffffu, 0x7fffffffu, 0xffffffffu};
18 
23 class CaloRecHit {
24 public:
25  constexpr CaloRecHit() : energy_(0), time_(0), flags_(0), aux_(0) {}
26  constexpr explicit CaloRecHit(const DetId& id, float energy, float time, uint32_t flags = 0, uint32_t aux = 0)
28 
29  constexpr float energy() const { return energy_; }
31  constexpr float time() const { return time_; }
32  constexpr void setTime(float time) { time_ = time; }
33  constexpr const DetId& detid() const { return id_; }
34  constexpr uint32_t flags() const { return flags_; }
35  constexpr void setFlags(uint32_t flags) { flags_ = flags; }
36  constexpr void setFlagField(uint32_t value, int base, int width = 1) {
38  value <<= std::max(std::min(base, 31), 0);
39  // clear out the relevant bits
40  uint32_t clear = calo_rechit_masks[std::max(std::min(width, 32), 0)];
41  clear = clear << std::max(std::min(base, 31), 0);
42  clear ^= 0xFFFFFFFFu;
43  flags_ &= clear;
44  flags_ |= value;
45  }
46  constexpr uint32_t flagField(int base, int width = 1) const {
47  return (flags_ >> std::max(std::min(base, 31), 0)) & calo_rechit_masks[std::max(std::min(width, 32), 0)];
48  }
49  constexpr void setAux(uint32_t value) { aux_ = value; }
50  constexpr uint32_t aux() const { return aux_; }
51 
52 private:
54  float energy_;
55  float time_;
56  uint32_t flags_;
57  uint32_t aux_;
58 };
59 
60 std::ostream& operator<<(std::ostream& s, const CaloRecHit& hit);
61 
62 #endif
constexpr CaloRecHit()
Definition: CaloRecHit.h:25
constexpr const DetId & detid() const
Definition: CaloRecHit.h:33
constexpr void setTime(float time)
Definition: CaloRecHit.h:32
base
Main Program
Definition: newFWLiteAna.py:92
constexpr CaloRecHit(const DetId &id, float energy, float time, uint32_t flags=0, uint32_t aux=0)
Definition: CaloRecHit.h:26
constexpr uint32_t calo_rechit_masks[]
Definition: CaloRecHit.h:12
uint32_t aux_
Definition: CaloRecHit.h:57
constexpr void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.h:36
constexpr float energy() const
Definition: CaloRecHit.h:29
float energy_
Definition: CaloRecHit.h:54
constexpr uint32_t flags() const
Definition: CaloRecHit.h:34
constexpr uint32_t aux() const
Definition: CaloRecHit.h:50
Definition: value.py:1
Definition: DetId.h:17
uint32_t flags_
Definition: CaloRecHit.h:56
std::ostream & operator<<(std::ostream &s, const CaloRecHit &hit)
Definition: CaloRecHit.cc:3
constexpr float time() const
Definition: CaloRecHit.h:31
float time_
Definition: CaloRecHit.h:55
constexpr void setFlags(uint32_t flags)
Definition: CaloRecHit.h:35
constexpr uint32_t flagField(int base, int width=1) const
Definition: CaloRecHit.h:46
constexpr void setAux(uint32_t value)
Definition: CaloRecHit.h:49
void clear(EGIsoObj &c)
Definition: egamma.h:82
constexpr void setEnergy(float energy)
Definition: CaloRecHit.h:30
DetId id_
Definition: CaloRecHit.h:53