CMS 3D CMS Logo

OptoScanHistograms.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningClients/interface/OptoScanHistograms.h"
00002 #include "CondFormats/SiStripObjects/interface/OptoScanAnalysis.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripConstants.h"
00004 #include "DQM/SiStripCommissioningAnalysis/interface/OptoScanAlgorithm.h"
00005 #include "DQM/SiStripCommissioningSummary/interface/OptoScanSummaryFactory.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 OptoScanHistograms::OptoScanHistograms( DQMOldReceiver* mui ) 
00019   : CommissioningHistograms( mui, sistrip::OPTO_SCAN )
00020 {
00021   factory_ = auto_ptr<OptoScanSummaryFactory>( new OptoScanSummaryFactory );
00022   LogTrace(mlDqmClient_) 
00023     << "[OptoScanHistograms::" << __func__ << "]"
00024     << " Constructing object...";
00025 }
00026 
00027 // -----------------------------------------------------------------------------
00029 OptoScanHistograms::OptoScanHistograms( DQMStore* bei ) 
00030   : CommissioningHistograms( bei, sistrip::OPTO_SCAN )
00031 {
00032   LogTrace(mlDqmClient_) 
00033     << "[OptoScanHistograms::" << __func__ << "]"
00034     << " Constructing object...";
00035 }
00036 
00037 // -----------------------------------------------------------------------------
00039 OptoScanHistograms::~OptoScanHistograms() {
00040   LogTrace(mlDqmClient_) 
00041     << "[OptoScanHistograms::" << __func__ << "]"
00042     << " Denstructing object...";
00043 }
00044 
00045 // -----------------------------------------------------------------------------         
00047 void OptoScanHistograms::histoAnalysis( bool debug ) {
00048   LogTrace(mlDqmClient_)
00049     << "[OptoScanHistograms::" << __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         << "[OptoScanHistograms::" << __func__ << "]"
00071         << " Zero histograms found!";
00072       continue;
00073     }
00074     
00075     // Retrieve pointers to 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     } 
00082 
00083     // Perform histo analysis
00084     OptoScanAnalysis* anal = new OptoScanAnalysis( iter->first );
00085     OptoScanAlgorithm 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       << "[OptoScanHistograms::" << __func__ << "]"
00098       << " Analyzed histograms for " << histos().size() 
00099       << " FED channels, of which " << valid 
00100       << " (" << 100 * valid / histos().size()
00101       << "%) are valid.";
00102   } else {
00103     edm::LogWarning(mlDqmClient_) 
00104       << "[OptoScanHistograms::" << __func__ << "]"
00105       << " No histograms to analyze!";
00106   }
00107 
00108   if ( !histos().empty() ) {
00109     edm::LogVerbatim(mlDqmClient_) 
00110       << "[OptoScanHistograms::" << __func__ << "]"
00111       << " Analyzed histograms for " << histos().size() 
00112       << " FED channels, of which " << valid 
00113       << " (" << 100 * valid / histos().size()
00114       << "%) are valid.";
00115     if ( !errors.empty() ) {
00116       uint16_t count = 0;
00117       std::stringstream ss;
00118       ss << std::endl;
00119       std::map<std::string,uint16_t>::const_iterator ii;
00120       for ( ii = errors.begin(); ii != errors.end(); ++ii ) { 
00121         ss << " " << ii->first << ": " << ii->second << std::endl;
00122         count += ii->second;
00123       }
00124       edm::LogWarning(mlDqmClient_) 
00125         << "[OptoScanHistograms::" << __func__ << "]"
00126         << " Found " << count << " errors ("
00127         << 100 * count / histos().size() << "%): " 
00128         << ss.str();
00129     }
00130   } else {
00131     edm::LogWarning(mlDqmClient_) 
00132       << "[OptoScanHistograms::" << __func__ << "]"
00133       << " No histograms to analyze!";
00134   }
00135   
00136 }
00137 
00138 // -----------------------------------------------------------------------------
00140 void OptoScanHistograms::printAnalyses() {
00141   Analyses::iterator ianal = data().begin();
00142   Analyses::iterator janal = data().end();
00143   for ( ; ianal != janal; ++ianal ) {
00144     if ( ianal->second ) {
00145       std::stringstream ss;
00146       if ( ianal->second->isValid() ) {
00147         ianal->second->print( ss );
00148         LogTrace(mlDqmClient_) << ss.str();
00149       } else {
00150         ianal->second->print( ss, 0 );
00151         ianal->second->print( ss, 1 );
00152         ianal->second->print( ss, 2 );
00153         ianal->second->print( ss, 3 );
00154         edm::LogWarning(mlDqmClient_) << ss.str();
00155       }
00156     }
00157   }
00158 }
00159 

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