CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CondFormats/SiStripObjects/src/OptoScanAnalysis.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiStripObjects/interface/OptoScanAnalysis.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006 #include <sstream>
00007 #include <iomanip>
00008 #include <cmath>
00009 
00010 using namespace sistrip;
00011 
00012 // ----------------------------------------------------------------------------
00013 // 
00014 const uint16_t OptoScanAnalysis::defaultGainSetting_ = sistrip::invalid_; //@@ 
00015 
00016 // ----------------------------------------------------------------------------
00017 // 
00018 const uint16_t OptoScanAnalysis::defaultBiasSetting_ = sistrip::invalid_; //@@ 
00019 
00020 // ----------------------------------------------------------------------------
00021 // 
00022 const float OptoScanAnalysis::fedAdcGain_ = 1.024 / 1024.; // [V/ADC]
00023 
00024 // ----------------------------------------------------------------------------
00025 // 
00026 OptoScanAnalysis::OptoScanAnalysis( const uint32_t& key ) 
00027   : CommissioningAnalysis(key,sistrip::optoScanAnalysis_),
00028     gain_(sistrip::invalid_), 
00029     bias_(4,sistrip::invalid_), 
00030     measGain_(4,sistrip::invalid_), 
00031     zeroLight_(4,sistrip::invalid_), 
00032     linkNoise_(4,sistrip::invalid_),
00033     liftOff_(4,sistrip::invalid_), 
00034     threshold_(4,sistrip::invalid_), 
00035     tickHeight_(4,sistrip::invalid_),
00036     baseSlope_(4,sistrip::invalid_)
00037 {;}
00038 
00039 // ----------------------------------------------------------------------------
00040 // 
00041 OptoScanAnalysis::OptoScanAnalysis() 
00042   : CommissioningAnalysis(sistrip::optoScanAnalysis_),
00043     gain_(sistrip::invalid_), 
00044     bias_(4,sistrip::invalid_), 
00045     measGain_(4,sistrip::invalid_), 
00046     zeroLight_(4,sistrip::invalid_), 
00047     linkNoise_(4,sistrip::invalid_),
00048     liftOff_(4,sistrip::invalid_), 
00049     threshold_(4,sistrip::invalid_), 
00050     tickHeight_(4,sistrip::invalid_),
00051     baseSlope_(4,sistrip::invalid_)
00052 {;}
00053 
00054 // ----------------------------------------------------------------------------
00055 // 
00056 void OptoScanAnalysis::reset() {
00057   gain_       = sistrip::invalid_; 
00058   bias_       = VInt(4,sistrip::invalid_); 
00059   measGain_   = VFloat(4,sistrip::invalid_); 
00060   zeroLight_  = VFloat(4,sistrip::invalid_); 
00061   linkNoise_  = VFloat(4,sistrip::invalid_);
00062   liftOff_    = VFloat(4,sistrip::invalid_); 
00063   threshold_  = VFloat(4,sistrip::invalid_); 
00064   tickHeight_ = VFloat(4,sistrip::invalid_);
00065   baseSlope_  = VFloat(4,sistrip::invalid_);
00066 }
00067   
00068 
00069 // ----------------------------------------------------------------------------
00070 // 
00071 bool OptoScanAnalysis::isValid() const {
00072   return ( gain_ < sistrip::maximum_ &&
00073            bias_[gain_] < sistrip::maximum_ &&
00074            getErrorCodes().empty() );
00075 }
00076 
00077 // ----------------------------------------------------------------------------
00078 // 
00079 void OptoScanAnalysis::summary( std::stringstream& ss ) const { 
00080 
00081   SiStripFecKey fec_key( fecKey() );
00082   SiStripFedKey fed_key( fedKey() );
00083   
00084   sistrip::RunType type = SiStripEnumsAndStrings::runType( myName() );
00085 
00086   std::stringstream extra1,extra2,extra3; 
00087   extra1 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::digital_ << "0";
00088   extra2 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::digital_ << "1";
00089   extra3 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::baselineRms_;
00090   
00091   std::string title1 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00092                                           type,
00093                                           sistrip::FED_KEY, 
00094                                           fed_key.key(),
00095                                           sistrip::LLD_CHAN, 
00096                                           fec_key.lldChan(),
00097                                           extra1.str() ).title();
00098   std::string title2 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00099                                           type,
00100                                           sistrip::FED_KEY, 
00101                                           fed_key.key(),
00102                                           sistrip::LLD_CHAN, 
00103                                           fec_key.lldChan(),
00104                                           extra2.str() ).title();
00105   std::string title3 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00106                                           type,
00107                                           sistrip::FED_KEY, 
00108                                           fed_key.key(),
00109                                           sistrip::LLD_CHAN, 
00110                                           fec_key.lldChan(),
00111                                           extra3.str() ).title();
00112   
00113   ss << " Summary"
00114      << ":"
00115      << ( isValid() ? "Valid" : "Invalid" )
00116      << ":"
00117      << sistrip::controlView_ << ":"
00118      << fec_key.fecCrate() << "/" 
00119      << fec_key.fecSlot() << "/" 
00120      << fec_key.fecRing() << "/" 
00121      << fec_key.ccuAddr() << "/" 
00122      << fec_key.ccuChan() 
00123      << ":"
00124      << sistrip::dqmRoot_ << sistrip::dir_ 
00125      << "Collate" << sistrip::dir_ 
00126      << SiStripFecKey( fec_key.fecCrate(),
00127                        fec_key.fecSlot(), 
00128                        fec_key.fecRing(), 
00129                        fec_key.ccuAddr(), 
00130                        fec_key.ccuChan() ).path()
00131      << ":"
00132      << title1 << ";" << title2 << ";" << title3
00133      << std::endl;
00134   
00135 }
00136 
00137 // ----------------------------------------------------------------------------
00138 // 
00139 void OptoScanAnalysis::print( std::stringstream& ss, uint32_t gain ) { 
00140 
00141   if ( gain >= 4 ) { gain = gain_; }
00142 
00143   if ( gain >= bias_.size() ) {
00144     edm::LogWarning(mlCommissioning_)
00145       << "[" << myName() << "::" << __func__ << "]"
00146       << " Unexpected gain setting: " << gain;
00147     return;
00148   }
00149 
00150   header( ss );
00151   ss <<  std::fixed << std::setprecision(2)
00152      << " Optimum LLD gain setting : " << gain_ << std::endl
00153      << " LLD gain setting         : " << gain << std::endl
00154      << " LLD bias setting         : " << bias_[gain] << std::endl
00155      << " Measured gain      [V/V] : " << measGain_[gain] << std::endl
00156      << " Zero light level   [ADC] : " << zeroLight_[gain] << std::endl
00157      << " Link noise [ADC]         : " << linkNoise_[gain] << std::endl
00158      << " Baseline 'lift off' [mA] : " << liftOff_[gain] << std::endl
00159      << " Laser threshold     [mA] : " << threshold_[gain] << std::endl
00160      << " Tick mark height   [ADC] : " << tickHeight_[gain] << std::endl
00161      << " Baseline slope [ADC/I2C] : " << baseSlope_[gain] << std::endl
00162      << std::boolalpha 
00163      << " isValid                  : " << isValid()  << std::endl
00164      << std::noboolalpha
00165      << " Error codes (found "
00166      << std::setw(2) << std::setfill(' ') << getErrorCodes().size() 
00167      << ")   : ";
00168   if ( getErrorCodes().empty() ) { ss << "(none)"; }
00169   else { 
00170     VString::const_iterator istr = getErrorCodes().begin();
00171     VString::const_iterator jstr = getErrorCodes().end();
00172     for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
00173   }
00174   ss << std::endl;
00175 
00176 }