CMS 3D CMS Logo

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

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripFedKey.h,v 1.14 2008/02/22 09:53:14 bainbrid Exp $
00002 
00003 #ifndef DataFormats_SiStripCommon_SiStripFedKey_H
00004 #define DataFormats_SiStripCommon_SiStripFedKey_H
00005 
00006 #include "DataFormats/SiStripCommon/interface/ConstantsForGranularity.h"
00007 #include "DataFormats/SiStripCommon/interface/SiStripKey.h"
00008 
00009 class SiStripFedKey;
00010 
00012 std::ostream& operator<< ( std::ostream&, const SiStripFedKey& );
00013 
00057 class SiStripFedKey : public SiStripKey {
00058   
00059  public:
00060   
00061   // ---------- Constructors ----------
00062   
00064   SiStripFedKey( const uint16_t& fed_id,
00065                  const uint16_t& fe_unit = 0,
00066                  const uint16_t& fe_chan = 0,
00067                  const uint16_t& fed_apv = 0 );
00068   
00070   SiStripFedKey( const uint32_t& fed_key );
00071   
00073   SiStripFedKey( const std::string& directory_path );
00074 
00076   SiStripFedKey( const SiStripFedKey& );
00077 
00079   SiStripFedKey( const SiStripKey& );
00080   
00082   SiStripFedKey();
00083   
00084   // ---------- Public interface to member data ----------
00085 
00087   inline const uint16_t& fedId() const;
00088 
00090   inline const uint16_t& feUnit() const;
00091 
00093   inline const uint16_t& feChan() const;
00094 
00096   inline const uint16_t& fedApv() const;
00097 
00099   inline uint16_t fedChannel() const;
00100 
00101   // ---------- Numbering schemes ---------- 
00102   
00105   static uint16_t fedCh( const uint16_t& fe_unit,
00106                          const uint16_t& fe_chan );
00107   
00110   static uint16_t feUnit( const uint16_t& fed_ch );
00111   
00114   static uint16_t feChan( const uint16_t& fed_ch );
00115   
00119   static uint32_t fedIndex( const uint16_t& fed_id,
00120                             const uint16_t& fed_ch );
00121   
00122   // ---------- Utility methods ---------- 
00123 
00125   bool isEqual( const SiStripKey& ) const;
00126   
00128   bool isConsistent( const SiStripKey& ) const;
00129 
00131   bool isValid() const;
00132   
00135   bool isValid( const sistrip::Granularity& ) const;
00136   
00138   bool isInvalid() const;
00139 
00142   bool isInvalid( const sistrip::Granularity& ) const;
00143 
00144   // ---------- Print methods ----------
00145   
00147   virtual void print( std::stringstream& ss ) const;
00148   
00150   virtual void terse( std::stringstream& ss ) const;
00151   
00152  private:
00153   
00154   // ---------- Private methods ----------
00155 
00156   void initFromValue();
00157   void initFromKey();
00158   void initFromPath();
00159   void initGranularity();
00160   
00161   // ---------- Private member data ----------
00162 
00164   uint16_t fedId_;  
00165 
00167   uint16_t feUnit_; 
00168 
00170   uint16_t feChan_; 
00171 
00173   uint16_t fedApv_; 
00174   
00175   // Definition of bit field positions for 32-bit key 
00176   static const uint16_t fedCrateOffset_ = 24;
00177   static const uint16_t fedSlotOffset_  = 19;
00178   static const uint16_t fedIdOffset_    = 10;
00179   static const uint16_t feUnitOffset_   =  6;
00180   static const uint16_t feChanOffset_   =  2;
00181   static const uint16_t fedApvOffset_   =  0;
00182 
00183   // Definition of bit field masks for 32-bit key 
00184   static const uint16_t fedCrateMask_ = 0x03F; // (6 bits)
00185   static const uint16_t fedSlotMask_  = 0x01F; // (5 bits)
00186   static const uint16_t fedIdMask_    = 0x1FF; // (9 bits)
00187   static const uint16_t feUnitMask_   = 0x00F; // (4 bits)
00188   static const uint16_t feChanMask_   = 0x00F; // (4 bits)
00189   static const uint16_t fedApvMask_   = 0x003; // (2 bits)
00190   
00191 };
00192 
00193 // ---------- Inline methods ----------
00194 
00195 const uint16_t& SiStripFedKey::fedId() const { return fedId_; }
00196 const uint16_t& SiStripFedKey::feUnit() const { return feUnit_; }
00197 const uint16_t& SiStripFedKey::feChan() const { return feChan_; }
00198 const uint16_t& SiStripFedKey::fedApv() const { return fedApv_; }
00199 uint16_t SiStripFedKey::fedChannel() const { return fedCh( feUnit_, feChan_ ); }
00200 
00201 #endif // DataFormats_SiStripCommon_SiStripFedKey_H
00202 
00203 
00204