CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SummaryPlotFactoryBase.cc
Go to the documentation of this file.
5 #include <iostream>
6 
7 using namespace sistrip;
8 
9 // -----------------------------------------------------------------------------
10 //
12  mon_(sistrip::UNKNOWN_MONITORABLE),
13  pres_(sistrip::UNKNOWN_PRESENTATION),
14  view_(sistrip::UNKNOWN_VIEW),
15  level_(sistrip::root_),
16  gran_(sistrip::UNKNOWN_GRAN),
17  generator_(0)
18 {;}
19 
20 // -----------------------------------------------------------------------------
21 //
23  if ( generator_ ) { delete generator_; }
24 }
25 
26 // -----------------------------------------------------------------------------
27 //
29  const sistrip::Presentation& pres,
30  const sistrip::View& view,
31  const std::string& level,
32  const sistrip::Granularity& gran ) {
33 
34  // Create generator object
35  if ( generator_ ) { delete generator_; generator_ = 0; }
37 
38  // Check if generator object exists
39  if ( !generator_ ) {
41  << "[SummaryPlotFactoryBase::" << __func__ << "]"
42  << " NULL pointer to generator object!";
43  return;
44  }
45 
46  // Clear map used to build histogram
48 
49  // Set parameters
50  mon_ = mon;
51  pres_ = pres;
52  view_ = view;
53  level_ = level;
54  gran_ = gran;
55 
56  // Some checks
60  << "[SummaryPlotFactoryBase::" << __func__ << "]"
61  << " Unexpected monitorable: "
63  }
64 
68  << "[SummaryPlotFactoryBase::" << __func__ << "]"
69  << " Unexpected presentation: "
71  }
72 
73  if ( view_ == sistrip::UNKNOWN_VIEW ||
76  << "[SummaryPlotFactoryBase::" << __func__ << "]"
77  << " Unexpected view: "
79  }
80 
81  if ( level_.empty() ||
82  level_.find(sistrip::unknownView_) != std::string::npos ||
83  level_.find(sistrip::undefinedView_) != std::string::npos ) {
85  << "[SummaryPlotFactoryBase::" << __func__ << "]"
86  << " Unexpected top-level directory: \""
87  << level_ << "\"";
88  }
89 
90  if ( ( gran_ == sistrip::UNKNOWN_GRAN ||
92  pres != sistrip::HISTO_1D ) {
94  << "[SummaryPlotFactoryBase::" << __func__ << "]"
95  << " Unexpected granularity: "
97  }
98 
99 // ss << "[SummaryPlotFactoryBase::" << __func__ << "]"
100 // << " Dump of parameters defining summary plot:" << std::endl
101 // << " Monitorable : " << SiStripEnumsAndStrings::monitorable( mon_ ) << std::endl
102 // << " Presentation : " << SiStripEnumsAndStrings::presentation( pres_ ) << std::endl
103 // << " Logical view : " << SiStripEnumsAndStrings::view( view_ ) << std::endl
104 // << " Top level dir : " << level_ << std::endl
105 // << " Granularity : " << SiStripEnumsAndStrings::granularity( gran_ );
106 // LogTrace(mlSummaryPlots_) << ss.str();
107 
108 }
109 
110 // -----------------------------------------------------------------------------
111 //
112 void SummaryPlotFactoryBase::fill( TH1& summary_histo ) {
113 
114  // Check if instance of generator class exists
115  if ( !generator_ ) {
117  << "[SummaryPlotFactoryBase::" << __func__ << "]"
118  << " NULL pointer to SummaryGenerator object!";
119  return;
120  }
121 
122  // Check if map is filled
123  if ( !generator_->nBins() ) {
125  << "[SummaryPlotFactoryBase::" << __func__ << "]"
126  << " Zero bins returned by SummaryGenerator!";
127  return;
128  }
129 
130  // Check if instance of generator class exists
131  if ( !(&summary_histo) ) {
133  << "[SummaryPlotFactoryBase::" << __func__ << "]"
134  << " NULL pointer to TH1 object!";
135  return;
136  }
137 
138  // Print contents of map for histogram
139  //generator_->printMap();
140 
141  // Generate appropriate summary histogram
142  if ( pres_ == sistrip::HISTO_1D ) {
143  generator_->histo1D( summary_histo );
144  } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
145  generator_->histo2DSum( summary_histo );
146  } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
147  generator_->histo2DScatter( summary_histo );
148  } else if ( pres_ == sistrip::PROFILE_1D ) {
149  generator_->profile1D( summary_histo );
150  } else {
152  << "[SummaryPlotFactoryBase::" << __func__ << "]"
153  << " Unexpected presentation type: "
155  return;
156  }
157 
158  // Histogram formatting
160  mon_,
161  pres_,
162  view_,
163  level_,
164  gran_,
165  summary_histo );
166 
167 }
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 &)
static std::string granularity(const sistrip::Granularity &)
static SummaryGenerator * instance(const sistrip::View &)
void histo2DScatter(TH1 &)
uint32_t nBins() const
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_[]
tuple level
Definition: testEve_cfg.py:34
void fill(TH1 &summary_histo)