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  public:
19  enum Detectors {
32  };
33 
35  CaloID() : detectors_(0) {}
36 
37  CaloID(Detectors det) : detectors_(0) { setDetector(det, true); }
38 
40  virtual ~CaloID() {}
41 
43  void setDetector(CaloID::Detectors theDetector, bool value);
44 
46  unsigned detectors() const { return detectors_; }
47 
49  bool detector(CaloID::Detectors theDetector) const;
50 
52  bool isSingleDetector() const {
53  // check that detectors_ is a power of 2
54  return static_cast<bool>(detectors_ && !((detectors_ - 1) & detectors_));
55  }
56 
59  Detectors detector() const;
60 
61  CaloID& operator=(const CaloID& rhs) {
62  detectors_ = rhs.detectors_;
63  return *this;
64  }
65 
66  friend std::ostream& operator<<(std::ostream& out, const CaloID& id);
67 
68  private:
70  int leastSignificantBitPosition(unsigned n) const;
71 
74  unsigned detectors_;
75  };
76 
77  std::ostream& operator<<(std::ostream& out, const CaloID& id);
78 
79 } // namespace reco
80 
81 #endif
bool isSingleDetector() const
Definition: CaloID.h:52
Detectors detector() const
Definition: CaloID.cc:19
CaloID & operator=(const CaloID &rhs)
Definition: CaloID.h:61
CaloID()
default constructor. Sets energy and position to zero
Definition: CaloID.h:35
friend std::ostream & operator<<(std::ostream &out, const CaloID &id)
CaloID(Detectors det)
Definition: CaloID.h:37
Definition: value.py:1
unsigned detectors_
Definition: CaloID.h:74
unsigned detectors() const
Definition: CaloID.h:46
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:7
virtual ~CaloID()
abstract class
Definition: CaloID.h:40
fixed size matrix
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:30