CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/CondFormats/SiStripObjects/src/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 bool operator< ( const FedChannelConnection& conn1, const FedChannelConnection& conn2 ) { 
00076   if ( conn1.fedId() < conn2.fedId() ) { return true; }
00077   else if ( conn1.fedId() == conn2.fedId() ) { return ( conn1.fedCh() < conn2.fedCh() ? true : false ); }
00078   else { return false; }
00079 }
00080 
00081 // -----------------------------------------------------------------------------
00082 //
00083 const uint16_t& FedChannelConnection::i2cAddr( const uint16_t& apv ) const { 
00084   if      ( apv == 0 ) { return apv0_; }
00085   else if ( apv == 1 ) { return apv1_; }
00086   else {
00087     if ( edm::isDebugEnabled() ) {
00088       edm::LogWarning(mlCabling_)
00089         << "[FedChannelConnection::" << __func__ << "]"
00090         << " Unexpected APV I2C address!" << apv;
00091     }
00092     static const uint16_t i2c_addr = 0;
00093     return i2c_addr;
00094   }
00095 }
00096 
00097 // -----------------------------------------------------------------------------
00098 //
00099 uint16_t FedChannelConnection::lldChannel() const {
00100   if      ( apv0_ == 32 || apv1_ == 33 ) { return 1; }
00101   else if ( apv0_ == 34 || apv1_ == 35 ) { return 2; }
00102   else if ( apv0_ == 36 || apv1_ == 37 ) { return 3; }
00103   else if ( apv0_ != sistrip::invalid_ ||
00104             apv1_ != sistrip::invalid_ ) {
00105     if ( edm::isDebugEnabled() ) {
00106       edm::LogWarning(mlCabling_)
00107         << "[FedChannelConnection::" << __func__ << "]"
00108         << " Unexpected APV I2C addresses!" 
00109         << " Apv0: " << apv0_
00110         << " Apv1: " << apv1_;
00111     }
00112   }
00113   return sistrip::invalid_;
00114 }
00115 
00116 // -----------------------------------------------------------------------------
00118 uint16_t FedChannelConnection::apvPairNumber() const {
00119   if ( nApvPairs_ == 2 ) {
00120     if      ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
00121     else if ( apv0_ == 36 || apv1_ == 37 ) { return 1; }
00122     else { 
00123       if ( edm::isDebugEnabled() ) {
00124         edm::LogWarning(mlCabling_)
00125           << "[FedChannelConnection::" << __func__ << "]"
00126           << " APV I2C addresses (" 
00127           << apv0_ << "/" << apv1_
00128           << ") are incompatible with"
00129           << " number of APV pairs (" 
00130           << nApvPairs_ << ") found for this module!";
00131       }
00132     }
00133   } else if ( nApvPairs_ == 3 ) {
00134     if      ( apv0_ == 32 || apv1_ == 33 ) { return 0; }
00135     else if ( apv0_ == 34 || apv1_ == 35 ) { return 1; }
00136     else if ( apv0_ == 36 || apv1_ == 37 ) { return 2; }
00137     else { 
00138       if ( edm::isDebugEnabled() ) {
00139         edm::LogWarning(mlCabling_)
00140           << "[FedChannelConnection::" << __func__ << "]"
00141           << " APV I2C addresses (" 
00142           << apv0_ << "/" << apv1_
00143           << ") are incompatible with"
00144           << " number of APV pairs (" 
00145           << nApvPairs_ << ") found for this module!";
00146       }
00147     }
00148   } else { 
00149     if ( edm::isDebugEnabled() ) {
00150       edm::LogWarning(mlCabling_) 
00151         << "[FedChannelConnection::" << __func__ << "]"
00152         << " Unexpected number of APV pairs: " << nApvPairs_;
00153     }
00154   }
00155   return sistrip::invalid_;
00156 }
00157 
00158 // -----------------------------------------------------------------------------
00159 // 
00160 void FedChannelConnection::print( std::stringstream& ss ) const {
00161   ss << " [FedChannelConnection::" << __func__ << "]" << std::endl
00162      << " FedCrate/FedSlot/FedId/FeUnit/FeChan/FedCh : "
00163      << fedCrate() << "/"
00164      << fedSlot() << "/"
00165      << fedId() << "/"
00166      << SiStripFedKey::feUnit( fedCh() ) << "/" 
00167      << SiStripFedKey::feChan( fedCh() ) << "/" 
00168      << fedCh() << std::endl
00169      << " FecCrate/FecSlot/FecRing/CcuAddr/CcuChan   : "
00170      << fecCrate() << "/"
00171      << fecSlot() << "/"
00172      << fecRing() << "/"
00173      << ccuAddr() << "/"
00174      << ccuChan() << std::endl
00175      << " DcuId/DetId                                : "
00176      << std::hex
00177      << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
00178      << "0x" << std::setfill('0') << std::setw(8) << detId() << std::endl
00179      << std::dec
00180      << " LldChan/APV0/APV1                          : "
00181      << lldChannel() << "/" 
00182      << i2cAddr(0) << "/"
00183      << i2cAddr(1) << std::endl
00184      << " pairNumber/nPairs/nStrips                  : "
00185      << apvPairNumber() << "/"
00186      << nApvPairs() << "/"
00187      << 256*nApvPairs() << std::endl
00188      << " DCU/MUX/PLL/LLD found                      : "
00189      << std::boolalpha
00190      << dcu() << "/"
00191      << mux() << "/"
00192      << pll() << "/"
00193      << lld()
00194      << std::noboolalpha;
00195 }
00196 
00197 // -----------------------------------------------------------------------------
00198 // 
00199 void FedChannelConnection::terse( std::stringstream& ss ) const {
00200   ss << " FED:cr/sl/id/fe/ch/chan=" 
00201      << fedCrate() << "/" 
00202      << fedSlot() << "/" 
00203      << fedId() << "/" 
00204      << SiStripFedKey::feUnit( fedCh() ) << "/" 
00205      << SiStripFedKey::feChan( fedCh() ) << "/" 
00206      << fedCh() << "," 
00207      << " FEC:cr/sl/ring/ccu/mod="
00208      << fecCrate() << "/"
00209      << fecSlot() << "/" 
00210      << fecRing() << "/"
00211      << ccuAddr() << "/" 
00212      << ccuChan() << ","
00213      << " apvs=" 
00214      << i2cAddr(0) << "/" 
00215      << i2cAddr(1) << "," 
00216      << " pair=" << apvPairNumber()+1
00217      << " (from " << nApvPairs() << "),"
00218      << " dcu/detid=" 
00219      << std::hex
00220      << "0x" << std::setfill('0') << std::setw(8) << dcuId() << "/"
00221      << "0x" << std::setfill('0') << std::setw(8) << detId() 
00222      << std::dec;
00223 }
00224 
00225 // -----------------------------------------------------------------------------
00226 //
00227 std::ostream& operator<< ( std::ostream& os, const FedChannelConnection& conn ) {
00228   std::stringstream ss;
00229   conn.print(ss);
00230   os << ss.str();
00231   return os;
00232 }
00233