CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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_(0)
19 {;}
20 
21 
22 // -----------------------------------------------------------------------------
23 //
25  if ( generator_ ) { delete generator_; }
26 }
27 
28 // -----------------------------------------------------------------------------
29 //
31  const sistrip::Presentation& pres,
32  const sistrip::View& view,
33  const std::string& top_level_dir,
34  const sistrip::Granularity& gran ) {
36  << "[SummaryHistogramFactory::" << __func__ << "]";
37  mon_ = mon;
38  pres_ = pres;
39  view_ = view;
40  level_ = top_level_dir;
41  gran_ = gran;
42 
43  // Retrieve utility class used to generate summary histograms
44  if ( generator_ ) { delete generator_; generator_ = 0; }
46 
47 }
48 
49 //------------------------------------------------------------------------------
50 //
51 uint32_t SummaryHistogramFactory<FedTimingAnalysis>::extract( const std::map<uint32_t,FedTimingAnalysis>& data ) {
52 
53  // Check if data are present
54  if ( data.empty() ) {
55  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
56  << " No data in monitorables std::map!";
57  return 0;
58  }
59 
60  // Check if instance of generator class exists
61  if ( !generator_ ) {
62  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
63  << " NULL pointer to SummaryGenerator object!";
64  return 0;
65  }
66 
67  // Transfer appropriate monitorables info to generator object
69  std::map<uint32_t,FedTimingAnalysis>::const_iterator iter = data.begin();
70  for ( ; iter != data.end(); iter++ ) {
71  if ( mon_ == sistrip::FED_TIMING_TIME ) {
72  generator_->fillMap( level_, gran_, iter->first, iter->second.time() );
73  } else if ( mon_ == sistrip::FED_TIMING_MAX_TIME ) {
74  generator_->fillMap( level_, gran_, iter->first, iter->second.max() );
75  } else if ( mon_ == sistrip::FED_TIMING_DELAY ) {
76  generator_->fillMap( level_, gran_, iter->first, iter->second.delay() );
77  } else if ( mon_ == sistrip::FED_TIMING_ERROR ) {
78  generator_->fillMap( level_, gran_, iter->first, iter->second.error() );
79  } else if ( mon_ == sistrip::FED_TIMING_BASE ) {
80  generator_->fillMap( level_, gran_, iter->first, iter->second.base() );
81  } else if ( mon_ == sistrip::FED_TIMING_PEAK ) {
82  generator_->fillMap( level_, gran_, iter->first, iter->second.peak() );
83  } else if ( mon_ == sistrip::FED_TIMING_HEIGHT ) {
84  generator_->fillMap( level_, gran_, iter->first, iter->second.height() );
85  } else {
86  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
87  << " Unexpected SummaryHisto value:"
89  ;
90  continue;
91  }
92  }
93  return generator_->size();
94 }
95 
96 //------------------------------------------------------------------------------
97 //
99 
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 instance of generator class exists
108  if ( !(&summary_histo) ) {
109  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
110  << " NULL pointer to SummaryGenerator object!";
111  return;
112  }
113 
114  // Check if std::map is filled
115  if ( !generator_->size() ) {
116  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
117  << " No data in the monitorables std::map!";
118  return;
119  }
120 
121  // Generate appropriate summary histogram
122  if ( pres_ == sistrip::HISTO_1D ) {
123  generator_->histo1D( summary_histo );
124  } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
125  generator_->histo2DSum( summary_histo );
126  } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
127  generator_->histo2DScatter( summary_histo );
128  } else if ( pres_ == sistrip::PROFILE_1D ) {
129  generator_->profile1D( summary_histo );
130  } else {
131  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
132  << " Unexpected SummaryType value:"
134  ;
135  return;
136  }
137 
138  // Histogram formatting
139  if ( mon_ == sistrip::FED_TIMING_TIME ) {
140  } else if ( mon_ == sistrip::FED_TIMING_MAX_TIME ) {
141  } else if ( mon_ == sistrip::FED_TIMING_DELAY ) {
142  } else if ( mon_ == sistrip::FED_TIMING_ERROR ) {
143  } else if ( mon_ == sistrip::FED_TIMING_BASE ) {
144  } else if ( mon_ == sistrip::FED_TIMING_PEAK ) {
145  } else if ( mon_ == sistrip::FED_TIMING_HEIGHT ) {
146  } else {
147  edm::LogWarning(mlSummaryPlots_) << "[SummaryHistogramFactory::" << __func__ << "]"
148  << " Unexpected SummaryHisto value:"
150  ;
151  }
153 
154 }
155 
156 // -----------------------------------------------------------------------------
157 //
159 
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 &)
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
#define LogTrace(id)
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 &)
static const char root_[]
sistrip::Presentation pres_