CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DataFormats/EcalDetId/interface/EcalScDetId.h

Go to the documentation of this file.
00001 // -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: t; tab-width: 8; -*-
00002 //$Id: EcalScDetId.h,v 1.8 2012/11/02 13:07:52 innocent Exp $
00003 //
00004 // \author Philippe Gras (CEA/Saclay). Code adapted from EEDetId.
00005 //
00006 #ifndef EcalDetId_EcalScDetId_h
00007 #define EcalDetId_EcalScDetId_h
00008 
00009 #include <iosfwd>
00010 #include "DataFormats/DetId/interface/DetId.h"
00011 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00012 
00013 
00025 class EcalScDetId : public DetId {
00026  public:
00027 
00030   EcalScDetId();
00031   
00036   EcalScDetId(uint32_t rawid);
00037 
00046   EcalScDetId(int ix, int iy, int iz);
00047   
00051   EcalScDetId(const DetId& id);
00052 
00056   EcalScDetId& operator=(const DetId& id);
00057 
00061   EcalSubdetector subdet() const { return EcalSubdetector(subdetId()); }
00062   
00066   int zside() const { return (id_&0x4000)?(1):(-1); }
00067   
00072   int ix() const { return (id_>>7)&0x7F; }
00073   
00078   int iy() const { return id_&0x7F; }
00079   
00102   int iquadrant() const ;
00103   
00104   
00109   int hashedIndex() const{
00110     checkHashedIndexMap();
00111     if(!validDetId(ix(),iy(),zside())) return -1;
00112     return xyz2HashedIndex[ix()-IX_MIN][iy()-IY_MIN][zside()>0?1:0];
00113   }
00114 
00119   static EcalScDetId unhashIndex(int hi){
00120     checkHashedIndexMap();
00121     if(hi < 0 || hi >= kSizeForDenseIndexing) return EcalScDetId();
00122     return hashedIndex2DetId[hi];
00123   }
00124   
00128   uint32_t denseIndex() const { return hashedIndex() ; }
00129 
00134   static bool validDenseIndex(uint32_t din) { return din < kSizeForDenseIndexing; }
00135 
00136   
00141   static bool validHashIndex(int hi) { return validDenseIndex(hi) ; }
00142 
00145   static const int SC_PER_EE_CNT = 312;
00146   
00149   static const int IX_MIN=1;
00150 
00153   static const int IY_MIN=1;
00154 
00157   static const int IX_MAX=20;
00158 
00161   static const int IY_MAX=20;
00162 
00165   static const int IHASHED_MIN = 0;
00166 
00169   static const int IHASHED_MAX = SC_PER_EE_CNT*2 - 1;
00170   
00178   static bool validDetId(int ix, int iy, int iz) ;
00179 
00180 private:
00183   static void checkHashedIndexMap();
00184   
00185 
00186   //fields
00187 public:
00188   enum {
00191     kSizeForDenseIndexing = SC_PER_EE_CNT * 2
00192   };
00193 
00194 private:
00195   static const int nEndcaps = 2;
00196   
00199   static short xyz2HashedIndex[IX_MAX][IY_MAX][nEndcaps];
00200   
00203   static EcalScDetId hashedIndex2DetId[kSizeForDenseIndexing];
00204 };
00205 
00206 
00207 std::ostream& operator<<(std::ostream& s,const EcalScDetId& id);
00208 
00209 
00210 #endif //EcalDetId_EcalScDetId_h not defined