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
10  constexpr
11 #endif
12  uint32_t calo_rechit_masks[] = {
13  0x00000000u,0x00000001u,0x00000003u,0x00000007u,0x0000000fu,0x0000001fu,
14  0x0000003fu,0x0000007fu,0x000000ffu,0x000001ffu,0x000003ffu,0x000007ffu,
15  0x00000fffu,0x00001fffu,0x00003fffu,0x00007fffu,0x0000ffffu,0x0001ffffu,
16  0x0003ffffu,0x0007ffffu,0x000fffffu,0x001fffffu,0x003fffffu,0x007fffffu,
17  0x00ffffffu,0x01ffffffu,0x03ffffffu,0x07ffffffu,0x0fffffffu,0x1fffffffu,
18  0x3fffffffu,0x7fffffffu,0xffffffffu};
19 
24 class CaloRecHit {
25 public:
26  constexpr CaloRecHit() : energy_(0), time_(0), flags_(0), aux_(0) {}
27  constexpr explicit CaloRecHit(const DetId& id, float energy, float time,
28  uint32_t flags = 0, uint32_t aux=0)
29  : id_(id),energy_(energy), time_(time), flags_(flags), aux_(aux) {}
30 
31  constexpr float energy() const { return energy_; }
33  constexpr float time() const { return time_; }
34  constexpr void setTime(float time) { time_=time; }
35  constexpr const DetId& detid() const { return id_; }
36  constexpr uint32_t flags() const { return flags_; }
37  constexpr void setFlags(uint32_t flags) { flags_=flags; }
38  constexpr void setFlagField(uint32_t value, int base, int width=1) {
40  value<<=std::max(std::min(base,31),0);
41  // clear out the relevant bits
43  clear=clear<<std::max(std::min(base,31),0);
44  clear^=0xFFFFFFFFu;
45  flags_&=clear;
46  flags_|=value;
47  }
48  constexpr uint32_t flagField(int base, int width=1) const {
49  return (flags_>>std::max(std::min(base,31),0))&calo_rechit_masks[std::max(std::min(width,32),0)];
50  }
51  constexpr void setAux(uint32_t value) { aux_=value; }
52  constexpr uint32_t aux() const { return aux_; }
53 private:
55  float energy_;
56  float time_;
57  uint32_t flags_;
58  uint32_t aux_;
59 };
60 
61 std::ostream& operator<<(std::ostream& s, const CaloRecHit& hit);
62 
63 #endif
constexpr float energy() const
Definition: CaloRecHit.h:31
constexpr CaloRecHit()
Definition: CaloRecHit.h:26
constexpr void setTime(float time)
Definition: CaloRecHit.h:34
constexpr const DetId & detid() const
Definition: CaloRecHit.h:35
constexpr CaloRecHit(const DetId &id, float energy, float time, uint32_t flags=0, uint32_t aux=0)
Definition: CaloRecHit.h:27
constexpr uint32_t calo_rechit_masks[]
Definition: CaloRecHit.h:12
uint32_t aux_
Definition: CaloRecHit.h:58
constexpr void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.h:38
float energy_
Definition: CaloRecHit.h:55
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
constexpr float time() const
Definition: CaloRecHit.h:33
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
base
Make Sure CMSSW is Setup ##.
Definition: DetId.h:18
uint32_t flags_
Definition: CaloRecHit.h:57
constexpr uint32_t flagField(int base, int width=1) const
Definition: CaloRecHit.h:48
std::ostream & operator<<(std::ostream &s, const CaloRecHit &hit)
Definition: CaloRecHit.cc:3
float time_
Definition: CaloRecHit.h:56
constexpr void setFlags(uint32_t flags)
Definition: CaloRecHit.h:37
constexpr uint32_t aux() const
Definition: CaloRecHit.h:52
constexpr void setAux(uint32_t value)
Definition: CaloRecHit.h:51
constexpr uint32_t flags() const
Definition: CaloRecHit.h:36
constexpr void setEnergy(float energy)
Definition: CaloRecHit.h:32
#define constexpr
DetId id_
Definition: CaloRecHit.h:54