CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CondFormats/SiStripObjects/src/PedsFullNoiseAnalysis.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiStripObjects/interface/PedsFullNoiseAnalysis.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 PedsFullNoiseAnalysis::PedsFullNoiseAnalysis( const uint32_t& key ) 
00014   : CommissioningAnalysis(key,"PedsFullNoiseAnalysis"),
00015     peds_(2,VFloat(128,sistrip::invalid_)), 
00016     noise_(2,VFloat(128,sistrip::invalid_)), 
00017     raw_(2,VFloat(128,sistrip::invalid_)),
00018     ksProb_(2,VFloat(0,sistrip::invalid_)),
00019     chi2Prob_(2,VFloat(0,sistrip::invalid_)),
00020     noiseGaus_(2,VFloat(0,sistrip::invalid_)),
00021     noiseBin84_(2,VFloat(0,sistrip::invalid_)),
00022     noiseRMS_(2,VFloat(0,sistrip::invalid_)),
00023     noiseSignif_(2,VFloat(0,sistrip::invalid_)),
00024     dead_(2,VInt(0,sistrip::invalid_)), 
00025     noisy_(2,VInt(0,sistrip::invalid_)),
00026     pedsMean_(2,sistrip::invalid_), 
00027     pedsSpread_(2,sistrip::invalid_), 
00028     noiseMean_(2,sistrip::invalid_), 
00029     noiseSpread_(2,sistrip::invalid_), 
00030     rawMean_(2,sistrip::invalid_), 
00031     rawSpread_(2,sistrip::invalid_), 
00032     pedsMax_(2,sistrip::invalid_), 
00033     pedsMin_(2,sistrip::invalid_), 
00034     noiseMax_(2,sistrip::invalid_), 
00035     noiseMin_(2,sistrip::invalid_),
00036     rawMax_(2,sistrip::invalid_), 
00037     rawMin_(2,sistrip::invalid_),
00038     legacy_(false)
00039 {
00040   dead_[0].reserve(128); dead_[1].reserve(128); 
00041   noisy_[0].reserve(128); noisy_[1].reserve(128);
00042   ksProb_[0].reserve(128); ksProb_[1].reserve(128);
00043   chi2Prob_[0].reserve(128); chi2Prob_[1].reserve(128);
00044   noiseGaus_[0].reserve(128); noiseGaus_[1].reserve(128);
00045   noiseBin84_[0].reserve(128); noiseBin84_[1].reserve(128);
00046   noiseRMS_[0].reserve(128); noiseRMS_[1].reserve(128);
00047   noiseSignif_[0].reserve(128); noiseSignif_[1].reserve(128);
00048 }
00049 
00050 // ----------------------------------------------------------------------------
00051 // 
00052 PedsFullNoiseAnalysis::PedsFullNoiseAnalysis() 
00053   : CommissioningAnalysis("PedsFullNoiseAnalysis"),
00054     peds_(2,VFloat(128,sistrip::invalid_)), 
00055     noise_(2,VFloat(128,sistrip::invalid_)), 
00056     raw_(2,VFloat(128,sistrip::invalid_)),
00057     ksProb_(2,VFloat(0,sistrip::invalid_)),
00058     chi2Prob_(2,VFloat(0,sistrip::invalid_)),
00059     noiseGaus_(2,VFloat(0,sistrip::invalid_)),
00060     noiseBin84_(2,VFloat(0,sistrip::invalid_)),
00061     noiseRMS_(2,VFloat(0,sistrip::invalid_)),
00062     noiseSignif_(2,VFloat(0,sistrip::invalid_)),
00063     dead_(2,VInt(0,sistrip::invalid_)), 
00064     noisy_(2,VInt(0,sistrip::invalid_)),
00065     pedsMean_(2,sistrip::invalid_), 
00066     pedsSpread_(2,sistrip::invalid_), 
00067     noiseMean_(2,sistrip::invalid_), 
00068     noiseSpread_(2,sistrip::invalid_), 
00069     rawMean_(2,sistrip::invalid_), 
00070     rawSpread_(2,sistrip::invalid_), 
00071     pedsMax_(2,sistrip::invalid_), 
00072     pedsMin_(2,sistrip::invalid_), 
00073     noiseMax_(2,sistrip::invalid_), 
00074     noiseMin_(2,sistrip::invalid_),
00075     rawMax_(2,sistrip::invalid_), 
00076     rawMin_(2,sistrip::invalid_),
00077     legacy_(false)
00078 {
00079   dead_[0].reserve(128); dead_[1].reserve(128); 
00080   noisy_[0].reserve(128); noisy_[1].reserve(128);
00081   ksProb_[0].reserve(128); ksProb_[1].reserve(128);
00082   chi2Prob_[0].reserve(128); chi2Prob_[1].reserve(128);
00083   noiseGaus_[0].reserve(128); noiseGaus_[1].reserve(128);
00084   noiseBin84_[0].reserve(128); noiseBin84_[1].reserve(128);
00085   noiseRMS_[0].reserve(128); noiseRMS_[1].reserve(128);
00086   noiseSignif_[0].reserve(128); noiseSignif_[1].reserve(128);
00087 }
00088 
00089 // ----------------------------------------------------------------------------
00090 // 
00091 void PedsFullNoiseAnalysis::reset() {
00092   peds_        = VVFloat(2,VFloat(128,sistrip::invalid_)); 
00093   noise_       = VVFloat(2,VFloat(128,sistrip::invalid_)); 
00094   raw_         = VVFloat(2,VFloat(128,sistrip::invalid_));
00095   ksProb_      = VVFloat(2,VFloat(0,sistrip::invalid_));
00096   chi2Prob_    = VVFloat(2,VFloat(0,sistrip::invalid_));
00097   noiseGaus_   = VVFloat(2,VFloat(0,sistrip::invalid_));
00098   noiseBin84_   = VVFloat(2,VFloat(0,sistrip::invalid_));
00099   noiseRMS_             = VVFloat(2,VFloat(0,sistrip::invalid_));
00100   noiseSignif_ = VVFloat(2,VFloat(0,sistrip::invalid_));
00101   dead_        = VVInt(2,VInt(0,sistrip::invalid_)); 
00102   noisy_       = VVInt(2,VInt(0,sistrip::invalid_));
00103   pedsMean_    = VFloat(2,sistrip::invalid_); 
00104   pedsSpread_  = VFloat(2,sistrip::invalid_); 
00105   noiseMean_   = VFloat(2,sistrip::invalid_); 
00106   noiseSpread_ = VFloat(2,sistrip::invalid_); 
00107   rawMean_     = VFloat(2,sistrip::invalid_);
00108   rawSpread_   = VFloat(2,sistrip::invalid_);
00109   pedsMax_     = VFloat(2,sistrip::invalid_); 
00110   pedsMin_     = VFloat(2,sistrip::invalid_); 
00111   noiseMax_    = VFloat(2,sistrip::invalid_); 
00112   noiseMin_    = VFloat(2,sistrip::invalid_);
00113   rawMax_      = VFloat(2,sistrip::invalid_);
00114   rawMin_      = VFloat(2,sistrip::invalid_);
00115   dead_[0].reserve(128);   dead_[1].reserve(128); 
00116   noisy_[0].reserve(128);  noisy_[1].reserve(128);
00117   ksProb_[0].reserve(128);  ksProb_[1].reserve(128);
00118   chi2Prob_[0].reserve(128);   chi2Prob_[1].reserve(128);
00119   noiseGaus_[0].reserve(128);  noiseGaus_[1].reserve(128);
00120   noiseBin84_[0].reserve(128);  noiseBin84_[1].reserve(128);
00121   noiseRMS_[0].reserve(128);  noiseRMS_[1].reserve(128);
00122   noiseSignif_[0].reserve(128);  noiseSignif_[1].reserve(128);
00123   legacy_ = false;
00124 }
00125 
00126 // ----------------------------------------------------------------------------
00127 // 
00128 bool PedsFullNoiseAnalysis::isValid() const {
00129   return ( pedsMean_[0] < sistrip::maximum_ &&
00130            pedsMean_[1] < sistrip::maximum_ &&
00131            pedsSpread_[0] < sistrip::maximum_ &&
00132            pedsSpread_[1] < sistrip::maximum_ &&
00133            noiseMean_[0] < sistrip::maximum_ &&
00134            noiseMean_[1] < sistrip::maximum_ &&
00135            noiseSpread_[0] < sistrip::maximum_ &&
00136            noiseSpread_[1] < sistrip::maximum_ &&
00137            rawMean_[0] < sistrip::maximum_ &&
00138            rawMean_[1] < sistrip::maximum_ &&
00139            rawSpread_[0] < sistrip::maximum_ &&
00140            rawSpread_[1] < sistrip::maximum_ &&
00141            pedsMax_[0] < sistrip::maximum_ &&
00142            pedsMax_[1] < sistrip::maximum_ &&
00143            pedsMin_[0] < sistrip::maximum_ &&
00144            pedsMin_[1] < sistrip::maximum_ &&
00145            noiseMax_[0] < sistrip::maximum_ &&
00146            noiseMax_[1] < sistrip::maximum_ &&
00147            noiseMin_[0] < sistrip::maximum_ &&
00148            noiseMin_[1] < sistrip::maximum_ &&
00149            rawMax_[0] < sistrip::maximum_ &&
00150            rawMax_[1] < sistrip::maximum_ &&
00151            rawMin_[0] < sistrip::maximum_ &&
00152            rawMin_[1] < sistrip::maximum_ &&
00153            getErrorCodes().empty() );
00154   //noiseMean_[0] <= rawMean_[0] && //@@ temp
00155   //noiseMean_[1] <= rawMean_[1] ); //@@ temp
00156 } 
00157 
00158 // ----------------------------------------------------------------------------
00159 // 
00160 void PedsFullNoiseAnalysis::summary( std::stringstream& ss ) const { 
00161 
00162   SiStripFecKey fec_key( fecKey() );
00163   SiStripFedKey fed_key( fedKey() );
00164   
00165   sistrip::RunType type = SiStripEnumsAndStrings::runType( myName() );
00166 
00167   std::stringstream extra1,extra2,extra3;
00168   if ( legacy_ ) {
00169     extra1 << sistrip::extrainfo::pedsAndRawNoise_; 
00170     extra2 << sistrip::extrainfo::pedsAndCmSubNoise_; 
00171     extra3 << sistrip::extrainfo::commonMode_;
00172   } else {
00173     extra1 << sistrip::extrainfo::pedestals_; 
00174     extra2 << sistrip::extrainfo::rawNoise_; 
00175     extra3 << sistrip::extrainfo::commonMode_;
00176   }
00177   
00178   std::string title1 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00179                                           type,
00180                                           sistrip::FED_KEY, 
00181                                           fed_key.key(),
00182                                           sistrip::LLD_CHAN, 
00183                                           fec_key.lldChan(),
00184                                           extra1.str() ).title();
00185   std::string title2 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00186                                           type,
00187                                           sistrip::FED_KEY, 
00188                                           fed_key.key(),
00189                                           sistrip::LLD_CHAN, 
00190                                           fec_key.lldChan(),
00191                                           extra2.str() ).title();
00192   std::string title3 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00193                                           type,
00194                                           sistrip::FED_KEY, 
00195                                           fed_key.key(),
00196                                           sistrip::APV, 
00197                                           SiStripFecKey::i2cAddr( fec_key.lldChan(), true ),
00198                                           extra3.str() ).title();
00199   std::string title4 = SiStripHistoTitle( sistrip::EXPERT_HISTO, 
00200                                           type,
00201                                           sistrip::FED_KEY, 
00202                                           fed_key.key(),
00203                                           sistrip::APV, 
00204                                           SiStripFecKey::i2cAddr( fec_key.lldChan(), false ),
00205                                           extra3.str() ).title();
00206   
00207   
00208   ss << " Summary"
00209      << ":"
00210      << ( isValid() ? "Valid" : "Invalid" )
00211      << ":"
00212      << sistrip::controlView_ << ":"
00213      << fec_key.fecCrate() << "/" 
00214      << fec_key.fecSlot() << "/" 
00215      << fec_key.fecRing() << "/" 
00216      << fec_key.ccuAddr() << "/" 
00217      << fec_key.ccuChan() 
00218      << ":"
00219      << sistrip::dqmRoot_ << sistrip::dir_ 
00220      << "Collate" << sistrip::dir_ 
00221      << SiStripFecKey( fec_key.fecCrate(),
00222                        fec_key.fecSlot(), 
00223                        fec_key.fecRing(), 
00224                        fec_key.ccuAddr(), 
00225                        fec_key.ccuChan() ).path()
00226      << ":"
00227      << title1 << ";" << title2 << ";" << title3 << ";" << title4
00228      << std::endl;
00229   
00230 }
00231 
00232 // ----------------------------------------------------------------------------
00233 // 
00234 void PedsFullNoiseAnalysis::print( std::stringstream& ss, uint32_t iapv ) { 
00235 
00236   if ( iapv == 1 || iapv == 2 ) { iapv--; }
00237   else { iapv = 0; }
00238   
00239   if ( peds_[iapv].size() < 128 ||
00240        noise_[iapv].size() < 128 ||
00241        raw_[iapv].size() < 128 ) { 
00242     edm::LogWarning(mlCommissioning_)
00243       << "[" << myName() << "::" << __func__ << "]"
00244       << " Unexpected number of pedestal/noise values: " 
00245       << peds_[iapv].size() << ", " 
00246       << noise_[iapv].size() << ", " 
00247       << raw_[iapv].size();
00248     return;
00249   }
00250   
00251   header( ss );
00252   ss << " Monitorables for APV number     : " << iapv;
00253   if ( iapv == 0 ) { ss << " (first of pair)"; }
00254   else if ( iapv == 1 ) { ss << " (second of pair)"; } 
00255   ss << std::endl;
00256   ss << std::fixed << std::setprecision(2);
00257   ss << " Example peds/noise for strips   : "
00258      << "     0,     31,     63,    127" << std::endl
00259      << "  Peds                     [ADC] : " 
00260      << std::setw(6) << peds_[iapv][0] << ", " 
00261      << std::setw(6) << peds_[iapv][31] << ", " 
00262      << std::setw(6) << peds_[iapv][63] << ", " 
00263      << std::setw(6) << peds_[iapv][127] << std::endl
00264      << "  Noise                    [ADC] : " 
00265      << std::setw(6) << noise_[iapv][0] << ", " 
00266      << std::setw(6) << noise_[iapv][31] << ", " 
00267      << std::setw(6) << noise_[iapv][63] << ", " 
00268      << std::setw(6) << noise_[iapv][127] << std::endl
00269      << "  Raw noise                [ADC] : " 
00270      << std::setw(6) << raw_[iapv][0] << ", " 
00271      << std::setw(6) << raw_[iapv][31] << ", " 
00272      << std::setw(6) << raw_[iapv][63] << ", " 
00273      << std::setw(6) << raw_[iapv][127] << std::endl
00274      << " Dead strips (<5s)       [strip] : (" << dead_[iapv].size() << " in total) ";
00275   for ( uint16_t ii = 0; ii < dead_[iapv].size(); ii++ ) { 
00276     ss << dead_[iapv][ii] << " "; }
00277   
00278   ss << std::endl;
00279   ss << " Noisy strips (>5s)      [strip] : (" << noisy_[iapv].size() << " in total) ";
00280   for ( uint16_t ii = 0; ii < noisy_[iapv].size(); ii++ ) { 
00281     ss << noisy_[iapv][ii] << " "; 
00282   } 
00283   ss << std::endl;
00284   ss << " Mean peds +/- spread      [ADC] : " << pedsMean_[iapv] << " +/- " << pedsSpread_[iapv] << std::endl 
00285      << " Min/Max pedestal          [ADC] : " << pedsMin_[iapv] << " <-> " << pedsMax_[iapv] << std::endl
00286      << " Mean noise +/- spread     [ADC] : " << noiseMean_[iapv] << " +/- " << noiseSpread_[iapv] << std::endl 
00287      << " Min/Max noise             [ADC] : " << noiseMin_[iapv] << " <-> " << noiseMax_[iapv] << std::endl
00288      << " Mean raw noise +/- spread [ADC] : " << rawMean_[iapv] << " +/- " << rawSpread_[iapv] << std::endl 
00289      << " Min/Max raw noise         [ADC] : " << rawMin_[iapv] << " <-> " << rawMax_[iapv] << std::endl
00290      << " Normalised noise                : " << "(yet to be implemented...)" << std::endl
00291      << std::boolalpha 
00292      << " isValid                         : " << isValid()  << std::endl
00293      << std::noboolalpha
00294      << " Error codes (found "
00295      << std::setw(2) << std::setfill(' ') << getErrorCodes().size() 
00296      << ")          : ";
00297   if ( getErrorCodes().empty() ) { ss << "(none)"; }
00298   else { 
00299     VString::const_iterator istr = getErrorCodes().begin();
00300     VString::const_iterator jstr = getErrorCodes().end();
00301     for ( ; istr != jstr; ++istr ) { ss << *istr << " "; }
00302   }
00303   ss << std::endl;
00304 }
00305