test
CMS 3D CMS Logo

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