CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FedTimingSummaryFactory.cc
Go to the documentation of this file.
5 #include <iostream>
6 #include <sstream>
7 
8 using namespace sistrip;
9 
10 // -----------------------------------------------------------------------------
11 //
13  : mon_(sistrip::UNKNOWN_MONITORABLE),
14  pres_(sistrip::UNKNOWN_PRESENTATION),
15  view_(sistrip::UNKNOWN_VIEW),
16  level_(sistrip::root_),
17  gran_(sistrip::UNKNOWN_GRAN),
18  generator_(nullptr) {
19  ;
20 }
21 
22 // -----------------------------------------------------------------------------
23 //
25  if (generator_) {
26  delete generator_;
27  }
28 }
29 
30 // -----------------------------------------------------------------------------
31 //
33  const sistrip::Presentation& pres,
34  const sistrip::View& view,
35  const std::string& top_level_dir,
36  const sistrip::Granularity& gran) {
37  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
38  mon_ = mon;
39  pres_ = pres;
40  view_ = view;
41  level_ = top_level_dir;
42  gran_ = gran;
43 
44  // Retrieve utility class used to generate summary histograms
45  if (generator_) {
46  delete generator_;
47  generator_ = nullptr;
48  }
50 }
51 
52 //------------------------------------------------------------------------------
53 //
54 uint32_t SummaryHistogramFactory<FedTimingAnalysis>::extract(const std::map<uint32_t, FedTimingAnalysis>& data) {
55  // Check if data are present
56  if (data.empty()) {
57  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
58  << " No data in monitorables std::map!";
59  return 0;
60  }
61 
62  // Check if instance of generator class exists
63  if (!generator_) {
64  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
65  << " NULL pointer to SummaryGenerator object!";
66  return 0;
67  }
68 
69  // Transfer appropriate monitorables info to generator object
71  std::map<uint32_t, FedTimingAnalysis>::const_iterator iter = data.begin();
72  for (; iter != data.end(); iter++) {
74  generator_->fillMap(level_, gran_, iter->first, iter->second.time());
75  } else if (mon_ == sistrip::FED_TIMING_MAX_TIME) {
76  generator_->fillMap(level_, gran_, iter->first, iter->second.max());
77  } else if (mon_ == sistrip::FED_TIMING_DELAY) {
78  generator_->fillMap(level_, gran_, iter->first, iter->second.delay());
79  } else if (mon_ == sistrip::FED_TIMING_ERROR) {
80  generator_->fillMap(level_, gran_, iter->first, iter->second.error());
81  } else if (mon_ == sistrip::FED_TIMING_BASE) {
82  generator_->fillMap(level_, gran_, iter->first, iter->second.base());
83  } else if (mon_ == sistrip::FED_TIMING_PEAK) {
84  generator_->fillMap(level_, gran_, iter->first, iter->second.peak());
85  } else if (mon_ == sistrip::FED_TIMING_HEIGHT) {
86  generator_->fillMap(level_, gran_, iter->first, iter->second.height());
87  } else {
88  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
89  << " Unexpected SummaryHisto value:"
91  continue;
92  }
93  }
94  return generator_->size();
95 }
96 
97 //------------------------------------------------------------------------------
98 //
100  // Check if instance of generator class exists
101  if (!generator_) {
102  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
103  << " NULL pointer to SummaryGenerator object!";
104  return;
105  }
106 
107  // Check if std::map is filled
108  if (!generator_->size()) {
109  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
110  << " No data in the monitorables std::map!";
111  return;
112  }
113 
114  // Generate appropriate summary histogram
115  if (pres_ == sistrip::HISTO_1D) {
116  generator_->histo1D(summary_histo);
117  } else if (pres_ == sistrip::HISTO_2D_SUM) {
118  generator_->histo2DSum(summary_histo);
119  } else if (pres_ == sistrip::HISTO_2D_SCATTER) {
120  generator_->histo2DScatter(summary_histo);
121  } else if (pres_ == sistrip::PROFILE_1D) {
122  generator_->profile1D(summary_histo);
123  } else {
124  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
125  << " Unexpected SummaryType value:" << SiStripEnumsAndStrings::presentation(pres_);
126  return;
127  }
128 
129  // Histogram formatting
131  } else if (mon_ == sistrip::FED_TIMING_MAX_TIME) {
132  } else if (mon_ == sistrip::FED_TIMING_DELAY) {
133  } else if (mon_ == sistrip::FED_TIMING_ERROR) {
134  } else if (mon_ == sistrip::FED_TIMING_BASE) {
135  } else if (mon_ == sistrip::FED_TIMING_PEAK) {
136  } else if (mon_ == sistrip::FED_TIMING_HEIGHT) {
137  } else {
138  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
139  << " Unexpected SummaryHisto value:" << SiStripEnumsAndStrings::monitorable(mon_);
140  }
142 }
static std::string monitorable(const sistrip::Monitorable &)
uint32_t extract(const std::map< uint32_t, T > &data)
void histo2DSum(TH1 &)
void init(const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &top_level_dir, const sistrip::Granularity &)
static SummaryGenerator * instance(const sistrip::View &)
void histo2DScatter(TH1 &)
#define LogTrace(id)
void fillMap(const std::string &top_level_dir, const sistrip::Granularity &, const uint32_t &key, const float &value, const float &error=0.)
void fill(TH1 &summary_histo)
uint32_t size() const
void format(const sistrip::RunType &, const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &directory, const sistrip::Granularity &, TH1 &)
static const char mlSummaryPlots_[]
static std::string presentation(const sistrip::Presentation &)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
static const char root_[]
Log< level::Warning, false > LogWarning
sistrip::Presentation pres_