CMS 3D CMS Logo

SummaryPlotFactoryBase.cc
Go to the documentation of this file.
5 #include <iostream>
6 
7 using namespace sistrip;
8 
9 // -----------------------------------------------------------------------------
10 //
14  view_(sistrip::UNKNOWN_VIEW),
15  level_(sistrip::root_),
16  gran_(sistrip::UNKNOWN_GRAN),
17  generator_(nullptr) {
18  ;
19 }
20 
21 // -----------------------------------------------------------------------------
22 //
24  if (generator_) {
25  delete generator_;
26  }
27 }
28 
29 // -----------------------------------------------------------------------------
30 //
32  const sistrip::Presentation& pres,
33  const sistrip::View& view,
34  const std::string& level,
35  const sistrip::Granularity& gran) {
36  // Create generator object
37  if (generator_) {
38  delete generator_;
39  generator_ = nullptr;
40  }
42 
43  // Check if generator object exists
44  if (!generator_) {
45  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
46  << " NULL pointer to generator object!";
47  return;
48  }
49 
50  // Clear map used to build histogram
52 
53  // Set parameters
54  mon_ = mon;
55  pres_ = pres;
56  view_ = view;
57  level_ = level;
58  gran_ = gran;
59 
60  // Some checks
62  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
63  << " Unexpected monitorable: " << SiStripEnumsAndStrings::monitorable(mon_);
64  }
65 
67  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
68  << " Unexpected presentation: " << SiStripEnumsAndStrings::presentation(pres_);
69  }
70 
72  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
73  << " Unexpected view: " << SiStripEnumsAndStrings::view(view_);
74  }
75 
76  if (level_.empty() || level_.find(sistrip::unknownView_) != std::string::npos ||
77  level_.find(sistrip::undefinedView_) != std::string::npos) {
78  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
79  << " Unexpected top-level directory: \"" << level_ << "\"";
80  }
81 
83  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
84  << " Unexpected granularity: " << SiStripEnumsAndStrings::granularity(gran_);
85  }
86 
87  // ss << "[SummaryPlotFactoryBase::" << __func__ << "]"
88  // << " Dump of parameters defining summary plot:" << std::endl
89  // << " Monitorable : " << SiStripEnumsAndStrings::monitorable( mon_ ) << std::endl
90  // << " Presentation : " << SiStripEnumsAndStrings::presentation( pres_ ) << std::endl
91  // << " Logical view : " << SiStripEnumsAndStrings::view( view_ ) << std::endl
92  // << " Top level dir : " << level_ << std::endl
93  // << " Granularity : " << SiStripEnumsAndStrings::granularity( gran_ );
94  // LogTrace(mlSummaryPlots_) << ss.str();
95 }
96 
97 // -----------------------------------------------------------------------------
98 //
99 void SummaryPlotFactoryBase::fill(TH1& summary_histo) {
100  // Check if instance of generator class exists
101  if (!generator_) {
102  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
103  << " NULL pointer to SummaryGenerator object!";
104  return;
105  }
106 
107  // Check if map is filled
108  if (!generator_->nBins()) {
109  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
110  << " Zero bins returned by SummaryGenerator!";
111  return;
112  }
113 
114  // Print contents of map for histogram
115  //generator_->printMap();
116 
117  // Generate appropriate summary histogram
118  if (pres_ == sistrip::HISTO_1D) {
119  generator_->histo1D(summary_histo);
120  } else if (pres_ == sistrip::HISTO_2D_SUM) {
121  generator_->histo2DSum(summary_histo);
122  } else if (pres_ == sistrip::HISTO_2D_SCATTER) {
123  generator_->histo2DScatter(summary_histo);
124  } else if (pres_ == sistrip::PROFILE_1D) {
125  generator_->profile1D(summary_histo);
126  } else {
127  edm::LogWarning(mlSummaryPlots_) << "[SummaryPlotFactoryBase::" << __func__ << "]"
128  << " Unexpected presentation type: "
130  return;
131  }
132 
133  // Histogram formatting
135  mon_,
136  pres_,
137  view_,
138  level_,
139  gran_,
140  summary_histo);
141 }
static const char unknownView_[]
static std::string monitorable(const sistrip::Monitorable &)
void histo2DSum(TH1 &)
sistrip::Monitorable mon_
void init(const sistrip::Monitorable &, const sistrip::Presentation &, const sistrip::View &, const std::string &top_level_dir, const sistrip::Granularity &)
#define nullptr
static std::string granularity(const sistrip::Granularity &)
static SummaryGenerator * instance(const sistrip::View &)
void histo2DScatter(TH1 &)
uint32_t nBins() const
sistrip classes
static const char undefinedView_[]
static std::string view(const sistrip::View &)
sistrip::Granularity gran_
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_[]
sistrip::Presentation pres_
static std::string presentation(const sistrip::Presentation &)
SummaryGenerator * generator_
static const char root_[]
void fill(TH1 &summary_histo)