CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/DataFormats/DetId/interface/DetId.h

Go to the documentation of this file.
00001 #ifndef DATAFORMATS_DETID_H
00002 #define DATAFORMATS_DETID_H
00003 
00004 
00005 //FIXME shall be removed and implemented where the operator is defined
00006 #include <ostream>
00007 
00008 #include <stdint.h>
00020 class DetId {
00021 public:
00022   static const int kDetOffset          = 28;
00023   static const int kSubdetOffset       = 25;
00024 
00025 
00026   enum Detector { Tracker=1,Muon=2,Ecal=3,Hcal=4,Calo=5 };
00028   DetId()  : id_(0) { }
00030   DetId(uint32_t id) : id_(id) { }
00032   DetId(Detector det, int subdet)  {
00033     id_=((det&0xF)<<28)|((subdet&0x7)<<25);
00034   }
00035 
00037   Detector det() const { return Detector((id_>>kDetOffset)&0xF); }
00039   int subdetId() const { return ((id_>>kSubdetOffset)&0x7); }
00040 
00041   uint32_t operator()() const { return id_; }
00042   operator uint32_t() const { return id_; }
00043 
00045   uint32_t rawId() const { return id_; }
00047   bool null() const { return id_==0; }
00048   
00050   bool operator==(DetId id) const { return id_==id.id_; }
00052   bool operator!=(DetId id) const { return id_!=id.id_; }
00054   bool operator<(DetId id) const { return id_<id.id_; }
00055 
00056 protected:
00057   uint32_t id_;
00058 };
00059 
00061 inline bool operator==(uint32_t i, DetId id)  { return i==id(); }
00062 inline bool operator==(DetId id, uint32_t i)  { return i==id(); }
00064 inline bool operator!=(uint32_t i, DetId id)  { return i!=id(); }
00065 inline bool operator!=(DetId id, uint32_t i) { return i!=id(); }
00067 inline bool operator<(uint32_t i, DetId id) { return i<id(); }
00068 inline bool operator<(DetId id, uint32_t i) { return id()<i; }
00069 
00070 
00071 //std::ostream& operator<<(std::ostream& s, const DetId& id);
00072 
00073 #endif