CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 {
33  };
34 
36  CaloID() : detectors_(0) {}
37 
38  CaloID(Detectors det) : detectors_(0) { setDetector(det, true); }
39 
41  virtual ~CaloID() {}
42 
44  void setDetector(CaloID::Detectors theDetector, bool value);
45 
47  unsigned detectors() const {return detectors_;}
48 
50  bool detector(CaloID::Detectors theDetector) const;
51 
53  bool isSingleDetector() const {
54  // check that detectors_ is a power of 2
55  return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
56  }
57 
60  Detectors detector() const;
61 
62  CaloID& operator=(const CaloID& rhs) {
63  detectors_ = rhs.detectors_;
64  return *this;
65  }
66 
67  friend std::ostream& operator<<(std::ostream& out,
68  const CaloID& id);
69 
70  private:
71 
73  int leastSignificantBitPosition(unsigned n) const;
74 
77  unsigned detectors_;
78  };
79 
80  std::ostream& operator<<(std::ostream& out, const CaloID& id);
81 
82 }
83 
84 #endif
bool isSingleDetector() const
Definition: CaloID.h:53
Detectors detector() const
Definition: CaloID.cc:27
CaloID & operator=(const CaloID &rhs)
Definition: CaloID.h:62
CaloID()
default constructor. Sets energy and position to zero
Definition: CaloID.h:36
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
friend std::ostream & operator<<(std::ostream &out, const CaloID &id)
CaloID(Detectors det)
Definition: CaloID.h:38
tuple out
Definition: dbtoconf.py:99
unsigned detectors_
Definition: CaloID.h:77
unsigned detectors() const
Definition: CaloID.h:47
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:41
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:39