CMS 3D CMS Logo

CSCIndexer Class Reference

Creates a linear index for various sublevels of the endcap muon CSC system. More...

#include <DataFormats/MuonDetId/interface/CSCIndexer.h>

List of all members.

Public Types

typedef uint16_t IndexType
typedef uint32_t LongIndexType

Public Member Functions

IndexType chamberIndex (IndexType ie, IndexType is, IndexType ir, IndexType ic) const
 Linear index for chamber 'ic' in ring 'ir' of station 'is' in endcap 'ie', in range 1-468 (CSCs 2008) or 469-540 (ME42).
IndexType chamberIndex (const CSCDetId &id) const
 Linear index to label each CSC in CSC system.
IndexType chamberLabelFromChamberIndex (IndexType) const
IndexType chambersInRingOfStation (IndexType is, IndexType ir) const
 How many chambers are there in ring ir of station is?
 CSCIndexer ()
int dbIndex (const CSCDetId &id, int &channel)
 Build index used internally in online CSC conditions databases (the 'Igor Index').
CSCDetId detIdFromChamberIndex (IndexType ici) const
CSCDetId detIdFromChamberIndex_OLD (IndexType ici) const
CSCDetId detIdFromChamberLabel (IndexType ie, IndexType icl) const
CSCDetId detIdFromLayerIndex (IndexType ili) const
 Decode CSCDetId from various indexes and labels.
std::pair< CSCDetId, IndexTypedetIdFromStripChannelIndex (LongIndexType ichi) const
IndexType layerIndex (IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const
 Linear index for layer 'il' of chamber 'ic' in ring 'ir' of station 'is' in endcap 'ie', in range 1-2808 (CSCs 2008) or 2809-3240 (ME42).
IndexType layerIndex (const CSCDetId &id) const
 Linear index to label each hardware layer in CSC system.
IndexType ringsInStation (IndexType is) const
 How many rings are there in station is=1, 2, 3, 4 ?
IndexType startChamberIndexInEndcap (IndexType ie, IndexType is, IndexType ir) const
 Starting index for first chamber in ring 'ir' of station 'is' in endcap 'ie', in range 1-468 (CSCs 2008) or 469-540 (ME42).
LongIndexType stripChannelIndex (const CSCDetId &id, IndexType istrip) const
 Linear index for strip channel 'istrip' in layer labelled by CSCDetId 'id'.
LongIndexType stripChannelIndex (IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip) const
 Linear index for strip channel istrip in layer 'il' of chamber 'ic' of ring 'ir' in station 'is' of endcap 'ie'.
IndexType stripChannelsPerLayer (IndexType is, IndexType ir) const
 Number of strip channels per layer in a chamber in ring ir of station is.
LongIndexType stripChannelStart (IndexType ie, IndexType is, IndexType ir) const
 Linear index for 1st strip channel in ring 'ir' of station 'is' in endcap 'ie'.
 ~CSCIndexer ()

Private Member Functions

void fillChamberLabel () const

Private Attributes

std::vector< IndexTypechamberLabel


Detailed Description

Creates a linear index for various sublevels of the endcap muon CSC system.

It supplies a linear index for: 1. Each chamber of the CSC system: range 1-468 (CSC system as installed 2008) 469-540 for ME42
2. Each layer of the CSC system: range 1-2808 (CSCs 2008) 2809-3240 for ME42
3. Each strip channel of the CSC system: range 1-217728 (CSCs 2008) 217729-252288 for ME42

The chamber and layer may be specified by CSCDetId or labels for endcap, station, ring, chamber, layer. The strip channel is a value 1-80 (or 64: ME13 chambers have only 64 channels.)

The main user interface is the set of functions
chamberIndex(.)
layerIndex(.)
stripChannelIndex(.)
But the other functions are public since they may be useful in contexts other than for Conditions Data for which the above functions are intended.

Warning:
This class is hard-wired for the CSC system at start-up of CMS in 2008. with rings ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41 totalling 234 chambers per endcap. But ME42 is appended (to permit simulation studies), so the chamber order is
+z ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41,
-z ME11, ME12, ME13, ME21, ME22, ME31, ME32, ME41,
+z ME42, -z ME42

This uses magic numbers galore!!

EVERY LABEL COUNTS FROM ONE NOT ZERO.

Definition at line 40 of file CSCIndexer.h.


Member Typedef Documentation

typedef uint16_t CSCIndexer::IndexType

Definition at line 46 of file CSCIndexer.h.

typedef uint32_t CSCIndexer::LongIndexType

Definition at line 47 of file CSCIndexer.h.


Constructor & Destructor Documentation

CSCIndexer::CSCIndexer (  )  [inline]

Definition at line 49 of file CSCIndexer.h.

00049 {};

CSCIndexer::~CSCIndexer (  )  [inline]

Definition at line 50 of file CSCIndexer.h.

00050 {};


Member Function Documentation

IndexType CSCIndexer::chamberIndex ( IndexType  ie,
IndexType  is,
IndexType  ir,
IndexType  ic 
) const [inline]

Linear index for chamber 'ic' in ring 'ir' of station 'is' in endcap 'ie', in range 1-468 (CSCs 2008) or 469-540 (ME42).

Definition at line 95 of file CSCIndexer.h.

References startChamberIndexInEndcap().

00095                                                                                         {
00096      return startChamberIndexInEndcap(ie,is,ir) + ic - 1; // -1 so start index _is_ ic=1
00097    }

IndexType CSCIndexer::chamberIndex ( const CSCDetId id  )  const [inline]

Linear index to label each CSC in CSC system.

Argument is the CSCDetId of some CSCChamber.

Output is 1-468 (CSCs 2008) 469-540 (ME42)

WARNING: Do not input ME1a values (i.e. ring '4'): does not consider ME1a and ME1b to be separate, No sanity checking on input value: if you supply an ME1a CSCDetId then you'll get nonsense.

Definition at line 62 of file CSCIndexer.h.

References GeomDetEnumerators::endcap.

Referenced by CSCConditions::isInBadChamber(), and layerIndex().

00062                                                       {
00063      return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
00064    }

CSCIndexer::IndexType CSCIndexer::chamberLabelFromChamberIndex ( IndexType  ici  )  const

Definition at line 86 of file CSCIndexer.cc.

References chamberLabel, and fillChamberLabel().

00086                                                                                   {
00087   // This is just for cross-checking
00088 
00089   // Expected range of input range argument is 1-540.
00090   // 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
00091 
00092   if ( ici > 468 ) {
00093     // ME42
00094     ici -= 234; // now in range 235-306
00095     if ( ici > 270 ) { // -z
00096       ici -= 36; // now in range 235-270
00097     }
00098   }
00099   else { // in range 1-468
00100     if ( ici > 234 ) { // -z
00101       ici -= 234; // now in range 1-234
00102     }
00103   }
00104   if (chamberLabel.empty()) fillChamberLabel();
00105   return chamberLabel[ici];  
00106 
00107 }

IndexType CSCIndexer::chambersInRingOfStation ( IndexType  is,
IndexType  ir 
) const [inline]

How many chambers are there in ring ir of station is?

Works for ME1a (ring 4 of ME1) too.

Definition at line 123 of file CSCIndexer.h.

Referenced by fillChamberLabel().

00123                                                                        {
00124       IndexType nc = 36; // most rings have 36 chambers
00125       if (is >1 && ir<2 ) nc = 18; // but 21, 31, 41 have 18
00126       return nc;
00127    }

int CSCIndexer::dbIndex ( const CSCDetId id,
int channel 
)

Build index used internally in online CSC conditions databases (the 'Igor Index').

This is the decimal integer ie*100000 + is*10000 + ir*1000 + ic*10 + il
(ie=1-2, is=1-4, ir=1-4, ic=1-36, il=1-6)
Channels 1-16 in ME1A (is=1, ir=4) are reset to channels 65-80 of ME11.

Definition at line 184 of file CSCIndexer.cc.

References st.

Referenced by CSCValidation::doADCTiming(), CSCValidation::doAFEBTiming(), CSCValidation::doCompTiming(), CSCValidation::doGasGain(), CSCPedestals::item(), CSCGains::item(), CSCNoiseMatrix::item(), and CSCcrosstalk::item().

00185 {
00186   int ec = id.endcap();
00187   int st = id.station();
00188   int rg = id.ring();
00189   int ch = id.chamber();
00190   int la = id.layer();
00191 
00192   // The channels of ME1A are channels 65-80 of ME11
00193   if(st == 1 && rg == 4)
00194     {
00195       rg = 1;
00196       if(channel <= 16) channel += 64; // no trapping for any bizarreness
00197     }
00198   return ec*100000 + st*10000 + rg*1000 + ch*10 + la;
00199 }

CSCDetId CSCIndexer::detIdFromChamberIndex ( IndexType  ici  )  const

Definition at line 62 of file CSCIndexer.cc.

References chamberLabel, detIdFromChamberLabel(), fillChamberLabel(), and label.

Referenced by detIdFromLayerIndex(), CSCConditions::fillBadStripWords(), and CSCConditions::fillBadWireWords().

00062                                                                 {
00063   // Expected range of input range argument is 1-540.
00064   // 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
00065 
00066   IndexType ie = 1;
00067   if ( ici > 468 ) {
00068     // ME42
00069     ici -= 234; // now in range 235-306
00070     if ( ici > 270 ) { // -z
00071       ie = 2;
00072       ici -= 36; // now in range 235-270
00073     }
00074   }
00075   else { // in range 1-468
00076     if ( ici > 234 ) { // -z
00077       ie = 2;
00078       ici -= 234; // now in range 1-234
00079     }
00080   }
00081   if (chamberLabel.empty()) fillChamberLabel();
00082   IndexType label = chamberLabel[ici];    
00083   return detIdFromChamberLabel( ie, label );
00084 }

CSCDetId CSCIndexer::detIdFromChamberIndex_OLD ( IndexType  ici  )  const

Definition at line 24 of file CSCIndexer.cc.

References i, and startChamberIndexInEndcap().

00024                                                                     {
00025 
00026   // Will not work as is for ME42
00027   // ============================
00028 
00029   IndexType ie = 1;
00030   if (ici > 234 ) {
00031      ie = 2;
00032      ici -= 234; 
00033   }
00034   // Now ici is in range 1-234 (assuming valid input in range 1-468)
00035 
00036   // MEij pairs...
00037   const IndexType station[] = {0,1,1,1,2,2,3,3,4};
00038   const IndexType ring[]    = {0,1,2,3,1,2,1,2,1};
00039 
00040   // MEij preceding a given MEij matching linear index above
00041   const IndexType prevs[] =  {0,0,1,1,1,2,2,3,3}; 
00042   const IndexType prevr[] =  {0,0,1,2,3,1,2,1,2};
00043 
00044   IndexType is = 4;
00045   IndexType ir = 1;
00046   for ( IndexType i = 2; i<=8; ++i) {
00047     IndexType js = station[i];
00048     IndexType jr = ring[i];
00049     // if it's before start of MEjs/jr then it's in the previous MEis/ir
00050       if ( ici < startChamberIndexInEndcap(ie,js,jr) ) {
00051         is = prevs[i];
00052         ir = prevr[i];
00053         break;
00054       }
00055       // otherwise it's in ME41
00056   }
00057   IndexType ic = ici - startChamberIndexInEndcap(ie,is,ir) + 1;
00058 
00059   return CSCDetId( ie, is, ir, ic );
00060 }

CSCDetId CSCIndexer::detIdFromChamberLabel ( IndexType  ie,
IndexType  icl 
) const

Definition at line 109 of file CSCIndexer.cc.

Referenced by detIdFromChamberIndex().

00109                                                                                 {
00110 
00111   IndexType is = label/1000;
00112   label -= is*1000;
00113   IndexType ir = label/100;
00114   label -= ir*100;
00115   IndexType ic = label;
00116 
00117   return CSCDetId( ie, is, ir, ic );
00118 }

CSCDetId CSCIndexer::detIdFromLayerIndex ( IndexType  ili  )  const

Decode CSCDetId from various indexes and labels.

Definition at line 120 of file CSCIndexer.cc.

References detIdFromChamberIndex(), and GeomDetEnumerators::endcap.

Referenced by detIdFromStripChannelIndex().

00120                                                               {
00121 
00122   IndexType il = (ili-1)%6 + 1;
00123   IndexType ici = (ili-1)/6 + 1;
00124   CSCDetId id = detIdFromChamberIndex( ici ); 
00125 
00126   return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), il);
00127 }

std::pair< CSCDetId, CSCIndexer::IndexType > CSCIndexer::detIdFromStripChannelIndex ( LongIndexType  ichi  )  const

Definition at line 129 of file CSCIndexer.cc.

References detIdFromLayerIndex().

Referenced by operator<<().

00129                                                                                                         {
00130 
00131   const LongIndexType lastnonme42 = 217728; // channels in 2008 installed chambers
00132   const LongIndexType lastplusznonme42 = 108864; // = 217728/2
00133   const LongIndexType firstme13  = 34561; // First channel of ME13
00134   const LongIndexType lastme13   = 48384; // Last channel of ME13
00135 
00136   const IndexType lastnonme42layer = 2808;
00137   const IndexType lastplusznonme42layer = 1404; // = 2808/2
00138   const IndexType firstme13layer  = 433; // = 72*6 + 1 (ME13 chambers are 72-108 in range 1-234)
00139   const IndexType lastme13layer   = 648; // = 108*6
00140 
00141   // All chambers but ME13 have 80 channels
00142   IndexType nchan = 80;
00143 
00144   // Set endcap to +z. This should work for ME42 channels too, since we don't need to calculate its endcap explicitly.
00145   IndexType ie = 1;
00146 
00147   LongIndexType istart = 0;
00148   IndexType layerOffset = 0;
00149 
00150   if ( isi <= lastnonme42 ) {   
00151     // Chambers as of 2008 Installation
00152 
00153     if ( isi > lastplusznonme42 ) {
00154       ie = 2;
00155       isi -= lastplusznonme42;
00156     }
00157         
00158     if ( isi > lastme13 ) { // after ME13
00159       istart = lastme13;
00160       layerOffset = lastme13layer;
00161     }
00162     else if ( isi >= firstme13 ) { // ME13
00163       istart = firstme13 - 1;
00164       layerOffset = firstme13layer - 1;
00165       nchan = 64;
00166     }
00167   }
00168   else {
00169      // ME42 chambers
00170 
00171     istart = lastnonme42;
00172     layerOffset = lastnonme42layer;
00173   }
00174 
00175    isi -= istart; // remove earlier group(s)
00176    IndexType ichan = (isi-1)%nchan + 1;
00177    IndexType ili = (isi-1)/nchan + 1;
00178    ili += layerOffset; // add appropriate offset for earlier group(s)
00179    if ( ie != 1 ) ili+= lastplusznonme42layer; // add offset to -z endcap; ME42 doesn't need this.
00180         
00181    return std::pair<CSCDetId, IndexType>(detIdFromLayerIndex(ili), ichan);
00182 }

void CSCIndexer::fillChamberLabel (  )  const [private]

Definition at line 4 of file CSCIndexer.cc.

References chamberLabel, chambersInRingOfStation(), count, and ringsInStation().

Referenced by chamberLabelFromChamberIndex(), and detIdFromChamberIndex().

00004                                         {
00005   // Fill the member vector which permits decoding of the linear chamber index
00006   // Logically const since initializes cache only,
00007   // Beware that the ME42 indices 235-270 within this vector do NOT correspond to
00008   // their 'real' linear indices (which are 469-504 for +z)
00009    chamberLabel.resize( 271 ); // one more than #chambers per endcap. Includes ME42.
00010    IndexType count = 0;
00011    chamberLabel[count] = 0;
00012 
00013    for ( IndexType is = 1 ; is != 5; ++is ) {
00014       IndexType irmax = ringsInStation(is);
00015       for ( IndexType ir = 1; ir != irmax+1; ++ir ) {
00016          IndexType icmax = chambersInRingOfStation(is, ir);
00017          for ( IndexType ic = 1; ic != icmax+1; ++ic ) {
00018            chamberLabel[ ++count ] = is*1000 + ir*100 + ic ;
00019          }
00020       } 
00021    }
00022 }

IndexType CSCIndexer::layerIndex ( IndexType  ie,
IndexType  is,
IndexType  ir,
IndexType  ic,
IndexType  il 
) const [inline]

Linear index for layer 'il' of chamber 'ic' in ring 'ir' of station 'is' in endcap 'ie', in range 1-2808 (CSCs 2008) or 2809-3240 (ME42).

Definition at line 103 of file CSCIndexer.h.

References chamberIndex().

00103                                                                                                     {
00104     const IndexType layersInChamber = 6;
00105      return (chamberIndex(ie,is,ir,ic) - 1 ) * layersInChamber + il;
00106    }

IndexType CSCIndexer::layerIndex ( const CSCDetId id  )  const [inline]

Linear index to label each hardware layer in CSC system.

Argument is the CSCDetId of some CSCLayer.

Output is 1-2808 (CSCs 2008) 2809-3240 (ME42)

WARNING: Do not input ME1a values (i.e. ring '4'): does not consider ME1a and ME1b to be separate, No sanity checking on input value: if you supply an ME1a CSCDetId then you'll get nonsense.

Definition at line 76 of file CSCIndexer.h.

References GeomDetEnumerators::endcap.

Referenced by CSCConditions::badStripWord(), CSCConditions::badWireWord(), CSCConditions::fillBadStripWords(), and CSCConditions::fillBadWireWords().

00076                                                     {
00077      return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
00078    }

IndexType CSCIndexer::ringsInStation ( IndexType  is  )  const [inline]

How many rings are there in station is=1, 2, 3, 4 ?

BEWARE! Includes ME42 so claims 2 rings in station 4. There is only 1 at CSC installation 2008.

Definition at line 113 of file CSCIndexer.h.

Referenced by fillChamberLabel().

00113                                                   {
00114       const IndexType nrins[5] = {0,3,2,2,2}; // rings per station
00115       return nrins[is];
00116    }

IndexType CSCIndexer::startChamberIndexInEndcap ( IndexType  ie,
IndexType  is,
IndexType  ir 
) const [inline]

Starting index for first chamber in ring 'ir' of station 'is' in endcap 'ie', in range 1-468 (CSCs 2008) or 469-540 (ME42).

Definition at line 84 of file CSCIndexer.h.

Referenced by chamberIndex(), and detIdFromChamberIndex_OLD().

00084                                                                                        {
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    }

LongIndexType CSCIndexer::stripChannelIndex ( const CSCDetId id,
IndexType  istrip 
) const [inline]

Linear index for strip channel 'istrip' in layer labelled by CSCDetId 'id'.

Output is 1-217728 (CSCs 2008) or 217729-252288 (ME42).

WARNING: Use at your own risk! The supplied CSCDetId must be a layer id. No trapping on out-of-range values!

Definition at line 185 of file CSCIndexer.h.

References GeomDetEnumerators::endcap, and stripChannelIndex().

00185                                                                                  {
00186       return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
00187    }

LongIndexType CSCIndexer::stripChannelIndex ( IndexType  ie,
IndexType  is,
IndexType  ir,
IndexType  ic,
IndexType  il,
IndexType  istrip 
) const [inline]

Linear index for strip channel istrip in layer 'il' of chamber 'ic' of ring 'ir' in station 'is' of endcap 'ie'.

Output is 1-217728 (CSCs 2008) or 217729-252288 (ME42).

WARNING: Use at your own risk! You must input labels within hardware ranges. No trapping on out-of-range values!

Definition at line 172 of file CSCIndexer.h.

References stripChannelsPerLayer(), and stripChannelStart().

Referenced by CSCDBCrosstalk::item(), CSCDBPedestals::item(), CSCDBGains::item(), CSCDBNoiseMatrix::item(), and stripChannelIndex().

00172                                                                                                                                    {
00173       return stripChannelStart(ie,is,ir)+( (ic-1)*6 + il - 1 )*stripChannelsPerLayer(is,ir) + (istrip-1);
00174    }

IndexType CSCIndexer::stripChannelsPerLayer ( IndexType  is,
IndexType  ir 
) const [inline]

Number of strip channels per layer in a chamber in ring ir of station is.

Station label range 1-4, Ring label range 1-3.

WARNING: ME1a channels are the last 16 of the 80 total in each layer of an ME11 chamber, and an input ir=4 is invalid and will give nonsense.
Considers ME42 as standard 80-strip per layer chambers.

Definition at line 138 of file CSCIndexer.h.

Referenced by stripChannelIndex().

00138                                                                        {
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    }

LongIndexType CSCIndexer::stripChannelStart ( IndexType  ie,
IndexType  is,
IndexType  ir 
) const [inline]

Linear index for 1st strip channel in ring 'ir' of station 'is' in endcap 'ie'.

Endcap label range 1-2, Station label range 1-4, Ring label range 1-3.

WARNING: ME1a channels are the last 16 of the 80 total in each layer of an ME11 chamber, and an input ir=4 is invalid and will give nonsense.

Definition at line 151 of file CSCIndexer.h.

Referenced by stripChannelIndex().

00151                                                                                      {
00152 
00153      // These are in the ranges 1-217728 (CSCs 2008) and 217729-252288 (ME42).
00154      // There are 1-108884 channels per endcap (CSCs 2008) and 17280 channels per endcap (ME42).
00155      // Start of -z channels (CSCs 2008) is 108864 + 1 = 108865
00156      // Start of +z (ME42) is 217728 + 1 = 217729
00157      // Start of -z (ME42) is 217728 + 1 + 17280 = 235009
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    }


Member Data Documentation

std::vector<IndexType> CSCIndexer::chamberLabel [mutable, private]

Definition at line 212 of file CSCIndexer.h.

Referenced by chamberLabelFromChamberIndex(), detIdFromChamberIndex(), and fillChamberLabel().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:17:21 2009 for CMSSW by  doxygen 1.5.4