CMS 3D CMS Logo

ContainerSingle1D.cc
Go to the documentation of this file.
1 
3 
4 namespace hcaldqm
5 {
6  using namespace quantity;
7  using namespace constants;
9  {
10  _qx = nullptr;
11  _qy = nullptr;
12  }
13 
15  Container(c._folder, c._qname)
16  {
17  _qx = c._qx->makeCopy();
18  _qy = c._qy->makeCopy();
19  }
20 
22  Quantity *qx, Quantity *qy):
23  Container(folder, qy->name()+"vs"+qx->name()), _qx(qx), _qy(qy)
24  {
27  }
28 
30  std::string const& qname,
31  Quantity *qx, Quantity *qy):
32  Container(folder, qname), _qx(qx), _qy(qy)
33  {
36  }
37 
39  {
40  if (_qx!=nullptr)
41  delete _qx;
42  if (_qy!=nullptr)
43  delete _qy;
44  _qx = nullptr;
45  _qy = nullptr;
46  }
47 
49  Quantity *qx, Quantity *qy, int debug/*=0*/)
50  {
51  Container::initialize(folder, qy->name()+"vs"+qx->name(), debug);
52  _qx = qx;
53  _qy = qy;
56  }
57 
59  std::string const& qname,
60  Quantity *qx, Quantity *qy, int debug/*=0*/)
61  {
62  Container::initialize(folder, qname, debug);
63  _qx = qx;
64  _qy = qy;
67  }
68 
70  std::string subsystem, std::string aux)
71  {
72  ib.setCurrentFolder(subsystem+"/"+_folder+"/"+_qname);
73  _me = ib.book1D(_qname+(aux.empty()?aux:"_"+aux),
74  _qname+(aux.empty()?aux:" "+aux),
75  _qx->nbins(), _qx->min(), _qx->max());
76  customize();
77  }
78 
79  /* virtual */ void ContainerSingle1D::book(DQMStore *store,
80  std::string subsystem, std::string aux)
81  {
82  store->setCurrentFolder(subsystem+"/"+_folder+"/"+_qname);
83  _me = store->book1D(_qname+(aux.empty()?aux:"_"+aux),
84  _qname+(aux.empty()?aux:" "+aux),
85  _qx->nbins(), _qx->min(), _qx->max());
86  customize();
87  }
88 
89  /* virtual */ void ContainerSingle1D::customize()
90  {
91  _me->setAxisTitle(_qx->name(), 1);
92  _me->setAxisTitle(_qy->name(), 2);
93 
94  TH1 *h = _me->getTH1();
95  _qx->setBits(h);
96  _qy->setBits(h);
97 
98  std::vector<std::string> xlabels = _qx->getLabels();
99  for (unsigned int i=0; i<xlabels.size(); i++)
100  _me->setBinLabel(i+1, xlabels[i], 1);
101  }
102 
103  /* virtual */ void ContainerSingle1D::fill(int x)
104  {
105  _me->Fill(_qx->getValue(x));
106  }
107 
108  /* virtual */ void ContainerSingle1D::fill(double x)
109  {
110  _me->Fill(_qx->getValue(x));
111  }
112 
113  /* virtual */ void ContainerSingle1D::fill(int x, int y)
114  {
115  _me->Fill(_qx->getValue(x), _qy->getValue(y));
116  }
117 
118  /* virtual */ void ContainerSingle1D::fill(int x, double y)
119  {
120  _me->Fill(_qx->getValue(x), _qy->getValue(y));
121  }
122 
123  /* virtual */ void ContainerSingle1D::fill(double x, int y)
124  {
125  _me->Fill(_qx->getValue(x), _qy->getValue(y));
126  }
127 
128  /* virtual */ void ContainerSingle1D::fill(double x, double y)
129  {
130  _me->Fill(_qx->getValue(x), _qy->getValue(y));
131  }
132 
133  /* virtual */ double ContainerSingle1D::getBinContent(int x)
134  {
135  return _me->getBinContent(_qx->getBin(x));
136  }
137  /* virtual */ double ContainerSingle1D::getBinContent(double x)
138  {
139  return _me->getBinContent(_qx->getBin(x));
140  }
141  /* virtual */ double ContainerSingle1D::getBinEntries(int x)
142  {
143  return _me->getBinEntries(_qx->getBin(x));
144  }
145  /* virtual */ double ContainerSingle1D::getBinEntries(double x)
146  {
147  return _me->getBinEntries(_qx->getBin(x));
148  }
149  /* virtual */ void ContainerSingle1D::setBinContent(int x, int y)
150  {
151  _me->setBinContent(_qx->getBin(x), y);
152  }
153  /* virtual */ void ContainerSingle1D::setBinContent(int x, double y)
154  {
155  _me->setBinContent(_qx->getBin(x), y);
156  }
157  /* virtual */ void ContainerSingle1D::setBinContent(double x, int y)
158  {
159  _me->setBinContent(_qx->getBin(x), y);
160  }
161  /* virtual */ void ContainerSingle1D::setBinContent(double x, double y)
162  {
163  _me->setBinContent(_qx->getBin(x), y);
164  }
165 
166  /* virtual */ void ContainerSingle1D::fill(HcalDetId const& id)
167  {
168  _me->Fill(_qx->getValue(id));
169  }
170 
171  /* virtual */ void ContainerSingle1D::fill(HcalDetId const& id, double x)
172  {
173  if (_qx->isCoordinate())
174  _me->Fill(_qx->getValue(id), _qy->getValue(x));
175  else
176  _me->Fill(_qx->getValue(x));
177  }
178 
179  /* virtual */ void ContainerSingle1D::fill(HcalDetId const& id, double x,
180  double y)
181  {
182  if (_qx->isCoordinate())
183  _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
184  else
185  _me->Fill(_qy->getValue(x), _qy->getValue(y));
186  }
187 
188  /* virtual */ double ContainerSingle1D::getBinContent(HcalDetId const& id)
189  {
190  return _me->getBinContent(_qx->getBin(id));
191  }
192  /* virtual */ double ContainerSingle1D::getBinEntries(HcalDetId const& id)
193  {
194  return _me->getBinEntries(_qx->getBin(id));
195  }
196 
197  /* virtual */ void ContainerSingle1D::setBinContent(HcalDetId const& id,
198  int x)
199  {
200  _me->setBinContent(_qx->getBin(id), x);
201  }
202  /* virtual */ void ContainerSingle1D::setBinContent(HcalDetId const& id,
203  double x)
204  {
205  _me->setBinContent(_qx->getBin(id), x);
206  }
207 
208  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const& id)
209  {
210  _me->Fill(_qx->getValue(id));
211  }
212 
213  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const& id,
214  double x)
215  {
216  if (_qx->isCoordinate())
217  _me->Fill(_qx->getValue(id), _qy->getValue(x));
218  else
219  _me->Fill(_qx->getValue(x));
220  }
221 
222  /* virtual */ void ContainerSingle1D::fill(HcalElectronicsId const& id,
223  double x, double y)
224  {
225  if (_qx->isCoordinate())
226  _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
227  else
228  _me->Fill(_qy->getValue(x), _qy->getValue(y));
229  }
230 
231  /* virtual */ double ContainerSingle1D::getBinContent(HcalElectronicsId const& id)
232  {
233  return _me->getBinContent(_qx->getBin(id));
234  }
235  /* virtual */ double ContainerSingle1D::getBinEntries(HcalElectronicsId const& id)
236  {
237  return _me->getBinEntries(_qx->getBin(id));
238  }
239 
241  int x)
242  {
243  _me->setBinContent(_qx->getBin(id), x);
244  }
246  double x)
247  {
248  _me->setBinContent(_qx->getBin(id), x);
249  }
250 
251  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const& id)
252  {
253  _me->Fill(_qx->getValue(id));
254  }
255 
256  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const& id,
257  double x)
258  {
259  if (_qx->isCoordinate())
260  _me->Fill(_qx->getValue(id), _qy->getValue(x));
261  else
262  _me->Fill(_qx->getValue(x));
263  }
264 
265  /* virtual */ void ContainerSingle1D::fill(HcalTrigTowerDetId const& id,
266  double x,
267  double y)
268  {
269  if (_qx->isCoordinate())
270  _me->Fill(_qx->getValue(id), _qy->getValue(x), y);
271  else
272  _me->Fill(_qy->getValue(x), _qy->getValue(y));
273  }
274 
275  /* virtual */ double ContainerSingle1D::getBinContent(HcalTrigTowerDetId const& id)
276  {
277  return _me->getBinContent(_qx->getBin(id));
278  }
279  /* virtual */ double ContainerSingle1D::getBinEntries(HcalTrigTowerDetId const& id)
280  {
281  return _me->getBinEntries(_qx->getBin(id));
282  }
283 
285  int x)
286  {
287  _me->setBinContent(_qx->getBin(id), x);
288  }
290  double x)
291  {
292  _me->setBinContent(_qx->getBin(id), x);
293  }
294 
295  /* virtual */ void ContainerSingle1D::extendAxisRange(int l)
296  {
297  if (l<_qx->nbins())
298  return;
299 
300  int x=_qx->nbins();
301  while(l>=x)
302  {
303  _me->getTH1()->LabelsInflate();
304  x*=2;
305  _qx->setMax(x);
306  }
307  }
308 
309  void ContainerSingle1D::showOverflowX(bool showOverflow) {
310  _qx->showOverflow(showOverflow);
311  }
312 
313  void ContainerSingle1D::showOverflowY(bool showOverflow) {
314  _qy->showOverflow(showOverflow);
315  }
316 
317 }
318 
319 
virtual void setBits(TH1 *o)
Definition: Quantity.h:65
void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void initialize(std::string const &folder, std::string const &qname, int debug=0)
Definition: Container.h:33
virtual std::string name()
Definition: Quantity.h:47
virtual void setAxisType(AxisType at)
Definition: Quantity.h:49
quantity::Quantity * _qx
virtual void book(DQMStore::IBooker &, std::string subsystem="Hcal", std::string aux="")
virtual std::vector< std::string > getLabels()
Definition: Quantity.h:78
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:882
virtual double max()
Definition: Quantity.h:76
virtual void setBinContent(int, int)
quantity::Quantity * _qy
TH1 * getTH1() const
virtual void setMax(double)
Definition: Quantity.h:81
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual void extendAxisRange(int)
void Fill(long long x)
virtual int getValue(HcalDetId const &)
Definition: Quantity.h:59
virtual void initialize(std::string const &folder, quantity::Quantity *, quantity::Quantity *qy=new quantity::ValueQuantity(quantity::fN), int debug=0)
virtual Quantity * makeCopy()
Definition: Quantity.h:50
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
virtual uint32_t getBin(HcalDetId const &)
Definition: Quantity.h:53
virtual void showOverflowX(bool showOverflow)
virtual double getBinContent(int)
virtual void showOverflow(bool showOverflow)
Definition: Quantity.h:85
std::string _folder
Definition: Container.h:42
#define debug
Definition: HDRShower.cc:19
virtual void showOverflowY(bool showOverflow)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
virtual double getBinEntries(int)
virtual double min()
Definition: Quantity.h:75
virtual bool isCoordinate()
Definition: Quantity.h:77
double getBinContent(int binx) const
get content of bin (1-D)
std::string _qname
Definition: Container.h:43
double getBinEntries(int bin) const
get # of bin entries (for profiles)
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
Readout chain identification for Hcal.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:588
ib
Definition: cuy.py:660