CMS 3D CMS Logo

MESetDet2D.cc
Go to the documentation of this file.
2 
4 
5 namespace ecaldqm {
7  binning::ObjectType _otype,
10  binning::AxisSpecs const *_zaxis /* = 0*/)
11  : MESetEcal(_fullPath, _otype, _btype, _kind, 2, nullptr, nullptr, _zaxis) {
12  switch (kind_) {
15  break;
16  default:
17  throw_("Unsupported MonitorElement kind");
18  }
19  }
20 
21  MESetDet2D::MESetDet2D(MESetDet2D const &_orig) : MESetEcal(_orig) {}
22 
24 
25  MESet *MESetDet2D::clone(std::string const &_path /* = ""*/) const {
27  if (!_path.empty())
28  path_ = _path;
29  MESet *copy(new MESetDet2D(*this));
30  path_ = path;
31  return copy;
32  }
33 
35  MESetEcal::book(_ibooker);
36 
37  if (btype_ == binning::kCrystal) {
38  for (unsigned iME(0); iME < mes_.size(); iME++) {
39  MonitorElement *me(mes_[iME]);
40 
41  binning::ObjectType actualObject(binning::getObject(otype_, iME));
42  if (actualObject == binning::kMEM) {
43  for (int iBin(1); iBin <= me->getNbinsX(); ++iBin)
44  me->setBinLabel(iBin, binning::channelName(memDCCId(iBin - 1)));
45  }
46  if (actualObject == binning::kEBMEM) {
47  for (int iBin(1); iBin <= me->getNbinsX(); ++iBin)
48  me->setBinLabel(iBin, binning::channelName(iBin + kEBmLow));
49  }
50  if (actualObject == binning::kEEMEM) {
51  for (int iBin(1); iBin <= me->getNbinsX() / 2; ++iBin) {
52  me->setBinLabel(iBin, binning::channelName(memDCCId(iBin - 1)));
53  me->setBinLabel(iBin + me->getNbinsX() / 2, binning::channelName(memDCCId(iBin + 39)));
54  }
55  }
56  }
57  } else if (btype_ == binning::kDCC) {
58  for (unsigned iME(0); iME < mes_.size(); iME++) {
59  MonitorElement *me(mes_[iME]);
60 
61  binning::ObjectType actualObject(binning::getObject(otype_, iME));
62  if (actualObject == binning::kEcal) {
63  me->setBinLabel(1, "EE", 2);
64  me->setBinLabel(6, "EE", 2);
65  me->setBinLabel(3, "EB", 2);
66  me->setBinLabel(5, "EB", 2);
67  }
68  }
69  }
70 
71  // To avoid the ambiguity between "content == 0 because the mean is 0" and
72  // "content == 0 because the entry is 0" RenderPlugin must be configured
73  // accordingly
75  resetAll(0., 0., -1.);
76  }
77 
78  void MESetDet2D::fill(DetId const &_id, double _w /* = 1.*/, double, double) {
79  if (!active_)
80  return;
81 
82  unsigned iME(binning::findPlotIndex(otype_, _id));
83  checkME_(iME);
84 
86 
87  int bin;
88 
89  if (btype_ == binning::kRCT) {
90  bin = binning::findBin2D(obj, btype_, _id);
91  fill_(iME, bin, _w);
92  } else {
93  if (isEndcapTTId(_id)) {
94  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
95  unsigned nId(ids.size());
96  for (unsigned iId(0); iId < nId; iId++) {
97  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
98  fill_(iME, bin, _w);
99  }
100  } else {
101  bin = binning::findBin2D(obj, btype_, _id);
102  fill_(iME, bin, _w);
103  }
104  }
105  }
106 
107  void MESetDet2D::fill(EcalElectronicsId const &_id, double _w /* = 1.*/, double, double) {
108  if (!active_)
109  return;
110 
111  unsigned iME(0);
114  else
115  iME = binning::findPlotIndex(otype_, _id);
116  checkME_(iME);
117 
119 
120  int bin;
121 
122  if (btype_ == binning::kPseudoStrip) {
123  EcalElectronicsId stid(_id);
124  std::vector<DetId> ids(
125  getElectronicsMap()->pseudoStripConstituents(stid.dccId(), stid.towerId(), stid.stripId()));
126  unsigned nId(ids.size());
127  for (unsigned iId(0); iId < nId; iId++) {
128  bin = binning::findBin2D(obj, btype_, ids[iId]);
129  fill_(iME, bin, _w);
130  }
131  } else {
132  bin = binning::findBin2D(obj, btype_, _id);
133  fill_(iME, bin, _w);
134  }
135  }
136 
137  void MESetDet2D::fill(int _dcctccid, double _w /* = 1.*/, double, double) {
138  if (!active_)
139  return;
140 
141  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
142  checkME_(iME);
143 
145 
146  int bin(binning::findBin2D(obj, btype_, _dcctccid));
147  fill_(iME, bin, _w);
148  }
149 
151  if (!active_)
152  return;
153 
154  unsigned iME(binning::findPlotIndex(otype_, _id));
155  checkME_(iME);
156 
158 
159  int bin;
160 
161  if (isEndcapTTId(_id)) {
162  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
163  unsigned nId(ids.size());
164  for (unsigned iId(0); iId < nId; iId++) {
165  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
166  mes_[iME]->setBinContent(bin, _content);
167  }
168  } else {
169  bin = binning::findBin2D(obj, btype_, _id);
170  mes_[iME]->setBinContent(bin, _content);
171  }
172  }
173 
175  if (!active_)
176  return;
177 
178  unsigned iME(binning::findPlotIndex(otype_, _id));
179  checkME_(iME);
180 
182 
183  int bin(binning::findBin2D(obj, btype_, _id));
184  mes_[iME]->setBinContent(bin, _content);
185  }
186 
187  void MESetDet2D::setBinContent(int _dcctccid, double _content) {
188  if (!active_)
189  return;
190 
191  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
192  checkME_(iME);
193 
195 
196  int bin(binning::findBin2D(obj, btype_, _dcctccid));
197  mes_[iME]->setBinContent(bin, _content);
198  }
199 
200  void MESetDet2D::setBinError(DetId const &_id, double _error) {
201  if (!active_)
202  return;
203 
204  unsigned iME(binning::findPlotIndex(otype_, _id));
205  checkME_(iME);
206 
208 
209  int bin;
210 
211  if (isEndcapTTId(_id)) {
212  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
213  unsigned nId(ids.size());
214  for (unsigned iId(0); iId < nId; iId++) {
215  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
216  mes_[iME]->setBinError(bin, _error);
217  }
218  } else {
219  bin = binning::findBin2D(obj, btype_, _id);
220  mes_[iME]->setBinError(bin, _error);
221  }
222  }
223 
224  void MESetDet2D::setBinError(EcalElectronicsId const &_id, double _error) {
225  if (!active_)
226  return;
227 
228  unsigned iME(binning::findPlotIndex(otype_, _id));
229  checkME_(iME);
230 
232 
233  int bin(binning::findBin2D(obj, btype_, _id));
234  mes_[iME]->setBinError(bin, _error);
235  }
236 
237  void MESetDet2D::setBinError(int _dcctccid, double _error) {
238  if (!active_)
239  return;
240 
241  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
242  checkME_(iME);
243 
245 
246  int bin(binning::findBin2D(obj, btype_, _dcctccid));
247  mes_[iME]->setBinError(bin, _error);
248  }
249 
250  void MESetDet2D::setBinEntries(DetId const &_id, double _entries) {
251  if (!active_)
252  return;
254  return;
255 
256  unsigned iME(binning::findPlotIndex(otype_, _id));
257  checkME_(iME);
258 
260 
261  int bin;
262 
263  if (isEndcapTTId(_id)) {
264  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
265  unsigned nId(ids.size());
266  for (unsigned iId(0); iId < nId; iId++) {
267  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
268  mes_[iME]->setBinEntries(bin, _entries);
269  }
270  } else {
271  bin = binning::findBin2D(obj, btype_, _id);
272  mes_[iME]->setBinEntries(bin, _entries);
273  }
274  }
275 
276  void MESetDet2D::setBinEntries(EcalElectronicsId const &_id, double _entries) {
277  if (!active_)
278  return;
280  return;
281 
282  unsigned iME(binning::findPlotIndex(otype_, _id));
283  checkME_(iME);
284 
286 
287  int bin(binning::findBin2D(obj, btype_, _id));
288  mes_[iME]->setBinEntries(bin, _entries);
289  }
290 
291  void MESetDet2D::setBinEntries(int _dcctccid, double _entries) {
292  if (!active_)
293  return;
294 
295  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
296  checkME_(iME);
297 
299 
300  int bin(binning::findBin2D(obj, btype_, _dcctccid));
301  mes_[iME]->setBinEntries(bin, _entries);
302  }
303 
304  double MESetDet2D::getBinContent(DetId const &_id, int) const {
305  if (!active_)
306  return 0.;
307 
308  unsigned iME(binning::findPlotIndex(otype_, _id));
309  checkME_(iME);
310 
312 
313  int bin;
314 
315  if (isEndcapTTId(_id)) {
316  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
317  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
318  } else {
319  bin = binning::findBin2D(obj, btype_, _id);
320  }
321 
322  return mes_[iME]->getBinContent(bin);
323  }
324 
325  double MESetDet2D::getBinContent(EcalElectronicsId const &_id, int) const {
326  if (!active_)
327  return 0.;
328 
329  unsigned iME(binning::findPlotIndex(otype_, _id));
330  checkME_(iME);
331 
333 
334  int bin(binning::findBin2D(obj, btype_, _id));
335 
336  return mes_[iME]->getBinContent(bin);
337  }
338 
339  double MESetDet2D::getBinContent(int _dcctccid, int) const {
340  if (!active_)
341  return 0.;
342 
343  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
344  checkME_(iME);
345 
347 
348  int bin(binning::findBin2D(obj, btype_, _dcctccid));
349 
350  return mes_[iME]->getBinContent(bin);
351  }
352 
353  double MESetDet2D::getBinError(DetId const &_id, int) const {
354  if (!active_)
355  return 0.;
356 
357  unsigned iME(binning::findPlotIndex(otype_, _id));
358  checkME_(iME);
359 
361 
362  int bin;
363 
364  if (isEndcapTTId(_id)) {
365  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
366  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
367  } else {
368  bin = binning::findBin2D(obj, btype_, _id);
369  }
370 
371  return mes_[iME]->getBinError(bin);
372  }
373 
374  double MESetDet2D::getBinError(EcalElectronicsId const &_id, int) const {
375  if (!active_)
376  return 0.;
377 
378  unsigned iME(binning::findPlotIndex(otype_, _id));
379  checkME_(iME);
380 
382 
383  int bin(binning::findBin2D(obj, btype_, _id));
384 
385  return mes_[iME]->getBinError(bin);
386  }
387 
388  double MESetDet2D::getBinError(int _dcctccid, int) const {
389  if (!active_)
390  return 0.;
391 
392  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
393  checkME_(iME);
394 
396 
397  int bin(binning::findBin2D(obj, btype_, _dcctccid));
398 
399  return mes_[iME]->getBinError(bin);
400  }
401 
402  double MESetDet2D::getBinEntries(DetId const &_id, int) const {
403  if (!active_)
404  return 0.;
406  return 0.;
407 
408  unsigned iME(binning::findPlotIndex(otype_, _id));
409  checkME_(iME);
410 
412 
413  int bin;
414 
415  if (isEndcapTTId(_id)) {
416  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
417  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
418  } else {
419  bin = binning::findBin2D(obj, btype_, _id);
420  }
421 
422  double entries(mes_[iME]->getBinEntries(bin));
423  if (entries < 0.)
424  return 0.;
425  else
426  return entries;
427  }
428 
429  double MESetDet2D::getBinEntries(EcalElectronicsId const &_id, int) const {
430  if (!active_)
431  return 0.;
433  return 0.;
434 
435  unsigned iME(binning::findPlotIndex(otype_, _id));
436  checkME_(iME);
437 
439 
440  int bin(binning::findBin2D(obj, btype_, _id));
441 
442  double entries(mes_[iME]->getBinEntries(bin));
443  if (entries < 0.)
444  return 0.;
445  else
446  return entries;
447  }
448 
449  double MESetDet2D::getBinEntries(int _dcctccid, int) const {
450  if (!active_)
451  return 0.;
452 
453  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
454  checkME_(iME);
455 
457 
458  int bin(binning::findBin2D(obj, btype_, _dcctccid));
459 
460  double entries(mes_[iME]->getBinEntries(bin));
461  if (entries < 0.)
462  return 0.;
463  else
464  return entries;
465  }
466 
467  int MESetDet2D::findBin(DetId const &_id) const {
468  if (!active_)
469  return 0;
470 
471  unsigned iME(binning::findPlotIndex(otype_, _id));
472  checkME_(iME);
473 
475 
476  if (isEndcapTTId(_id)) {
477  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
478  return binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
479  } else
480  return binning::findBin2D(obj, btype_, _id);
481  }
482 
484  if (!active_)
485  return 0;
486 
487  unsigned iME(binning::findPlotIndex(otype_, _id));
488  checkME_(iME);
489 
491 
492  return binning::findBin2D(obj, btype_, _id);
493  }
494 
495  void MESetDet2D::reset(double _content /* = 0.*/, double _err /* = 0.*/, double _entries /* = 0.*/) {
496  unsigned nME(binning::getNObjects(otype_));
497 
498  bool isProfile(kind_ == MonitorElement::DQM_KIND_TPROFILE2D);
499 
500  for (unsigned iME(0); iME < nME; iME++) {
501  MonitorElement *me(mes_[iME]);
502 
504 
505  int nbinsX(me->getTH1()->GetNbinsX());
506  int nbinsY(me->getTH1()->GetNbinsY());
507  for (int ix(1); ix <= nbinsX; ix++) {
508  for (int iy(1); iy <= nbinsY; iy++) {
509  int bin((nbinsX + 2) * iy + ix);
510  if (!binning::isValidIdBin(obj, btype_, iME, bin))
511  continue;
512  me->setBinContent(bin, _content);
513  me->setBinError(bin, _err);
514  if (isProfile)
515  me->setBinEntries(bin, _entries);
516  }
517  }
518  }
519  }
520 
524  resetAll(0., 0., -1.);
525  }
526 
527  void MESetDet2D::fill_(unsigned _iME, int _bin, double _w) {
529  MonitorElement *me(mes_.at(_iME));
530  if (me->getBinEntries(_bin) < 0.) {
531  me->setBinContent(_bin, 0.);
532  me->setBinEntries(_bin, 0.);
533  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
534  }
535  }
536 
537  MESet::fill_(_iME, _bin, _w);
538  }
539 
540  void MESetDet2D::fill_(unsigned _iME, int _bin, double _y, double _w) {
542  MonitorElement *me(mes_.at(_iME));
543  if (me->getBinEntries(_bin) < 0.) {
544  me->setBinContent(_bin, 0.);
545  me->setBinEntries(_bin, 0.);
546  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
547  }
548  }
549 
550  MESet::fill_(_iME, _bin, _y, _w);
551  }
552 
553  void MESetDet2D::fill_(unsigned _iME, double _x, double _wy, double _w) {
555  MonitorElement *me(mes_.at(_iME));
556  int bin(me->getTProfile2D()->FindBin(_x, _wy));
557  if (me->getBinEntries(bin) < 0.) {
558  me->setBinContent(bin, 0.);
559  me->setBinEntries(bin, 0.);
560  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
561  }
562  }
563 
564  MESet::fill_(_iME, _x, _wy, _w);
565  }
566 } // namespace ecaldqm
MonitorElement::Kind kind_
Definition: MESet.h:129
void setBinContent(int binx, double content)
set content of bin (1-D)
def copy(args, dbName)
int stripId() const
get the tower id
virtual void checkME_(unsigned _iME) const
Definition: MESet.h:114
bool isValidIdBin(ObjectType, BinningType, unsigned, int)
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
unsigned getNObjects(ObjectType)
EcalElectronicsMapping const * getElectronicsMap()
#define nullptr
TH1 * getTH1() const
~MESetDet2D() override
Definition: MESetDet2D.cc:23
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)
void reset(double=0., double=0., double=0.) override
Definition: MESetDet2D.cc:495
int towerId() const
get the tower id
void setBinContent(DetId const &, double) override
Definition: MESetDet2D.cc:150
bool batchMode_
Definition: MESet.h:132
void setBinError(DetId const &, double) override
Definition: MESetDet2D.cc:200
ObjectType getObject(ObjectType, unsigned)
void book(DQMStore::IBooker &) override
Definition: MESetDet2D.cc:34
MESet * clone(std::string const &="") const override
Definition: MESetDet2D.cc:25
bool isEndcapTTId(DetId const &)
void fill(DetId const &, double=1., double=0., double=0.) override
Definition: MESetDet2D.cc:78
double getBinContent(DetId const &, int=0) const override
Definition: MESetDet2D.cc:304
void throw_(std::string const &_message) const
Definition: MESet.h:122
EcalTrigTowerConstituentsMap const * getTrigTowerMap()
void fill_(unsigned, int, double) override
Definition: MESetDet2D.cc:527
double getBinError(DetId const &, int=0) const override
Definition: MESetDet2D.cc:353
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::string channelName(uint32_t, BinningType _btype=kDCC)
virtual void fill_(unsigned, int, double)
Definition: MESet.cc:266
bin
set the eta bin as selection string.
unsigned memDCCId(unsigned)
Definition: DetId.h:18
int findBin2D(ObjectType, BinningType, DetId const &)
virtual void softReset()
Definition: MESet.cc:246
unsigned findPlotIndex(ObjectType, DetId const &)
virtual void resetAll(double=0., double=0., double=0.)
Definition: MESet.cc:105
bool active_
Definition: MESet.h:134
double getBinEntries(DetId const &, int=0) const override
Definition: MESetDet2D.cc:402
void softReset() override
Definition: MESetDet2D.cc:521
int findBin(DetId const &) const
Definition: MESetDet2D.cc:467
binning::ObjectType otype_
Definition: MESet.h:127
void setBinEntries(DetId const &, double) override
Definition: MESetDet2D.cc:250
int getNbinsX() const
get # of bins in X-axis
MESetDet2D(std::string const &, binning::ObjectType, binning::BinningType, MonitorElement::Kind, binning::AxisSpecs const *=0)
Definition: MESetDet2D.cc:6
binning::BinningType btype_
Definition: MESet.h:128
std::string path_
Definition: MESet.h:126
void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
std::vector< MonitorElement * > mes_
Definition: MESet.h:124
void book(DQMStore::IBooker &) override
Definition: MESetEcal.cc:70