Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DQM/SiStripCommissioningSummary/interface/FedTimingSummaryFactory.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 #include <sstream>
0007 
0008 using namespace sistrip;
0009 
0010 // -----------------------------------------------------------------------------
0011 //
0012 SummaryHistogramFactory<FedTimingAnalysis>::SummaryHistogramFactory()
0013     : mon_(sistrip::UNKNOWN_MONITORABLE),
0014       pres_(sistrip::UNKNOWN_PRESENTATION),
0015       view_(sistrip::UNKNOWN_VIEW),
0016       level_(sistrip::root_),
0017       gran_(sistrip::UNKNOWN_GRAN),
0018       generator_(nullptr) {
0019   ;
0020 }
0021 
0022 // -----------------------------------------------------------------------------
0023 //
0024 SummaryHistogramFactory<FedTimingAnalysis>::~SummaryHistogramFactory() {
0025   if (generator_) {
0026     delete generator_;
0027   }
0028 }
0029 
0030 // -----------------------------------------------------------------------------
0031 //
0032 void SummaryHistogramFactory<FedTimingAnalysis>::init(const sistrip::Monitorable& mon,
0033                                                       const sistrip::Presentation& pres,
0034                                                       const sistrip::View& view,
0035                                                       const std::string& top_level_dir,
0036                                                       const sistrip::Granularity& gran) {
0037   LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
0038   mon_ = mon;
0039   pres_ = pres;
0040   view_ = view;
0041   level_ = top_level_dir;
0042   gran_ = gran;
0043 
0044   // Retrieve utility class used to generate summary histograms
0045   if (generator_) {
0046     delete generator_;
0047     generator_ = nullptr;
0048   }
0049   generator_ = SummaryGenerator::instance(view);
0050 }
0051 
0052 //------------------------------------------------------------------------------
0053 //
0054 uint32_t SummaryHistogramFactory<FedTimingAnalysis>::extract(const std::map<uint32_t, FedTimingAnalysis>& data) {
0055   // Check if data are present
0056   if (data.empty()) {
0057     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0058                                      << " No data in monitorables std::map!";
0059     return 0;
0060   }
0061 
0062   // Check if instance of generator class exists
0063   if (!generator_) {
0064     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0065                                      << " NULL pointer to SummaryGenerator object!";
0066     return 0;
0067   }
0068 
0069   // Transfer appropriate monitorables info to generator object
0070   generator_->clearMap();
0071   std::map<uint32_t, FedTimingAnalysis>::const_iterator iter = data.begin();
0072   for (; iter != data.end(); iter++) {
0073     if (mon_ == sistrip::FED_TIMING_TIME) {
0074       generator_->fillMap(level_, gran_, iter->first, iter->second.time());
0075     } else if (mon_ == sistrip::FED_TIMING_MAX_TIME) {
0076       generator_->fillMap(level_, gran_, iter->first, iter->second.max());
0077     } else if (mon_ == sistrip::FED_TIMING_DELAY) {
0078       generator_->fillMap(level_, gran_, iter->first, iter->second.delay());
0079     } else if (mon_ == sistrip::FED_TIMING_ERROR) {
0080       generator_->fillMap(level_, gran_, iter->first, iter->second.error());
0081     } else if (mon_ == sistrip::FED_TIMING_BASE) {
0082       generator_->fillMap(level_, gran_, iter->first, iter->second.base());
0083     } else if (mon_ == sistrip::FED_TIMING_PEAK) {
0084       generator_->fillMap(level_, gran_, iter->first, iter->second.peak());
0085     } else if (mon_ == sistrip::FED_TIMING_HEIGHT) {
0086       generator_->fillMap(level_, gran_, iter->first, iter->second.height());
0087     } else {
0088       edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0089                                        << " Unexpected SummaryHisto value:"
0090                                        << SiStripEnumsAndStrings::monitorable(mon_);
0091       continue;
0092     }
0093   }
0094   return generator_->size();
0095 }
0096 
0097 //------------------------------------------------------------------------------
0098 //
0099 void SummaryHistogramFactory<FedTimingAnalysis>::fill(TH1& summary_histo) {
0100   // Check if instance of generator class exists
0101   if (!generator_) {
0102     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0103                                      << " NULL pointer to SummaryGenerator object!";
0104     return;
0105   }
0106 
0107   // Check if std::map is filled
0108   if (!generator_->size()) {
0109     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0110                                      << " No data in the monitorables std::map!";
0111     return;
0112   }
0113 
0114   // Generate appropriate summary histogram
0115   if (pres_ == sistrip::HISTO_1D) {
0116     generator_->histo1D(summary_histo);
0117   } else if (pres_ == sistrip::HISTO_2D_SUM) {
0118     generator_->histo2DSum(summary_histo);
0119   } else if (pres_ == sistrip::HISTO_2D_SCATTER) {
0120     generator_->histo2DScatter(summary_histo);
0121   } else if (pres_ == sistrip::PROFILE_1D) {
0122     generator_->profile1D(summary_histo);
0123   } else {
0124     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0125                                      << " Unexpected SummaryType value:" << SiStripEnumsAndStrings::presentation(pres_);
0126     return;
0127   }
0128 
0129   // Histogram formatting
0130   if (mon_ == sistrip::FED_TIMING_TIME) {
0131   } else if (mon_ == sistrip::FED_TIMING_MAX_TIME) {
0132   } else if (mon_ == sistrip::FED_TIMING_DELAY) {
0133   } else if (mon_ == sistrip::FED_TIMING_ERROR) {
0134   } else if (mon_ == sistrip::FED_TIMING_BASE) {
0135   } else if (mon_ == sistrip::FED_TIMING_PEAK) {
0136   } else if (mon_ == sistrip::FED_TIMING_HEIGHT) {
0137   } else {
0138     edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
0139                                      << " Unexpected SummaryHisto value:" << SiStripEnumsAndStrings::monitorable(mon_);
0140   }
0141   generator_->format(sistrip::FED_TIMING, mon_, pres_, view_, level_, gran_, summary_histo);
0142 }