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>
20 class DetId {
21 public:
22  static const int kDetOffset = 28;
23  static const int kSubdetOffset = 25;
24 
25 
26  enum Detector { Tracker=1,Muon=2,Ecal=3,Hcal=4,Calo=5 };
28  DetId() : id_(0) { }
30  DetId(uint32_t id) : id_(id) { }
32  DetId(Detector det, int subdet) {
33  id_=((det&0xF)<<28)|((subdet&0x7)<<25);
34  }
35 
37  Detector det() const { return Detector((id_>>kDetOffset)&0xF); }
39  int subdetId() const { return ((id_>>kSubdetOffset)&0x7); }
40 
41  uint32_t operator()() const { return id_; }
42  operator uint32_t() const { return id_; }
43 
45  uint32_t rawId() const { return id_; }
47  bool null() const { return id_==0; }
48 
50  bool operator==(DetId id) const { return id_==id.id_; }
52  bool operator!=(DetId id) const { return id_!=id.id_; }
54  bool operator<(DetId id) const { return id_<id.id_; }
55 
56 protected:
57  uint32_t id_;
58 };
59 
61 inline bool operator==(uint32_t i, DetId id) { return i==id(); }
62 inline bool operator==(DetId id, uint32_t i) { return i==id(); }
64 inline bool operator!=(uint32_t i, DetId id) { return i!=id(); }
65 inline bool operator!=(DetId id, uint32_t i) { return i!=id(); }
67 inline bool operator<(uint32_t i, DetId id) { return i<id(); }
68 inline bool operator<(DetId id, uint32_t i) { return id()<i; }
69 
70 
71 //std::ostream& operator<<(std::ostream& s, const DetId& id);
72 
73 #endif
int i
Definition: DBlmapReader.cc:9
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
bool operator==(const CaloTower &t1, const CaloTower &t2)
Definition: CaloTower.h:211
static const int kSubdetOffset
Definition: DetId.h:23
DetId()
Create an empty or null id (also for persistence)
Definition: DetId.h:28
DetId(uint32_t id)
Create an id from a raw number.
Definition: DetId.h:30
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
bool operator==(DetId id) const
equality
Definition: DetId.h:50
bool operator!=(DetId id) const
inequality
Definition: DetId.h:52
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
Definition: DetId.h:20
Detector
Definition: DetId.h:26
uint32_t id_
Definition: DetId.h:57
bool null() const
is this a null id ?
Definition: DetId.h:47
bool operator<(DetId id) const
comparison
Definition: DetId.h:54
static const int kDetOffset
Definition: DetId.h:22
DetId(Detector det, int subdet)
Create an id, filling the detector and subdetector fields as specified.
Definition: DetId.h:32
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
uint32_t operator()() const
Definition: DetId.h:41