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 
9 
15 class EEDetId : public DetId {
16 public:
17  enum {
21  };
22 
25  EEDetId() {}
26 
30  EEDetId(uint32_t rawid) : DetId(rawid) {}
31 
44  // fast
45  EEDetId(int crystal_ix, int crystal_iy, int iz) :
46  DetId( Ecal, EcalEndcap ) {
47  id_|=(crystal_iy&0x7f)|((crystal_ix&0x7f)<<7)|((iz>0)?(0x4000):(0));
48  }
49  // slow
50  EEDetId(int i, int j, int iz, int mode);
51 
55  EEDetId(const DetId& id) : DetId(id){}
56 
60  EEDetId& operator=(const DetId& id) {id_ = id.rawId(); return *this;}
61 
65  static EcalSubdetector subdet() { return EcalEndcap;}
66 
70  int zside() const { return (id_&0x4000)?(1):(-1); }
71 
76  int ix() const { return (id_>>7)&0x7F; }
77 
82  int iy() const { return id_&0x7F; }
83 
88  EcalScDetId sc() const {
89  const int scEdge = 5;
90  return EcalScDetId(1+(ix()-1)/scEdge, 1+(iy()-1)/scEdge, zside());
91  }
92 
125  int isc() const ;
126 
150  int ic() const;
151 
168  int iquadrant() const ;
169 
173  bool positiveZ() const { return id_&0x4000;}
174 
175  int iPhiOuterRing() const ; // 1-360 else==0 if not on outer ring!
176 
177  static EEDetId idOuterRing( int iPhi , int zEnd ) ;
178 
182  int hashedIndex() const
183  {
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
250  crystal_ix >= IX_MIN && crystal_ix <= IX_MAX &&
251  crystal_iy >= IY_MIN && crystal_iy <= IY_MAX &&
252  std::abs(iz)==1 &&
253  ( fastValidDetId(crystal_ix,crystal_iy) ||
254  slowValidDetId(crystal_ix,crystal_iy) );
255  }
256  static bool slowValidDetId(int crystal_ix, int crystal_iy);
257 
262  static bool fastValidDetId(int crystal_ix, int crystal_iy) {
263  float x = crystal_ix; float y = crystal_iy;
264  float r = (x - 50.5f) * (x - 50.5f) + (y - 50.5f) * (y - 50.5f);
265  return r > 12.f * 12.f && r < 48.f * 48.f;
266  }
267 
273  static int distanceX(const EEDetId& a,const EEDetId& b);
274 
280  static int distanceY(const EEDetId& a,const EEDetId& b);
281 
282 
289  static int isc( int iscCol, // output is 1-316
290  int iscRow ) ; //
291 
294  static const int IX_MIN =1;
295 
298  static const int IY_MIN =1;
299 
302  static const int IX_MAX =100;
303 
306  static const int IY_MAX =100;
307 
310  static const int ISC_MIN=1;
311 
314  static const int ICR_MIN=1;
315 
320  static const int ISC_MAX=316;
321 
324  static const int ICR_MAX=25;
325 
326  enum {
329  kEEhalf = 7324 ,
334  };
335 
339  static const int XYMODE = 0;
340  static const int SCCRYSTALMODE = 1;
343 private:
344 
345  bool isOuterRing() const ;
346 
347  static bool isOuterRingXY( int ax, int ay ) ;
348 
349  //Functions from B. Kennedy to retrieve ix and iy from SC and Crystal number
350 
351  static const int nCols = 10;
352  static const int nCrys = 5; /* Number of crystals per row in SC */
353  static const int QuadColLimits[nCols+1];
354  static const int iYoffset[nCols+1];
355 
356  static const unsigned short kxf[2*IY_MAX] ;
357  static const unsigned short kdi[2*IY_MAX] ;
358 
359  int ix( int iSC, int iCrys ) const;
360  int iy( int iSC, int iCrys ) const;
361  int ixQuadrantOne() const;
362  int iyQuadrantOne() const;
363 };
364 
365 
366 std::ostream& operator<<(std::ostream& s,const EEDetId& id);
367 
368 #endif
static EcalSubdetector subdet()
Definition: EEDetId.h:65
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:220
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:361
static const int ISC_MAX
Definition: EEDetId.h:320
int ix() const
Definition: EEDetId.h:76
int ic() const
Definition: EEDetId.cc:324
EEDetId(const DetId &id)
Definition: EEDetId.h:55
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:577
bool positiveZ() const
Definition: EEDetId.h:173
int isc() const
Definition: EEDetId.cc:285
static const int XYMODE
Definition: EEDetId.h:339
EEDetId(uint32_t rawid)
Definition: EEDetId.h:30
int iquadrant() const
Definition: EEDetId.cc:264
EEDetId offsetBy(int nrStepsX, int nrStepsY) const
Definition: EEDetId.cc:474
int ixQuadrantOne() const
Definition: EEDetId.cc:241
static const int ISC_MIN
Definition: EEDetId.h:310
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
static const int SCCRYSTALMODE
Definition: EEDetId.h:340
static const int IX_MIN
Definition: EEDetId.h:294
static const int IY_MIN
Definition: EEDetId.h:298
static bool validHashIndex(int i)
Definition: EEDetId.h:239
static const int iYoffset[nCols+1]
Definition: EEDetId.h:354
bool isOuterRing() const
Definition: EEDetId.cc:520
static bool isOuterRingXY(int ax, int ay)
Definition: EEDetId.cc:531
static const int nCols
Definition: EEDetId.h:351
static bool slowValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.cc:546
int zside() const
Definition: EEDetId.h:70
static const int ICR_MIN
Definition: EEDetId.h:314
int iPhiOuterRing() const
Definition: EEDetId.cc:388
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
double f[11][100]
int iy() const
Definition: EEDetId.h:82
static int distanceY(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:582
static bool isNextToDBoundary(EEDetId id)
Definition: EEDetId.cc:367
static const int IX_MAX
Definition: EEDetId.h:302
EEDetId switchZSide() const
Definition: EEDetId.cc:487
Definition: DetId.h:18
int hashedIndex() const
Definition: EEDetId.h:182
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
static const int nCrys
Definition: EEDetId.h:352
uint32_t id_
Definition: DetId.h:59
EcalScDetId sc() const
Definition: EEDetId.h:88
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:353
static const unsigned short kxf[2 *IY_MAX]
Definition: EEDetId.h:356
static EEDetId idOuterRing(int iPhi, int zEnd)
Definition: EEDetId.cc:435
int iyQuadrantOne() const
Definition: EEDetId.cc:252
static const int IY_MAX
Definition: EEDetId.h:306
EEDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:45
static const unsigned short kdi[2 *IY_MAX]
Definition: EEDetId.h:357
EcalSubdetector
static bool fastValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.h:262
static const int ICR_MAX
Definition: EEDetId.h:324
EEDetId()
Definition: EEDetId.h:25
std::ostream & operator<<(std::ostream &s, const EEDetId &id)
Definition: EEDetId.cc:588
EEDetId & operator=(const DetId &id)
Definition: EEDetId.h:60