Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:02:40

0001 #include "CondFormats/SiStripObjects/interface/OptoScanAnalysis.h"
0002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include <iostream>
0006 #include <sstream>
0007 #include <iomanip>
0008 #include <cmath>
0009 
0010 using namespace sistrip;
0011 
0012 // ----------------------------------------------------------------------------
0013 //
0014 const uint16_t OptoScanAnalysis::defaultGainSetting_ = sistrip::invalid_;  //@@
0015 
0016 // ----------------------------------------------------------------------------
0017 //
0018 const uint16_t OptoScanAnalysis::defaultBiasSetting_ = sistrip::invalid_;  //@@
0019 
0020 // ----------------------------------------------------------------------------
0021 //
0022 const float OptoScanAnalysis::fedAdcGain_ = 1.024 / 1024.;  // [V/ADC]
0023 
0024 // ----------------------------------------------------------------------------
0025 //
0026 OptoScanAnalysis::OptoScanAnalysis(const uint32_t& key)
0027     : CommissioningAnalysis(key, sistrip::optoScanAnalysis_),
0028       gain_(sistrip::invalid_),
0029       bias_(4, sistrip::invalid_),
0030       measGain_(4, sistrip::invalid_),
0031       zeroLight_(4, sistrip::invalid_),
0032       linkNoise_(4, sistrip::invalid_),
0033       liftOff_(4, sistrip::invalid_),
0034       threshold_(4, sistrip::invalid_),
0035       tickHeight_(4, sistrip::invalid_),
0036       baseSlope_(4, sistrip::invalid_) {
0037   ;
0038 }
0039 
0040 // ----------------------------------------------------------------------------
0041 //
0042 OptoScanAnalysis::OptoScanAnalysis()
0043     : CommissioningAnalysis(sistrip::optoScanAnalysis_),
0044       gain_(sistrip::invalid_),
0045       bias_(4, sistrip::invalid_),
0046       measGain_(4, sistrip::invalid_),
0047       zeroLight_(4, sistrip::invalid_),
0048       linkNoise_(4, sistrip::invalid_),
0049       liftOff_(4, sistrip::invalid_),
0050       threshold_(4, sistrip::invalid_),
0051       tickHeight_(4, sistrip::invalid_),
0052       baseSlope_(4, sistrip::invalid_) {
0053   ;
0054 }
0055 
0056 // ----------------------------------------------------------------------------
0057 //
0058 void OptoScanAnalysis::reset() {
0059   gain_ = sistrip::invalid_;
0060   bias_ = VInt(4, sistrip::invalid_);
0061   measGain_ = VFloat(4, sistrip::invalid_);
0062   zeroLight_ = VFloat(4, sistrip::invalid_);
0063   linkNoise_ = VFloat(4, sistrip::invalid_);
0064   liftOff_ = VFloat(4, sistrip::invalid_);
0065   threshold_ = VFloat(4, sistrip::invalid_);
0066   tickHeight_ = VFloat(4, sistrip::invalid_);
0067   baseSlope_ = VFloat(4, sistrip::invalid_);
0068 }
0069 
0070 // ----------------------------------------------------------------------------
0071 //
0072 bool OptoScanAnalysis::isValid() const {
0073   return (gain_ < sistrip::maximum_ && bias_[gain_] < sistrip::maximum_ && getErrorCodes().empty());
0074 }
0075 
0076 // ----------------------------------------------------------------------------
0077 //
0078 void OptoScanAnalysis::summary(std::stringstream& ss) const {
0079   SiStripFecKey fec_key(fecKey());
0080   SiStripFedKey fed_key(fedKey());
0081 
0082   sistrip::RunType type = SiStripEnumsAndStrings::runType(myName());
0083 
0084   std::stringstream extra1, extra2, extra3;
0085   extra1 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::digital_ << "0";
0086   extra2 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::digital_ << "1";
0087   extra3 << sistrip::extrainfo::gain_ << gain() << sistrip::extrainfo::baselineRms_;
0088 
0089   std::string title1 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0090                                          type,
0091                                          sistrip::FED_KEY,
0092                                          fed_key.key(),
0093                                          sistrip::LLD_CHAN,
0094                                          fec_key.lldChan(),
0095                                          extra1.str())
0096                            .title();
0097   std::string title2 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0098                                          type,
0099                                          sistrip::FED_KEY,
0100                                          fed_key.key(),
0101                                          sistrip::LLD_CHAN,
0102                                          fec_key.lldChan(),
0103                                          extra2.str())
0104                            .title();
0105   std::string title3 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0106                                          type,
0107                                          sistrip::FED_KEY,
0108                                          fed_key.key(),
0109                                          sistrip::LLD_CHAN,
0110                                          fec_key.lldChan(),
0111                                          extra3.str())
0112                            .title();
0113 
0114   ss << " Summary"
0115      << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::controlView_ << ":" << fec_key.fecCrate() << "/"
0116      << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << ":"
0117      << sistrip::dqmRoot_ << sistrip::dir_ << "Collate" << sistrip::dir_
0118      << SiStripFecKey(fec_key.fecCrate(), fec_key.fecSlot(), fec_key.fecRing(), fec_key.ccuAddr(), fec_key.ccuChan())
0119             .path()
0120      << ":" << title1 << ";" << title2 << ";" << title3 << std::endl;
0121 }
0122 
0123 // ----------------------------------------------------------------------------
0124 //
0125 void OptoScanAnalysis::print(std::stringstream& ss, uint32_t gain) {
0126   if (gain >= 4) {
0127     gain = gain_;
0128   }
0129 
0130   if (gain >= bias_.size()) {
0131     edm::LogWarning(mlCommissioning_) << "[" << myName() << "::" << __func__ << "]"
0132                                       << " Unexpected gain setting: " << gain;
0133     return;
0134   }
0135 
0136   header(ss);
0137   ss << std::fixed << std::setprecision(2) << " Optimum LLD gain setting : " << gain_ << std::endl
0138      << " LLD gain setting         : " << gain << std::endl
0139      << " LLD bias setting         : " << bias_[gain] << std::endl
0140      << " Measured gain      [V/V] : " << measGain_[gain] << std::endl
0141      << " Zero light level   [ADC] : " << zeroLight_[gain] << std::endl
0142      << " Link noise [ADC]         : " << linkNoise_[gain] << std::endl
0143      << " Baseline 'lift off' [mA] : " << liftOff_[gain] << std::endl
0144      << " Laser threshold     [mA] : " << threshold_[gain] << std::endl
0145      << " Tick mark height   [ADC] : " << tickHeight_[gain] << std::endl
0146      << " Baseline slope [ADC/I2C] : " << baseSlope_[gain] << std::endl
0147      << std::boolalpha << " isValid                  : " << isValid() << std::endl
0148      << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
0149      << ")   : ";
0150   if (getErrorCodes().empty()) {
0151     ss << "(none)";
0152   } else {
0153     VString::const_iterator istr = getErrorCodes().begin();
0154     VString::const_iterator jstr = getErrorCodes().end();
0155     for (; istr != jstr; ++istr) {
0156       ss << *istr << " ";
0157     }
0158   }
0159   ss << std::endl;
0160 }