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
operator<<
std::ostream & operator<<(std::ostream &s, const EEDetId &id)
Definition: EEDetId.cc:479
DDAxes::y
EEDetId::isNextToBoundary
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:277
mps_fire.i
i
Definition: mps_fire.py:355
EEDetId::SCCRYSTALMODE
static const int SCCRYSTALMODE
Definition: EEDetId.h:336
EEDetId::kEEhalf
Definition: EEDetId.h:325
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
EEDetId::isc
int isc() const
Definition: EEDetId.cc:222
EEDetId::isOuterRing
bool isOuterRing() const
Definition: EEDetId.cc:429
EEDetId::unhashIndex
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
EEDetId::switchZSide
EEDetId switchZSide() const
Definition: EEDetId.cc:402
EEDetId::fastValidDetId
static bool fastValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.h:258
EEDetId::IX_MIN
static const int IX_MIN
Definition: EEDetId.h:290
EEDetId::EEDetId
EEDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:44
EcalSubdetector
EcalSubdetector
Definition: EcalSubdetector.h:10
DDAxes::x
EEDetId::IY_MIN
static const int IY_MIN
Definition: EEDetId.h:294
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
EEDetId::kxf
static const unsigned short kxf[2 *IY_MAX]
Definition: EEDetId.h:351
EEDetId::ic
int ic() const
Definition: EEDetId.cc:245
EEDetId::denseIndex
uint32_t denseIndex() const
Definition: EEDetId.h:192
EEDetId::detIdFromDenseIndex
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
DetId
Definition: DetId.h:17
EEDetId::nCrys
static const int nCrys
Definition: EEDetId.h:347
alignCSCRings.s
s
Definition: alignCSCRings.py:92
EEDetId::validDenseIndex
static bool validDenseIndex(uint32_t din)
Definition: EEDetId.h:213
EEDetId::QuadColLimits
static const int QuadColLimits[nCols+1]
Definition: EEDetId.h:348
EEDetId::offsetBy
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:391
EEDetId::isOuterRingXY
static bool isOuterRingXY(int ax, int ay)
Definition: EEDetId.cc:437
EEDetId::kSizeForDenseIndexing
Definition: EEDetId.h:329
EcalScDetId
Definition: EcalScDetId.h:24
EEDetId::nCols
static const int nCols
Definition: EEDetId.h:346
EEDetId::IY_MAX
static const int IY_MAX
Definition: EEDetId.h:302
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
EEDetId::ISC_MAX
static const int ISC_MAX
Definition: EEDetId.h:316
EEDetId::iquadrant
int iquadrant() const
Definition: EEDetId.cc:206
b
double b
Definition: hdecay.h:118
EEDetId::subdet
static EcalSubdetector subdet()
Definition: EEDetId.h:66
EEDetId
Definition: EEDetId.h:14
EcalSubdetector.h
EcalEndcap
Definition: EcalSubdetector.h:10
EEDetId::distanceX
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:474
EEDetId::distanceY
static int distanceY(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:476
EEDetId::EEDetId
EEDetId(uint32_t rawid)
Definition: EEDetId.h:29
EEDetId::kdi
static const unsigned short kdi[2 *IY_MAX]
Definition: EEDetId.h:352
a
double a
Definition: hdecay.h:119
cropTnPTrees.din
din
Definition: cropTnPTrees.py:30
DetId::id_
uint32_t id_
Definition: DetId.h:69
EEDetId::operator=
EEDetId & operator=(const DetId &id)
Definition: EEDetId.h:58
EEDetId::isNextToRingBoundary
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:284
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
EEDetId::IX_MAX
static const int IX_MAX
Definition: EEDetId.h:298
EEDetId::ISC_MIN
static const int ISC_MIN
Definition: EEDetId.h:306
EEDetId::validHashIndex
static bool validHashIndex(int i)
Definition: EEDetId.h:239
EEDetId::iyQuadrantOne
int iyQuadrantOne() const
Definition: EEDetId.cc:196
EEDetId::sc
EcalScDetId sc() const
Definition: EEDetId.h:89
DetId::Ecal
Definition: DetId.h:27
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
alignCSCRings.r
r
Definition: alignCSCRings.py:93
EEDetId::EEDetId
EEDetId()
Definition: EEDetId.h:24
hi
Definition: HiEvtPlaneList.h:38
EEDetId::positiveZ
bool positiveZ() const
Definition: EEDetId.h:174
EEDetId::slowValidDetId
static bool slowValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.cc:444
EEDetId::ICR_MAX
static const int ICR_MAX
Definition: EEDetId.h:320
EEDetId::idOuterRing
static EEDetId idOuterRing(int iPhi, int zEnd)
Definition: EEDetId.cc:339
EEDetId::XYMODE
static const int XYMODE
Definition: EEDetId.h:335
DetId.h
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EEDetId::isNextToDBoundary
static bool isNextToDBoundary(EEDetId id)
Definition: EEDetId.cc:279
EcalScDetId.h
EEDetId::ICR_MIN
static const int ICR_MIN
Definition: EEDetId.h:310
EEDetId::iYoffset
static const int iYoffset[nCols+1]
Definition: EEDetId.h:349
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EEDetId::iPhiOuterRing
int iPhiOuterRing() const
Definition: EEDetId.cc:295
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
EEDetId::EEDetId
EEDetId(const DetId &id)
Definition: EEDetId.h:53
EEDetId::ixQuadrantOne
int ixQuadrantOne() const
Definition: EEDetId.cc:186
EEDetId::Subdet
Definition: EEDetId.h:19