00001 #ifndef MuonDetId_CSCIndexer_h
00002 #define MuonDetId_CSCIndexer_h
00003
00035 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00036 #include <vector>
00037 #include <iosfwd>
00038 #include <utility>
00039
00040 class CSCIndexer {
00041
00042 public:
00043
00044
00045
00046 typedef uint16_t IndexType;
00047 typedef uint32_t LongIndexType;
00048
00049 CSCIndexer(){};
00050 ~CSCIndexer(){};
00051
00062 IndexType chamberIndex( const CSCDetId& id ) const {
00063 return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
00064 }
00065
00076 IndexType layerIndex( const CSCDetId& id ) const {
00077 return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
00078 }
00079
00084 IndexType startChamberIndexInEndcap(IndexType ie, IndexType is, IndexType ir) const {
00085 const IndexType nschin[24] = {1,37,73, 109,127,0, 163,181,0, 217,469,0,
00086 235,271,307, 343,361,0, 397,415,0, 451,505,0 };
00087 return nschin[(ie-1)*12 + (is-1)*3 + ir-1];
00088
00089 }
00090
00095 IndexType chamberIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic) const {
00096 return startChamberIndexInEndcap(ie,is,ir) + ic - 1;
00097 }
00098
00103 IndexType layerIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const {
00104 const IndexType layersInChamber = 6;
00105 return (chamberIndex(ie,is,ir,ic) - 1 ) * layersInChamber + il;
00106 }
00107
00113 IndexType ringsInStation( IndexType is ) const {
00114 const IndexType nrins[5] = {0,3,2,2,2};
00115 return nrins[is];
00116 }
00117
00123 IndexType chambersInRingOfStation(IndexType is, IndexType ir) const {
00124 IndexType nc = 36;
00125 if (is >1 && ir<2 ) nc = 18;
00126 return nc;
00127 }
00128
00138 IndexType stripChannelsPerLayer( IndexType is, IndexType ir ) const {
00139 const IndexType nSCinC[12] = { 80,80,64, 80,80,0, 80,80,0, 80,80,0 };
00140 return nSCinC[(is-1)*3 + ir - 1];
00141 }
00142
00151 LongIndexType stripChannelStart( IndexType ie, IndexType is, IndexType ir ) const {
00152
00153
00154
00155
00156
00157
00158 const LongIndexType nStart[24] = { 1,17281,34561, 48385,57025,0, 74305,82945,0, 100225,217729,0,
00159 108865,126145,143425, 157249,165889,0, 183169,191809,0, 209089,235009,0 };
00160 return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
00161 }
00162
00172 LongIndexType stripChannelIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip ) const {
00173 return stripChannelStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*stripChannelsPerLayer(is,ir) + (istrip-1);
00174 }
00175
00185 LongIndexType stripChannelIndex( const CSCDetId& id, IndexType istrip ) const {
00186 return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
00187 }
00188
00192 CSCDetId detIdFromLayerIndex( IndexType ili ) const;
00193 CSCDetId detIdFromChamberIndex( IndexType ici ) const;
00194 CSCDetId detIdFromChamberIndex_OLD( IndexType ici ) const;
00195 CSCDetId detIdFromChamberLabel( IndexType ie, IndexType icl ) const;
00196 std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex( LongIndexType ichi ) const;
00197
00198 IndexType chamberLabelFromChamberIndex( IndexType ) const;
00199
00207 int dbIndex(const CSCDetId & id, int & channel);
00208
00209 private:
00210 void fillChamberLabel() const;
00211
00212 mutable std::vector<IndexType> chamberLabel;
00213
00214
00215 };
00216
00217 #endif
00218
00219
00220
00221
00222
00223