CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DetId.h
Go to the documentation of this file.
1 #ifndef DATAFORMATS_DETID_H
2 #define DATAFORMATS_DETID_H
3 
4 
5 //FIXME shall be removed and implemented where the operator is defined
6 #include <ostream>
7 
8 #include <stdint.h>
18 class DetId {
19 public:
20  static const int kDetOffset = 28;
21  static const int kSubdetOffset = 25;
22 
23 
24  enum Detector { Tracker=1,Muon=2,Ecal=3,Hcal=4,Calo=5 };
26  DetId() : id_(0) { }
28  DetId(uint32_t id) : id_(id) { }
30  DetId(Detector det, int subdet) {
31  id_=((det&0xF)<<28)|((subdet&0x7)<<25);
32  }
33 
35  Detector det() const { return Detector((id_>>kDetOffset)&0xF); }
37  int subdetId() const { return ((id_>>kSubdetOffset)&0x7); }
38 
39  uint32_t operator()() const { return id_; }
40  operator uint32_t() const { return id_; }
41 
43  uint32_t rawId() const { return id_; }
45  bool null() const { return id_==0; }
46 
48  bool operator==(DetId id) const { return id_==id.id_; }
50  bool operator!=(DetId id) const { return id_!=id.id_; }
52  bool operator<(DetId id) const { return id_<id.id_; }
53 
54 protected:
55  uint32_t id_;
56 };
57 
59 inline bool operator==(uint32_t i, DetId id) { return i==id(); }
60 inline bool operator==(DetId id, uint32_t i) { return i==id(); }
62 inline bool operator!=(uint32_t i, DetId id) { return i!=id(); }
63 inline bool operator!=(DetId id, uint32_t i) { return i!=id(); }
65 inline bool operator<(uint32_t i, DetId id) { return i<id(); }
66 inline bool operator<(DetId id, uint32_t i) { return id()<i; }
67 
68 
69 //std::ostream& operator<<(std::ostream& s, const DetId& id);
70 
71 #endif
int i
Definition: DBlmapReader.cc:9
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
static const int kSubdetOffset
Definition: DetId.h:21
DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:26
DetId(uint32_t id)
Create an id from a raw number.
Definition: DetId.h:28
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
bool operator==(DetId id) const
equality
Definition: DetId.h:48
bool operator!=(DetId id) const
inequality
Definition: DetId.h:50
bool operator==(const QGLikelihoodParameters &lhs, const QGLikelihoodCategory &rhs)
Test if parameters are compatible with category.
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
Definition: DetId.h:18
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:55
bool null() const
is this a null id ?
Definition: DetId.h:45
bool operator<(DetId id) const
comparison
Definition: DetId.h:52
static const int kDetOffset
Definition: DetId.h:20
DetId(Detector det, int subdet)
Create an id, filling the detector and subdetector fields as specified.
Definition: DetId.h:30
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
uint32_t operator()() const
Definition: DetId.h:39