Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/SiStripObjects/interface/VpspScanAnalysis.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 VpspScanAnalysis::VpspScanAnalysis(const uint32_t& key)
0015     : CommissioningAnalysis(key, "VpspScanAnalysis"),
0016       vpsp_(2, sistrip::invalid_),
0017       adcLevel_(2, sistrip::invalid_),
0018       fraction_(2, sistrip::invalid_),
0019       topEdge_(2, sistrip::invalid_),
0020       bottomEdge_(2, sistrip::invalid_),
0021       topLevel_(2, sistrip::invalid_),
0022       bottomLevel_(2, sistrip::invalid_) {
0023   ;
0024 }
0025 
0026 // -----------------------------------------------------------------------------
0027 //
0028 VpspScanAnalysis::VpspScanAnalysis()
0029     : CommissioningAnalysis("VpspScanAnalysis"),
0030       vpsp_(2, sistrip::invalid_),
0031       adcLevel_(2, sistrip::invalid_),
0032       fraction_(2, sistrip::invalid_),
0033       topEdge_(2, sistrip::invalid_),
0034       bottomEdge_(2, sistrip::invalid_),
0035       topLevel_(2, sistrip::invalid_),
0036       bottomLevel_(2, sistrip::invalid_) {
0037   ;
0038 }
0039 
0040 // -----------------------------------------------------------------------------
0041 //
0042 void VpspScanAnalysis::reset() { vpsp_ = VInt(2, sistrip::invalid_); }
0043 
0044 // ----------------------------------------------------------------------------
0045 //
0046 bool VpspScanAnalysis::isValid() const {
0047   return (vpsp_[0] < 1. * sistrip::valid_ && vpsp_[1] < 1. * sistrip::valid_ && adcLevel_[0] < 1. * sistrip::valid_ &&
0048           adcLevel_[1] < 1. * sistrip::valid_ && topLevel_[0] < 1. * sistrip::valid_ &&
0049           topLevel_[1] < 1. * sistrip::valid_ && bottomLevel_[0] < 1. * sistrip::valid_ &&
0050           bottomLevel_[1] < 1. * sistrip::valid_ && getErrorCodes().empty());
0051 }
0052 
0053 // ----------------------------------------------------------------------------
0054 //
0055 void VpspScanAnalysis::summary(std::stringstream& ss) const {
0056   SiStripFecKey fec_key(fecKey());
0057   SiStripFedKey fed_key(fedKey());
0058 
0059   sistrip::RunType type = SiStripEnumsAndStrings::runType(myName());
0060 
0061   std::stringstream extra1, extra2;
0062   extra1 << sistrip::apv_ << "0";
0063   extra2 << sistrip::apv_ << "1";
0064 
0065   std::string title1 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0066                                          type,
0067                                          sistrip::FED_KEY,
0068                                          fed_key.key(),
0069                                          sistrip::LLD_CHAN,
0070                                          fec_key.lldChan(),
0071                                          extra1.str())
0072                            .title();
0073   std::string title2 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0074                                          type,
0075                                          sistrip::FED_KEY,
0076                                          fed_key.key(),
0077                                          sistrip::LLD_CHAN,
0078                                          fec_key.lldChan(),
0079                                          extra2.str())
0080                            .title();
0081 
0082   ss << " Summary"
0083      << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::controlView_ << ":" << fec_key.fecCrate() << "/"
0084      << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << ":"
0085      << sistrip::dqmRoot_ << sistrip::dir_ << "Collate" << sistrip::dir_
0086      << SiStripFecKey(fec_key.fecCrate(), fec_key.fecSlot(), fec_key.fecRing(), fec_key.ccuAddr(), fec_key.ccuChan())
0087             .path()
0088      << ":" << title1 << ";" << title2 << std::endl;
0089 }
0090 
0091 // ----------------------------------------------------------------------------
0092 //
0093 void VpspScanAnalysis::print(std::stringstream& ss, uint32_t iapv) {
0094   if (iapv == 1 || iapv == 2) {
0095     iapv--;
0096   } else {
0097     iapv = 0;
0098   }
0099   header(ss);
0100   ss << " Monitorables for APV : " << iapv;
0101   if (iapv == 0) {
0102     ss << " (first of pair)";
0103   } else if (iapv == 1) {
0104     ss << " (second of pair)";
0105   }
0106   ss << std::endl;
0107   ss << std::fixed << std::setprecision(2) << " VPSP setting         : " << vpsp_[iapv] << std::endl
0108      << " Signal level   [ADC] : " << adcLevel_[iapv] << std::endl
0109      << " Fraction         [%] : "
0110      << "(N/A)" /*fraction_[iapv]*/ << std::endl
0111      << " Top edge       [bin] : " << topEdge_[iapv] << std::endl
0112      << " Bottom edge    [bin] : " << bottomEdge_[iapv] << std::endl
0113      << " Top level      [ADC] : " << topLevel_[iapv] << std::endl
0114      << " Bottom level   [ADC] : " << bottomLevel_[iapv] << std::endl
0115      << std::boolalpha << " isValid              : " << isValid() << std::endl
0116      << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
0117      << "): ";
0118   if (getErrorCodes().empty()) {
0119     ss << "(none)";
0120   } else {
0121     VString::const_iterator istr = getErrorCodes().begin();
0122     VString::const_iterator jstr = getErrorCodes().end();
0123     for (; istr != jstr; ++istr) {
0124       ss << *istr << " ";
0125     }
0126   }
0127   ss << std::endl;
0128 }