CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DQM/SiStripCommissioningClients/src/PedsFullNoiseHistograms.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningClients/interface/PedsFullNoiseHistograms.h"
00002 #include "CondFormats/SiStripObjects/interface/PedsFullNoiseAnalysis.h"
00003 #include "DQM/SiStripCommissioningAnalysis/interface/PedsFullNoiseAlgorithm.h"
00004 #include "DQM/SiStripCommissioningSummary/interface/PedsFullNoiseSummaryFactory.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 PedsFullNoiseHistograms::PedsFullNoiseHistograms( const edm::ParameterSet& pset,
00019                                                   DQMStore* bei ) 
00020   : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("PedsFullNoiseParameters"),
00021                              bei,
00022                              sistrip::PEDS_FULL_NOISE )
00023 {
00024   factory_ = auto_ptr<PedsFullNoiseSummaryFactory>( new PedsFullNoiseSummaryFactory );
00025   LogTrace(mlDqmClient_) 
00026     << "[PedsFullNoiseHistograms::" << __func__ << "]"
00027     << " Constructing object...";
00028 }
00029 
00030 // -----------------------------------------------------------------------------
00032 PedsFullNoiseHistograms::~PedsFullNoiseHistograms() {
00033   LogTrace(mlDqmClient_) 
00034     << "[PedsFullNoiseHistograms::" << __func__ << "]"
00035     << " Destructing object...";
00036 }
00037 
00038 // -----------------------------------------------------------------------------         
00040 void PedsFullNoiseHistograms::histoAnalysis( bool debug ) {
00041   LogTrace(mlDqmClient_)
00042     << "[PedsFullNoiseHistograms::" << __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         << "[PedsFullNoiseHistograms::" << __func__ << "]"
00064         << " Zero histograms found!";
00065       continue;
00066     }
00067     
00068     // Retrieve pointers to peds and noise histos
00069     std::vector<TH1*> hists;
00070     Histos::const_iterator ihis = iter->second.begin(); 
00071     for ( ; ihis != iter->second.end(); ihis++ ) {
00072       // pedestal profiles
00073       TProfile* prof = ExtractTObject<TProfile>().extract( (*ihis)->me_ );
00074       if ( prof ) { hists.push_back(prof); }
00075       //@@ Common mode histos?...
00076       //TH1F* his = ExtractTObject<TH1F>().extract( (*ihis)->me_ );
00077       //if ( his ) { profs.push_back(his); }
00078       // noise 2D histos
00079       TH2S * his2D = ExtractTObject<TH2S>().extract( (*ihis)->me_ );
00080       if ( his2D ) { hists.push_back(his2D); }
00081     }
00082 
00083     // Perform histo analysis
00084     PedsFullNoiseAnalysis * anal = new PedsFullNoiseAnalysis( iter->first );
00085     PedsFullNoiseAlgorithm algo( this->pset(), anal );
00086     algo.analysis( hists );
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       << "[PedsFullNoiseHistograms::" << __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         << "[PedsFullNoiseHistograms::" << __func__ << "]"
00113         << " Found " << count << " errors ("
00114         << 100 * count / histos().size() << "%): " 
00115         << ss.str();
00116     }
00117   } else {
00118     edm::LogWarning(mlDqmClient_) 
00119       << "[PedsFullNoiseHistograms::" << __func__ << "]"
00120       << " No histograms to analyze!";
00121   }
00122   
00123 }
00124 
00125 // -----------------------------------------------------------------------------         
00127 void PedsFullNoiseHistograms::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 }