CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34  void MESetDet2D::book(DQMStore::IBooker &_ibooker, const EcalElectronicsMapping *electronicsMap) {
35  MESetEcal::book(_ibooker, electronicsMap);
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(electronicsMap, memDCCId(iBin - 1)));
45  }
46  if (actualObject == binning::kEBMEM) {
47  for (int iBin(1); iBin <= me->getNbinsX(); ++iBin)
48  me->setBinLabel(iBin, binning::channelName(electronicsMap, iBin + kEBmLow));
49  }
50  if (actualObject == binning::kEEMEM) {
51  for (int iBin(1); iBin <= me->getNbinsX() / 2; ++iBin) {
52  me->setBinLabel(iBin, binning::channelName(electronicsMap, memDCCId(iBin - 1)));
53  me->setBinLabel(iBin + me->getNbinsX() / 2, binning::channelName(electronicsMap, 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(EcalDQMSetupObjects const edso, DetId const &_id, double _w /* = 1.*/, double, double) {
79  if (!active_)
80  return;
81 
82  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
83  checkME_(iME);
84 
86 
87  int bin;
88 
89  if (btype_ == binning::kRCT) {
90  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
91  fill_(iME, bin, _w);
92  } else {
93  if (isEndcapTTId(_id)) {
94  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
95  unsigned nId(ids.size());
96  for (unsigned iId(0); iId < nId; iId++) {
97  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[iId]);
98  fill_(iME, bin, _w);
99  }
100  } else {
101  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
102  fill_(iME, bin, _w);
103  }
104  }
105  }
106 
108  EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _w /* = 1.*/, double, double) {
109  if (!active_)
110  return;
111 
112  unsigned iME(0);
115  else
116  iME = binning::findPlotIndex(edso.electronicsMap, otype_, _id);
117  checkME_(iME);
118 
120 
121  int bin;
122 
123  if (btype_ == binning::kPseudoStrip) {
124  EcalElectronicsId stid(_id);
125  std::vector<DetId> ids(
126  edso.electronicsMap->pseudoStripConstituents(stid.dccId(), stid.towerId(), stid.stripId()));
127  unsigned nId(ids.size());
128  for (unsigned iId(0); iId < nId; iId++) {
129  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, ids[iId]);
130  fill_(iME, bin, _w);
131  }
132  } else {
133  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
134  fill_(iME, bin, _w);
135  }
136  }
137 
138  void MESetDet2D::fill(EcalDQMSetupObjects const edso, int _dcctccid, double _w /* = 1.*/, double, double) {
139  if (!active_)
140  return;
141 
142  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
143  checkME_(iME);
144 
146 
147  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
148  fill_(iME, bin, _w);
149  }
150 
151  void MESetDet2D::setBinContent(EcalDQMSetupObjects const edso, DetId const &_id, double _content) {
152  if (!active_)
153  return;
154 
155  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
156  checkME_(iME);
157 
159 
160  int bin;
161 
162  if (isEndcapTTId(_id)) {
163  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
164  unsigned nId(ids.size());
165  for (unsigned iId(0); iId < nId; iId++) {
166  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[iId]);
167  mes_[iME]->setBinContent(bin, _content);
168  }
169  } else {
170  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
171  mes_[iME]->setBinContent(bin, _content);
172  }
173  }
174 
176  if (!active_)
177  return;
178 
179  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
180  checkME_(iME);
181 
183 
184  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
185  mes_[iME]->setBinContent(bin, _content);
186  }
187 
188  void MESetDet2D::setBinContent(EcalDQMSetupObjects const edso, int _dcctccid, double _content) {
189  if (!active_)
190  return;
191 
192  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
193  checkME_(iME);
194 
196 
197  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
198  mes_[iME]->setBinContent(bin, _content);
199  }
200 
201  void MESetDet2D::setBinError(EcalDQMSetupObjects const edso, DetId const &_id, double _error) {
202  if (!active_)
203  return;
204 
205  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
206  checkME_(iME);
207 
209 
210  int bin;
211 
212  if (isEndcapTTId(_id)) {
213  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
214  unsigned nId(ids.size());
215  for (unsigned iId(0); iId < nId; iId++) {
216  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[iId]);
217  mes_[iME]->setBinError(bin, _error);
218  }
219  } else {
220  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
221  mes_[iME]->setBinError(bin, _error);
222  }
223  }
224 
225  void MESetDet2D::setBinError(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _error) {
226  if (!active_)
227  return;
228 
229  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
230  checkME_(iME);
231 
233 
234  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
235  mes_[iME]->setBinError(bin, _error);
236  }
237 
238  void MESetDet2D::setBinError(EcalDQMSetupObjects const edso, int _dcctccid, double _error) {
239  if (!active_)
240  return;
241 
242  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
243  checkME_(iME);
244 
246 
247  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
248  mes_[iME]->setBinError(bin, _error);
249  }
250 
251  void MESetDet2D::setBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, double _entries) {
252  if (!active_)
253  return;
255  return;
256 
257  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
258  checkME_(iME);
259 
261 
262  int bin;
263 
264  if (isEndcapTTId(_id)) {
265  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
266  unsigned nId(ids.size());
267  for (unsigned iId(0); iId < nId; iId++) {
268  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[iId]);
269  mes_[iME]->setBinEntries(bin, _entries);
270  }
271  } else {
272  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
273  mes_[iME]->setBinEntries(bin, _entries);
274  }
275  }
276 
277  void MESetDet2D::setBinEntries(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _entries) {
278  if (!active_)
279  return;
281  return;
282 
283  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
284  checkME_(iME);
285 
287 
288  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
289  mes_[iME]->setBinEntries(bin, _entries);
290  }
291 
292  void MESetDet2D::setBinEntries(EcalDQMSetupObjects const edso, int _dcctccid, double _entries) {
293  if (!active_)
294  return;
295 
296  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
297  checkME_(iME);
298 
300 
301  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
302  mes_[iME]->setBinEntries(bin, _entries);
303  }
304 
305  double MESetDet2D::getBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
306  if (!active_)
307  return 0.;
308 
309  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
310  checkME_(iME);
311 
313 
314  int bin;
315 
316  if (isEndcapTTId(_id)) {
317  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
318  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[0]);
319  } else {
320  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
321  }
322 
323  return mes_[iME]->getBinContent(bin);
324  }
325 
326  double MESetDet2D::getBinContent(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, int) const {
327  if (!active_)
328  return 0.;
329 
330  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
331  checkME_(iME);
332 
334 
335  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
336 
337  return mes_[iME]->getBinContent(bin);
338  }
339 
340  double MESetDet2D::getBinContent(EcalDQMSetupObjects const edso, int _dcctccid, int) const {
341  if (!active_)
342  return 0.;
343 
344  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
345  checkME_(iME);
346 
348 
349  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
350 
351  return mes_[iME]->getBinContent(bin);
352  }
353 
354  double MESetDet2D::getBinError(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
355  if (!active_)
356  return 0.;
357 
358  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
359  checkME_(iME);
360 
362 
363  int bin;
364 
365  if (isEndcapTTId(_id)) {
366  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
367  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[0]);
368  } else {
369  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
370  }
371 
372  return mes_[iME]->getBinError(bin);
373  }
374 
375  double MESetDet2D::getBinError(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, int) const {
376  if (!active_)
377  return 0.;
378 
379  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
380  checkME_(iME);
381 
383 
384  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
385 
386  return mes_[iME]->getBinError(bin);
387  }
388 
389  double MESetDet2D::getBinError(EcalDQMSetupObjects const edso, int _dcctccid, int) const {
390  if (!active_)
391  return 0.;
392 
393  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
394  checkME_(iME);
395 
397 
398  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
399 
400  return mes_[iME]->getBinError(bin);
401  }
402 
403  double MESetDet2D::getBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
404  if (!active_)
405  return 0.;
407  return 0.;
408 
409  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
410  checkME_(iME);
411 
413 
414  int bin;
415 
416  if (isEndcapTTId(_id)) {
417  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
418  bin = binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[0]);
419  } else {
420  bin = binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
421  }
422 
423  double entries(mes_[iME]->getBinEntries(bin));
424  if (entries < 0.)
425  return 0.;
426  else
427  return entries;
428  }
429 
430  double MESetDet2D::getBinEntries(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, int) const {
431  if (!active_)
432  return 0.;
434  return 0.;
435 
436  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
437  checkME_(iME);
438 
440 
441  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _id));
442 
443  double entries(mes_[iME]->getBinEntries(bin));
444  if (entries < 0.)
445  return 0.;
446  else
447  return entries;
448  }
449 
450  double MESetDet2D::getBinEntries(EcalDQMSetupObjects const edso, int _dcctccid, int) const {
451  if (!active_)
452  return 0.;
453 
454  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
455  checkME_(iME);
456 
458 
459  int bin(binning::findBin2D(edso.electronicsMap, obj, btype_, _dcctccid));
460 
461  double entries(mes_[iME]->getBinEntries(bin));
462  if (entries < 0.)
463  return 0.;
464  else
465  return entries;
466  }
467 
468  int MESetDet2D::findBin(EcalDQMSetupObjects const edso, DetId const &_id) const {
469  if (!active_)
470  return 0;
471 
472  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
473  checkME_(iME);
474 
476 
477  if (isEndcapTTId(_id)) {
478  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(EcalTrigTowerDetId(_id)));
479  return binning::findBin2D(edso.electronicsMap, obj, binning::kTriggerTower, ids[0]);
480  } else
481  return binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
482  }
483 
484  int MESetDet2D::findBin(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id) const {
485  if (!active_)
486  return 0;
487 
488  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
489  checkME_(iME);
490 
492 
493  return binning::findBin2D(edso.electronicsMap, obj, btype_, _id);
494  }
495 
496  void MESetDet2D::reset(EcalElectronicsMapping const *electronicsMap,
497  double _content /* = 0.*/,
498  double _err /* = 0.*/,
499  double _entries /* = 0.*/) {
500  unsigned nME(binning::getNObjects(otype_));
501 
502  bool isProfile(kind_ == MonitorElement::Kind::TPROFILE2D);
503 
504  for (unsigned iME(0); iME < nME; iME++) {
505  MonitorElement *me(mes_[iME]);
506 
508 
509  int nbinsX(me->getTH1()->GetNbinsX());
510  int nbinsY(me->getTH1()->GetNbinsY());
511  for (int ix(1); ix <= nbinsX; ix++) {
512  for (int iy(1); iy <= nbinsY; iy++) {
513  int bin((nbinsX + 2) * iy + ix);
514  if (!binning::isValidIdBin(electronicsMap, obj, btype_, iME, bin))
515  continue;
516  me->setBinContent(bin, _content);
517  me->setBinError(bin, _err);
518  if (isProfile)
519  me->setBinEntries(bin, _entries);
520  }
521  }
522  }
523  }
524 
525  void MESetDet2D::fill_(unsigned _iME, int _bin, double _w) {
527  MonitorElement *me(mes_.at(_iME));
528  if (me->getBinEntries(_bin) < 0.) {
529  me->setBinContent(_bin, 0.);
530  me->setBinEntries(_bin, 0.);
531  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
532  }
533  }
534 
535  MESet::fill_(_iME, _bin, _w);
536  }
537 
538  void MESetDet2D::fill_(unsigned _iME, int _bin, double _y, double _w) {
540  MonitorElement *me(mes_.at(_iME));
541  if (me->getBinEntries(_bin) < 0.) {
542  me->setBinContent(_bin, 0.);
543  me->setBinEntries(_bin, 0.);
544  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
545  }
546  }
547 
548  MESet::fill_(_iME, _bin, _y, _w);
549  }
550 
551  void MESetDet2D::fill_(unsigned _iME, double _x, double _wy, double _w) {
553  MonitorElement *me(mes_.at(_iME));
554  int bin(me->getTProfile2D()->FindBin(_x, _wy));
555  if (me->getBinEntries(bin) < 0.) {
556  me->setBinContent(bin, 0.);
557  me->setBinEntries(bin, 0.);
558  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
559  }
560  }
561 
562  MESet::fill_(_iME, _x, _wy, _w);
563  }
564 } // namespace ecaldqm
MonitorElement::Kind kind_
Definition: MESet.h:156
bool isValidIdBin(EcalElectronicsMapping const *, ObjectType, BinningType, unsigned, int)
int stripId() const
get the tower id
virtual void checkME_(unsigned _iME) const
Definition: MESet.h:141
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
unsigned getNObjects(ObjectType)
std::vector< DetId > pseudoStripConstituents(int tccId, int tt, int pseudostrip) const
Get the constituent detids for this dccId.
~MESetDet2D() override
Definition: MESetDet2D.cc:23
MESet * clone(std::string const &="") const override
Definition: MESetDet2D.cc:25
int towerId() const
get the tower id
bool batchMode_
Definition: MESet.h:159
ObjectType getObject(ObjectType, unsigned)
bool isEndcapTTId(DetId const &)
virtual int getNbinsX() const
get # of bins in X-axis
void throw_(std::string const &_message) const
Definition: MESet.h:149
void fill_(unsigned, int, double) override
Definition: MESetDet2D.cc:525
void setBinEntries(EcalDQMSetupObjects const, DetId const &, double) override
Definition: MESetDet2D.cc:251
int findBin2D(EcalElectronicsMapping const *, ObjectType, BinningType, DetId const &)
int findBin(EcalDQMSetupObjects const, DetId const &) const
Definition: MESetDet2D.cc:468
MESetDet2D(std::string const &, binning::ObjectType, binning::BinningType, MonitorElement::Kind, binning::AxisSpecs const *=nullptr)
Definition: MESetDet2D.cc:6
virtual 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)
EcalElectronicsMapping const * electronicsMap
Definition: MESet.h:34
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
void book(DQMStore::IBooker &, EcalElectronicsMapping const *) override
Definition: MESetEcal.cc:70
void reset(EcalElectronicsMapping const *, double=0., double=0., double=0.) override
Definition: MESetDet2D.cc:496
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
virtual void fill_(unsigned, int, double)
Definition: MESet.cc:252
unsigned memDCCId(unsigned)
Definition: DetId.h:17
unsigned findPlotIndex(EcalElectronicsMapping const *, ObjectType, DetId const &)
virtual void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
EcalTrigTowerConstituentsMap const * trigtowerMap
Definition: MESet.h:35
void setBinContent(EcalDQMSetupObjects const, DetId const &, double) override
Definition: MESetDet2D.cc:151
virtual void resetAll(double=0., double=0., double=0.)
Definition: MESet.cc:108
bool active_
Definition: MESet.h:161
void book(DQMStore::IBooker &, EcalElectronicsMapping const *) override
Definition: MESetDet2D.cc:34
binning::ObjectType otype_
Definition: MESet.h:154
std::string channelName(EcalElectronicsMapping const *, uint32_t, BinningType _btype=kDCC)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void setBinError(EcalDQMSetupObjects const, DetId const &, double) override
Definition: MESetDet2D.cc:201
void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=0., double=0.) override
Definition: MESetDet2D.cc:78
double getBinContent(EcalDQMSetupObjects const, DetId const &, int=0) const override
Definition: MESetDet2D.cc:305
binning::BinningType btype_
Definition: MESet.h:155
double getBinEntries(EcalDQMSetupObjects const, DetId const &, int=0) const override
Definition: MESetDet2D.cc:403
double getBinError(EcalDQMSetupObjects const, DetId const &, int=0) const override
Definition: MESetDet2D.cc:354
std::string path_
Definition: MESet.h:153
virtual TH1 * getTH1() const
std::vector< MonitorElement * > mes_
Definition: MESet.h:151