CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCIndexer.h
Go to the documentation of this file.
1 #ifndef MuonDetId_CSCIndexer_h
2 #define MuonDetId_CSCIndexer_h
3 
39 #include <vector>
40 #include <iosfwd>
41 #include <utility> // for pair
42 
43 class CSCIndexer {
44 
45 public:
46 
47  // typedef unsigned short int IndexType;
48  // typedef unsigned int LongIndexType;
49  typedef uint16_t IndexType;
50  typedef uint32_t LongIndexType;
51 
54 
65  IndexType chamberIndex( const CSCDetId& id ) const {
66  return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
67  }
68 
79  IndexType layerIndex( const CSCDetId& id ) const {
80  return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
81  }
82 
88  const IndexType nschin[24] = {1,37,73, 109,127,0, 163,181,0, 217,469,0,
89  235,271,307, 343,361,0, 397,415,0, 451,505,0 };
90  return nschin[(ie-1)*12 + (is-1)*3 + ir-1];
91 
92  }
93 
99  return startChamberIndexInEndcap(ie,is,ir) + ic - 1; // -1 so start index _is_ ic=1
100  }
101 
107  const IndexType layersInChamber = 6;
108  return (chamberIndex(ie,is,ir,ic) - 1 ) * layersInChamber + il;
109  }
110 
117  const IndexType nrins[5] = {0,3,2,2,2}; // rings per station
118  return nrins[is];
119  }
120 
127  IndexType nc = 36; // most rings have 36 chambers
128  if (is >1 && ir<2 ) nc = 18; // but 21, 31, 41 have 18
129  return nc;
130  }
131 
142  const IndexType nSCinC[12] = { 80,80,64, 80,80,0, 80,80,0, 80,80,0 };
143  return nSCinC[(is-1)*3 + ir - 1];
144  }
145 
155 
156  // These are in the ranges 1-217728 (CSCs 2008) and 217729-252288 (ME42).
157  // There are 1-108884 channels per endcap (CSCs 2008) and 17280 channels per endcap (ME42).
158  // Start of -z channels (CSCs 2008) is 108864 + 1 = 108865
159  // Start of +z (ME42) is 217728 + 1 = 217729
160  // Start of -z (ME42) is 217728 + 1 + 17280 = 235009
161  const LongIndexType nStart[24] = { 1,17281,34561, 48385,57025,0, 74305,82945,0, 100225,217729,0,
162  108865,126145,143425, 157249,165889,0, 183169,191809,0, 209089,235009,0 };
163  return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
164  }
165 
176  return stripChannelStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*stripChannelsPerLayer(is,ir) + (istrip-1);
177  }
178 
188  LongIndexType stripChannelIndex( const CSCDetId& id, IndexType istrip ) const {
189  return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
190  }
191 
202  const IndexType nCinL[12] = { 5,5,4, 5,5,0, 5,5,0, 5,5,0 };
203  return nCinL[(is-1)*3 + ir - 1];
204  }
205 
215 
216  // These are in the ranges 1-13608 (CSCs 2008) and 13609-15768 (ME42).
217  // There are 1-6804 chips per endcap (CSCs 2008) and 1080 channels per endcap (ME42).
218  // Start of -z channels (CSCs 2008) is 6804 + 1 = 6805
219  // Start of +z (ME42) is 13608 + 1 = 13609
220  // Start of -z (ME42) is 13608 + 1 + 1080 = 14689
221  const IndexType nStart[24] = {1, 1081, 2161, 3025, 3565, 0, 4645, 5185, 0, 6265, 13609,0,
222  6805, 7885, 8965, 9829, 10369,0, 11449, 11989, 0, 13069, 14689 ,0 };
223 
224  return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
225  }
226 
237  //printf("ME%d/%d/%d/%d layer %d chip %d chipindex %d\n",ie,is,ir,ic,il,ichip,chipStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*chipsPerLayer(is,ir) + (ichip-1));
238  return chipStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*chipsPerLayer(is,ir) + (ichip-1);
239 
240  }
241 
251  IndexType chipIndex( const CSCDetId& id, IndexType ichip ) const {
252  return chipIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), ichip );
253  }
254 
265  IndexType chipIndex( IndexType istrip ) const {
266  return (istrip-1)/16+1;
267  }
268 
276  std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex( LongIndexType ichi ) const;
277  std::pair<CSCDetId, IndexType> detIdFromChipIndex( IndexType ichi ) const;
278 
279  IndexType chamberLabelFromChamberIndex( IndexType ) const; // just for cross-checks
280 
288  int dbIndex(const CSCDetId & id, int & channel);
289 
290 private:
291  void fillChamberLabel() const; // const so it can be called in const function detIdFromChamberIndex
292 
293  mutable std::vector<IndexType> chamberLabel; // mutable so can be filled by fillChamberLabel
294 
295 
296 };
297 
298 #endif
299 
300 
301 
302 
303 
304 
std::pair< CSCDetId, IndexType > detIdFromStripChannelIndex(LongIndexType ichi) const
Definition: CSCIndexer.cc:129
IndexType chamberLabelFromChamberIndex(IndexType) const
Definition: CSCIndexer.cc:86
IndexType chipsPerLayer(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:201
IndexType layerIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const
Definition: CSCIndexer.h:106
IndexType chamberIndex(const CSCDetId &id) const
Definition: CSCIndexer.h:65
void fillChamberLabel() const
Definition: CSCIndexer.cc:4
IndexType chambersInRingOfStation(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:126
LongIndexType stripChannelIndex(const CSCDetId &id, IndexType istrip) const
Definition: CSCIndexer.h:188
IndexType ringsInStation(IndexType is) const
Definition: CSCIndexer.h:116
int dbIndex(const CSCDetId &id, int &channel)
Definition: CSCIndexer.cc:240
CSCDetId detIdFromChamberIndex(IndexType ici) const
Definition: CSCIndexer.cc:62
CSCDetId detIdFromChamberIndex_OLD(IndexType ici) const
Definition: CSCIndexer.cc:24
uint16_t IndexType
Definition: CSCIndexer.h:49
std::pair< CSCDetId, IndexType > detIdFromChipIndex(IndexType ichi) const
Definition: CSCIndexer.cc:185
IndexType chamberIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic) const
Definition: CSCIndexer.h:98
IndexType chipIndex(IndexType istrip) const
Definition: CSCIndexer.h:265
IndexType chipStart(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:214
CSCDetId detIdFromChamberLabel(IndexType ie, IndexType icl) const
Definition: CSCIndexer.cc:109
uint32_t LongIndexType
Definition: CSCIndexer.h:50
IndexType chipIndex(const CSCDetId &id, IndexType ichip) const
Definition: CSCIndexer.h:251
IndexType stripChannelsPerLayer(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:141
IndexType layerIndex(const CSCDetId &id) const
Definition: CSCIndexer.h:79
IndexType chipIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip) const
Definition: CSCIndexer.h:236
IndexType startChamberIndexInEndcap(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:87
std::vector< IndexType > chamberLabel
Definition: CSCIndexer.h:293
LongIndexType stripChannelStart(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:154
LongIndexType stripChannelIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip) const
Definition: CSCIndexer.h:175
CSCDetId detIdFromLayerIndex(IndexType ili) const
Definition: CSCIndexer.cc:120