CMS 3D CMS Logo

FedChannelConnection.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiStripObjects/interface/FedChannelConnection.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripFedKey.h"
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include <iomanip>
00005 #include <string>
00006 
00007 using namespace sistrip;
00008 
00009 // -----------------------------------------------------------------------------
00010 // 
00011 FedChannelConnection::FedChannelConnection( const uint16_t& fec_crate, 
00012                                             const uint16_t& fec_slot, 
00013                                             const uint16_t& fec_ring, 
00014                                             const uint16_t& ccu_addr, 
00015                                             const uint16_t& ccu_chan, 
00016                                             const uint16_t& apv0,
00017                                             const uint16_t& apv1,
00018                                             const uint32_t& dcu_id,
00019                                             const uint32_t& det_id,
00020                                             const uint16_t& pairs ,
00021                                             const uint16_t& fed_id,
00022                                             const uint16_t& fed_ch,
00023                                             const uint16_t& length,
00024                                             const bool& dcu,
00025                                             const bool& pll,
00026                                             const bool& mux,
00027                                             const bool& lld ) :
00028   fecCrate_(fec_crate), 
00029   fecSlot_(fec_slot), 
00030   fecRing_(fec_ring), 
00031   ccuAddr_(ccu_addr), 
00032   ccuChan_(ccu_chan),
00033   apv0_(apv0), 
00034   apv1_(apv1),
00035   dcuId_(dcu_id), 
00036   detId_(det_id), 
00037   nApvPairs_(pairs), 
00038   fedCrate_(sistrip::invalid_),
00039   fedSlot_(sistrip::invalid_),
00040   fedId_(fed_id), 
00041   fedCh_(fed_ch), 
00042   length_(length),
00043   dcu0x00_(dcu), 
00044   mux0x43_(mux), 
00045   pll0x44_(pll), 
00046   lld0x60_(lld)
00047 {;}
00048 
00049 // -----------------------------------------------------------------------------
00050 // 
00051 FedChannelConnection::FedChannelConnection() :
00052   fecCrate_(sistrip::invalid_), 
00053   fecSlot_(sistrip::invalid_), 
00054   fecRing_(sistrip::invalid_), 
00055   ccuAddr_(sistrip::invalid_), 
00056   ccuChan_(sistrip::invalid_),
00057   apv0_(sistrip::invalid_), 
00058   apv1_(sistrip::invalid_),
00059   dcuId_(sistrip::invalid32_), 
00060   detId_(sistrip::invalid32_), 
00061   nApvPairs_(sistrip::invalid_), 
00062   fedCrate_(sistrip::invalid_),
00063   fedSlot_(sistrip::invalid_),
00064   fedId_(sistrip::invalid_), 
00065   fedCh_(sistrip::invalid_), 
00066   length_(sistrip::invalid_),
00067   dcu0x00_(false), 
00068   mux0x43_(false), 
00069   pll0x44_(false), 
00070   lld0x60_(false)
00071 {;}
00072 
00073 // -----------------------------------------------------------------------------
00074 //
00075 const uint16_t& FedChannelConnection::i2cAddr( const uint16_t& apv ) const { 
00076   if      ( apv == 0 ) { return apv0_; }
00077   else if ( apv == 1 ) { return apv1_; }
00078   else {
00079     if ( edm::isDebugEnabled() ) {
00080       edm::LogWarning(mlCabling_)
00081         << "[FedChannelConnection::" << __func__ << "]"
00082         << " Unexpected APV I2C address!" << apv;
00083     }
00084     static const uint16_t i2c_addr = 0;
00085     return i2c_addr;
00086   }
00087 }
00088 
00089 // -----------------------------------------------------------------------------
00090 //
00091 uint16_t FedChannelConnection::lldChannel() const {
00092   if      ( apv0_ == 32 || apv1_ == 33 ) { return 1; }
00093   else if ( apv0_ == 34 || apv1_ == 35 ) { return 2; }
00094   else if ( apv0_ == 36 || apv1_ == 37 ) { return 3; }
00095   else if ( apv0_ != sistrip::invalid_ ||
00096             apv1_ != sistrip::invalid_ ) {
00097     if ( edm::isDebugEnabled() ) {
00098       edm::LogWarning(mlCabling_)
00099         << "[FedChannelConnection::" << __func__ << "]"
00100         << " Unexpected APV I2C addresses!" 
00101         << " Apv0: " << apv0_
00102         << " Apv1: " << apv1_;
00103     }
00104   }
00105   return 0; //@@ sistrip::invalid_
00106 }
00107 
00108 // -----------------------------------------------------------------------------
00110 uint16_t FedChannelConnection::apvPairNumber() const {
00111   if ( nApvPairs_ == 2 ) {
00112     if      ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
00113     else if ( apv0_ == 36 || apv1_ == 37 ) { return 1; }
00114     else { 
00115       if ( edm::isDebugEnabled() ) {
00116         edm::LogWarning(mlCabling_)
00117           << "[FedChannelConnection::" << __func__ << "]"
00118           << " APV I2C addresses (" 
00119           << apv0_ << "/" << apv1_
00120           << ") are incompatible with"
00121           << " number of APV pairs (" 
00122           << nApvPairs_ << ") found for this module!";
00123       }
00124     }
00125   } else if ( nApvPairs_ == 3 ) {
00126     if      ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
00127     else if ( apv0_ == 34 || apv1_ == 35 ) { return 1; }
00128     else if ( apv0_ == 36 || apv1_ == 37 ) { return 2; }
00129     else { 
00130       if ( edm::isDebugEnabled() ) {
00131         edm::LogWarning(mlCabling_)
00132           << "[FedChannelConnection::" << __func__ << "]"
00133           << " APV I2C addresses (" 
00134           << apv0_ << "/" << apv1_
00135           << ") are incompatible with"
00136           << " number of APV pairs (" 
00137           << nApvPairs_ << ") found for this module!";
00138       }
00139     }
00140   } else { 
00141     if ( edm::isDebugEnabled() ) {
00142       edm::LogWarning(mlCabling_) 
00143         << "[FedChannelConnection::" << __func__ << "]"
00144         << " Unexpected number of APV pairs: " << nApvPairs_;
00145     }
00146   }
00147   return 0; //@@ sistrip::invalid_;
00148 }
00149 
00150 // -----------------------------------------------------------------------------
00151 // 
00152 void FedChannelConnection::print( std::stringstream& ss ) const {
00153   ss << " [FedChannelConnection::" << __func__ << "]" << std::endl
00154      << " FedCrate/FedSlot/FedId/FeUnit/FeChan/FedCh : "
00155      << fedCrate() << "/"
00156      << fedSlot() << "/"
00157      << fedId() << "/"
00158      << SiStripFedKey::feUnit( fedCh() ) << "/" 
00159      << SiStripFedKey::feChan( fedCh() ) << "/" 
00160      << fedCh() << std::endl
00161      << " FecCrate/FecSlot/FecRing/CcuAddr/CcuChan   : "
00162      << fecCrate() << "/"
00163      << fecSlot() << "/"
00164      << fecRing() << "/"
00165      << ccuAddr() << "/"
00166      << ccuChan() << std::endl
00167      << " DcuId/DetId                                : "
00168      << std::hex
00169      << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
00170      << "0x" << std::setfill('0') << std::setw(8) << detId() << std::endl
00171      << std::dec
00172      << " LldChan/APV0/APV1                          : "
00173      << lldChannel() << "/" 
00174      << i2cAddr(0) << "/"
00175      << i2cAddr(1) << std::endl
00176      << " pairNumber/nPairs/nStrips                  : "
00177      << apvPairNumber() << "/"
00178      << nApvPairs() << "/"
00179      << 256*nApvPairs() << std::endl
00180      << " DCU/MUX/PLL/LLD found                      : "
00181      << std::boolalpha
00182      << dcu() << "/"
00183      << mux() << "/"
00184      << pll() << "/"
00185      << lld()
00186      << std::noboolalpha;
00187 }
00188 
00189 // -----------------------------------------------------------------------------
00190 // 
00191 void FedChannelConnection::terse( std::stringstream& ss ) const {
00192   ss << " FED:cr/sl/id/fe/ch/chan=" 
00193      << fedCrate() << "/" 
00194      << fedSlot() << "/" 
00195      << fedId() << "/" 
00196      << SiStripFedKey::feUnit( fedCh() ) << "/" 
00197      << SiStripFedKey::feChan( fedCh() ) << "/" 
00198      << fedCh() << "," 
00199      << " FEC:cr/sl/ring/ccu/mod="
00200      << fecCrate() << "/"
00201      << fecSlot() << "/" 
00202      << fecRing() << "/"
00203      << ccuAddr() << "/" 
00204      << ccuChan() << ","
00205      << " apvs=" 
00206      << i2cAddr(0) << "/" 
00207      << i2cAddr(1) << "," 
00208      << " pair=" << apvPairNumber()+1
00209      << " (from " << nApvPairs() << "),"
00210      << " dcu/detid=" 
00211      << std::hex
00212      << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
00213      << "0x" << std::setfill('0') << std::setw(8) << detId() 
00214      << std::dec;
00215 }
00216 
00217 // -----------------------------------------------------------------------------
00218 //
00219 std::ostream& operator<< ( std::ostream& os, const FedChannelConnection& conn ) {
00220   std::stringstream ss;
00221   conn.print(ss);
00222   os << ss.str();
00223   return os;
00224 }
00225 

Generated on Tue Jun 9 17:26:49 2009 for CMSSW by  doxygen 1.5.4