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( const edm::ParameterSet& pset,
00019 DQMStore* bei )
00020 : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
00021 bei,
00022 sistrip::NOISE )
00023 {
00024 factory_ = auto_ptr<NoiseSummaryFactory>( new NoiseSummaryFactory );
00025 LogTrace(mlDqmClient_)
00026 << "[NoiseHistograms::" << __func__ << "]"
00027 << " Constructing object...";
00028 }
00029
00030
00032 NoiseHistograms::~NoiseHistograms() {
00033 LogTrace(mlDqmClient_)
00034 << "[NoiseHistograms::" << __func__ << "]"
00035 << " Destructing object...";
00036 }
00037
00038
00040 void NoiseHistograms::histoAnalysis( bool debug ) {
00041 LogTrace(mlDqmClient_)
00042 << "[NoiseHistograms::" << __func__ << "]";
00043
00044
00045 uint16_t valid = 0;
00046 HistosMap::const_iterator iter;
00047 Analyses::iterator ianal;
00048 std::map<std::string,uint16_t> errors;
00049
00050
00051 for ( ianal = data().begin(); ianal != data().end(); ianal++ ) {
00052 if ( ianal->second ) { delete ianal->second; }
00053 }
00054 data().clear();
00055
00056
00057 for ( iter = histos().begin();
00058 iter != histos().end(); iter++ ) {
00059
00060
00061 if ( iter->second.empty() ) {
00062 edm::LogWarning(mlDqmClient_)
00063 << "[NoiseHistograms::" << __func__ << "]"
00064 << " Zero histograms found!";
00065 continue;
00066 }
00067
00068
00069 std::vector<TH1*> profs;
00070 Histos::const_iterator ihis = iter->second.begin();
00071 for ( ; ihis != iter->second.end(); ihis++ ) {
00072 TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
00073 if ( prof ) { profs.push_back(prof); }
00074
00075
00076
00077 }
00078
00079
00080 NoiseAnalysis* anal = new NoiseAnalysis( iter->first );
00081 NoiseAlgorithm algo( this->pset(), anal );
00082 algo.analysis( profs );
00083 data()[iter->first] = anal;
00084 if ( anal->isValid() ) { valid++; }
00085 if ( !anal->getErrorCodes().empty() ) {
00086 errors[anal->getErrorCodes()[0]]++;
00087 }
00088
00089 }
00090
00091 if ( !histos().empty() ) {
00092 edm::LogVerbatim(mlDqmClient_)
00093 << "[NoiseHistograms::" << __func__ << "]"
00094 << " Analyzed histograms for " << histos().size()
00095 << " FED channels, of which " << valid
00096 << " (" << 100 * valid / histos().size()
00097 << "%) are valid.";
00098 if ( !errors.empty() ) {
00099 uint16_t count = 0;
00100 std::stringstream ss;
00101 ss << std::endl;
00102 std::map<std::string,uint16_t>::const_iterator ii;
00103 for ( ii = errors.begin(); ii != errors.end(); ++ii ) {
00104 ss << " " << ii->first << ": " << ii->second << std::endl;
00105 count += ii->second;
00106 }
00107 edm::LogWarning(mlDqmClient_)
00108 << "[NoiseHistograms::" << __func__ << "]"
00109 << " Found " << count << " errors ("
00110 << 100 * count / histos().size() << "%): "
00111 << ss.str();
00112 }
00113 } else {
00114 edm::LogWarning(mlDqmClient_)
00115 << "[NoiseHistograms::" << __func__ << "]"
00116 << " No histograms to analyze!";
00117 }
00118
00119 }
00120
00121
00123 void NoiseHistograms::printAnalyses() {
00124 Analyses::iterator ianal = data().begin();
00125 Analyses::iterator janal = data().end();
00126 for ( ; ianal != janal; ++ianal ) {
00127 if ( ianal->second ) {
00128 std::stringstream ss;
00129 ianal->second->print( ss, 1 );
00130 ianal->second->print( ss, 2 );
00131 if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str();
00132 } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
00133 }
00134 }
00135 }