CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/SiStripCommissioningSummary/src/DaqScopeModeSummaryFactory.cc

Go to the documentation of this file.
00001 #include "DQM/SiStripCommissioningSummary/interface/DaqScopeModeSummaryFactory.h"
00002 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
00003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
00004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00005 #include <iostream>
00006 #include <sstream>
00007 
00008 using namespace sistrip;
00009 
00010 // -----------------------------------------------------------------------------
00011 //
00012 SummaryHistogramFactory<DaqScopeModeAnalysis>::SummaryHistogramFactory() :
00013   mon_(sistrip::UNKNOWN_MONITORABLE),
00014   pres_(sistrip::UNKNOWN_PRESENTATION),
00015   view_(sistrip::UNKNOWN_VIEW),
00016   level_(sistrip::root_),
00017   gran_(sistrip::UNKNOWN_GRAN),
00018   generator_(0) 
00019 {;} 
00020 
00021 
00022 // -----------------------------------------------------------------------------
00023 //
00024 SummaryHistogramFactory<DaqScopeModeAnalysis>::~SummaryHistogramFactory() {
00025   if ( generator_ ) { delete generator_; }
00026 }
00027 
00028 // -----------------------------------------------------------------------------
00029 //
00030 void SummaryHistogramFactory<DaqScopeModeAnalysis>::init( const sistrip::Monitorable& mon, 
00031                                                           const sistrip::Presentation& pres,
00032                                                           const sistrip::View& view, 
00033                                                           const std::string& top_level_dir, 
00034                                                           const sistrip::Granularity& gran ) {
00035   mon_ = mon;
00036   pres_ = pres;
00037   view_ = view;
00038   level_ = top_level_dir;
00039   gran_ = gran;
00040 
00041   // Retrieve utility class used to generate summary histograms
00042   if ( generator_ ) { delete generator_; generator_ = 0; }
00043   generator_ = SummaryGenerator::instance( view );
00044   
00045 }
00046 
00047 //------------------------------------------------------------------------------
00048 //
00049 uint32_t SummaryHistogramFactory<DaqScopeModeAnalysis>::extract( const std::map<uint32_t,DaqScopeModeAnalysis>& data ) {
00050   
00051   // Check if data are present
00052   if ( data.empty() ) { 
00053     edm::LogWarning(mlSummaryPlots_)
00054       << "[SummaryHistogramFactory::" << __func__ << "]" 
00055       << " No data in monitorables std::map!";
00056     return 0; 
00057   }
00058   
00059   // Check if instance of generator class exists
00060   if ( !generator_ ) { 
00061     edm::LogWarning(mlSummaryPlots_)
00062       << "[SummaryHistogramFactory::" << __func__ << "]" 
00063       << " NULL pointer to SummaryGenerator object!";
00064     return 0;
00065   }
00066   
00067   // Transfer appropriate monitorables info to generator object
00068   generator_->clearMap();
00069   std::map<uint32_t,DaqScopeModeAnalysis>::const_iterator iter = data.begin();
00070   for ( ; iter != data.end(); iter++ ) {
00071     if ( mon_ == sistrip::DAQ_SCOPE_MODE_MEAN_SIGNAL ) { 
00072       generator_->fillMap( level_, gran_, iter->first, iter->second.mean() ); 
00073     } else { continue; }
00074   }
00075   return generator_->size();
00076 }
00077 
00078 //------------------------------------------------------------------------------
00079 //
00080 void SummaryHistogramFactory<DaqScopeModeAnalysis>::fill( TH1& summary_histo ) {
00081 
00082   // Check if instance of generator class exists
00083   if ( !generator_ ) { 
00084     edm::LogWarning(mlSummaryPlots_)
00085       << "[SummaryHistogramFactory::" << __func__ << "]" 
00086       << " NULL pointer to SummaryGenerator object!";
00087     return;
00088   }
00089 
00090   // Check if instance of generator class exists
00091   if ( !(&summary_histo) ) { 
00092     edm::LogWarning(mlSummaryPlots_)
00093       << "[SummaryHistogramFactory::" << __func__ << "]" 
00094       << " NULL pointer to SummaryGenerator object!";
00095     return;
00096   }
00097 
00098   // Check if std::map is filled
00099   if ( !generator_->size() ) { 
00100     edm::LogWarning(mlSummaryPlots_)
00101       << "[SummaryHistogramFactory::" << __func__ << "]" 
00102       << " No data in the monitorables std::map!";
00103     return; 
00104   } 
00105 
00106   // Generate appropriate summary histogram 
00107   if ( pres_ == sistrip::HISTO_1D ) {
00108     generator_->histo1D( summary_histo );
00109   } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
00110     generator_->histo2DSum( summary_histo );
00111   } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
00112     generator_->histo2DScatter( summary_histo );
00113   } else if ( pres_ == sistrip::PROFILE_1D ) {
00114     generator_->profile1D( summary_histo );
00115   } else { 
00116     edm::LogWarning(mlSummaryPlots_)
00117       << "[SummaryHistogramFactory::" << __func__ << "]" 
00118       << " Unexpected SummaryType value:"
00119       << SiStripEnumsAndStrings::presentation( pres_ );
00120     return; 
00121   }
00122   
00123   // Histogram formatting
00124   if ( mon_ == sistrip::DAQ_SCOPE_MODE_MEAN_SIGNAL ) { 
00125     generator_->axisLabel( "Mean signal [adc]" );
00126   } else { 
00127     edm::LogWarning(mlSummaryPlots_)
00128       << "[SummaryHistogramFactory::" << __func__ << "]" 
00129       << " Unexpected SummaryHisto value:"
00130       << SiStripEnumsAndStrings::monitorable( mon_ );
00131   } 
00132   generator_->format( sistrip::APV_TIMING, mon_, pres_, view_, level_, gran_, summary_histo );
00133   
00134 }
00135 
00136 // -----------------------------------------------------------------------------
00137 //
00138 template class SummaryHistogramFactory<DaqScopeModeAnalysis>;
00139