CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
16 class EEDetId : public DetId {
17 public:
18  enum {
22  };
23 
26  EEDetId() {}
27 
31  EEDetId(uint32_t rawid) : DetId(rawid) {}
32 
45  // fast
46  EEDetId(int crystal_ix, int crystal_iy, int iz) :
47  DetId( Ecal, EcalEndcap ) {
48  id_|=(crystal_iy&0x7f)|((crystal_ix&0x7f)<<7)|((iz>0)?(0x4000):(0));
49  }
50  // slow
51  EEDetId(int i, int j, int iz, int mode);
52 
56  EEDetId(const DetId& id) : DetId(id){}
57 
61  EEDetId& operator=(const DetId& id) {id_ = id.rawId(); return *this;}
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  {
185  const uint32_t jx ( ix() ) ;
186  const uint32_t jd ( 2*( iy() - 1 ) + ( jx - 1 )/50 ) ;
187  return ( ( positiveZ() ? kEEhalf : 0) + kdi[jd] + jx - kxf[jd] ) ;
188  }
189 
193  uint32_t denseIndex() const { return hashedIndex() ; }
194 
197  EEDetId offsetBy( int nrStepsX, int nrStepsY ) const;
198 
201  EEDetId switchZSide() const;
202 
206  static DetId offsetBy( const DetId startId, int nrStepsX, int nrStepsY );
207  static DetId switchZSide( const DetId startId );
208 
214  static bool validDenseIndex( uint32_t din ) { return validHashIndex( din ) ; }
215 
221  static EEDetId detIdFromDenseIndex( uint32_t din ) { return unhashIndex( din ) ; }
222 
223  static bool isNextToBoundary( EEDetId id ) ;
224 
225  static bool isNextToDBoundary( EEDetId id ) ;
226 
227  static bool isNextToRingBoundary( EEDetId id ) ;
228 
233  static EEDetId unhashIndex( int hi ) ;
234 
240  static bool validHashIndex( int i ) { return ( i < kSizeForDenseIndexing ) ; }
241 
249  static bool validDetId(int crystal_ix, int crystal_iy, int iz) {
250  return
251  crystal_ix >= IX_MIN && crystal_ix <= IX_MAX &&
252  crystal_iy >= IY_MIN && crystal_iy <= IY_MAX &&
253  std::abs(iz)==1 &&
254  ( fastValidDetId(crystal_ix,crystal_iy) ||
255  slowValidDetId(crystal_ix,crystal_iy) );
256  }
257  static bool slowValidDetId(int crystal_ix, int crystal_iy);
258 
263  static bool fastValidDetId(int crystal_ix, int crystal_iy) {
264  float x = crystal_ix; float y = crystal_iy;
265  float r = (x - 50.5f) * (x - 50.5f) + (y - 50.5f) * (y - 50.5f);
266  return r > 12.f * 12.f && r < 48.f * 48.f;
267  }
268 
274  static int distanceX(const EEDetId& a,const EEDetId& b);
275 
281  static int distanceY(const EEDetId& a,const EEDetId& b);
282 
283 
290  static int isc( int iscCol, // output is 1-316
291  int iscRow ) ; //
292 
295  static const int IX_MIN =1;
296 
299  static const int IY_MIN =1;
300 
303  static const int IX_MAX =100;
304 
307  static const int IY_MAX =100;
308 
311  static const int ISC_MIN=1;
312 
315  static const int ICR_MIN=1;
316 
321  static const int ISC_MAX=316;
322 
325  static const int ICR_MAX=25;
326 
327  enum {
330  kEEhalf = 7324 ,
335  };
336 
340  static const int XYMODE = 0;
341  static const int SCCRYSTALMODE = 1;
344 private:
345 
346  bool isOuterRing() const ;
347 
348  static bool isOuterRingXY( int ax, int ay ) ;
349 
350  //Functions from B. Kennedy to retrieve ix and iy from SC and Crystal number
351 
352  static const int nCols = 10;
353  static const int nCrys = 5; /* Number of crystals per row in SC */
354  static const int QuadColLimits[nCols+1];
355  static const int iYoffset[nCols+1];
356 
357  static const unsigned short kxf[2*IY_MAX] ;
358  static const unsigned short kdi[2*IY_MAX] ;
359 
360  int ix( int iSC, int iCrys ) const;
361  int iy( int iSC, int iCrys ) const;
362  int ixQuadrantOne() const;
363  int iyQuadrantOne() const;
364 };
365 
366 
367 std::ostream& operator<<(std::ostream& s,const EEDetId& id);
368 
369 #endif
static EcalSubdetector subdet()
Definition: EEDetId.h:66
static EEDetId detIdFromDenseIndex(uint32_t din)
Definition: EEDetId.h:221
static bool isNextToBoundary(EEDetId id)
Definition: EEDetId.cc:361
int i
Definition: DBlmapReader.cc:9
static const int ISC_MAX
Definition: EEDetId.h:321
int ix() const
Definition: EEDetId.h:77
int ic() const
Definition: EEDetId.cc:324
EEDetId(const DetId &id)
Definition: EEDetId.h:56
static int distanceX(const EEDetId &a, const EEDetId &b)
Definition: EEDetId.cc:577
bool positiveZ() const
Definition: EEDetId.h:174
int isc() const
Definition: EEDetId.cc:285
static const int XYMODE
Definition: EEDetId.h:340
EEDetId(uint32_t rawid)
Definition: EEDetId.h:31
#define abs(x)
Definition: mlp_lapack.h:159
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:311
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const int SCCRYSTALMODE
Definition: EEDetId.h:341
static const int IX_MIN
Definition: EEDetId.h:295
static const int IY_MIN
Definition: EEDetId.h:299
static bool validHashIndex(int i)
Definition: EEDetId.h:240
static const int iYoffset[nCols+1]
Definition: EEDetId.h:355
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:352
static bool slowValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.cc:546
int zside() const
Definition: EEDetId.h:71
static const int ICR_MIN
Definition: EEDetId.h:315
int iPhiOuterRing() const
Definition: EEDetId.cc:388
int j
Definition: DBlmapReader.cc:9
static bool isNextToRingBoundary(EEDetId id)
Definition: EEDetId.cc:375
double f[11][100]
int iy() const
Definition: EEDetId.h:83
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:303
EEDetId switchZSide() const
Definition: EEDetId.cc:487
Definition: DetId.h:20
int hashedIndex() const
Definition: EEDetId.h:183
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:249
static const int nCrys
Definition: EEDetId.h:353
uint32_t id_
Definition: DetId.h:57
EcalScDetId sc() const
Definition: EEDetId.h:89
double b
Definition: hdecay.h:120
uint32_t denseIndex() const
Definition: EEDetId.h:193
static bool validDenseIndex(uint32_t din)
Definition: EEDetId.h:214
double a
Definition: hdecay.h:121
static const int QuadColLimits[nCols+1]
Definition: EEDetId.h:354
static const unsigned short kxf[2 *IY_MAX]
Definition: EEDetId.h:357
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:307
EEDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:46
static const unsigned short kdi[2 *IY_MAX]
Definition: EEDetId.h:358
Definition: DDAxes.h:10
EcalSubdetector
static bool fastValidDetId(int crystal_ix, int crystal_iy)
Definition: EEDetId.h:263
static const int ICR_MAX
Definition: EEDetId.h:325
EEDetId()
Definition: EEDetId.h:26
EEDetId & operator=(const DetId &id)
Definition: EEDetId.h:61