CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloRecHit.cc
Go to the documentation of this file.
2 
3 
4 CaloRecHit::CaloRecHit() : energy_(0), time_(0), flags_(0), aux_(0) {
5 }
6 
7 CaloRecHit::CaloRecHit(const DetId& id, float energy, float time, uint32_t flags, uint32_t aux) :
8  id_(id),energy_(energy), time_(time), flags_(flags), aux_(aux) {
9 }
10 
11 
12 constexpr uint32_t 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 
20 void CaloRecHit::setFlagField(uint32_t value, int base, int width) {
21  value&=masks[std::max(std::min(width,32),0)];
22  value<<=std::max(std::min(base,31),0);
23  // clear out the relevant bits
24  uint32_t clear=masks[std::max(std::min(width,32),0)];
25  clear=clear<<std::max(std::min(base,31),0);
26  clear^=0xFFFFFFFFu;
27  flags_&=clear;
28  flags_|=value;
29 }
30 
31 uint32_t CaloRecHit::flagField(int base, int width) const {
32  return (flags_>>std::max(std::min(base,31),0))&masks[std::max(std::min(width,32),0)];
33 }
34 
35 
36 std::ostream& operator<<(std::ostream& s, const CaloRecHit& hit) {
37  s << hit.detid().rawId() << ", " << hit.energy() << " GeV, " << hit.time() << " ns ";
38  s << " flags=0x" << std::hex << hit.flags() << std::dec << " ";
39  s << " aux=0x" << std::hex << hit.aux() << std::dec << " ";
40  return s;
41 }
42 
tuple base
Main Program
Definition: newFWLiteAna.py:91
uint32_t aux() const
Definition: CaloRecHit.h:27
const DetId & detid() const
Definition: CaloRecHit.h:21
void setFlagField(uint32_t value, int base, int width=1)
Definition: CaloRecHit.cc:20
std::vector< Variable::Flags > flags
Definition: MVATrainer.cc:135
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
float time() const
Definition: CaloRecHit.h:19
#define constexpr
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
float energy() const
Definition: CaloRecHit.h:17
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
Definition: matutil.cc:167
uint32_t flags() const
Definition: CaloRecHit.h:22
T min(T a, T b)
Definition: MathUtil.h:58
Definition: DetId.h:18
uint32_t flags_
Definition: CaloRecHit.h:32
constexpr uint32_t masks[]
Definition: CaloRecHit.cc:12
uint32_t flagField(int base, int width=1) const
Definition: CaloRecHit.cc:31