Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/SiStripObjects/interface/PedsOnlyAnalysis.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 <iomanip>
0007 #include <cmath>
0008 
0009 using namespace sistrip;
0010 
0011 // ----------------------------------------------------------------------------
0012 //
0013 PedsOnlyAnalysis::PedsOnlyAnalysis(const uint32_t& key)
0014     : CommissioningAnalysis(key, "PedsOnlyAnalysis"),
0015       peds_(2, VFloat(128, sistrip::invalid_)),
0016       raw_(2, VFloat(128, sistrip::invalid_)),
0017       pedsMean_(2, sistrip::invalid_),
0018       pedsSpread_(2, sistrip::invalid_),
0019       rawMean_(2, sistrip::invalid_),
0020       rawSpread_(2, sistrip::invalid_),
0021       pedsMax_(2, sistrip::invalid_),
0022       pedsMin_(2, sistrip::invalid_),
0023       rawMax_(2, sistrip::invalid_),
0024       rawMin_(2, sistrip::invalid_),
0025       legacy_(false) {}
0026 
0027 // ----------------------------------------------------------------------------
0028 //
0029 PedsOnlyAnalysis::PedsOnlyAnalysis()
0030     : CommissioningAnalysis("PedsOnlyAnalysis"),
0031       peds_(2, VFloat(128, sistrip::invalid_)),
0032       raw_(2, VFloat(128, sistrip::invalid_)),
0033       pedsMean_(2, sistrip::invalid_),
0034       pedsSpread_(2, sistrip::invalid_),
0035       rawMean_(2, sistrip::invalid_),
0036       rawSpread_(2, sistrip::invalid_),
0037       pedsMax_(2, sistrip::invalid_),
0038       pedsMin_(2, sistrip::invalid_),
0039       rawMax_(2, sistrip::invalid_),
0040       rawMin_(2, sistrip::invalid_),
0041       legacy_(false) {}
0042 
0043 // ----------------------------------------------------------------------------
0044 //
0045 void PedsOnlyAnalysis::reset() {
0046   peds_ = VVFloat(2, VFloat(128, sistrip::invalid_));
0047   raw_ = VVFloat(2, VFloat(128, sistrip::invalid_));
0048   pedsMean_ = VFloat(2, sistrip::invalid_);
0049   pedsSpread_ = VFloat(2, sistrip::invalid_);
0050   rawMean_ = VFloat(2, sistrip::invalid_);
0051   rawSpread_ = VFloat(2, sistrip::invalid_);
0052   pedsMax_ = VFloat(2, sistrip::invalid_);
0053   pedsMin_ = VFloat(2, sistrip::invalid_);
0054   rawMax_ = VFloat(2, sistrip::invalid_);
0055   rawMin_ = VFloat(2, sistrip::invalid_);
0056   legacy_ = false;
0057 }
0058 
0059 // ----------------------------------------------------------------------------
0060 //
0061 bool PedsOnlyAnalysis::isValid() const {
0062   return (pedsMean_[0] < sistrip::maximum_ && pedsMean_[1] < sistrip::maximum_ && pedsSpread_[0] < sistrip::maximum_ &&
0063           pedsSpread_[1] < sistrip::maximum_ && rawMean_[0] < sistrip::maximum_ && rawMean_[1] < sistrip::maximum_ &&
0064           rawSpread_[0] < sistrip::maximum_ && rawSpread_[1] < sistrip::maximum_ && pedsMax_[0] < sistrip::maximum_ &&
0065           pedsMax_[1] < sistrip::maximum_ && pedsMin_[0] < sistrip::maximum_ && pedsMin_[1] < sistrip::maximum_ &&
0066           rawMax_[0] < sistrip::maximum_ && rawMax_[1] < sistrip::maximum_ && rawMin_[0] < sistrip::maximum_ &&
0067           rawMin_[1] < sistrip::maximum_ && getErrorCodes().empty());
0068 }
0069 
0070 // ----------------------------------------------------------------------------
0071 //
0072 void PedsOnlyAnalysis::summary(std::stringstream& ss) const {
0073   SiStripFecKey fec_key(fecKey());
0074   SiStripFedKey fed_key(fedKey());
0075 
0076   sistrip::RunType type = SiStripEnumsAndStrings::runType(myName());
0077 
0078   std::stringstream extra1, extra2, extra3;
0079   if (legacy_) {
0080     extra1 << sistrip::extrainfo::pedsAndRawNoise_;
0081     extra2 << sistrip::extrainfo::pedsAndCmSubNoise_;
0082     extra3 << sistrip::extrainfo::commonMode_;
0083   } else {
0084     extra1 << sistrip::extrainfo::pedestals_;
0085     extra2 << sistrip::extrainfo::rawNoise_;
0086     extra3 << sistrip::extrainfo::commonMode_;
0087   }
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::APV,
0110                                          SiStripFecKey::i2cAddr(fec_key.lldChan(), true),
0111                                          extra3.str())
0112                            .title();
0113   std::string title4 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0114                                          type,
0115                                          sistrip::FED_KEY,
0116                                          fed_key.key(),
0117                                          sistrip::APV,
0118                                          SiStripFecKey::i2cAddr(fec_key.lldChan(), false),
0119                                          extra3.str())
0120                            .title();
0121 
0122   ss << " Summary"
0123      << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::controlView_ << ":" << fec_key.fecCrate() << "/"
0124      << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << ":"
0125      << sistrip::dqmRoot_ << sistrip::dir_ << "Collate" << sistrip::dir_
0126      << SiStripFecKey(fec_key.fecCrate(), fec_key.fecSlot(), fec_key.fecRing(), fec_key.ccuAddr(), fec_key.ccuChan())
0127             .path()
0128      << ":" << title1 << ";" << title2 << ";" << title3 << ";" << title4 << std::endl;
0129 }
0130 
0131 // ----------------------------------------------------------------------------
0132 //
0133 void PedsOnlyAnalysis::print(std::stringstream& ss, uint32_t iapv) {
0134   if (iapv == 1 || iapv == 2) {
0135     iapv--;
0136   } else {
0137     iapv = 0;
0138   }
0139 
0140   if (peds_[iapv].size() < 128 || raw_[iapv].size() < 128) {
0141     edm::LogWarning(mlCommissioning_) << "[" << myName() << "::" << __func__ << "]"
0142                                       << " Unexpected number of pedestal/noise values: " << peds_[iapv].size() << ", "
0143                                       << raw_[iapv].size();
0144     return;
0145   }
0146 
0147   header(ss);
0148   ss << " Monitorables for APV number     : " << iapv;
0149   if (iapv == 0) {
0150     ss << " (first of pair)";
0151   } else if (iapv == 1) {
0152     ss << " (second of pair)";
0153   }
0154   ss << std::endl;
0155   ss << std::fixed << std::setprecision(2);
0156   ss << " Example peds/noise for strips   : "
0157      << "     0,     31,     63,    127" << std::endl
0158      << "  Peds                     [ADC] : " << std::setw(6) << peds_[iapv][0] << ", " << std::setw(6)
0159      << peds_[iapv][31] << ", " << std::setw(6) << peds_[iapv][63] << ", " << std::setw(6) << peds_[iapv][127]
0160      << std::endl
0161      << "  Raw noise                [ADC] : " << std::setw(6) << raw_[iapv][0] << ", " << std::setw(6) << raw_[iapv][31]
0162      << ", " << std::setw(6) << raw_[iapv][63] << ", " << std::setw(6) << raw_[iapv][127] << std::endl;
0163   ss << " Mean peds +/- spread      [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
0164      << " Min/Max pedestal          [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
0165      << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
0166      << " Min/Max raw noise         [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
0167      << std::boolalpha << " isValid                         : " << isValid() << std::endl
0168      << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
0169      << ")          : ";
0170   if (getErrorCodes().empty()) {
0171     ss << "(none)";
0172   } else {
0173     VString::const_iterator istr = getErrorCodes().begin();
0174     VString::const_iterator jstr = getErrorCodes().end();
0175     for (; istr != jstr; ++istr) {
0176       ss << *istr << " ";
0177     }
0178   }
0179   ss << std::endl;
0180 }