CMS 3D CMS Logo

EEDetId.h
Go to the documentation of this file.
1 #ifndef ECALDETID_EEDETID_H
2 #define ECALDETID_EEDETID_H
3 
4 #include <iosfwd>
8 
14 class EEDetId : public DetId {
15 public:
16  enum {
20  };
21 
24  EEDetId() {}
25 
29  EEDetId(uint32_t rawid) : DetId(rawid) {}
30 
43  // fast
44  EEDetId(int crystal_ix, int crystal_iy, int iz) : DetId(Ecal, EcalEndcap) {
45  id_ |= (crystal_iy & 0x7f) | ((crystal_ix & 0x7f) << 7) | ((iz > 0) ? (0x4000) : (0));
46  }
47  // slow
48  EEDetId(int i, int j, int iz, int mode);
49 
53  EEDetId(const DetId& id) : DetId(id) {}
54 
58  EEDetId& operator=(const DetId& id) {
59  id_ = id.rawId();
60  return *this;
61  }
62 
66  static EcalSubdetector subdet() { return EcalEndcap; }
67 
71  int zside() const { return (id_ & 0x4000) ? (1) : (-1); }
72 
77  int ix() const { return (id_ >> 7) & 0x7F; }
78 
83  int iy() const { return id_ & 0x7F; }
84 
89  EcalScDetId sc() const {
90  const int scEdge = 5;
91  return EcalScDetId(1 + (ix() - 1) / scEdge, 1 + (iy() - 1) / scEdge, zside());
92  }
93 
126  int isc() const;
127 
151  int ic() const;
152 
169  int iquadrant() const;
170 
174  bool positiveZ() const { return id_ & 0x4000; }
175 
176  int iPhiOuterRing() const; // 1-360 else==0 if not on outer ring!
177 
178  static EEDetId idOuterRing(int iPhi, int zEnd);
179 
183  int hashedIndex() const {
184  const uint32_t jx(ix());
185  const uint32_t jd(2 * (iy() - 1) + (jx - 1) / 50);
186  return ((positiveZ() ? kEEhalf : 0) + kdi[jd] + jx - kxf[jd]);
187  }
188 
192  uint32_t denseIndex() const { return hashedIndex(); }
193 
196  EEDetId offsetBy(int nrStepsX, int nrStepsY) const;
197 
200  EEDetId switchZSide() const;
201 
205  static DetId offsetBy(const DetId startId, int nrStepsX, int nrStepsY);
206  static DetId switchZSide(const DetId startId);
207 
213  static bool validDenseIndex(uint32_t din) { return validHashIndex(din); }
214 
220  static EEDetId detIdFromDenseIndex(uint32_t din) { return unhashIndex(din); }
221 
222  static bool isNextToBoundary(EEDetId id);
223 
224  static bool isNextToDBoundary(EEDetId id);
225 
226  static bool isNextToRingBoundary(EEDetId id);
227 
232  static EEDetId unhashIndex(int hi);
233 
239  static bool validHashIndex(int i) { return (i < kSizeForDenseIndexing); }
240 
248  static bool validDetId(int crystal_ix, int crystal_iy, int iz) {
249  return crystal_ix >= IX_MIN && crystal_ix <= IX_MAX && crystal_iy >= IY_MIN && crystal_iy <= IY_MAX &&
250  std::abs(iz) == 1 && (fastValidDetId(crystal_ix, crystal_iy) || slowValidDetId(crystal_ix, crystal_iy));
251  }
252  static bool slowValidDetId(int crystal_ix, int crystal_iy);
253 
258  static bool fastValidDetId(int crystal_ix, int crystal_iy) {
259  float x = crystal_ix;
260  float y = crystal_iy;
261  float r = (x - 50.5f) * (x - 50.5f) + (y - 50.5f) * (y - 50.5f);
262  return r > 12.f * 12.f && r < 48.f * 48.f;
263  }
264 
270  static int distanceX(const EEDetId& a, const EEDetId& b);
271 
277  static int distanceY(const EEDetId& a, const EEDetId& b);
278 
285  static int isc(int iscCol, // output is 1-316
286  int iscRow); //
287 
290  static const int IX_MIN = 1;
291 
294  static const int IY_MIN = 1;
295 
298  static const int IX_MAX = 100;
299 
302  static const int IY_MAX = 100;
303 
306  static const int ISC_MIN = 1;
307 
310  static const int ICR_MIN = 1;
311 
316  static const int ISC_MAX = 316;
317 
320  static const int ICR_MAX = 25;
321 
322  enum {
325  kEEhalf = 7324,
330  };
331 
335  static const int XYMODE = 0;
336  static const int SCCRYSTALMODE = 1;
339 private:
340  bool isOuterRing() const;
341 
342  static bool isOuterRingXY(int ax, int ay);
343 
344  //Functions from B. Kennedy to retrieve ix and iy from SC and Crystal number
345 
346  static const int nCols = 10;
347  static const int nCrys = 5; /* Number of crystals per row in SC */
348  static const int QuadColLimits[nCols + 1];
349  static const int iYoffset[nCols + 1];
350 
351  static const unsigned short kxf[2 * IY_MAX];
352  static const unsigned short kdi[2 * IY_MAX];
353 
354  int ix(int iSC, int iCrys) const;
355  int iy(int iSC, int iCrys) const;
356  int ixQuadrantOne() const;
357  int iyQuadrantOne() const;
358 };
359 
360 std::ostream& operator<<(std::ostream& s, const EEDetId& id);
361 
362 #endif
static EcalSubdetector subdet()
Definition: EEDetId.h:66
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:277
static const int ISC_MAX
Definition: EEDetId.h:316
int ix() const
Definition: EEDetId.h:77
int ic() const
Definition: EEDetId.cc:245
EEDetId(const DetId &id)
Definition: EEDetId.h:53
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:474
bool positiveZ() const
Definition: EEDetId.h:174
int isc() const
Definition: EEDetId.cc:222
static const int XYMODE
Definition: EEDetId.h:335
EEDetId(uint32_t rawid)
Definition: EEDetId.h:29
int iquadrant() const
Definition: EEDetId.cc:206
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:391
int ixQuadrantOne() const
Definition: EEDetId.cc:186
static const int ISC_MIN
Definition: EEDetId.h:306
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
static const int SCCRYSTALMODE
Definition: EEDetId.h:336
static const int IX_MIN
Definition: EEDetId.h:290
static const int IY_MIN
Definition: EEDetId.h:294
static bool validHashIndex(int i)
Definition: EEDetId.h:239
static const int iYoffset[nCols+1]
Definition: EEDetId.h:349
bool isOuterRing() const
Definition: EEDetId.cc:429
static bool isOuterRingXY(int ax, int ay)
Definition: EEDetId.cc:437
static const int nCols
Definition: EEDetId.h:346
static bool slowValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.cc:444
int zside() const
Definition: EEDetId.h:71
static const int ICR_MIN
Definition: EEDetId.h:310
int iPhiOuterRing() const
Definition: EEDetId.cc:295
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:284
double f[11][100]
int iy() const
Definition: EEDetId.h:83
static int distanceY(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:476
static bool isNextToDBoundary(EEDetId id)
Definition: EEDetId.cc:279
static const int IX_MAX
Definition: EEDetId.h:298
EEDetId switchZSide() const
Definition: EEDetId.cc:402
Definition: DetId.h:18
int hashedIndex() const
Definition: EEDetId.h:183
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int nCrys
Definition: EEDetId.h:347
uint32_t id_
Definition: DetId.h:62
EcalScDetId sc() const
Definition: EEDetId.h:89
double b
Definition: hdecay.h:120
uint32_t denseIndex() const
Definition: EEDetId.h:192
static bool validDenseIndex(uint32_t din)
Definition: EEDetId.h:213
double a
Definition: hdecay.h:121
static const int QuadColLimits[nCols+1]
Definition: EEDetId.h:348
static const unsigned short kxf[2 *IY_MAX]
Definition: EEDetId.h:351
static EEDetId idOuterRing(int iPhi, int zEnd)
Definition: EEDetId.cc:339
int iyQuadrantOne() const
Definition: EEDetId.cc:196
static const int IY_MAX
Definition: EEDetId.h:302
EEDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:44
static const unsigned short kdi[2 *IY_MAX]
Definition: EEDetId.h:352
EcalSubdetector
static bool fastValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.h:258
static const int ICR_MAX
Definition: EEDetId.h:320
EEDetId()
Definition: EEDetId.h:24
std::ostream & operator<<(std::ostream &s, const EEDetId &id)
Definition: EEDetId.cc:479
EEDetId & operator=(const DetId &id)
Definition: EEDetId.h:58