test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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>
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_(0)
19 {
21  << "[SummaryHistogramFactory::" << __func__ << "]";
22 }
23 
24 // -----------------------------------------------------------------------------
25 //
26 template<class T>
28  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
29  if ( generator_ ) { delete generator_; }
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_ = 0;
51  generator_ = SummaryGenerator::instance( view );
52  }
53 
54 }
55 
56 // -----------------------------------------------------------------------------
57 //
58 template<class T>
59 uint32_t SummaryHistogramFactory<T>::extract( const std::map<uint32_t,T>& data ) {
60  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
61 
62  // Check if data are present
63  if ( data.empty() ) {
64  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
65  << " No data in monitorables std::map!";
66  return 0;
67  }
68 
69  // Check if instance of generator class exists
70  if ( !generator_ ) {
71  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
72  << " NULL pointer to SummaryGenerator object!";
73  return 0;
74  }
75 
76  // Transfer appropriate monitorables info to generator object
77  generator_->clearMap();
78  typename std::map<uint32_t,T>::const_iterator iter = data.begin();
79  for ( ; iter != data.end(); iter++ ) {
80  generator_->fillMap( level_, // top-level directory
81  gran_, // granularity
82  iter->first, // device key
83  static_cast<float>(iter->second) ); // value
84  }
85 
86  return generator_->size();
87 }
88 
89 // -----------------------------------------------------------------------------
90 //
91 template<class T>
92 void SummaryHistogramFactory<T>::fill( TH1& summary_histo ) {
93  LogTrace(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]";
94 
95  // Check if instance of generator class exists
96  if ( !generator_ ) {
97  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
98  << " NULL pointer to SummaryGenerator object!";
99  return;
100  }
101 
102  // Check if instance of generator class exists
103  if ( !(&summary_histo) ) {
104  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
105  << " NULL pointer to SummaryGenerator object!";
106  return;
107  }
108 
109  // Check if std::map is filled
110  if ( !generator_->size() ) {
111  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
112  << " No data in the monitorables std::map!";
113  return;
114  }
115 
116  // Generate appropriate summary histogram
117  if ( pres_ == sistrip::HISTO_1D ) {
118  generator_->histo1D( summary_histo );
119  } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
120  generator_->histo2DSum( summary_histo );
121  } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
122  generator_->histo2DScatter( summary_histo );
123  } else if ( pres_ == sistrip::PROFILE_1D ) {
124  generator_->profile1D( summary_histo );
125  } else { return; }
126 
127  // Histogram formatting
128  generator_->format( sistrip::UNKNOWN_RUN_TYPE, mon_, pres_, view_, level_, gran_, summary_histo );
129 
130 }
131 
132 // -----------------------------------------------------------------------------
133 //
134 template class SummaryHistogramFactory<uint32_t>;
135 template class SummaryHistogramFactory<uint16_t>;
136 template class SummaryHistogramFactory<float>;
137 
uint32_t extract(const std::map< uint32_t, T > &data)
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 fill(TH1 &summary_histo)
#define LogTrace(id)
static const char mlSummaryPlots_[]
static const char root_[]