CMS 3D CMS Logo

SummaryHistogramFactory.cc
Go to the documentation of this file.
4 #include <iostream>
5 #include <sstream>
6 
7 using namespace sistrip;
8 
9 // -----------------------------------------------------------------------------
10 //
11 template <class T>
15  view_(sistrip::UNKNOWN_VIEW),
16  level_(sistrip::root_),
17  gran_(sistrip::UNKNOWN_GRAN),
18  generator_(nullptr) {
19  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
20 }
21 
22 // -----------------------------------------------------------------------------
23 //
24 template <class T>
26  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
27  if (generator_) {
28  delete generator_;
29  }
30 }
31 
32 // -----------------------------------------------------------------------------
33 //
34 template <class T>
36  const sistrip::Presentation& pres,
37  const sistrip::View& view,
38  const std::string& top_level_dir,
39  const sistrip::Granularity& gran) {
40  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
41  mon_ = mon;
42  pres_ = pres;
43  view_ = view;
44  level_ = top_level_dir;
45  gran_ = gran;
46 
47  // Retrieve utility class used to generate summary histograms
48  if (generator_) {
49  delete generator_;
50  generator_ = nullptr;
51  generator_ = SummaryGenerator::instance(view);
52  }
53 }
54 
55 // -----------------------------------------------------------------------------
56 //
57 template <class T>
58 uint32_t SummaryHistogramFactory<T>::extract(const std::map<uint32_t, T>& data) {
59  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
60 
61  // Check if data are present
62  if (data.empty()) {
63  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
64  << " No data in monitorables std::map!";
65  return 0;
66  }
67 
68  // Check if instance of generator class exists
69  if (!generator_) {
70  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
71  << " NULL pointer to SummaryGenerator object!";
72  return 0;
73  }
74 
75  // Transfer appropriate monitorables info to generator object
76  generator_->clearMap();
77  typename std::map<uint32_t, T>::const_iterator iter = data.begin();
78  for (; iter != data.end(); iter++) {
79  generator_->fillMap(level_, // top-level directory
80  gran_, // granularity
81  iter->first, // device key
82  static_cast<float>(iter->second)); // value
83  }
84 
85  return generator_->size();
86 }
87 
88 // -----------------------------------------------------------------------------
89 //
90 template <class T>
91 void SummaryHistogramFactory<T>::fill(TH1& summary_histo) {
92  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
93 
94  // Check if instance of generator class exists
95  if (!generator_) {
96  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
97  << " NULL pointer to SummaryGenerator object!";
98  return;
99  }
100 
101  // Check if std::map is filled
102  if (!generator_->size()) {
103  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
104  << " No data in the monitorables std::map!";
105  return;
106  }
107 
108  // Generate appropriate summary histogram
109  if (pres_ == sistrip::HISTO_1D) {
110  generator_->histo1D(summary_histo);
111  } else if (pres_ == sistrip::HISTO_2D_SUM) {
112  generator_->histo2DSum(summary_histo);
113  } else if (pres_ == sistrip::HISTO_2D_SCATTER) {
114  generator_->histo2DScatter(summary_histo);
115  } else if (pres_ == sistrip::PROFILE_1D) {
116  generator_->profile1D(summary_histo);
117  } else {
118  return;
119  }
120 
121  // Histogram formatting
122  generator_->format(sistrip::UNKNOWN_RUN_TYPE, mon_, pres_, view_, level_, gran_, summary_histo);
123 }
124 
125 // -----------------------------------------------------------------------------
126 //
127 template class SummaryHistogramFactory<uint32_t>;
128 template class SummaryHistogramFactory<uint16_t>;
129 template class SummaryHistogramFactory<float>;
sistrip::Granularity
Granularity
Definition: ConstantsForGranularity.h:60
sistrip::UNKNOWN_MONITORABLE
Definition: ConstantsForMonitorable.h:201
MessageLogger.h
SummaryHistogramFactory::init
void init(const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &top_level_dir, const sistrip::Granularity &)
Definition: SummaryHistogramFactory.cc:35
sistrip::View
View
Definition: ConstantsForView.h:26
sistrip::HISTO_2D_SUM
Definition: ConstantsForPresentation.h:32
sistrip::UNKNOWN_GRAN
Definition: ConstantsForGranularity.h:62
SummaryHistogramFactory::~SummaryHistogramFactory
~SummaryHistogramFactory()
Definition: SummaryHistogramFactory.cc:25
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
SummaryHistogramFactory.h
sistrip::Monitorable
Monitorable
Definition: ConstantsForMonitorable.h:200
sistrip::Presentation
Presentation
Definition: ConstantsForPresentation.h:28
LaserDQM_cfi.mon
mon
Definition: LaserDQM_cfi.py:3
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
SummaryHistogramFactory::fill
void fill(TH1 &summary_histo)
Definition: SummaryHistogramFactory.cc:91
sistrip::HISTO_1D
Definition: ConstantsForPresentation.h:31
sistrip::HISTO_2D_SCATTER
Definition: ConstantsForPresentation.h:33
sistrip::UNKNOWN_RUN_TYPE
Definition: ConstantsForRunType.h:94
sistrip::PROFILE_1D
Definition: ConstantsForPresentation.h:34
sistrip::root_
static const char root_[]
Definition: ConstantsForDqm.h:30
SummaryGenerator::instance
static SummaryGenerator * instance(const sistrip::View &)
Definition: SummaryGenerator.cc:23
sistrip::UNKNOWN_VIEW
Definition: ConstantsForView.h:27
SummaryHistogramFactory
Definition: SummaryHistogramFactory.h:13
sistrip::mlSummaryPlots_
static const char mlSummaryPlots_[]
Definition: ConstantsForLogger.h:26
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
SummaryGenerator.h
SummaryHistogramFactory::SummaryHistogramFactory
SummaryHistogramFactory()
Definition: SummaryHistogramFactory.cc:12
LogTrace
#define LogTrace(id)
Definition: MessageLogger.h:224
sistrip
sistrip classes
Definition: SiStripQualityHelpers.h:14
SummaryHistogramFactory::extract
uint32_t extract(const std::map< uint32_t, T > &data)
Definition: SummaryHistogramFactory.cc:58
sistrip::UNKNOWN_PRESENTATION
Definition: ConstantsForPresentation.h:29