Go to the documentation of this file.00001 #ifndef ECALDETID_EBDETID_H
00002 #define ECALDETID_EBDETID_H
00003
00004 #include <ostream>
00005 #include <cmath>
00006 #include <cstdlib>
00007 #include "DataFormats/DetId/interface/DetId.h"
00008 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00009 #include "DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h"
00010
00011
00020 class EBDetId : public DetId {
00021 public:
00022 enum { Subdet=EcalBarrel};
00024 EBDetId() {}
00026 EBDetId(uint32_t rawid) : DetId(rawid) {}
00029 EBDetId(int index1, int index2, int mode = ETAPHIMODE);
00031 EBDetId(const DetId& id);
00033 EBDetId& operator=(const DetId& id);
00034
00036
00037 static EcalSubdetector subdet() { return EcalBarrel;}
00038
00040 int zside() const { return (id_&0x10000)?(1):(-1); }
00042 int ietaAbs() const { return (id_>>9)&0x7F; }
00044 int ieta() const { return zside()*ietaAbs(); }
00046 int iphi() const { return id_&0x1FF; }
00048 int tower_ieta() const { return ((ietaAbs()-1)/5+1)*zside(); }
00050 int tower_iphi() const;
00052 EcalTrigTowerDetId tower() const { return EcalTrigTowerDetId(zside(),EcalBarrel,abs(tower_ieta()),tower_iphi()); }
00054 int ism() const;
00056 int im() const;
00058 int ic() const;
00060 int ietaSM() const { return ietaAbs(); }
00062 int iphiSM() const { return (( ic() -1 ) % kCrystalsInPhi ) + 1; }
00063
00064
00065 bool positiveZ() const { return id_&0x10000;}
00066
00067 int numberByEtaPhi() const {
00068 return (MAX_IETA + (positiveZ() ? ietaAbs()-1 : -ietaAbs()) )*MAX_IPHI+ iphi()-1;
00069 }
00070
00071 int numberBySM() const;
00073 int hashedIndex() const { return numberByEtaPhi(); }
00074
00075 uint32_t denseIndex() const { return hashedIndex() ; }
00076
00079 EBDetId offsetBy( int nrStepsEta, int nrStepsPhi ) const;
00080
00083 EBDetId switchZSide() const;
00084
00088 static DetId offsetBy( const DetId startId, int nrStepsEta, int nrStepsPhi );
00089 static DetId switchZSide( const DetId startId );
00090
00093 float approxEta() const { return ieta() * crystalUnitToEta; }
00094 static float approxEta( const DetId id );
00095
00096 static bool validDenseIndex( uint32_t din ) { return ( din < kSizeForDenseIndexing ) ; }
00097
00098 static EBDetId detIdFromDenseIndex( uint32_t di ) { return unhashIndex( di ) ; }
00099
00101 static EBDetId unhashIndex( int hi ) ;
00102
00103 static bool validHashIndex(int i) { return !(i<MIN_HASH || i>MAX_HASH); }
00104
00106 static bool validDetId(int i, int j) ;
00107
00108 static bool isNextToBoundary(EBDetId id);
00109
00110 static bool isNextToEtaBoundary(EBDetId id);
00111
00112 static bool isNextToPhiBoundary(EBDetId id);
00113
00114
00115 static int distanceEta(const EBDetId& a,const EBDetId& b);
00116
00117 static int distancePhi(const EBDetId& a,const EBDetId& b);
00118
00120 static const int MIN_IETA = 1;
00121 static const int MIN_IPHI = 1;
00122 static const int MAX_IETA = 85;
00123 static const int MAX_IPHI = 360;
00124 static const int kChannelsPerCard = 5;
00125 static const int kTowersInPhi = 4;
00126 static const int kModulesPerSM = 4;
00127 static const int kModuleBoundaries[4] ;
00128 static const int kCrystalsInPhi = 20;
00129 static const int kCrystalsInEta = 85;
00130 static const int kCrystalsPerSM = 1700;
00131 static const int MIN_SM = 1;
00132 static const int MAX_SM = 36;
00133 static const int MIN_C = 1;
00134 static const int MAX_C = kCrystalsPerSM;
00135 static const int MIN_HASH = 0;
00136 static const int MAX_HASH = 2*MAX_IPHI*MAX_IETA-1;
00137
00138
00139 static const float crystalUnitToEta;
00140
00141 enum { kSizeForDenseIndexing = MAX_HASH + 1 } ;
00142
00143
00144
00145 static const int ETAPHIMODE = 0;
00146 static const int SMCRYSTALMODE = 1;
00147 };
00148
00149 std::ostream& operator<<(std::ostream& s,const EBDetId& id);
00150
00151
00152 #endif