CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/CalibMuon/CSCCalibration/interface/CSCIndexerBase.h

Go to the documentation of this file.
00001 #ifndef CSCIndexerBase_H
00002 #define CSCIndexerBase_H
00003 
00050 #include <DataFormats/MuonDetId/interface/CSCDetId.h>
00051 #include <vector>
00052 #include <utility>  // for pair
00053 #include <boost/tuple/tuple.hpp>
00054 
00055 class CSCIndexerBase
00056 {
00057 public:
00058 
00059   typedef uint16_t IndexType;
00060   typedef uint32_t LongIndexType;
00061   typedef boost::tuple<CSCDetId,  // id
00062                        IndexType, // HV segment
00063                        IndexType  // chip
00064                       > GasGainIndexType;
00065 
00066   CSCIndexerBase();
00067   virtual ~CSCIndexerBase();
00068 
00069   virtual std::string name() const { return "CSCIndexerBase"; }
00070 
00078   IndexType maxChamberIndex() const          { return 540; }
00079   IndexType maxLayerIndex() const            { return 3240; }
00080   virtual LongIndexType maxStripChannelIndex() const = 0;
00081   virtual IndexType maxChipIndex() const = 0;
00082   virtual IndexType maxGasGainIndex() const = 0;
00084 
00085 
00087 
00088 
00091   IndexType ringsInStation( IndexType is ) const
00092   {
00093     const IndexType nrins[5] = {0, 3, 2, 2, 2}; // physical rings per station
00094     return nrins[is];
00095   }
00096 
00100   virtual IndexType onlineRingsInStation( IndexType is ) const = 0;
00101 
00108   IndexType offlineRingsInStation( IndexType is ) const
00109   {
00110     const IndexType nrings[5] = { 0, 4, 2, 2, 2 }; // offline rings per station
00111     return nrings[is];
00112   }
00113 
00118   IndexType chambersInRingOfStation(IndexType is, IndexType ir) const
00119   {
00120     const IndexType nCinR[16] = { 36,36,36,36,  18,36,0,0,  18,36,0,0,  18,36,0,0 }; // chambers in ring
00121     return nCinR[(is - 1)*4 + ir - 1];
00122   }
00123 
00129   virtual IndexType stripChannelsPerOfflineLayer( IndexType is, IndexType ir ) const = 0;
00130 
00136   virtual IndexType stripChannelsPerOnlineLayer( IndexType is, IndexType ir ) const = 0;
00137 
00143   virtual IndexType chipsPerOnlineLayer( IndexType is, IndexType ir ) const = 0;
00144 
00153   IndexType sectorsPerOnlineLayer( IndexType is, IndexType ir ) const
00154   {
00155     return chipsPerOnlineLayer(is, ir) * hvSegmentsPerLayer(is, ir);
00156   }
00157 
00159 
00160 
00162 
00163 
00170   IndexType startChamberIndexInEndcap(IndexType ie, IndexType is, IndexType ir) const
00171   {
00172     const IndexType nschin[32] =
00173       { 1,37,73,1,        109,127,0,0,  163,181,0,0,  217,469,0,0,
00174         235,271,307,235,  343,361,0,0,  397,415,0,0,  451,505,0,0 };
00175     return nschin[(ie - 1)*16 + (is - 1)*4 + ir - 1];
00176   }
00177 
00186   IndexType chamberIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic) const
00187   {
00188     return startChamberIndexInEndcap(ie, is, ir) + ic - 1; // -1 so start index _is_ ic=1
00189   }
00190 
00201   IndexType chamberIndex( const CSCDetId& id ) const
00202   {
00203     return chamberIndex( id.endcap(), id.station(), id.ring(), id.chamber() );
00204   }
00206 
00207 
00209 
00210 
00218   IndexType layerIndex(IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il) const
00219   {
00220     const IndexType layersInChamber = 6;
00221     return (chamberIndex(ie, is, ir, ic) - 1 ) * layersInChamber + il;
00222   }
00223 
00234   IndexType layerIndex(const CSCDetId& id) const
00235   {
00236     return layerIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer());
00237   }
00239 
00240 
00242 
00243 
00258   virtual IndexType stripChannelsPerLayer( IndexType is, IndexType ir ) const = 0;
00259 
00265   virtual LongIndexType stripChannelStart( IndexType ie, IndexType is, IndexType ir ) const = 0;
00266 
00273   LongIndexType stripChannelIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType istrip ) const
00274   {
00275     return stripChannelStart(ie, is, ir)
00276            + ( (ic - 1)*6 + il - 1 ) * stripChannelsPerLayer(is, ir)
00277            + (istrip - 1);
00278   }
00279 
00285   LongIndexType stripChannelIndex( const CSCDetId& id, IndexType istrip ) const
00286   {
00287     return stripChannelIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), istrip );
00288   }
00290 
00291 
00293 
00294 
00299   virtual IndexType chipsPerLayer( IndexType is, IndexType ir ) const = 0;
00300 
00306   virtual IndexType chipStart( IndexType ie, IndexType is, IndexType ir ) const = 0;
00307 
00316   IndexType chipIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il, IndexType ichip ) const
00317   {
00318     return chipStart(ie, is, ir)
00319            + ( (ic - 1)*6 + il - 1 ) * chipsPerLayer(is, ir)
00320            + (ichip - 1);
00321   }
00322 
00331   IndexType chipIndex( const CSCDetId& id, IndexType ichip ) const
00332   {
00333     return chipIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), ichip );
00334   }
00335 
00344   IndexType chipIndex( IndexType istrip ) const
00345   {
00346     return (istrip - 1)/16 + 1;
00347   }
00349 
00350 
00352 
00353 
00360   IndexType hvSegmentsPerLayer( IndexType is, IndexType ir ) const
00361   {
00362     const IndexType nSinL[16] = { 1,3,3,1, 3,5,0,0, 3,5,0,0, 3,5,0,0 };
00363     return nSinL[(is - 1) * 4 + ir - 1];
00364   }
00365 
00374   IndexType hvSegmentIndex(IndexType is, IndexType ir, IndexType iwire ) const;
00375 
00383   IndexType sectorsPerLayer( IndexType is, IndexType ir ) const
00384   {
00385     return chipsPerLayer(is, ir) * hvSegmentsPerLayer(is, ir);
00386   }
00387 
00399   virtual IndexType sectorStart( IndexType ie, IndexType is, IndexType ir ) const = 0;
00400 
00411   IndexType gasGainIndex( IndexType ie, IndexType is, IndexType ir, IndexType ic, IndexType il,
00412                           IndexType ihvsegment, IndexType ichip ) const
00413   {
00414     return sectorStart(ie,is,ir)
00415            + ( (ic-1)*6 + il - 1 ) * sectorsPerLayer(is,ir)
00416            + (ihvsegment - 1) * chipsPerLayer(is,ir)
00417            + (ichip - 1);
00418   }
00419 
00428   IndexType gasGainIndex( const CSCDetId& id, IndexType istrip, IndexType iwire ) const
00429   {
00430     return gasGainIndex( id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(),
00431                          hvSegmentIndex( id.station(), id.ring(), iwire ),
00432                          chipIndex(istrip) );
00433   }
00434 
00447   IndexType gasGainIndex( IndexType ihvsegment, IndexType ichip, const CSCDetId& id ) const
00448   {
00449     return gasGainIndex(id.endcap(), id.station(), id.ring(), id.chamber(), id.layer(), ihvsegment, ichip);
00450   }
00452 
00453 
00456 
00457 
00462   CSCDetId detIdFromChamberIndex( IndexType ici ) const;
00463 
00469   CSCDetId detIdFromLayerIndex( IndexType ili ) const;
00470 
00478   virtual std::pair<CSCDetId, IndexType> detIdFromStripChannelIndex( LongIndexType ichi ) const = 0;
00479 
00487   virtual std::pair<CSCDetId, IndexType> detIdFromChipIndex( IndexType ichi ) const = 0;
00488 
00496   virtual GasGainIndexType detIdFromGasGainIndex( IndexType igg ) const = 0;
00497 
00499 
00500 
00509   virtual int dbIndex(const CSCDetId & id, int & channel) const = 0;
00510 
00511 
00516   IndexType chamberLabelFromChamberIndex( IndexType ) const;
00517 
00518 protected:
00519 
00524   CSCDetId detIdFromChamberLabel( IndexType ie, IndexType icl ) const;
00525 
00530   std::vector<IndexType> chamberLabel_;
00531 };
00532 
00533 #endif