test
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 
40 #include <vector>
41 #include <iosfwd>
42 #include <utility> // for pair
43 
44 class CSCIndexer {
45 
46 public:
47 
48  // typedef unsigned short int IndexType;
49  // typedef unsigned int LongIndexType;
50  typedef uint16_t IndexType;
51  typedef uint32_t LongIndexType;
52 
55 
66  IndexType chamberIndex( const CSCDetId& id ) const {
67  return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
68  }
69 
80  IndexType layerIndex( const CSCDetId& id ) const {
81  return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
82  }
83 
89  const IndexType nschin[24] = {1,37,73, 109,127,0, 163,181,0, 217,469,0,
90  235,271,307, 343,361,0, 397,415,0, 451,505,0 };
91  return nschin[(ie-1)*12 + (is-1)*3 + ir-1];
92 
93  }
94 
100  return startChamberIndexInEndcap(ie,is,ir) + ic - 1; // -1 so start index _is_ ic=1
101  }
102 
108  const IndexType layersInChamber = 6;
109  return (chamberIndex(ie,is,ir,ic) - 1 ) * layersInChamber + il;
110  }
111 
118  const IndexType nrins[5] = {0,3,2,2,2}; // rings per station
119  return nrins[is];
120  }
121 
128  IndexType nc = 36; // most rings have 36 chambers
129  if (is >1 && ir<2 ) nc = 18; // but 21, 31, 41 have 18
130  return nc;
131  }
132 
143  const IndexType nSCinC[12] = { 80,80,64, 80,80,0, 80,80,0, 80,80,0 };
144  return nSCinC[(is-1)*3 + ir - 1];
145  }
146 
156 
157  // These are in the ranges 1-217728 (CSCs 2008) and 217729-252288 (ME42).
158  // There are 1-108884 channels per endcap (CSCs 2008) and 17280 channels per endcap (ME42).
159  // Start of -z channels (CSCs 2008) is 108864 + 1 = 108865
160  // Start of +z (ME42) is 217728 + 1 = 217729
161  // Start of -z (ME42) is 217728 + 1 + 17280 = 235009
162  const LongIndexType nStart[24] = { 1,17281,34561, 48385,57025,0, 74305,82945,0, 100225,217729,0,
163  108865,126145,143425, 157249,165889,0, 183169,191809,0, 209089,235009,0 };
164  return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
165  }
166 
177  return stripChannelStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*stripChannelsPerLayer(is,ir) + (istrip-1);
178  }
179 
189  LongIndexType stripChannelIndex( const CSCDetId& id, IndexType istrip ) const {
190  return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
191  }
192 
203  const IndexType nCinL[12] = { 5,5,4, 5,5,0, 5,5,0, 5,5,0 };
204  return nCinL[(is-1)*3 + ir - 1];
205  }
206 
216 
217  // These are in the ranges 1-13608 (CSCs 2008) and 13609-15768 (ME42).
218  // There are 1-6804 chips per endcap (CSCs 2008) and 1080 channels per endcap (ME42).
219  // Start of -z channels (CSCs 2008) is 6804 + 1 = 6805
220  // Start of +z (ME42) is 13608 + 1 = 13609
221  // Start of -z (ME42) is 13608 + 1 + 1080 = 14689
222  const IndexType nStart[24] = {1, 1081, 2161, 3025, 3565, 0, 4645, 5185, 0, 6265, 13609,0,
223  6805, 7885, 8965, 9829, 10369,0, 11449, 11989, 0, 13069, 14689 ,0 };
224 
225  return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
226  }
227 
238  //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));
239  return chipStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*chipsPerLayer(is,ir) + (ichip-1);
240 
241  }
242 
252  IndexType chipIndex( const CSCDetId& id, IndexType ichip ) const {
253  return chipIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), ichip );
254  }
255 
266  IndexType chipIndex( IndexType istrip ) const {
267  return (istrip-1)/16+1;
268  }
269 
279  const IndexType nSinL[12] = { 1,3,3, 3,5,0, 3,5,0, 3,5,0 };
280  return nSinL[(is-1)*3 + ir - 1];
281  }
282 
292  return chipsPerLayer(is,ir)*hvSegmentsPerLayer(is,ir);
293  }
294 
304 
305  IndexType hvSegment = 1; // There is only one HV segment in ME1/1
306 
307  if (is > 2 && ir == 1) { // HV segments are the same in ME3/1 and ME4/1
308  if ( iwire >= 33 && iwire <= 64 ) { hvSegment = 2; }
309  else if ( iwire >= 65 && iwire <= 96 ) { hvSegment = 3; }
310 
311  } else if (is > 1 && ir == 2) { // HV segments are the same in ME2/2, ME3/2, and ME4/2
312  if ( iwire >= 17 && iwire <= 28 ) { hvSegment = 2; }
313  else if ( iwire >= 29 && iwire <= 40 ) { hvSegment = 3; }
314  else if ( iwire >= 41 && iwire <= 52 ) { hvSegment = 4; }
315  else if ( iwire >= 53 && iwire <= 64 ) { hvSegment = 5; }
316 
317  } else if (is == 1 && ir == 2) {
318  if ( iwire >= 25 && iwire <= 48 ) { hvSegment = 2; }
319  else if ( iwire >= 49 && iwire <= 64 ) { hvSegment = 3; }
320 
321  } else if (is == 1 && ir == 3) {
322  if ( iwire >= 13 && iwire <= 22 ) { hvSegment = 2; }
323  else if ( iwire >= 23 && iwire <= 32 ) { hvSegment = 3; }
324 
325  } else if (is == 2 && ir == 1) {
326  if ( iwire >= 45 && iwire <= 80 ) { hvSegment = 2; }
327  else if ( iwire >= 81 && iwire <= 112) { hvSegment = 3; }
328 
329  }
330 
331  return hvSegment;
332  }
333 
343  // There are 36 chambers * 6 layers * 5 CFEB's * 1 HV segment = 1080 gas-gain sectors in ME1/1
344  // There are 36*6*5*3 = 3240 gas-gain sectors in ME1/2
345  // There are 36*6*4*3 = 2592 gas-gain sectors in ME1/3
346  // There are 18*6*5*3 = 1620 gas-gain sectors in ME[2-4]/1
347  // There are 36*6*5*5 = 5400 gas-gain sectors in ME[2-4]/2
348  // Start of -z channels (CSCs 2008) is 22572 + 1 = 22573
349  // Start of +z (ME42) is 45144 + 1 = 45145
350  // Start of -z (ME42) is 45144 + 1 + 5400 = 50545
351  const IndexType nStart[24] = {1 ,1081 , 4321, //ME+1/1,ME+1/2,ME+1/3
352  6913 ,8533 , 0, //ME+2/1,ME+2/2,ME+2/3
353  13933,15553, 0, //ME+3/1,ME+3/2,ME+3/3
354  20953,45145, 0, //ME+4/1,ME+4/2,ME+4/3 (note, ME+4/2 index follows ME-4/1...)
355  22573,23653,26893, //ME-1/1,ME-1/2,ME-1/3
356  29485,31105 ,0, //ME-2/1,ME-2/2,ME-2/3
357  36505,38125, 0, //ME-3/1,ME-3/2,ME-3/3
358  43525,50545, 0}; //ME-4/1,ME-4/2,ME-4/3 (note, ME-4/2 index follows ME+4/2...)
359  return nStart[(ie-1)*12 + (is-1)*3 + ir - 1];
360  }
361 
370  IndexType gasGainIndex( const CSCDetId& id, IndexType istrip, IndexType iwire ) const {
371  return gasGainIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip, iwire);
372  }
373 
384  IndexType ichip = this->chipIndex(istrip);
385  IndexType ihvsegment = this->hvSegmentIndex(is,ir,iwire);
386  return sectorStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*sectorsPerLayer(is,ir) + (ihvsegment-1)*chipsPerLayer(is,ir) + (ichip-1);
387  }
388 
396  std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex( LongIndexType ichi ) const;
397  std::pair<CSCDetId, IndexType> detIdFromChipIndex( IndexType ichi ) const;
398 
399  IndexType chamberLabelFromChamberIndex( IndexType ) const; // just for cross-checks
400 
408  int dbIndex(const CSCDetId & id, int & channel);
409 
410 private:
411  void fillChamberLabel() const; // const so it can be called in const function detIdFromChamberIndex
412 
413  mutable std::vector<IndexType> chamberLabel; // mutable so can be filled by fillChamberLabel
414 
415 
416 };
417 
418 #endif
419 
420 
421 
422 
423 
424 
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:202
IndexType layerIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const
Definition: CSCIndexer.h:107
IndexType chamberIndex(const CSCDetId &id) const
Definition: CSCIndexer.h:66
void fillChamberLabel() const
Definition: CSCIndexer.cc:4
IndexType chambersInRingOfStation(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:127
IndexType hvSegmentIndex(IndexType is, IndexType ir, IndexType iwire) const
Definition: CSCIndexer.h:303
LongIndexType stripChannelIndex(const CSCDetId &id, IndexType istrip) const
Definition: CSCIndexer.h:189
IndexType ringsInStation(IndexType is) const
Definition: CSCIndexer.h:117
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:50
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:99
IndexType chipIndex(IndexType istrip) const
Definition: CSCIndexer.h:266
IndexType chipStart(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:215
CSCDetId detIdFromChamberLabel(IndexType ie, IndexType icl) const
Definition: CSCIndexer.cc:109
uint32_t LongIndexType
Definition: CSCIndexer.h:51
IndexType sectorsPerLayer(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:291
IndexType chipIndex(const CSCDetId &id, IndexType ichip) const
Definition: CSCIndexer.h:252
IndexType stripChannelsPerLayer(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:142
IndexType layerIndex(const CSCDetId &id) const
Definition: CSCIndexer.h:80
IndexType chipIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip) const
Definition: CSCIndexer.h:237
IndexType startChamberIndexInEndcap(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:88
std::vector< IndexType > chamberLabel
Definition: CSCIndexer.h:413
IndexType hvSegmentsPerLayer(IndexType is, IndexType ir) const
Definition: CSCIndexer.h:278
LongIndexType stripChannelStart(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:155
LongIndexType stripChannelIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip) const
Definition: CSCIndexer.h:176
IndexType gasGainIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip, IndexType iwire) const
Definition: CSCIndexer.h:383
CSCDetId detIdFromLayerIndex(IndexType ili) const
Definition: CSCIndexer.cc:120
IndexType gasGainIndex(const CSCDetId &id, IndexType istrip, IndexType iwire) const
Definition: CSCIndexer.h:370
IndexType sectorStart(IndexType ie, IndexType is, IndexType ir) const
Definition: CSCIndexer.h:342