CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/CalibFormats/SiStripObjects/interface/SiStripModule.h

Go to the documentation of this file.
00001 // Last commit: $Id: SiStripModule.h,v 1.12 2008/02/06 16:40:42 bainbrid Exp $
00002 
00003 #ifndef CalibFormats_SiStripObjects_SiStripModule_H
00004 #define CalibFormats_SiStripObjects_SiStripModule_H
00005 
00006 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00007 #include "DataFormats/SiStripCommon/interface/SiStripFecKey.h"
00008 #include <boost/cstdint.hpp>
00009 #include <sstream>
00010 #include <ostream>
00011 #include <vector>
00012 #include <map>
00013 
00014 class SiStripModule;
00015 
00017 std::ostream& operator<< ( std::ostream&, const SiStripModule& );
00018 
00025 class SiStripModule {
00026   
00027  public: 
00028 
00029   // ---------- Constructors and adding devices ----------
00030   
00032   SiStripModule( const FedChannelConnection& conn );
00033   
00035   ~SiStripModule() {;}
00036   
00038   void addDevices( const FedChannelConnection& conn );
00039 
00040   // ---------- Typedefs and enums ----------
00041 
00043   typedef std::pair<uint16_t,uint16_t> PairOfU16;
00044   
00046   //typedef PairOfU16 FedChannel;
00047   class FedChannel {
00048   public:
00049     uint16_t fedCrate_;
00050     uint16_t fedSlot_;
00051     uint16_t fedId_;
00052     uint16_t fedCh_;
00053     FedChannel( const uint16_t& crate, const uint16_t& slot, const uint16_t& id, const uint16_t& ch ) : 
00054       fedCrate_(crate), fedSlot_(slot), fedId_(id), fedCh_(ch) {;}
00055     FedChannel() : fedCrate_(0), fedSlot_(0), fedId_(0), fedCh_(0) {;}
00056   };
00057   
00058   
00060   typedef std::map< uint16_t, FedChannel > FedCabling;
00061   
00062   // ---------- Control structure ----------
00063   
00064   inline const uint16_t& fecCrate() const;
00065   inline const uint16_t& fecSlot() const;
00066   inline const uint16_t& fecRing() const;
00067   inline const uint16_t& ccuAddr() const;
00068   inline const uint16_t& ccuChan() const;
00069   
00072   inline const SiStripFecKey& key() const;
00073   
00074   // ---------- APV devices ----------
00075   
00077   std::vector<uint16_t> activeApvs() const;
00078   
00082   const uint16_t& activeApv( const uint16_t& apv_address ) const;
00083   
00086   PairOfU16 activeApvPair( const uint16_t& lld_channel ) const;
00087 
00089   void addApv( const uint16_t& apv_address );
00090   
00091   // ---------- Other hybrid devices ----------
00092   
00094   inline const uint16_t& dcu() const;
00095   
00097   inline const uint16_t& mux() const;
00098   
00100   inline const uint16_t& pll() const;
00101   
00103   inline const uint16_t& lld() const;
00104 
00105   // ---------- Module information ----------
00106   
00108   inline const uint32_t& dcuId() const;
00109   
00111   uint16_t lldChannel( const uint16_t& apv_pair_num ) const;
00112   
00114   inline void dcuId( const uint32_t& dcu_id );
00115   
00116   // ---------- Detector information ----------
00117   
00119   inline const uint32_t& detId() const;
00120   
00122   uint16_t apvPairNumber( const uint16_t& lld_channel ) const;
00123   
00125   inline const uint16_t& nApvPairs() const;
00126   
00128   inline uint16_t nDetStrips() const;
00129   
00131   inline void detId( const uint32_t& det_id );
00132 
00134   void nApvPairs( const uint16_t& npairs );
00135   
00136   // ---------- FED connection information ----------
00137   
00139   inline const FedCabling& fedChannels() const;
00140   
00142   FedChannel fedCh( const uint16_t& apv_pair_num ) const;
00143   
00146   bool fedCh( const uint16_t& apv_address, 
00147               const FedChannel& fed_ch );
00148   
00149   // ---------- Miscellaneous ----------
00150 
00152   void print( std::stringstream& ) const; 
00153 
00155   void terse( std::stringstream& ) const; 
00156 
00158   inline const uint16_t& length() const;
00159   
00161   inline void length( const uint16_t& length );
00162 
00163  private: 
00164   
00166   SiStripFecKey key_;
00167   
00168   // APVs found (identified by decimal I2C address)  
00169   uint16_t apv32_;
00170   uint16_t apv33_;
00171   uint16_t apv34_;
00172   uint16_t apv35_;
00173   uint16_t apv36_;
00174   uint16_t apv37_;
00175   
00176   // Devices found (with hex addr)  
00177   uint16_t dcu0x00_;
00178   uint16_t mux0x43_;
00179   uint16_t pll0x44_;
00180   uint16_t lld0x60_;
00181   
00182   // Detector
00183   uint32_t dcuId_;
00184   uint32_t detId_;
00185   uint16_t nApvPairs_;
00186   
00188   FedCabling cabling_;
00189   uint16_t length_;
00190   
00191 };
00192 
00193 // --------------- inline methods ---------------
00194 
00195 const uint16_t& SiStripModule::fecCrate() const { return key_.fecCrate(); } 
00196 const uint16_t& SiStripModule::fecSlot() const { return key_.fecSlot(); } 
00197 const uint16_t& SiStripModule::fecRing() const { return key_.fecRing(); }
00198 const uint16_t& SiStripModule::ccuAddr() const { return key_.ccuAddr(); }
00199 const uint16_t& SiStripModule::ccuChan() const { return key_.ccuChan(); }
00200 
00201 const SiStripFecKey& SiStripModule::key() const { return key_; }
00202 
00203 const uint32_t& SiStripModule::dcuId() const { return dcuId_; } 
00204 const uint32_t& SiStripModule::detId() const { return detId_; } 
00205 const uint16_t& SiStripModule::nApvPairs() const { return nApvPairs_; }
00206 uint16_t SiStripModule::nDetStrips() const { return 256*nApvPairs_; }
00207 
00208 void SiStripModule::dcuId( const uint32_t& dcu_id ) { if ( dcu_id ) { dcuId_ = dcu_id; dcu0x00_ = true; } }
00209 void SiStripModule::detId( const uint32_t& det_id ) { if ( det_id ) { detId_ = det_id; } } 
00210 const SiStripModule::FedCabling& SiStripModule::fedChannels() const { return cabling_; } 
00211 
00212 const uint16_t& SiStripModule::length() const { return length_; } 
00213 void SiStripModule::length( const uint16_t& length ) { length_ = length; } 
00214 
00215 const uint16_t& SiStripModule::dcu() const { return dcu0x00_; } 
00216 const uint16_t& SiStripModule::mux() const { return mux0x43_; } 
00217 const uint16_t& SiStripModule::pll() const { return pll0x44_; } 
00218 const uint16_t& SiStripModule::lld() const { return lld0x60_; } 
00219 
00220 #endif // CalibTracker_SiStripObjects_SiStripModule_H
00221 
00222