CMS 3D CMS Logo

CaloID.h

Go to the documentation of this file.
00001 #ifndef DataFormats_CaloRecHit_CaloID_h
00002 #define DataFormats_CaloRecHit_CaloID_h
00003 
00013 #include <iostream>
00014 
00015 namespace reco {
00016 
00017   class CaloID {
00018     
00019   public:
00020 
00021     enum Detectors {
00022       DET_ECAL_BARREL = 0,
00023       DET_ECAL_ENDCAP,
00024       DET_PS1,
00025       DET_PS2,
00026       DET_HCAL_BARREL,
00027       DET_HCAL_ENDCAP,
00028       DET_HF,
00029       DET_HO,
00030       DET_NONE
00031     };
00032 
00034     CaloID() : detectors_(0) {}
00035 
00036     CaloID(Detectors det) : detectors_(0) { setDetector(det, true); }
00037     
00039     virtual ~CaloID() {}
00040 
00042     void setDetector(CaloID::Detectors theDetector, bool value);
00043         
00045     unsigned detectors() const {return detectors_;}
00046     
00048     bool detector(CaloID::Detectors theDetector) const;
00049 
00051     bool isSingleDetector() const {
00052       // check that detectors_ is a power of 2
00053       return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
00054     }
00055 
00058     Detectors  detector() const; 
00059 
00060     CaloID& operator=(const CaloID& rhs) { 
00061       detectors_ = rhs.detectors_;
00062       return *this;
00063     }
00064 
00065     friend std::ostream& operator<<(std::ostream& out,
00066                                     const CaloID& id);
00067    
00068   private:
00069     
00071     int leastSignificantBitPosition(unsigned n) const;
00072 
00075     unsigned  detectors_;
00076   };
00077 
00078 }
00079 
00080 #endif

Generated on Tue Jun 9 17:27:14 2009 for CMSSW by  doxygen 1.5.4