CMS 3D CMS Logo

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