CMS 3D CMS Logo

CaloID.h
Go to the documentation of this file.
1 #ifndef DataFormats_CaloRecHit_CaloID_h
2 #define DataFormats_CaloRecHit_CaloID_h
3 
13 #include <iosfwd>
14 
15 namespace reco {
16 
17  class CaloID {
18 
19  public:
20 
21  enum Detectors {
34  };
35 
37  CaloID() : detectors_(0) {}
38 
39  CaloID(Detectors det) : detectors_(0) { setDetector(det, true); }
40 
42  virtual ~CaloID() {}
43 
45  void setDetector(CaloID::Detectors theDetector, bool value);
46 
48  unsigned detectors() const {return detectors_;}
49 
51  bool detector(CaloID::Detectors theDetector) const;
52 
54  bool isSingleDetector() const {
55  // check that detectors_ is a power of 2
56  return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
57  }
58 
61  Detectors detector() const;
62 
63  CaloID& operator=(const CaloID& rhs) {
64  detectors_ = rhs.detectors_;
65  return *this;
66  }
67 
68  friend std::ostream& operator<<(std::ostream& out,
69  const CaloID& id);
70 
71  private:
72 
74  int leastSignificantBitPosition(unsigned n) const;
75 
78  unsigned detectors_;
79  };
80 
81  std::ostream& operator<<(std::ostream& out, const CaloID& id);
82 
83 }
84 
85 #endif
bool isSingleDetector() const
Definition: CaloID.h:54
Detectors detector() const
Definition: CaloID.cc:27
CaloID & operator=(const CaloID &rhs)
Definition: CaloID.h:63
CaloID()
default constructor. Sets energy and position to zero
Definition: CaloID.h:37
friend std::ostream & operator<<(std::ostream &out, const CaloID &id)
CaloID(Detectors det)
Definition: CaloID.h:39
Definition: value.py:1
unsigned detectors_
Definition: CaloID.h:78
unsigned detectors() const
Definition: CaloID.h:48
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:8
virtual ~CaloID()
abstract class
Definition: CaloID.h:42
fixed size matrix
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:39