CMS 3D CMS Logo

NoiseHistograms.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningClients/interface/NoiseHistograms.h"
00002 #include "CondFormats/SiStripObjects/interface/NoiseAnalysis.h"
00003 #include "DQM/SiStripCommissioningAnalysis/interface/NoiseAlgorithm.h"
00004 #include "DQM/SiStripCommissioningSummary/interface/NoiseSummaryFactory.h"
00005 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00006 #include "DQM/SiStripCommon/interface/ExtractTObject.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include <iostream>
00009 #include <sstream>
00010 #include <iomanip>
00011 #include "TProfile.h"
00012 
00013 using namespace std;
00014 using namespace sistrip;
00015 
00016 // -----------------------------------------------------------------------------
00018 NoiseHistograms::NoiseHistograms( DQMOldReceiver* mui ) 
00019   : CommissioningHistograms( mui, sistrip::NOISE )
00020 {
00021   factory_ = auto_ptr<NoiseSummaryFactory>( new NoiseSummaryFactory );
00022   LogTrace(mlDqmClient_) 
00023     << "[NoiseHistograms::" << __func__ << "]"
00024     << " Constructing object...";
00025 }
00026 
00027 // -----------------------------------------------------------------------------
00029 NoiseHistograms::NoiseHistograms( DQMStore* bei ) 
00030   : CommissioningHistograms( bei, sistrip::NOISE )
00031 {
00032   LogTrace(mlDqmClient_) 
00033     << "[NoiseHistograms::" << __func__ << "]"
00034     << " Constructing object...";
00035 }
00036 
00037 // -----------------------------------------------------------------------------
00039 NoiseHistograms::~NoiseHistograms() {
00040   LogTrace(mlDqmClient_) 
00041     << "[NoiseHistograms::" << __func__ << "]"
00042     << " Destructing object...";
00043 }
00044 
00045 // -----------------------------------------------------------------------------         
00047 void NoiseHistograms::histoAnalysis( bool debug ) {
00048   LogTrace(mlDqmClient_)
00049     << "[NoiseHistograms::" << __func__ << "]";
00050 
00051   // Some initialisation
00052   uint16_t valid = 0;
00053   HistosMap::const_iterator iter;
00054   Analyses::iterator ianal;
00055   std::map<std::string,uint16_t> errors;
00056 
00057   // Clear map holding analysis objects
00058   for ( ianal = data().begin(); ianal != data().end(); ianal++ ) { 
00059     if ( ianal->second ) { delete ianal->second; }
00060   } 
00061   data().clear();
00062   
00063   // Iterate through map containing histograms
00064   for ( iter = histos().begin(); 
00065         iter != histos().end(); iter++ ) {
00066     
00067     // Check vector of histos is not empty
00068     if ( iter->second.empty() ) {
00069       edm::LogWarning(mlDqmClient_) 
00070         << "[NoiseHistograms::" << __func__ << "]"
00071         << " Zero histograms found!";
00072       continue;
00073     }
00074     
00075     // Retrieve pointers to profile histos
00076     std::vector<TH1*> profs;
00077     Histos::const_iterator ihis = iter->second.begin(); 
00078     for ( ; ihis != iter->second.end(); ihis++ ) {
00079       TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
00080       if ( prof ) { profs.push_back(prof); }
00081       //@@ Common mode histos?...
00082       //TH1F* his = ExtractTObject<TH1F>().extract( (*ihis)->me_ );
00083       //if ( his ) { profs.push_back(his); }
00084     }
00085     
00086     // Perform histo analysis
00087     NoiseAnalysis* anal = new NoiseAnalysis( iter->first );
00088     NoiseAlgorithm algo( anal );
00089     algo.analysis( profs );
00090     data()[iter->first] = anal; 
00091     if ( anal->isValid() ) { valid++; }
00092     if ( !anal->getErrorCodes().empty() ) { 
00093       errors[anal->getErrorCodes()[0]]++;
00094     }
00095     
00096   }
00097   
00098   if ( !histos().empty() ) {
00099     edm::LogVerbatim(mlDqmClient_) 
00100       << "[NoiseHistograms::" << __func__ << "]"
00101       << " Analyzed histograms for " << histos().size() 
00102       << " FED channels, of which " << valid 
00103       << " (" << 100 * valid / histos().size()
00104       << "%) are valid.";
00105     if ( !errors.empty() ) {
00106       uint16_t count = 0;
00107       std::stringstream ss;
00108       ss << std::endl;
00109       std::map<std::string,uint16_t>::const_iterator ii;
00110       for ( ii = errors.begin(); ii != errors.end(); ++ii ) { 
00111         ss << " " << ii->first << ": " << ii->second << std::endl;
00112         count += ii->second;
00113       }
00114       edm::LogWarning(mlDqmClient_) 
00115         << "[NoiseHistograms::" << __func__ << "]"
00116         << " Found " << count << " errors ("
00117         << 100 * count / histos().size() << "%): " 
00118         << ss.str();
00119     }
00120   } else {
00121     edm::LogWarning(mlDqmClient_) 
00122       << "[NoiseHistograms::" << __func__ << "]"
00123       << " No histograms to analyze!";
00124   }
00125   
00126 }
00127 
00128 // -----------------------------------------------------------------------------         
00130 void NoiseHistograms::printAnalyses() {
00131   Analyses::iterator ianal = data().begin();
00132   Analyses::iterator janal = data().end();
00133   for ( ; ianal != janal; ++ianal ) { 
00134     if ( ianal->second ) { 
00135       std::stringstream ss;
00136       ianal->second->print( ss, 1 ); 
00137       ianal->second->print( ss, 2 ); 
00138       if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str(); 
00139       } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
00140     }
00141   }
00142 }

Generated on Tue Jun 9 17:33:28 2009 for CMSSW by  doxygen 1.5.4