CMS 3D CMS Logo

ESDetId.h
Go to the documentation of this file.
1 #ifndef ECALDETID_ESDETID_H
2 #define ECALDETID_ESDETID_H
3 
4 #include <iosfwd>
8 
15 class ESDetId : public DetId {
16 public:
17  enum { Subdet = EcalPreshower };
19  ESDetId() {}
21  ESDetId(uint32_t rawid) : DetId(rawid) {}
22 
24  ESDetId(int strip, int ixs, int iys, int plane, int iz, bool doverify = false) : DetId(Ecal, EcalPreshower) {
25  id_ |= (strip & 0x3F) | ((ixs & 0x3F) << 6) | ((iys & 0x3F) << 12) | (((plane - 1) & 0x1) << 18) |
26  ((iz > 0) ? (1 << 19) : (0));
27  if (doverify)
28  verify(strip, ixs, iys, plane, iz);
29  }
30 
32  ESDetId(const DetId& id);
34  ESDetId& operator=(const DetId& id);
35 
39  int zside() const { return (id_ & 0x80000) ? (1) : (-1); }
41  int plane() const { return ((id_ >> 18) & 0x1) + 1; }
43  int six() const { return (id_ >> 6) & 0x3F; }
45  int siy() const { return (id_ >> 12) & 0x3F; }
47  int strip() const { return (id_ & 0x3F); }
49  int hashedIndex() const;
50 
51  uint32_t denseIndex() const { return hashedIndex(); }
52 
53  static bool validDenseIndex(uint32_t din) { return validHashIndex(din); }
54 
55  static ESDetId detIdFromDenseIndex(uint32_t din) { return unhashIndex(din); }
56 
58  static ESDetId unhashIndex(int hi);
59  static bool validHashIndex(int hi) { return (hi < kSizeForDenseIndexing); }
61  static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz);
62  static void verify(int istrip, int ixs, int iys, int iplane, int iz);
63 
64  static const int IX_MIN = 1;
65  static const int IY_MIN = 1;
66  static const int IX_MAX = 40;
67  static const int IY_MAX = 40;
68  static const int ISTRIP_MIN = 1;
69  static const int ISTRIP_MAX = 32;
70  static const int PLANE_MIN = 1;
71  static const int PLANE_MAX = 2;
72  static const int IZ_NUM = 2;
73 
74 private:
75  enum {
76  kXYMAX = 1072,
77  kXYMIN = 1,
78  kXMAX = 40,
79  kYMAX = 40,
80  kXMIN = 1,
81  kYMIN = 1,
82  // now normalize to A-D notation for ease of use
84  kNb = PLANE_MAX - PLANE_MIN + 1,
85  kNc = kXYMAX - kXYMIN + 1,
86  kNd = ISTRIP_MAX - ISTRIP_MIN + 1,
87  kLd = kNd,
88  kLc = kLd * kNc,
89  kLb = kLc * kNb,
90  kLa = kLb * kNa
91  };
92 
93  static const unsigned short hxy1[kXMAX][kYMAX];
94  static const unsigned short hx1[kXYMAX];
95  static const unsigned short hy1[kXYMAX];
96 
97  static const unsigned short hxy2[kXMAX][kYMAX];
98  static const unsigned short hx2[kXYMAX];
99  static const unsigned short hy2[kXYMAX];
100 
101 public:
103 };
104 
105 std::ostream& operator<<(std::ostream&, const ESDetId& id);
106 
107 inline ESDetId::ESDetId(const DetId& gen) : DetId(gen) {
108 #ifdef EDM_ML_DEBUG
109  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalPreshower)) {
110  throw cms::Exception("InvalidDetId");
111  }
112 #endif
113 }
114 
116 #ifdef EDM_ML_DEBUG
117  if (!gen.null() && (gen.det() != Ecal || gen.subdetId() != EcalPreshower)) {
118  throw cms::Exception("InvalidDetId");
119  }
120 #endif
121  id_ = gen.rawId();
122  return *this;
123 }
124 
125 #endif
static bool validDenseIndex(uint32_t din)
Definition: ESDetId.h:53
int strip() const
Definition: ESDetId.h:47
ESDetId(uint32_t rawid)
Definition: ESDetId.h:21
ESDetId(int strip, int ixs, int iys, int plane, int iz, bool doverify=false)
constructor from strip, ix, iy, plane, and iz
Definition: ESDetId.h:24
static const unsigned short hy2[kXYMAX]
Definition: ESDetId.h:99
static const unsigned short hxy2[kXMAX][kYMAX]
Definition: ESDetId.h:97
constexpr bool null() const
is this a null id ?
Definition: DetId.h:52
static const unsigned short hy1[kXYMAX]
Definition: ESDetId.h:95
static const int IY_MAX
Definition: ESDetId.h:67
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
int six() const
Definition: ESDetId.h:43
static const int ISTRIP_MAX
Definition: ESDetId.h:69
ESDetId & operator=(const DetId &id)
Definition: ESDetId.h:115
static const int PLANE_MIN
Definition: ESDetId.h:70
static void verify(int istrip, int ixs, int iys, int iplane, int iz)
Definition: ESDetId.cc:6
int siy() const
Definition: ESDetId.h:45
static const int PLANE_MAX
Definition: ESDetId.h:71
ESDetId()
Definition: ESDetId.h:19
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
std::ostream & operator<<(std::ostream &, const ESDetId &id)
Definition: ESDetId.cc:62
int zside() const
Definition: ESDetId.h:39
static ESDetId detIdFromDenseIndex(uint32_t din)
Definition: ESDetId.h:55
uint32_t denseIndex() const
Definition: ESDetId.h:51
static const unsigned short hxy1[kXMAX][kYMAX]
Definition: ESDetId.h:93
Definition: DetId.h:18
static const int IY_MIN
Definition: ESDetId.h:65
static const int IZ_NUM
Definition: ESDetId.h:72
static const unsigned short hx2[kXYMAX]
Definition: ESDetId.h:98
uint32_t id_
Definition: DetId.h:62
static bool validDetId(int istrip, int ixs, int iys, int iplane, int iz)
check if a valid index combination
Definition: ESDetId.cc:15
static const int IX_MAX
Definition: ESDetId.h:66
int plane() const
Definition: ESDetId.h:41
static ESDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: ESDetId.cc:32
EcalSubdetector
EcalSubdetector subdet() const
get the subdetector
Definition: ESDetId.h:37
static const unsigned short hx1[kXYMAX]
Definition: ESDetId.h:94
static const int ISTRIP_MIN
Definition: ESDetId.h:68
static bool validHashIndex(int hi)
Definition: ESDetId.h:59
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
static const int IX_MIN
Definition: ESDetId.h:64
int hashedIndex() const
get a compact index for arrays [TODO: NEEDS WORK]
Definition: ESDetId.cc:21