CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch12/src/DataFormats/EcalDetId/interface/EEDetId.h

Go to the documentation of this file.
00001 #ifndef ECALDETID_EEDETID_H
00002 #define ECALDETID_EEDETID_H
00003 
00004 #include <ostream>
00005 #include "DataFormats/DetId/interface/DetId.h"
00006 #include "DataFormats/EcalDetId/interface/EcalScDetId.h"
00007 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00008 
00009 
00016 class EEDetId : public DetId {
00017    public:
00018       enum {
00021          Subdet=EcalEndcap
00022       };
00023       
00026       EEDetId() {}
00027       
00031       EEDetId(uint32_t rawid) : DetId(rawid) {}
00032       
00045       EEDetId(int i, int j, int iz, int mode = XYMODE);
00046       
00050       EEDetId(const DetId& id);
00051       
00055       EEDetId& operator=(const DetId& id);
00056       
00060       static EcalSubdetector subdet() { return EcalEndcap;}
00061       
00065       int zside() const { return (id_&0x4000)?(1):(-1); }
00066       
00071       int ix() const { return (id_>>7)&0x7F; }
00072       
00077       int iy() const { return id_&0x7F; }
00078       
00083       EcalScDetId sc() const {
00084          const int scEdge = 5;
00085          return EcalScDetId(1+(ix()-1)/scEdge, 1+(iy()-1)/scEdge, zside());
00086       }
00087       
00120       int isc() const ;
00121       
00145       int ic() const;
00146       
00163       int iquadrant() const ;
00164       
00168       bool positiveZ() const { return id_&0x4000;}
00169       
00170       int iPhiOuterRing() const ; // 1-360 else==0 if not on outer ring!
00171 
00172       static EEDetId idOuterRing( int iPhi , int zEnd ) ;
00173 
00177       int hashedIndex() const 
00178       {
00179          const uint32_t jx ( ix() ) ;
00180          const uint32_t jd ( 2*( iy() - 1 ) + ( jx - 1 )/50 ) ;
00181          return (  ( zside()<0 ? 0 : kEEhalf ) + kdi[jd] + jx - kxf[jd] ) ;
00182       }
00183 
00187       uint32_t denseIndex() const { return hashedIndex() ; }
00188 
00191       EEDetId offsetBy( int nrStepsX, int nrStepsY ) const;
00192 
00195       EEDetId switchZSide() const;
00196  
00200       static DetId offsetBy( const DetId startId, int nrStepsX, int nrStepsY );
00201       static DetId switchZSide( const DetId startId );
00202 
00208       static bool validDenseIndex( uint32_t din ) { return validHashIndex( din ) ; }
00209 
00215       static EEDetId detIdFromDenseIndex( uint32_t din ) { return unhashIndex( din ) ; }
00216 
00217       static bool isNextToBoundary(     EEDetId id ) ;
00218       
00219       static bool isNextToDBoundary(    EEDetId id ) ;
00220 
00221       static bool isNextToRingBoundary( EEDetId id ) ;
00222 
00227       static EEDetId unhashIndex( int hi ) ;
00228 
00234       static bool validHashIndex( int i ) { return ( i < kSizeForDenseIndexing ) ; }
00235 
00243       static bool validDetId(int crystal_ix, int crystal_iy, int iz);
00244 
00250       static int distanceX(const EEDetId& a,const EEDetId& b);
00251       
00257       static int distanceY(const EEDetId& a,const EEDetId& b); 
00258 
00259 
00266       static int isc( int iscCol,   // output is 1-316
00267                       int iscRow ) ; // 
00268 
00271       static const int IX_MIN =1;
00272 
00275       static const int IY_MIN =1;
00276       
00279       static const int IX_MAX =100;
00280 
00283       static const int IY_MAX =100;
00284 
00287       static const int ISC_MIN=1;
00288 
00291       static const int ICR_MIN=1;
00292 
00297       static const int ISC_MAX=316;
00298 
00301       static const int ICR_MAX=25;
00302       
00303       enum {
00306          kEEhalf = 7324 ,
00310          kSizeForDenseIndexing = 2*kEEhalf
00311       };
00312 
00316       static const int XYMODE        = 0;
00317       static const int SCCRYSTALMODE = 1;
00320    private:
00321 
00322       bool        isOuterRing() const ;
00323 
00324       static bool isOuterRingXY( int ax, int ay ) ;
00325 
00326       //Functions from B. Kennedy to retrieve ix and iy from SC and Crystal number
00327 
00328       static const int nCols = 10;
00329       static const int nCrys = 5; /* Number of crystals per row in SC */
00330       static const int QuadColLimits[nCols+1];
00331       static const int iYoffset[nCols+1];
00332 
00333       static const unsigned short kxf[2*IY_MAX] ;
00334       static const unsigned short kdi[2*IY_MAX] ;
00335   
00336       int ix( int iSC, int iCrys ) const;
00337       int iy( int iSC, int iCrys ) const;
00338       int ixQuadrantOne() const;
00339       int iyQuadrantOne() const;
00340 };
00341 
00342 
00343 std::ostream& operator<<(std::ostream& s,const EEDetId& id);
00344 
00345 #endif