CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/DataFormats/CaloRecHit/interface/CaloID.h

Go to the documentation of this file.
00001 #ifndef DataFormats_CaloRecHit_CaloID_h
00002 #define DataFormats_CaloRecHit_CaloID_h
00003 
00013 #include <iosfwd>
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_HF_EM,
00030       DET_HF_HAD,
00031       DET_HO,
00032       DET_NONE
00033     };
00034 
00036     CaloID() : detectors_(0) {}
00037 
00038     CaloID(Detectors det) : detectors_(0) { setDetector(det, true); }
00039     
00041     virtual ~CaloID() {}
00042 
00044     void setDetector(CaloID::Detectors theDetector, bool value);
00045         
00047     unsigned detectors() const {return detectors_;}
00048     
00050     bool detector(CaloID::Detectors theDetector) const;
00051 
00053     bool isSingleDetector() const {
00054       // check that detectors_ is a power of 2
00055       return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
00056     }
00057 
00060     Detectors  detector() const; 
00061 
00062     CaloID& operator=(const CaloID& rhs) { 
00063       detectors_ = rhs.detectors_;
00064       return *this;
00065     }
00066 
00067     friend std::ostream& operator<<(std::ostream& out,
00068                                     const CaloID& id);
00069    
00070   private:
00071     
00073     int leastSignificantBitPosition(unsigned n) const;
00074 
00077     unsigned  detectors_;
00078   };
00079 
00080   std::ostream& operator<<(std::ostream& out, const CaloID& id);
00081 
00082 }
00083 
00084 #endif