CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/CalibMuon/CSCCalibration/src/CSCIndexerBase.cc

Go to the documentation of this file.
00001 #include "CalibMuon/CSCCalibration/interface/CSCIndexerBase.h"
00002 
00003 CSCIndexerBase::CSCIndexerBase()
00004 : chamberLabel_(271) // # of physical chambers per endcap + 1. Includes ME42.
00005 {
00006   // Fill the member vector which permits decoding of the linear chamber index.
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   IndexType count = 0;
00010   chamberLabel_[count] = 0;
00011 
00012   for ( IndexType is = 1 ; is <= 4; ++is )
00013   {
00014     IndexType irmax = ringsInStation(is);
00015     for ( IndexType ir = 1; ir <= irmax; ++ir )
00016     {
00017       IndexType icmax = chambersInRingOfStation(is, ir);
00018       for ( IndexType ic = 1; ic <= icmax; ++ic )
00019       {
00020         chamberLabel_[ ++count ] = is*1000 + ir*100 + ic ;
00021       }
00022     }
00023   }
00024 }
00025 
00026 
00027 CSCIndexerBase::~CSCIndexerBase() {}
00028 
00029 
00030 CSCIndexerBase::IndexType CSCIndexerBase::chamberLabelFromChamberIndex( IndexType ici ) const
00031 {
00032   // This is just for cross-checking
00033 
00034   // Expected range of input range argument is 1-540.
00035   // 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
00036 
00037   if ( ici > 468 )
00038   {
00039     // ME42
00040     ici -= 234; // now in range 235-306
00041     if ( ici > 270 ) // -z
00042     {
00043       ici -= 36; // now in range 235-270
00044     }
00045   }
00046   else // in range 1-468
00047   {
00048     if ( ici > 234 ) // -z
00049     {
00050       ici -= 234; // now in range 1-234
00051     }
00052   }
00053   return chamberLabel_[ici];
00054 }
00055 
00056 
00057 CSCIndexerBase::IndexType CSCIndexerBase::hvSegmentIndex(IndexType is, IndexType ir, IndexType iwire ) const
00058 {
00059   IndexType hvSegment = 1;   // There is only one HV segment in ME1/1
00060 
00061   if (is > 2 && ir == 1)        // HV segments are the same in ME3/1 and ME4/1
00062   {
00063     if      ( iwire >= 33 && iwire <= 64 ) { hvSegment = 2; }
00064     else if ( iwire >= 65 && iwire <= 96 ) { hvSegment = 3; }
00065   }
00066   else if (is > 1 && ir == 2) // HV segments are the same in ME2/2, ME3/2, and ME4/2
00067   {
00068     if      ( iwire >= 17 && iwire <= 28 ) { hvSegment = 2; }
00069     else if ( iwire >= 29 && iwire <= 40 ) { hvSegment = 3; }
00070     else if ( iwire >= 41 && iwire <= 52 ) { hvSegment = 4; }
00071     else if ( iwire >= 53 && iwire <= 64 ) { hvSegment = 5; }
00072   }
00073   else if (is == 1 && ir == 2)
00074   {
00075     if      ( iwire >= 25 && iwire <= 48 ) { hvSegment = 2; }
00076     else if ( iwire >= 49 && iwire <= 64 ) { hvSegment = 3; }
00077   }
00078   else if (is == 1 && ir == 3)
00079   {
00080     if      ( iwire >= 13 && iwire <= 22 ) { hvSegment = 2; }
00081     else if ( iwire >= 23 && iwire <= 32 ) { hvSegment = 3; }
00082   }
00083   else if (is == 2 && ir == 1)
00084   {
00085     if      ( iwire >= 45 && iwire <= 80 ) { hvSegment = 2; }
00086     else if ( iwire >= 81 && iwire <= 112) { hvSegment = 3; }
00087   }
00088   return hvSegment;
00089 }
00090 
00091 
00092 CSCDetId CSCIndexerBase::detIdFromChamberLabel( IndexType ie, IndexType label ) const
00093 {
00094   IndexType is = label/1000;
00095   label -= is*1000;
00096   IndexType ir = label/100;
00097   label -= ir*100;
00098   IndexType ic = label;
00099 
00100   return CSCDetId( ie, is, ir, ic );
00101 }
00102 
00103 
00104 CSCDetId CSCIndexerBase::detIdFromChamberIndex( IndexType ici ) const
00105 {
00106   // Expected range of input range argument is 1-540.
00107   // 1-468 for CSCs installed at 2008 start-up. 469-540 for ME42.
00108 
00109   IndexType ie = 1;
00110   if ( ici > 468 )
00111   {
00112     // ME42
00113     ici -= 234; // now in range 235-306
00114     if ( ici > 270 ) // -z
00115     {
00116       ie = 2;
00117       ici -= 36; // now in range 235-270
00118     }
00119   }
00120   else // in range 1-468
00121   {
00122     if ( ici > 234 ) // -z
00123     {
00124       ie = 2;
00125       ici -= 234; // now in range 1-234
00126     }
00127   }
00128 
00129   IndexType label = chamberLabel_[ici];
00130   return detIdFromChamberLabel( ie, label );
00131 }
00132 
00133 
00134 CSCDetId CSCIndexerBase::detIdFromLayerIndex( IndexType ili ) const
00135 {
00136   IndexType il = (ili - 1)%6 + 1;
00137   IndexType ici = (ili - 1)/6 + 1;
00138   CSCDetId id = detIdFromChamberIndex( ici );
00139 
00140   return CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), il);
00141 }