CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQM/SiStripCommissioningClients/src/VpspScanHistograms.cc

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