CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HistogramBase.cc
Go to the documentation of this file.
4 
5 #include "DQM/SiStripMonitorHardware/interface/HistogramBase.hh"
6 
7 
8 
9 void HistogramBase::fillHistogram(HistogramConfig & histogram,
10  double value,
11  double weight)
12 {
13  if (histogram.monitorEle) histogram.monitorEle->Fill(value,weight);
14 }
15 
16 
17 void HistogramBase::fillHistogram(MonitorElement* histogram,
18  double value,
19  double weight)
20 {
21  if (histogram) histogram->Fill(value,weight);
22 }
23 
24 
25 void HistogramBase::fillTkHistoMap(TkHistoMap* aMap,
26  uint32_t & detid,
27  float value
28  ){
29  if (aMap) aMap->fill(detid,value);
30 }
31 
32 
33 void HistogramBase::getConfigForHistogram(HistogramConfig & aConfig,
34  const std::string& configName,
35  const edm::ParameterSet& psetContainingConfigPSet,
36  std::ostringstream* pDebugStream
37  )
38 {
39 
40  aConfig.monitorEle = 0;
41  aConfig.enabled = false;
42  aConfig.nBins = 0;
43  aConfig.min = aConfig.max = 0.;
44 
45  const std::string psetName = configName+std::string("HistogramConfig");
46 
47  bool isTimeHisto = configName.find("vsTime") != configName.npos;
48 
49  if (psetContainingConfigPSet.exists(psetName)) {
50  const edm::ParameterSet& pset = psetContainingConfigPSet.getUntrackedParameter<edm::ParameterSet>(psetName);
51  aConfig.enabled = (pset.exists("Enabled") ? pset.getUntrackedParameter<bool>("Enabled") : true);
52  if (aConfig.enabled) {
53  aConfig.nBins = (pset.exists("NBins") ? pset.getUntrackedParameter<unsigned int>("NBins") : 600);
54  aConfig.min = (pset.exists("Min") ? pset.getUntrackedParameter<double>("Min") : 0);
55  aConfig.max = (pset.exists("Max") ? pset.getUntrackedParameter<double>("Max") : 3600);
56  if (aConfig.nBins) {
57  if (pDebugStream) (*pDebugStream) << "[HistogramBase]\tHistogram: " << configName << "\tEnabled"
58  << "\tNBins: " << aConfig.nBins << "\tMin: " << aConfig.min << "\tMax: " << aConfig.max << std::endl;
59  } else {
60  if (pDebugStream) (*pDebugStream) << "[HistogramBase]\tHistogram: " << configName << "\tEnabled" << std::endl;
61  }
62  } else {
63  aConfig.enabled = false;
64  aConfig.nBins = 0;
65  aConfig.min = aConfig.max = 0.;
66  if (pDebugStream) (*pDebugStream) << "[HistogramBase]\tHistogram: " << configName << "\tDisabled" << std::endl;
67  }
68  }
69  else {
70  aConfig.enabled = false;
71  aConfig.nBins = 0;
72  aConfig.min = aConfig.max = 0.;
73  if (pDebugStream) (*pDebugStream) << "[HistogramBase]\tHistogram: " << configName << "\tDisabled" << std::endl;
74  }
75 
76  //for timehisto, if global parameter exists => overwrite individual settings
77  if (psetContainingConfigPSet.exists("TimeHistogramConfig") && isTimeHisto)
78  {
79  const edm::ParameterSet& pset = psetContainingConfigPSet.getUntrackedParameter<edm::ParameterSet>("TimeHistogramConfig");
80  aConfig.nBins = (pset.exists("NBins") ? pset.getUntrackedParameter<unsigned int>("NBins") : 600);
81  aConfig.min = (pset.exists("Min") ? pset.getUntrackedParameter<double>("Min") : 0);
82  aConfig.max = (pset.exists("Max") ? pset.getUntrackedParameter<double>("Max") : 3600);
83  }
84 
85 }
86 
87 void HistogramBase::bookHistogram(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
88  const std::string& name,
89  const std::string& title,
90  const unsigned int nBins,
91  const double min,
92  const double max,
93  const std::string& xAxisTitle
94  )
95 {
96 
97  if (aConfig.enabled) {
98  aConfig.monitorEle = ibooker.book1D(name,title,nBins,min,max);
99  aConfig.monitorEle->setAxisTitle(xAxisTitle,1);
100  } else {
101  aConfig.monitorEle = 0;
102  }
103 
104 }
105 
106 void HistogramBase::bookHistogram(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
107  MonitorElement* & aHist,
108  const std::string& name,
109  const std::string& title,
110  const unsigned int nBins,
111  const double min,
112  const double max,
113  const std::string& xAxisTitle
114  )
115 {
116 
117  if (aConfig.enabled) {
118  aHist = ibooker.book1D(name,title,nBins,min,max);
119  aHist->setAxisTitle(xAxisTitle,1);
120  } else {
121  aHist = 0;
122  }
123 
124 }
125 
126 void HistogramBase::bookHistogram(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
127  const std::string& name,
128  const std::string& title,
129  const std::string& xAxisTitle
130  )
131 {
132  return bookHistogram(ibooker , aConfig,name,title,aConfig.nBins,aConfig.min,aConfig.max,xAxisTitle);
133 
134 }
135 
136 void HistogramBase::book2DHistogram(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
137  const std::string& name,
138  const std::string& title,
139  const unsigned int nBins,
140  const double min,
141  const double max,
142  const unsigned int nBinsY,
143  const double minY,
144  const double maxY,
145  const std::string& xAxisTitle,
146  const std::string& yAxisTitle
147  )
148 {
149  if (aConfig.enabled) {
150  aConfig.monitorEle = ibooker.book2D(name,title,nBins,min,max,nBinsY,minY,maxY);
151  aConfig.monitorEle->setAxisTitle(xAxisTitle,1);
152  aConfig.monitorEle->setAxisTitle(yAxisTitle,2);
153  } else {
154  aConfig.monitorEle=NULL;
155  }
156 }
157 
158 
159 void HistogramBase::book2DHistogram(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
160  MonitorElement* & aHist,
161  const std::string& name,
162  const std::string& title,
163  const unsigned int nBins,
164  const double min,
165  const double max,
166  const unsigned int nBinsY,
167  const double minY,
168  const double maxY,
169  const std::string& xAxisTitle,
170  const std::string& yAxisTitle
171  )
172 {
173  if (aConfig.enabled) {
174  aHist = ibooker.book2D(name,title,nBins,min,max,nBinsY,minY,maxY);
175  aHist->setAxisTitle(xAxisTitle,1);
176  aHist->setAxisTitle(yAxisTitle,2);
177  } else {
178  aHist=NULL;
179  }
180 }
181 
182 
183 void HistogramBase::bookProfile(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
184  const std::string& name,
185  const std::string& title,
186  const unsigned int nBins,
187  const double min,
188  const double max,
189  const double minY,
190  const double maxY,
191  const std::string& xAxisTitle,
192  const std::string& yAxisTitle
193  )
194 {
195 
196  if (aConfig.enabled) {
197  aConfig.monitorEle = ibooker.bookProfile(name,
198  title,
199  nBins,
200  min,
201  max,
202  minY,
203  maxY
204  );
205 
206  aConfig.monitorEle->setAxisTitle(xAxisTitle,1);
207  aConfig.monitorEle->setAxisTitle(yAxisTitle,2);
208  } else {
209  aConfig.monitorEle = NULL;
210  }
211 }
212 
213 void HistogramBase::bookProfile(DQMStore::IBooker & ibooker , HistogramConfig & aConfig,
214  const std::string& name,
215  const std::string& title,
216  const double minY,
217  const double maxY,
218  const std::string& xAxisTitle,
219  const std::string& yAxisTitle
220  )
221 {
222 
223  bookProfile(ibooker , aConfig,
224  name,
225  title,
226  aConfig.nBins,
227  aConfig.min,
228  aConfig.max,
229  minY,
230  maxY,
231  xAxisTitle,
232  yAxisTitle);
233 
234  //automatically set the axis range: will accomodate new values keeping the same number of bins.
235  if (aConfig.monitorEle) aConfig.monitorEle->getTProfile()->SetCanExtend(TH1::kAllAxes);
236 }
237 
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define NULL
Definition: scimark2.h:8
void Fill(long long x)
void fill(uint32_t &detid, float value)
Definition: TkHistoMap.cc:180
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
T min(T a, T b)
Definition: MathUtil.h:58
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
Constants and enumerated types for FED/FEC systems.
int weight
Definition: histoStyle.py:50
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)