CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DataFormats/SiStripCommon/interface/SiStripFecKey.h

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripFecKey.h,v 1.16 2008/02/21 16:51:55 bainbrid Exp $
00002 
00003 #ifndef DataFormats_SiStripCommon_SiStripFecKey_H
00004 #define DataFormats_SiStripCommon_SiStripFecKey_H
00005 
00006 #include "DataFormats/SiStripCommon/interface/ConstantsForGranularity.h"
00007 #include "DataFormats/SiStripCommon/interface/SiStripKey.h"
00008 
00046 class SiStripFecKey : public SiStripKey {
00047   
00048  public:
00049   
00050   // ---------- Constructors ----------
00051 
00053   SiStripFecKey( const uint16_t& fec_crate, 
00054                  const uint16_t& fec_slot = 0, 
00055                  const uint16_t& fec_ring = 0, 
00056                  const uint16_t& ccu_addr = 0, 
00057                  const uint16_t& ccu_chan = 0,
00058                  const uint16_t& lld_chan = 0,
00059                  const uint16_t& i2c_addr = 0 );
00060   
00062   SiStripFecKey( const uint32_t& fec_key );
00063   
00065   SiStripFecKey( const std::string& directory_path );
00066 
00068   SiStripFecKey( const SiStripFecKey& );
00069 
00071   SiStripFecKey( const SiStripKey& );
00072 
00074   SiStripFecKey( const SiStripKey&,
00075                  const sistrip::Granularity& );
00076 
00078   SiStripFecKey();
00079   
00080   // ---------- Control structure ----------
00081   
00083   inline const uint16_t& fecCrate() const;
00084   
00086   inline const uint16_t& fecSlot() const;
00087   
00089   inline const uint16_t& fecRing() const;
00090   
00092   inline const uint16_t& ccuAddr() const;
00093 
00095   inline const uint16_t& ccuChan() const;
00096 
00098   inline const uint16_t& lldChan() const;
00099 
00101   inline const uint16_t& i2cAddr() const;
00102 
00103   // ---------- Hybrid APV/LLD numbering scheme ---------- 
00104   
00106   static uint16_t hybridPos( const uint16_t& i2c_addr );
00107   
00109   static uint16_t i2cAddr( const uint16_t& hybrid_pos );
00110   
00112   static uint16_t lldChan( const uint16_t& i2c_addr );
00113   
00115   static bool firstApvOfPair( const uint16_t& i2c_addr );
00116   
00118   static uint16_t i2cAddr( const uint16_t& lld_chan,
00119                            const bool& first_apv_of_pair );
00120   
00121   // ---------- Utility methods ---------- 
00122   
00124   bool isEqual( const SiStripKey& ) const;
00125   
00127   bool isConsistent( const SiStripKey& ) const;
00128   
00130   bool isValid() const;
00131   
00134   bool isValid( const sistrip::Granularity& ) const;
00135   
00137   bool isInvalid() const;
00138 
00141   bool isInvalid( const sistrip::Granularity& ) const;
00142 
00143   // ---------- Print methods ----------
00144 
00146   virtual void print( std::stringstream& ss ) const;
00147 
00149   virtual void terse( std::stringstream& ss ) const;
00150   
00151  private:
00152   
00153   // ---------- Private methods ----------
00154   
00155   void initFromValue();
00156   void initFromKey();
00157   void initFromPath();
00158   void initGranularity();
00159   
00160   // ---------- Private member data ----------
00161 
00163   uint16_t fecCrate_;
00164 
00166   uint16_t fecSlot_;
00167 
00169   uint16_t fecRing_;
00170 
00172   uint16_t ccuAddr_;
00173 
00175   uint16_t ccuChan_;
00176 
00178   uint16_t lldChan_;
00179 
00181   uint16_t i2cAddr_;
00182   
00183   // Definition of bit field positions for 32-bit key 
00184   static const uint16_t fecCrateOffset_ = 27;
00185   static const uint16_t fecSlotOffset_  = 22;
00186   static const uint16_t fecRingOffset_  = 18;
00187   static const uint16_t ccuAddrOffset_  = 10;
00188   static const uint16_t ccuChanOffset_  =  5;
00189   static const uint16_t lldChanOffset_  =  2;
00190   static const uint16_t i2cAddrOffset_  =  0;
00191   
00192   // Definition of bit field masks for 32-bit key 
00193   static const uint16_t fecCrateMask_ = 0x07; // (3 bits)
00194   static const uint16_t fecSlotMask_  = 0x1F; // (5 bits)
00195   static const uint16_t fecRingMask_  = 0x0F; // (4 bits)
00196   static const uint16_t ccuAddrMask_  = 0xFF; // (8 bits)
00197   static const uint16_t ccuChanMask_  = 0x1F; // (5 bits)
00198   static const uint16_t lldChanMask_  = 0x07; // (3 bits)
00199   static const uint16_t i2cAddrMask_  = 0x03; // (2 bits)
00200   
00201 };
00202 
00203 // ---------- Inline methods ----------
00204 
00205 const uint16_t& SiStripFecKey::fecCrate() const { return fecCrate_; }
00206 const uint16_t& SiStripFecKey::fecSlot() const { return fecSlot_; }
00207 const uint16_t& SiStripFecKey::fecRing() const { return fecRing_; }
00208 const uint16_t& SiStripFecKey::ccuAddr() const { return ccuAddr_; }
00209 const uint16_t& SiStripFecKey::ccuChan() const { return ccuChan_; }
00210 const uint16_t& SiStripFecKey::lldChan() const { return lldChan_; }
00211 const uint16_t& SiStripFecKey::i2cAddr() const { return i2cAddr_; }
00212 
00213 /* const uint16_t& SiStripFecKey::fecCrate() const {  */
00214 /*   return ( key()>>fecCrateOffset_ ) & fecCrateMask_ != fecCrateMask_ ? ( key()>>fecCrateOffset_ ) & fecCrateMask_ : sistrip::invalid_;  */
00215 /* } */
00216 /* const uint16_t& SiStripFecKey::fecSlot() const {  */
00217 /*   return ( key()>>fecSlotOffset_ ) & fecSlotMask_ != fecSlotMask_ ? ( key()>>fecSlotOffset_ ) & fecSlotMask_ : sistrip::invalid_;  */
00218 /* } */
00219 /* const uint16_t& SiStripFecKey::fecRing() const {  */
00220 /*   return ( key()>>fecRingOffset_ ) & fecRingMask_ != fecRingMask_ ? ( key()>>fecRingOffset_ ) & fecRingMask_ : sistrip::invalid_;  */
00221 /* } */
00222 /* const uint16_t& SiStripFecKey::ccuAddr() const {  */
00223 /*   return ( key()>>ccuAddrOffset_ ) & ccuAddrMask_ != ccuAddrMask_ ? ( key()>>ccuAddrOffset_ ) & ccuAddrMask_ : sistrip::invalid_;  */
00224 /* } */
00225 /* const uint16_t& SiStripFecKey::ccuChan() const {  */
00226 /*   return ( key()>>ccuChanOffset_ ) & ccuChanMask_ != ccuChanMask_ ? ( key()>>ccuChanOffset_ ) & ccuChanMask_ : sistrip::invalid_;  */
00227 /* } */
00228 /* const uint16_t& SiStripFecKey::lldChan() const {  */
00229 /*   return ( key()>>lldChanOffset_ ) & lldChanMask_ != lldChanMask_ ? ( key()>>lldChanOffset_ ) & lldChanMask_ : sistrip::invalid_;  */
00230 /* } */
00231 /* const uint16_t& SiStripFecKey::i2cAddr() const {  */
00232 /*   return ( key()>>i2cAddrOffset_ ) & i2cAddrMask_ != i2cAddrMask_ ? ( key()>>i2cAddrOffset_ ) & i2cAddrMask_ : sistrip::invalid_;  */
00233 /* } */
00234 
00235 std::ostream& operator<< ( std::ostream&, const SiStripFecKey& );
00236 
00237 inline bool operator< ( const SiStripFecKey& a, const SiStripFecKey& b ) { return ( a.key() < b.key() ); }
00238 
00239 class ConsistentWithKey {
00240  public: 
00241   explicit ConsistentWithKey( const SiStripFecKey& key );
00242   bool operator() ( const uint32_t&, const uint32_t& ) const;
00243  private:
00244   explicit ConsistentWithKey();
00245   SiStripFecKey mask_;
00246 };
00247 
00248 #endif // DataFormats_SiStripCommon_SiStripFecKey_H