Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:51:39

0001 #include "CondFormats/SiStripObjects/interface/FastFedCablingAnalysis.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 float FastFedCablingAnalysis::threshold_ = 100.;  // [ADC]
0015 
0016 // ----------------------------------------------------------------------------
0017 //
0018 const float FastFedCablingAnalysis::dirtyThreshold_ = 800;  // [ADC]
0019 
0020 // ----------------------------------------------------------------------------
0021 //
0022 const float FastFedCablingAnalysis::trimDacThreshold_ = 10;  // [ADC]
0023 
0024 // ----------------------------------------------------------------------------
0025 //
0026 const uint16_t FastFedCablingAnalysis::nBitsForDcuId_ = 32;
0027 
0028 // ----------------------------------------------------------------------------
0029 //
0030 const uint16_t FastFedCablingAnalysis::nBitsForLldCh_ = 2;
0031 
0032 // ----------------------------------------------------------------------------
0033 //
0034 FastFedCablingAnalysis::FastFedCablingAnalysis(const uint32_t& key)
0035     : CommissioningAnalysis(key, sistrip::fastCablingAnalysis_),
0036       dcuHardId_(sistrip::invalid32_),
0037       lldCh_(sistrip::invalid_),
0038       highMedian_(1. * sistrip::invalid_),
0039       highMean_(1. * sistrip::invalid_),
0040       highRms_(1. * sistrip::invalid_),
0041       lowMedian_(1. * sistrip::invalid_),
0042       lowMean_(1. * sistrip::invalid_),
0043       lowRms_(1. * sistrip::invalid_),
0044       range_(1. * sistrip::invalid_),
0045       midRange_(1. * sistrip::invalid_),
0046       max_(1. * sistrip::invalid_),
0047       min_(1. * sistrip::invalid_) {
0048   fecKey(SiStripFecKey(sistrip::invalid_,
0049                        sistrip::invalid_,
0050                        sistrip::invalid_,
0051                        sistrip::invalid_,
0052                        sistrip::invalid_,
0053                        sistrip::invalid_,
0054                        sistrip::invalid_)
0055              .key());
0056   fedKey(key);
0057 }
0058 
0059 // ----------------------------------------------------------------------------
0060 //
0061 FastFedCablingAnalysis::FastFedCablingAnalysis()
0062     : CommissioningAnalysis(sistrip::fastCablingAnalysis_),
0063       dcuHardId_(sistrip::invalid32_),
0064       lldCh_(sistrip::invalid_),
0065       highMedian_(1. * sistrip::invalid_),
0066       highMean_(1. * sistrip::invalid_),
0067       highRms_(1. * sistrip::invalid_),
0068       lowMedian_(1. * sistrip::invalid_),
0069       lowMean_(1. * sistrip::invalid_),
0070       lowRms_(1. * sistrip::invalid_),
0071       range_(1. * sistrip::invalid_),
0072       midRange_(1. * sistrip::invalid_),
0073       max_(1. * sistrip::invalid_),
0074       min_(1. * sistrip::invalid_) {
0075   ;
0076 }
0077 
0078 // ----------------------------------------------------------------------------
0079 //
0080 void FastFedCablingAnalysis::reset() {
0081   dcuHardId_ = sistrip::invalid32_;
0082   lldCh_ = sistrip::invalid_;
0083   highMedian_ = 1. * sistrip::invalid_;
0084   highMean_ = 1. * sistrip::invalid_;
0085   highRms_ = 1. * sistrip::invalid_;
0086   lowMedian_ = 1. * sistrip::invalid_;
0087   lowMean_ = 1. * sistrip::invalid_;
0088   lowRms_ = 1. * sistrip::invalid_;
0089   range_ = 1. * sistrip::invalid_;
0090   midRange_ = 1. * sistrip::invalid_;
0091   max_ = 1. * sistrip::invalid_;
0092   min_ = 1. * sistrip::invalid_;
0093 }
0094 
0095 // ----------------------------------------------------------------------------
0096 //
0097 bool FastFedCablingAnalysis::isValid() const {
0098   return (dcuHardId_ < sistrip::invalid32_ && lldCh_ < sistrip::valid_ && highMedian_ < sistrip::valid_ &&
0099           highMean_ < sistrip::valid_ && highRms_ < sistrip::valid_ && lowMedian_ < sistrip::valid_ &&
0100           lowMean_ < sistrip::valid_ && lowRms_ < sistrip::valid_ && range_ < sistrip::valid_ &&
0101           midRange_ < sistrip::valid_ && max_ < sistrip::valid_ && min_ < sistrip::valid_ && getErrorCodes().empty());
0102 }
0103 
0104 // ----------------------------------------------------------------------------
0105 //
0106 bool FastFedCablingAnalysis::isDirty() const { return (highMean_ < dirtyThreshold_); }
0107 
0108 // ----------------------------------------------------------------------------
0109 //
0110 bool FastFedCablingAnalysis::badTrimDac() const { return (lowMean_ < trimDacThreshold_); }
0111 
0112 // ----------------------------------------------------------------------------
0113 //
0114 void FastFedCablingAnalysis::header(std::stringstream& ss) const {
0115   ss << "[" << myName() << "] Monitorables (65535 means \"invalid\"):" << std::endl;
0116 
0117   //summary(ss);
0118 
0119   SiStripFecKey fec_key(fecKey());
0120   if (fec_key.isValid()) {
0121     ss << " Crate/FEC/Ring/CCU/Mod/LLD     : " << fec_key.fecCrate() << "/" << fec_key.fecSlot() << "/"
0122        << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << "/" << fec_key.lldChan()
0123        << std::endl;
0124   } else {
0125     ss << " Crate/FEC/Ring/CCU/Mod/LLD     : (invalid)" << std::endl;
0126   }
0127 
0128   SiStripFedKey fed_key(fedKey());
0129   ss << " FedId/FeUnit/FeChan/FedChannel : " << fed_key.fedId() << "/" << fed_key.feUnit() << "/" << fed_key.feChan()
0130      << "/" << fed_key.fedChannel() << std::endl;
0131   // if ( fed_key.fedChannel() != sistrip::invalid_ ) { ss << fed_key.fedChannel(); }
0132   // else { ss << "(invalid)"; }
0133   // ss << std::endl;
0134 
0135   ss << " FecKey/Fedkey (hex)            : 0x" << std::hex << std::setw(8) << std::setfill('0') << fecKey() << " / 0x"
0136      << std::setw(8) << std::setfill('0') << fedKey() << std::dec << std::endl;
0137 
0138   ss << " DcuId (hex/dec)                : 0x" << std::hex << std::setw(8) << std::setfill('0') << dcuId() << " / "
0139      << std::dec << std::setw(10) << std::setfill(' ') << dcuId() << std::endl;
0140 
0141   ss << " DetId (hex/dec)                : 0x" << std::hex << std::setw(8) << std::setfill('0') << detId() << " / "
0142      << std::dec << std::setw(10) << std::setfill(' ') << detId() << std::endl;
0143 }
0144 
0145 // ----------------------------------------------------------------------------
0146 //
0147 void FastFedCablingAnalysis::summary(std::stringstream& ss) const {
0148   SiStripFecKey fec_key(fecKey());
0149   SiStripFedKey fed_key(fedKey());
0150 
0151   sistrip::RunType type = SiStripEnumsAndStrings::runType(myName());
0152   std::string title =
0153       SiStripHistoTitle(
0154           sistrip::EXPERT_HISTO, type, sistrip::FED_KEY, fed_key.key(), sistrip::LLD_CHAN, fec_key.lldChan())
0155           .title();
0156 
0157   ss << " Summary"
0158      << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::readoutView_ << ":" << fed_key.fedId() << "/"
0159      << fed_key.feUnit() << "/" << fed_key.feChan() << ":" << sistrip::dqmRoot_ << sistrip::dir_ << "Collate"
0160      << sistrip::dir_ << fed_key.path() << ":" << title << std::endl;
0161 }
0162 
0163 // ----------------------------------------------------------------------------
0164 //
0165 void FastFedCablingAnalysis::print(std::stringstream& ss, uint32_t not_used) {
0166   header(ss);
0167   ss << std::fixed << std::setprecision(2) << " DCU id extracted from histo     : 0x" << std::hex << std::setw(8)
0168      << std::setfill('0') << dcuHardId_ << std::endl
0169      << std::dec << " LLD chan extracted from histo   : " << (lldCh_ > 3 ? sistrip::invalid_ : lldCh_) << std::endl
0170      << " \"High\" level (mean+/-rms) [ADC] : " << highMean_ << " +/- " << highRms_ << std::endl
0171      << " \"Low\" level (mean+/-rms)  [ADC] : " << lowMean_ << " +/- " << lowRms_ << std::endl
0172      << " Median \"high\" level       [ADC] : " << highMedian_ << std::endl
0173      << " Median \"low\" level        [ADC] : " << lowMedian_ << std::endl
0174      << " Range                     [ADC] : " << range_ << std::endl
0175      << " Mid-range level           [ADC] : " << midRange_ << std::endl
0176      << " Maximum level             [ADC] : " << max_ << std::endl
0177      << " Minimum level             [ADC] : " << min_ << std::endl;
0178   ss << std::boolalpha << " isValid                         : " << isValid() << std::endl
0179      << " isDirty                         : " << isDirty() << std::endl
0180      << " badTrimDac                      : " << badTrimDac() << std::endl
0181      << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
0182      << ")          : ";
0183   if (getErrorCodes().empty()) {
0184     ss << "(none)";
0185   } else {
0186     VString::const_iterator istr = getErrorCodes().begin();
0187     VString::const_iterator jstr = getErrorCodes().end();
0188     for (; istr != jstr; ++istr) {
0189       ss << *istr << " ";
0190     }
0191   }
0192   ss << std::endl;
0193 }