Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:11:41

0001 #include "DQM/SiStripCommissioningSummary/interface/SummaryPlotFactoryBase.h"
0002 #include "DQM/SiStripCommissioningSummary/interface/SummaryGenerator.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include <iostream>
0006 
0007 using namespace sistrip;
0008 
0009 // -----------------------------------------------------------------------------
0010 //
0011 SummaryPlotFactoryBase::SummaryPlotFactoryBase()
0012     : mon_(sistrip::UNKNOWN_MONITORABLE),
0013       pres_(sistrip::UNKNOWN_PRESENTATION),
0014       view_(sistrip::UNKNOWN_VIEW),
0015       level_(sistrip::root_),
0016       gran_(sistrip::UNKNOWN_GRAN),
0017       generator_(nullptr) {
0018   ;
0019 }
0020 
0021 // -----------------------------------------------------------------------------
0022 //
0023 SummaryPlotFactoryBase::~SummaryPlotFactoryBase() {
0024   if (generator_) {
0025     delete generator_;
0026   }
0027 }
0028 
0029 // -----------------------------------------------------------------------------
0030 //
0031 void SummaryPlotFactoryBase::init(const sistrip::Monitorable& mon,
0032                                   const sistrip::Presentation& pres,
0033                                   const sistrip::View& view,
0034                                   const std::string& level,
0035                                   const sistrip::Granularity& gran) {
0036   // Create generator object
0037   if (generator_) {
0038     delete generator_;
0039     generator_ = nullptr;
0040   }
0041   generator_ = SummaryGenerator::instance(view);
0042 
0043   // Check if generator object exists
0044   if (!generator_) {
0045     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0046                                      << " NULL pointer to generator object!";
0047     return;
0048   }
0049 
0050   // Clear map used to build histogram
0051   generator_->clearMap();
0052 
0053   // Set parameters
0054   mon_ = mon;
0055   pres_ = pres;
0056   view_ = view;
0057   level_ = level;
0058   gran_ = gran;
0059 
0060   // Some checks
0061   if (mon_ == sistrip::UNKNOWN_MONITORABLE || mon_ == sistrip::UNDEFINED_MONITORABLE) {
0062     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0063                                      << " Unexpected monitorable: " << SiStripEnumsAndStrings::monitorable(mon_);
0064   }
0065 
0066   if (pres_ == sistrip::UNKNOWN_PRESENTATION || pres_ == sistrip::UNDEFINED_PRESENTATION) {
0067     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0068                                      << " Unexpected presentation: " << SiStripEnumsAndStrings::presentation(pres_);
0069   }
0070 
0071   if (view_ == sistrip::UNKNOWN_VIEW || view_ == sistrip::UNDEFINED_VIEW) {
0072     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0073                                      << " Unexpected view: " << SiStripEnumsAndStrings::view(view_);
0074   }
0075 
0076   if (level_.empty() || level_.find(sistrip::unknownView_) != std::string::npos ||
0077       level_.find(sistrip::undefinedView_) != std::string::npos) {
0078     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0079                                      << " Unexpected top-level directory: \"" << level_ << "\"";
0080   }
0081 
0082   if ((gran_ == sistrip::UNKNOWN_GRAN || gran_ == sistrip::UNDEFINED_GRAN) && pres != sistrip::HISTO_1D) {
0083     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0084                                      << " Unexpected granularity: " << SiStripEnumsAndStrings::granularity(gran_);
0085   }
0086 
0087   //   ss << "[SummaryPlotFactoryBase::" << __func__ << "]"
0088   //      << " Dump of parameters defining summary plot:" << std::endl
0089   //      << " Monitorable   : " << SiStripEnumsAndStrings::monitorable( mon_ ) << std::endl
0090   //      << " Presentation  : " << SiStripEnumsAndStrings::presentation( pres_ ) << std::endl
0091   //      << " Logical view  : " << SiStripEnumsAndStrings::view( view_ ) << std::endl
0092   //      << " Top level dir : " << level_ << std::endl
0093   //      << " Granularity   : " << SiStripEnumsAndStrings::granularity( gran_ );
0094   //   LogTrace(mlSummaryPlots_) << ss.str();
0095 }
0096 
0097 // -----------------------------------------------------------------------------
0098 //
0099 void SummaryPlotFactoryBase::fill(TH1& summary_histo) {
0100   // Check if instance of generator class exists
0101   if (!generator_) {
0102     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0103                                      << " NULL pointer to SummaryGenerator object!";
0104     return;
0105   }
0106 
0107   // Check if map is filled
0108   if (!generator_->nBins()) {
0109     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0110                                      << " Zero bins returned by SummaryGenerator!";
0111     return;
0112   }
0113 
0114   // Print contents of map for histogram
0115   //generator_->printMap();
0116 
0117   // Generate appropriate summary histogram
0118   if (pres_ == sistrip::HISTO_1D) {
0119     generator_->histo1D(summary_histo);
0120   } else if (pres_ == sistrip::HISTO_2D_SUM) {
0121     generator_->histo2DSum(summary_histo);
0122   } else if (pres_ == sistrip::HISTO_2D_SCATTER) {
0123     generator_->histo2DScatter(summary_histo);
0124   } else if (pres_ == sistrip::PROFILE_1D) {
0125     generator_->profile1D(summary_histo);
0126   } else {
0127     edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
0128                                      << " Unexpected presentation type: "
0129                                      << SiStripEnumsAndStrings::presentation(pres_);
0130     return;
0131   }
0132 
0133   // Histogram formatting
0134   generator_->format(sistrip::UNKNOWN_RUN_TYPE,  //@@ not used
0135                      mon_,
0136                      pres_,
0137                      view_,
0138                      level_,
0139                      gran_,
0140                      summary_histo);
0141 }