00001 #include "CondFormats/SiStripObjects/interface/PedsOnlyAnalysis.h"
00002 #include "DataFormats/SiStripCommon/interface/SiStripHistoTitle.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006 #include <iomanip>
00007 #include <cmath>
00008
00009 using namespace sistrip;
00010
00011
00012
00013 PedsOnlyAnalysis::PedsOnlyAnalysis( const uint32_t& key )
00014 : CommissioningAnalysis(key,"PedsOnlyAnalysis"),
00015 peds_(2,VFloat(128,sistrip::invalid_)),
00016 raw_(2,VFloat(128,sistrip::invalid_)),
00017 pedsMean_(2,sistrip::invalid_),
00018 pedsSpread_(2,sistrip::invalid_),
00019 rawMean_(2,sistrip::invalid_),
00020 rawSpread_(2,sistrip::invalid_),
00021 pedsMax_(2,sistrip::invalid_),
00022 pedsMin_(2,sistrip::invalid_),
00023 rawMax_(2,sistrip::invalid_),
00024 rawMin_(2,sistrip::invalid_),
00025 legacy_(false)
00026 {}
00027
00028
00029
00030 PedsOnlyAnalysis::PedsOnlyAnalysis()
00031 : CommissioningAnalysis("PedsOnlyAnalysis"),
00032 peds_(2,VFloat(128,sistrip::invalid_)),
00033 raw_(2,VFloat(128,sistrip::invalid_)),
00034 pedsMean_(2,sistrip::invalid_),
00035 pedsSpread_(2,sistrip::invalid_),
00036 rawMean_(2,sistrip::invalid_),
00037 rawSpread_(2,sistrip::invalid_),
00038 pedsMax_(2,sistrip::invalid_),
00039 pedsMin_(2,sistrip::invalid_),
00040 rawMax_(2,sistrip::invalid_),
00041 rawMin_(2,sistrip::invalid_),
00042 legacy_(false)
00043 {}
00044
00045
00046
00047 void PedsOnlyAnalysis::reset() {
00048 peds_ = VVFloat(2,VFloat(128,sistrip::invalid_));
00049 raw_ = VVFloat(2,VFloat(128,sistrip::invalid_));
00050 pedsMean_ = VFloat(2,sistrip::invalid_);
00051 pedsSpread_ = VFloat(2,sistrip::invalid_);
00052 rawMean_ = VFloat(2,sistrip::invalid_);
00053 rawSpread_ = VFloat(2,sistrip::invalid_);
00054 pedsMax_ = VFloat(2,sistrip::invalid_);
00055 pedsMin_ = VFloat(2,sistrip::invalid_);
00056 rawMax_ = VFloat(2,sistrip::invalid_);
00057 rawMin_ = VFloat(2,sistrip::invalid_);
00058 legacy_ = false;
00059 }
00060
00061
00062
00063 bool PedsOnlyAnalysis::isValid() const {
00064 return ( pedsMean_[0] < sistrip::maximum_ &&
00065 pedsMean_[1] < sistrip::maximum_ &&
00066 pedsSpread_[0] < sistrip::maximum_ &&
00067 pedsSpread_[1] < sistrip::maximum_ &&
00068 rawMean_[0] < sistrip::maximum_ &&
00069 rawMean_[1] < sistrip::maximum_ &&
00070 rawSpread_[0] < sistrip::maximum_ &&
00071 rawSpread_[1] < sistrip::maximum_ &&
00072 pedsMax_[0] < sistrip::maximum_ &&
00073 pedsMax_[1] < sistrip::maximum_ &&
00074 pedsMin_[0] < sistrip::maximum_ &&
00075 pedsMin_[1] < sistrip::maximum_ &&
00076 rawMax_[0] < sistrip::maximum_ &&
00077 rawMax_[1] < sistrip::maximum_ &&
00078 rawMin_[0] < sistrip::maximum_ &&
00079 rawMin_[1] < sistrip::maximum_ &&
00080 getErrorCodes().empty() );
00081 }
00082
00083
00084
00085 void PedsOnlyAnalysis::summary( std::stringstream& ss ) const {
00086
00087 SiStripFecKey fec_key( fecKey() );
00088 SiStripFedKey fed_key( fedKey() );
00089
00090 sistrip::RunType type = SiStripEnumsAndStrings::runType( myName() );
00091
00092 std::stringstream extra1,extra2,extra3;
00093 if ( legacy_ ) {
00094 extra1 << sistrip::extrainfo::pedsAndRawNoise_;
00095 extra2 << sistrip::extrainfo::pedsAndCmSubNoise_;
00096 extra3 << sistrip::extrainfo::commonMode_;
00097 } else {
00098 extra1 << sistrip::extrainfo::pedestals_;
00099 extra2 << sistrip::extrainfo::rawNoise_;
00100 extra3 << sistrip::extrainfo::commonMode_;
00101 }
00102
00103 std::string title1 = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00104 type,
00105 sistrip::FED_KEY,
00106 fed_key.key(),
00107 sistrip::LLD_CHAN,
00108 fec_key.lldChan(),
00109 extra1.str() ).title();
00110 std::string title2 = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00111 type,
00112 sistrip::FED_KEY,
00113 fed_key.key(),
00114 sistrip::LLD_CHAN,
00115 fec_key.lldChan(),
00116 extra2.str() ).title();
00117 std::string title3 = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00118 type,
00119 sistrip::FED_KEY,
00120 fed_key.key(),
00121 sistrip::APV,
00122 SiStripFecKey::i2cAddr( fec_key.lldChan(), true ),
00123 extra3.str() ).title();
00124 std::string title4 = SiStripHistoTitle( sistrip::EXPERT_HISTO,
00125 type,
00126 sistrip::FED_KEY,
00127 fed_key.key(),
00128 sistrip::APV,
00129 SiStripFecKey::i2cAddr( fec_key.lldChan(), false ),
00130 extra3.str() ).title();
00131
00132
00133 ss << " Summary"
00134 << ":"
00135 << ( isValid() ? "Valid" : "Invalid" )
00136 << ":"
00137 << sistrip::controlView_ << ":"
00138 << fec_key.fecCrate() << "/"
00139 << fec_key.fecSlot() << "/"
00140 << fec_key.fecRing() << "/"
00141 << fec_key.ccuAddr() << "/"
00142 << fec_key.ccuChan()
00143 << ":"
00144 << sistrip::dqmRoot_ << sistrip::dir_
00145 << "Collate" << sistrip::dir_
00146 << SiStripFecKey( fec_key.fecCrate(),
00147 fec_key.fecSlot(),
00148 fec_key.fecRing(),
00149 fec_key.ccuAddr(),
00150 fec_key.ccuChan() ).path()
00151 << ":"
00152 << title1 << ";" << title2 << ";" << title3 << ";" << title4
00153 << std::endl;
00154
00155 }
00156
00157
00158
00159 void PedsOnlyAnalysis::print( std::stringstream& ss, uint32_t iapv ) {
00160
00161 if ( iapv == 1 || iapv == 2 ) { iapv--; }
00162 else { iapv = 0; }
00163
00164 if ( peds_[iapv].size() < 128 ||
00165 raw_[iapv].size() < 128 ) {
00166 edm::LogWarning(mlCommissioning_)
00167 << "[" << myName() << "::" << __func__ << "]"
00168 << " Unexpected number of pedestal/noise values: "
00169 << peds_[iapv].size() << ", "
00170 << raw_[iapv].size();
00171 return;
00172 }
00173
00174 header( ss );
00175 ss << " Monitorables for APV number : " << iapv;
00176 if ( iapv == 0 ) { ss << " (first of pair)"; }
00177 else if ( iapv == 1 ) { ss << " (second of pair)"; }
00178 ss << std::endl;
00179 ss << std::fixed << std::setprecision(2);
00180 ss << " Example peds/noise for strips : "
00181 << " 0, 31, 63, 127" << std::endl
00182 << " Peds [ADC] : "
00183 << std::setw(6) << peds_[iapv][0] << ", "
00184 << std::setw(6) << peds_[iapv][31] << ", "
00185 << std::setw(6) << peds_[iapv][63] << ", "
00186 << std::setw(6) << peds_[iapv][127] << std::endl
00187 << " Raw noise [ADC] : "
00188 << std::setw(6) << raw_[iapv][0] << ", "
00189 << std::setw(6) << raw_[iapv][31] << ", "
00190 << std::setw(6) << raw_[iapv][63] << ", "
00191 << std::setw(6) << raw_[iapv][127] << std::endl;
00192 ss << " Mean peds +/- spread [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl
00193 << " Min/Max pedestal [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
00194 << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl
00195 << " Min/Max raw noise [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
00196 << std::boolalpha
00197 << " isValid : " << isValid() << std::endl
00198 << std::noboolalpha
00199 << " Error codes (found "
00200 << std::setw(2) << std::setfill(' ') << getErrorCodes().size()
00201 << ") : ";
00202 if ( getErrorCodes().empty() ) { ss << "(none)"; }
00203 else {
00204 VString::const_iterator istr = getErrorCodes().begin();
00205 VString::const_iterator jstr = getErrorCodes().end();
00206 for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
00207 }
00208 ss << std::endl;
00209 }
00210