CMS 3D CMS Logo

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( DQMOldReceiver* mui ) 
00019   : CommissioningHistograms( mui, sistrip::VPSP_SCAN )
00020 {
00021   factory_ = auto_ptr<VpspScanSummaryFactory>( new VpspScanSummaryFactory );
00022   LogTrace(mlDqmClient_) 
00023     << "[VpspScanHistograms::" << __func__ << "]"
00024     << " Constructing object...";
00025 }
00026 
00027 // -----------------------------------------------------------------------------
00029 VpspScanHistograms::VpspScanHistograms( DQMStore* bei ) 
00030   : CommissioningHistograms( bei, sistrip::VPSP_SCAN )
00031 {
00032   LogTrace(mlDqmClient_) 
00033     << "[VpspScanHistograms::" << __func__ << "]"
00034     << " Constructing object...";
00035 }
00036 
00037 // -----------------------------------------------------------------------------
00039 VpspScanHistograms::~VpspScanHistograms() {
00040   LogTrace(mlDqmClient_) 
00041     << "[VpspScanHistograms::" << __func__ << "]"
00042     << " Denstructing object...";
00043 }
00044 
00045 // -----------------------------------------------------------------------------         
00047 void VpspScanHistograms::histoAnalysis( bool debug ) {
00048   LogTrace(mlDqmClient_)
00049     << "[VpspScanHistograms::" << __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         << "[VpspScanHistograms::" << __func__ << "]"
00071         << " Zero histograms found!" << endl;
00072       continue;
00073     }
00074     
00075     // Retrieve pointers to profile histos for this FED channel 
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     } 
00082 
00083     // Perform histo analysis
00084     VpspScanAnalysis* anal = new VpspScanAnalysis( iter->first );
00085     VpspScanAlgorithm algo( anal );
00086     algo.analysis( profs );
00087     data()[iter->first] = anal; 
00088     if ( anal->isValid() ) { valid++; }
00089     if ( !anal->getErrorCodes().empty() ) { 
00090       errors[anal->getErrorCodes()[0]]++;
00091     }
00092     
00093   }
00094   
00095   if ( !histos().empty() ) {
00096     edm::LogVerbatim(mlDqmClient_) 
00097       << "[VpspScanHistograms::" << __func__ << "]"
00098       << " Analyzed histograms for " << histos().size() 
00099       << " FED channels, of which " << valid 
00100       << " (" << 100 * valid / histos().size()
00101       << "%) are valid.";
00102     if ( !errors.empty() ) {
00103       uint16_t count = 0;
00104       std::stringstream ss;
00105       ss << std::endl;
00106       std::map<std::string,uint16_t>::const_iterator ii;
00107       for ( ii = errors.begin(); ii != errors.end(); ++ii ) { 
00108         ss << " " << ii->first << ": " << ii->second << std::endl;
00109         count += ii->second;
00110       }
00111       edm::LogWarning(mlDqmClient_) 
00112         << "[VpspScanHistograms::" << __func__ << "]"
00113         << " Found " << count << " errors ("
00114         << 100 * count / histos().size() << "%): " 
00115         << ss.str();
00116     }
00117   } else {
00118     edm::LogWarning(mlDqmClient_) 
00119       << "[VpspScanHistograms::" << __func__ << "]"
00120       << " No histograms to analyze!";
00121   }
00122   
00123 }
00124 
00125 // -----------------------------------------------------------------------------
00127 void VpspScanHistograms::printAnalyses() {
00128   Analyses::iterator ianal = data().begin();
00129   Analyses::iterator janal = data().end();
00130   for ( ; ianal != janal; ++ianal ) { 
00131     if ( ianal->second ) { 
00132       std::stringstream ss;
00133       ianal->second->print( ss, 1 ); 
00134       ianal->second->print( ss, 2 ); 
00135       if ( ianal->second->isValid() ) { LogTrace(mlDqmClient_) << ss.str(); 
00136       } else { edm::LogWarning(mlDqmClient_) << ss.str(); }
00137     }
00138   }
00139 }

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