00001 #ifndef MuonDetId_CSCIndexer_h
00002 #define MuonDetId_CSCIndexer_h
00003
00038 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00039 #include <vector>
00040 #include <iosfwd>
00041 #include <utility>
00042
00043 class CSCIndexer {
00044
00045 public:
00046
00047
00048
00049 typedef uint16_t IndexType;
00050 typedef uint32_t LongIndexType;
00051
00052 CSCIndexer(){};
00053 ~CSCIndexer(){};
00054
00065 IndexType chamberIndex( const CSCDetId& id ) const {
00066 return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
00067 }
00068
00079 IndexType layerIndex( const CSCDetId& id ) const {
00080 return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
00081 }
00082
00087 IndexType startChamberIndexInEndcap(IndexType ie, IndexType is, IndexType ir) const {
00088 const IndexType nschin[24] = {1,37,73, 109,127,0, 163,181,0, 217,469,0,
00089 235,271,307, 343,361,0, 397,415,0, 451,505,0 };
00090 return nschin[(ie-1)*12 + (is-1)*3 + ir-1];
00091
00092 }
00093
00098 IndexType chamberIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic) const {
00099 return startChamberIndexInEndcap(ie,is,ir) + ic - 1;
00100 }
00101
00106 IndexType layerIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const {
00107 const IndexType layersInChamber = 6;
00108 return (chamberIndex(ie,is,ir,ic) - 1 ) * layersInChamber + il;
00109 }
00110
00116 IndexType ringsInStation( IndexType is ) const {
00117 const IndexType nrins[5] = {0,3,2,2,2};
00118 return nrins[is];
00119 }
00120
00126 IndexType chambersInRingOfStation(IndexType is, IndexType ir) const {
00127 IndexType nc = 36;
00128 if (is >1 && ir<2 ) nc = 18;
00129 return nc;
00130 }
00131
00141 IndexType stripChannelsPerLayer( IndexType is, IndexType ir ) const {
00142 const IndexType nSCinC[12] = { 80,80,64, 80,80,0, 80,80,0, 80,80,0 };
00143 return nSCinC[(is-1)*3 + ir - 1];
00144 }
00145
00154 LongIndexType stripChannelStart( IndexType ie, IndexType is, IndexType ir ) const {
00155
00156
00157
00158
00159
00160
00161 const LongIndexType nStart[24] = { 1,17281,34561, 48385,57025,0, 74305,82945,0, 100225,217729,0,
00162 108865,126145,143425, 157249,165889,0, 183169,191809,0, 209089,235009,0 };
00163 return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
00164 }
00165
00175 LongIndexType stripChannelIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip ) const {
00176 return stripChannelStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*stripChannelsPerLayer(is,ir) + (istrip-1);
00177 }
00178
00188 LongIndexType stripChannelIndex( const CSCDetId& id, IndexType istrip ) const {
00189 return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
00190 }
00191
00201 IndexType chipsPerLayer( IndexType is, IndexType ir ) const {
00202 const IndexType nCinL[12] = { 5,5,4, 5,5,0, 5,5,0, 5,5,0 };
00203 return nCinL[(is-1)*3 + ir - 1];
00204 }
00205
00214 IndexType chipStart( IndexType ie, IndexType is, IndexType ir ) const {
00215
00216
00217
00218
00219
00220
00221 const IndexType nStart[24] = {1, 1081, 2161, 3025, 3565, 0, 4645, 5185, 0, 6265, 13609,0,
00222 6805, 7885, 8965, 9829, 10369,0, 11449, 11989, 0, 13069, 14689 ,0 };
00223
00224 return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
00225 }
00226
00236 IndexType chipIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip ) const {
00237
00238 return chipStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*chipsPerLayer(is,ir) + (ichip-1);
00239
00240 }
00241
00251 IndexType chipIndex( const CSCDetId& id, IndexType ichip ) const {
00252 return chipIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), ichip );
00253 }
00254
00265 IndexType chipIndex( IndexType istrip ) const {
00266 return (istrip-1)/16+1;
00267 }
00268
00272 CSCDetId detIdFromLayerIndex( IndexType ili ) const;
00273 CSCDetId detIdFromChamberIndex( IndexType ici ) const;
00274 CSCDetId detIdFromChamberIndex_OLD( IndexType ici ) const;
00275 CSCDetId detIdFromChamberLabel( IndexType ie, IndexType icl ) const;
00276 std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex( LongIndexType ichi ) const;
00277 std::pair<CSCDetId, IndexType> detIdFromChipIndex( IndexType ichi ) const;
00278
00279 IndexType chamberLabelFromChamberIndex( IndexType ) const;
00280
00288 int dbIndex(const CSCDetId & id, int & channel);
00289
00290 private:
00291 void fillChamberLabel() const;
00292
00293 mutable std::vector<IndexType> chamberLabel;
00294
00295
00296 };
00297
00298 #endif
00299
00300
00301
00302
00303
00304