Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "CondFormats/SiStripObjects/interface/PedestalsAnalysis.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 PedestalsAnalysis::PedestalsAnalysis(const uint32_t& key)
0014     : CommissioningAnalysis(key, "PedestalsAnalysis"),
0015       peds_(2, VFloat(128, sistrip::invalid_)),
0016       noise_(2, VFloat(128, sistrip::invalid_)),
0017       raw_(2, VFloat(128, sistrip::invalid_)),
0018       dead_(2, VInt(0, sistrip::invalid_)),
0019       noisy_(2, VInt(0, sistrip::invalid_)),
0020       pedsMean_(2, sistrip::invalid_),
0021       pedsSpread_(2, sistrip::invalid_),
0022       noiseMean_(2, sistrip::invalid_),
0023       noiseSpread_(2, sistrip::invalid_),
0024       rawMean_(2, sistrip::invalid_),
0025       rawSpread_(2, sistrip::invalid_),
0026       pedsMax_(2, sistrip::invalid_),
0027       pedsMin_(2, sistrip::invalid_),
0028       noiseMax_(2, sistrip::invalid_),
0029       noiseMin_(2, sistrip::invalid_),
0030       rawMax_(2, sistrip::invalid_),
0031       rawMin_(2, sistrip::invalid_),
0032       legacy_(false) {
0033   dead_[0].reserve(256);
0034   dead_[1].reserve(256);
0035   noisy_[0].reserve(256);
0036   noisy_[1].reserve(256);
0037 }
0038 
0039 // ----------------------------------------------------------------------------
0040 //
0041 PedestalsAnalysis::PedestalsAnalysis()
0042     : CommissioningAnalysis("PedestalsAnalysis"),
0043       peds_(2, VFloat(128, sistrip::invalid_)),
0044       noise_(2, VFloat(128, sistrip::invalid_)),
0045       raw_(2, VFloat(128, sistrip::invalid_)),
0046       dead_(2, VInt(0, sistrip::invalid_)),
0047       noisy_(2, VInt(0, sistrip::invalid_)),
0048       pedsMean_(2, sistrip::invalid_),
0049       pedsSpread_(2, sistrip::invalid_),
0050       noiseMean_(2, sistrip::invalid_),
0051       noiseSpread_(2, sistrip::invalid_),
0052       rawMean_(2, sistrip::invalid_),
0053       rawSpread_(2, sistrip::invalid_),
0054       pedsMax_(2, sistrip::invalid_),
0055       pedsMin_(2, sistrip::invalid_),
0056       noiseMax_(2, sistrip::invalid_),
0057       noiseMin_(2, sistrip::invalid_),
0058       rawMax_(2, sistrip::invalid_),
0059       rawMin_(2, sistrip::invalid_),
0060       legacy_(false) {
0061   dead_[0].reserve(256);
0062   dead_[1].reserve(256);
0063   noisy_[0].reserve(256);
0064   noisy_[1].reserve(256);
0065 }
0066 
0067 // ----------------------------------------------------------------------------
0068 //
0069 void PedestalsAnalysis::reset() {
0070   peds_ = VVFloat(2, VFloat(128, sistrip::invalid_));
0071   noise_ = VVFloat(2, VFloat(128, sistrip::invalid_));
0072   raw_ = VVFloat(2, VFloat(128, sistrip::invalid_));
0073   dead_ = VVInt(2, VInt(0, sistrip::invalid_));
0074   noisy_ = VVInt(2, VInt(0, sistrip::invalid_));
0075   pedsMean_ = VFloat(2, sistrip::invalid_);
0076   pedsSpread_ = VFloat(2, sistrip::invalid_);
0077   noiseMean_ = VFloat(2, sistrip::invalid_);
0078   noiseSpread_ = VFloat(2, sistrip::invalid_);
0079   rawMean_ = VFloat(2, sistrip::invalid_);
0080   rawSpread_ = VFloat(2, sistrip::invalid_);
0081   pedsMax_ = VFloat(2, sistrip::invalid_);
0082   pedsMin_ = VFloat(2, sistrip::invalid_);
0083   noiseMax_ = VFloat(2, sistrip::invalid_);
0084   noiseMin_ = VFloat(2, sistrip::invalid_);
0085   rawMax_ = VFloat(2, sistrip::invalid_);
0086   rawMin_ = VFloat(2, sistrip::invalid_);
0087   dead_[0].reserve(256);
0088   dead_[1].reserve(256);
0089   noisy_[0].reserve(256);
0090   noisy_[1].reserve(256);
0091   legacy_ = false;
0092 }
0093 
0094 // ----------------------------------------------------------------------------
0095 //
0096 bool PedestalsAnalysis::isValid() const {
0097   return (pedsMean_[0] < sistrip::maximum_ && pedsMean_[1] < sistrip::maximum_ && pedsSpread_[0] < sistrip::maximum_ &&
0098           pedsSpread_[1] < sistrip::maximum_ && noiseMean_[0] < sistrip::maximum_ &&
0099           noiseMean_[1] < sistrip::maximum_ && noiseSpread_[0] < sistrip::maximum_ &&
0100           noiseSpread_[1] < sistrip::maximum_ && rawMean_[0] < sistrip::maximum_ && rawMean_[1] < sistrip::maximum_ &&
0101           rawSpread_[0] < sistrip::maximum_ && rawSpread_[1] < sistrip::maximum_ && pedsMax_[0] < sistrip::maximum_ &&
0102           pedsMax_[1] < sistrip::maximum_ && pedsMin_[0] < sistrip::maximum_ && pedsMin_[1] < sistrip::maximum_ &&
0103           noiseMax_[0] < sistrip::maximum_ && noiseMax_[1] < sistrip::maximum_ && noiseMin_[0] < sistrip::maximum_ &&
0104           noiseMin_[1] < sistrip::maximum_ && rawMax_[0] < sistrip::maximum_ && rawMax_[1] < sistrip::maximum_ &&
0105           rawMin_[0] < sistrip::maximum_ && rawMin_[1] < sistrip::maximum_ && getErrorCodes().empty());
0106   //noiseMean_[0] <= rawMean_[0] && //@@ temp
0107   //noiseMean_[1] <= rawMean_[1] ); //@@ temp
0108 }
0109 
0110 // ----------------------------------------------------------------------------
0111 //
0112 void PedestalsAnalysis::summary(std::stringstream& ss) const {
0113   SiStripFecKey fec_key(fecKey());
0114   SiStripFedKey fed_key(fedKey());
0115 
0116   sistrip::RunType type = SiStripEnumsAndStrings::runType(myName());
0117 
0118   std::stringstream extra1, extra2, extra3;
0119   if (legacy_) {
0120     extra1 << sistrip::extrainfo::pedsAndRawNoise_;
0121     extra2 << sistrip::extrainfo::pedsAndCmSubNoise_;
0122     extra3 << sistrip::extrainfo::commonMode_;
0123   } else {
0124     extra1 << sistrip::extrainfo::pedestals_;
0125     extra2 << sistrip::extrainfo::rawNoise_;
0126     extra3 << sistrip::extrainfo::commonMode_;
0127   }
0128 
0129   std::string title1 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0130                                          type,
0131                                          sistrip::FED_KEY,
0132                                          fed_key.key(),
0133                                          sistrip::LLD_CHAN,
0134                                          fec_key.lldChan(),
0135                                          extra1.str())
0136                            .title();
0137   std::string title2 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0138                                          type,
0139                                          sistrip::FED_KEY,
0140                                          fed_key.key(),
0141                                          sistrip::LLD_CHAN,
0142                                          fec_key.lldChan(),
0143                                          extra2.str())
0144                            .title();
0145   std::string title3 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0146                                          type,
0147                                          sistrip::FED_KEY,
0148                                          fed_key.key(),
0149                                          sistrip::APV,
0150                                          SiStripFecKey::i2cAddr(fec_key.lldChan(), true),
0151                                          extra3.str())
0152                            .title();
0153   std::string title4 = SiStripHistoTitle(sistrip::EXPERT_HISTO,
0154                                          type,
0155                                          sistrip::FED_KEY,
0156                                          fed_key.key(),
0157                                          sistrip::APV,
0158                                          SiStripFecKey::i2cAddr(fec_key.lldChan(), false),
0159                                          extra3.str())
0160                            .title();
0161 
0162   ss << " Summary"
0163      << ":" << (isValid() ? "Valid" : "Invalid") << ":" << sistrip::controlView_ << ":" << fec_key.fecCrate() << "/"
0164      << fec_key.fecSlot() << "/" << fec_key.fecRing() << "/" << fec_key.ccuAddr() << "/" << fec_key.ccuChan() << ":"
0165      << sistrip::dqmRoot_ << sistrip::dir_ << "Collate" << sistrip::dir_
0166      << SiStripFecKey(fec_key.fecCrate(), fec_key.fecSlot(), fec_key.fecRing(), fec_key.ccuAddr(), fec_key.ccuChan())
0167             .path()
0168      << ":" << title1 << ";" << title2 << ";" << title3 << ";" << title4 << std::endl;
0169 }
0170 
0171 // ----------------------------------------------------------------------------
0172 //
0173 void PedestalsAnalysis::print(std::stringstream& ss, uint32_t iapv) {
0174   if (iapv == 1 || iapv == 2) {
0175     iapv--;
0176   } else {
0177     iapv = 0;
0178   }
0179 
0180   if (peds_[iapv].size() < 128 || noise_[iapv].size() < 128 || raw_[iapv].size() < 128) {
0181     edm::LogWarning(mlCommissioning_) << "[" << myName() << "::" << __func__ << "]"
0182                                       << " Unexpected number of pedestal/noise values: " << peds_[iapv].size() << ", "
0183                                       << noise_[iapv].size() << ", " << raw_[iapv].size();
0184     return;
0185   }
0186 
0187   header(ss);
0188   ss << " Monitorables for APV number     : " << iapv;
0189   if (iapv == 0) {
0190     ss << " (first of pair)";
0191   } else if (iapv == 1) {
0192     ss << " (second of pair)";
0193   }
0194   ss << std::endl;
0195   ss << std::fixed << std::setprecision(2);
0196   ss << " Example peds/noise for strips   : "
0197      << "     0,     31,     63,    127" << std::endl
0198      << "  Peds                     [ADC] : " << std::setw(6) << peds_[iapv][0] << ", " << std::setw(6)
0199      << peds_[iapv][31] << ", " << std::setw(6) << peds_[iapv][63] << ", " << std::setw(6) << peds_[iapv][127]
0200      << std::endl
0201      << "  Noise                    [ADC] : " << std::setw(6) << noise_[iapv][0] << ", " << std::setw(6)
0202      << noise_[iapv][31] << ", " << std::setw(6) << noise_[iapv][63] << ", " << std::setw(6) << noise_[iapv][127]
0203      << std::endl
0204      << "  Raw noise                [ADC] : " << std::setw(6) << raw_[iapv][0] << ", " << std::setw(6) << raw_[iapv][31]
0205      << ", " << std::setw(6) << raw_[iapv][63] << ", " << std::setw(6) << raw_[iapv][127] << std::endl
0206      << " Dead strips (<5s)       [strip] : (" << dead_[iapv].size() << " in total) ";
0207   for (uint16_t ii = 0; ii < dead_[iapv].size(); ii++) {
0208     ss << dead_[iapv][ii] << " ";
0209   }
0210 
0211   ss << std::endl;
0212   ss << " Noisy strips (>5s)      [strip] : (" << noisy_[iapv].size() << " in total) ";
0213   for (uint16_t ii = 0; ii < noisy_[iapv].size(); ii++) {
0214     ss << noisy_[iapv][ii] << " ";
0215   }
0216   ss << std::endl;
0217   ss << " Mean peds +/- spread      [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
0218      << " Min/Max pedestal          [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
0219      << " Mean noise +/- spread     [ADC] : " << noiseMean_[iapv] << " +/- " << noiseSpread_[iapv] << std::endl
0220      << " Min/Max noise             [ADC] : " << noiseMin_[iapv] << " <-> " << noiseMax_[iapv] << std::endl
0221      << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
0222      << " Min/Max raw noise         [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
0223      << " Normalised noise                : "
0224      << "(yet to be implemented...)" << std::endl
0225      << std::boolalpha << " isValid                         : " << isValid() << std::endl
0226      << std::noboolalpha << " Error codes (found " << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
0227      << ")          : ";
0228   if (getErrorCodes().empty()) {
0229     ss << "(none)";
0230   } else {
0231     VString::const_iterator istr = getErrorCodes().begin();
0232     VString::const_iterator jstr = getErrorCodes().end();
0233     for (; istr != jstr; ++istr) {
0234       ss << *istr << " ";
0235     }
0236   }
0237   ss << std::endl;
0238 }