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 //
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_ = nullptr; }
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  // Print contents of map for histogram
131  //generator_->printMap();
132 
133  // Generate appropriate summary histogram
134  if ( pres_ == sistrip::HISTO_1D ) {
135  generator_->histo1D( summary_histo );
136  } else if ( pres_ == sistrip::HISTO_2D_SUM ) {
137  generator_->histo2DSum( summary_histo );
138  } else if ( pres_ == sistrip::HISTO_2D_SCATTER ) {
139  generator_->histo2DScatter( summary_histo );
140  } else if ( pres_ == sistrip::PROFILE_1D ) {
141  generator_->profile1D( summary_histo );
142  } else {
144  << "[SummaryPlotFactoryBase::" << __func__ << "]"
145  << " Unexpected presentation type: "
147  return;
148  }
149 
150  // Histogram formatting
152  mon_,
153  pres_,
154  view_,
155  level_,
156  gran_,
157  summary_histo );
158 
159 }
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)