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