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(btype_ == binning::kRCT){
97  bin = binning::findBin2D(obj, btype_, _id);
98  fill_(iME, bin, _w);
99  }
100  else{
101  if(isEndcapTTId(_id)){
102  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
103  unsigned nId(ids.size());
104  for(unsigned iId(0); iId < nId; iId++){
105  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
106  fill_(iME, bin, _w);
107  }
108  }
109  else{
110  bin = binning::findBin2D(obj, btype_, _id);
111  fill_(iME, bin, _w);
112  }
113  }
114  }
115 
116  void
117  MESetDet2D::fill(EcalElectronicsId const& _id, double _w/* = 1.*/, double, double)
118  {
119  if(!active_) return;
120 
121  unsigned iME(0);
123  else iME = binning::findPlotIndex(otype_, _id);
124  checkME_(iME);
125 
127 
128  int bin;
129 
131  EcalElectronicsId stid(_id);
132  std::vector<DetId> ids(getElectronicsMap()->pseudoStripConstituents(stid.dccId(), stid.towerId(), stid.stripId()));
133  unsigned nId(ids.size());
134  for(unsigned iId(0); iId < nId; iId++){
135  bin = binning::findBin2D(obj, btype_ , ids[iId]);
136  fill_(iME, bin, _w);
137  }
138  }
139  else{
140  bin = binning::findBin2D(obj, btype_, _id);
141  fill_(iME, bin, _w);
142  }
143  }
144 
145  void
146  MESetDet2D::fill(int _dcctccid, double _w/* = 1.*/, double, double)
147  {
148  if(!active_) return;
149 
150  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
151  checkME_(iME);
152 
154 
155  int bin(binning::findBin2D(obj, btype_, _dcctccid));
156  fill_(iME, bin, _w);
157  }
158 
159  void
161  {
162  if(!active_) return;
163 
164  unsigned iME(binning::findPlotIndex(otype_, _id));
165  checkME_(iME);
166 
168 
169  int bin;
170 
171  if(isEndcapTTId(_id)){
172  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
173  unsigned nId(ids.size());
174  for(unsigned iId(0); iId < nId; iId++){
175  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
176  mes_[iME]->setBinContent(bin, _content);
177  }
178  }
179  else{
180  bin = binning::findBin2D(obj, btype_, _id);
181  mes_[iME]->setBinContent(bin, _content);
182  }
183  }
184 
185  void
187  {
188  if(!active_) return;
189 
190  unsigned iME(binning::findPlotIndex(otype_, _id));
191  checkME_(iME);
192 
194 
195  int bin(binning::findBin2D(obj, btype_, _id));
196  mes_[iME]->setBinContent(bin, _content);
197  }
198 
199  void
200  MESetDet2D::setBinContent(int _dcctccid, double _content)
201  {
202  if(!active_) return;
203 
204  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
205  checkME_(iME);
206 
208 
209  int bin(binning::findBin2D(obj, btype_, _dcctccid));
210  mes_[iME]->setBinContent(bin, _content);
211  }
212 
213  void
214  MESetDet2D::setBinError(DetId const& _id, double _error)
215  {
216  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]->setBinError(bin, _error);
231  }
232  }
233  else{
234  bin = binning::findBin2D(obj, btype_, _id);
235  mes_[iME]->setBinError(bin, _error);
236  }
237  }
238 
239  void
240  MESetDet2D::setBinError(EcalElectronicsId const& _id, double _error)
241  {
242  if(!active_) return;
243 
244  unsigned iME(binning::findPlotIndex(otype_, _id));
245  checkME_(iME);
246 
248 
249  int bin(binning::findBin2D(obj, btype_, _id));
250  mes_[iME]->setBinError(bin, _error);
251  }
252 
253  void
254  MESetDet2D::setBinError(int _dcctccid, double _error)
255  {
256  if(!active_) return;
257 
258  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
259  checkME_(iME);
260 
262 
263  int bin(binning::findBin2D(obj, btype_, _dcctccid));
264  mes_[iME]->setBinError(bin, _error);
265  }
266 
267  void
268  MESetDet2D::setBinEntries(DetId const& _id, double _entries)
269  {
270  if(!active_) return;
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  unsigned nId(ids.size());
283  for(unsigned iId(0); iId < nId; iId++){
284  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[iId]);
285  mes_[iME]->setBinEntries(bin, _entries);
286  }
287  }
288  else{
289  bin = binning::findBin2D(obj, btype_, _id);
290  mes_[iME]->setBinEntries(bin, _entries);
291  }
292  }
293 
294  void
295  MESetDet2D::setBinEntries(EcalElectronicsId const& _id, double _entries)
296  {
297  if(!active_) return;
299 
300  unsigned iME(binning::findPlotIndex(otype_, _id));
301  checkME_(iME);
302 
304 
305  int bin(binning::findBin2D(obj, btype_, _id));
306  mes_[iME]->setBinEntries(bin, _entries);
307  }
308 
309  void
310  MESetDet2D::setBinEntries(int _dcctccid, double _entries)
311  {
312  if(!active_) return;
313 
314  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
315  checkME_(iME);
316 
318 
319  int bin(binning::findBin2D(obj, btype_, _dcctccid));
320  mes_[iME]->setBinEntries(bin, _entries);
321  }
322 
323  double
324  MESetDet2D::getBinContent(DetId const& _id, int) const
325  {
326  if(!active_) return 0.;
327 
328  unsigned iME(binning::findPlotIndex(otype_, _id));
329  checkME_(iME);
330 
332 
333  int bin;
334 
335  if(isEndcapTTId(_id)){
336  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
337  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
338  }
339  else{
340  bin = binning::findBin2D(obj, btype_, _id);
341  }
342 
343  return mes_[iME]->getBinContent(bin);
344  }
345 
346  double
348  {
349  if(!active_) return 0.;
350 
351  unsigned iME(binning::findPlotIndex(otype_, _id));
352  checkME_(iME);
353 
355 
356  int bin(binning::findBin2D(obj, btype_, _id));
357 
358  return mes_[iME]->getBinContent(bin);
359  }
360 
361  double
362  MESetDet2D::getBinContent(int _dcctccid, int) const
363  {
364  if(!active_) return 0.;
365 
366  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
367  checkME_(iME);
368 
370 
371  int bin(binning::findBin2D(obj, btype_, _dcctccid));
372 
373  return mes_[iME]->getBinContent(bin);
374  }
375 
376  double
377  MESetDet2D::getBinError(DetId const& _id, int) const
378  {
379  if(!active_) return 0.;
380 
381  unsigned iME(binning::findPlotIndex(otype_, _id));
382  checkME_(iME);
383 
385 
386  int bin;
387 
388  if(isEndcapTTId(_id)){
389  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
390  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
391  }
392  else{
393  bin = binning::findBin2D(obj, btype_, _id);
394  }
395 
396  return mes_[iME]->getBinError(bin);
397  }
398 
399  double
401  {
402  if(!active_) return 0.;
403 
404  unsigned iME(binning::findPlotIndex(otype_, _id));
405  checkME_(iME);
406 
408 
409  int bin(binning::findBin2D(obj, btype_, _id));
410 
411  return mes_[iME]->getBinError(bin);
412  }
413 
414  double
415  MESetDet2D::getBinError(int _dcctccid, int) const
416  {
417  if(!active_) return 0.;
418 
419  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
420  checkME_(iME);
421 
423 
424  int bin(binning::findBin2D(obj, btype_, _dcctccid));
425 
426  return mes_[iME]->getBinError(bin);
427  }
428 
429  double
430  MESetDet2D::getBinEntries(DetId const& _id, int) const
431  {
432  if(!active_) return 0.;
434 
435  unsigned iME(binning::findPlotIndex(otype_, _id));
436  checkME_(iME);
437 
439 
440  int bin;
441 
442  if(isEndcapTTId(_id)){
443  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
444  bin = binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
445  }
446  else{
447  bin = binning::findBin2D(obj, btype_, _id);
448  }
449 
450  double entries(mes_[iME]->getBinEntries(bin));
451  if(entries < 0.) return 0.;
452  else return entries;
453  }
454 
455  double
457  {
458  if(!active_) return 0.;
460 
461  unsigned iME(binning::findPlotIndex(otype_, _id));
462  checkME_(iME);
463 
465 
466  int bin(binning::findBin2D(obj, btype_, _id));
467 
468  double entries(mes_[iME]->getBinEntries(bin));
469  if(entries < 0.) return 0.;
470  else return entries;
471  }
472 
473  double
474  MESetDet2D::getBinEntries(int _dcctccid, int) const
475  {
476  if(!active_) return 0.;
477 
478  unsigned iME(binning::findPlotIndex(otype_, _dcctccid));
479  checkME_(iME);
480 
482 
483  int bin(binning::findBin2D(obj, btype_, _dcctccid));
484 
485  double entries(mes_[iME]->getBinEntries(bin));
486  if(entries < 0.) return 0.;
487  else return entries;
488  }
489 
490  int
491  MESetDet2D::findBin(DetId const& _id) const
492  {
493  if(!active_) return 0;
494 
495  unsigned iME(binning::findPlotIndex(otype_, _id));
496  checkME_(iME);
497 
499 
500  if(isEndcapTTId(_id)){
501  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(EcalTrigTowerDetId(_id)));
502  return binning::findBin2D(obj, binning::kTriggerTower, ids[0]);
503  }
504  else
505  return binning::findBin2D(obj, btype_, _id);
506  }
507 
508  int
510  {
511  if(!active_) return 0;
512 
513  unsigned iME(binning::findPlotIndex(otype_, _id));
514  checkME_(iME);
515 
517 
518  return binning::findBin2D(obj, btype_, _id);
519  }
520 
521  void
522  MESetDet2D::reset(double _content/* = 0.*/, double _err/* = 0.*/, double _entries/* = 0.*/)
523  {
524  unsigned nME(binning::getNObjects(otype_));
525 
526  bool isProfile(kind_ == MonitorElement::DQM_KIND_TPROFILE2D);
527 
528  for(unsigned iME(0); iME < nME; iME++) {
529  MonitorElement* me(mes_[iME]);
530 
532 
533  int nbinsX(me->getTH1()->GetNbinsX());
534  int nbinsY(me->getTH1()->GetNbinsY());
535  for(int ix(1); ix <= nbinsX; ix++){
536  for(int iy(1); iy <= nbinsY; iy++){
537  int bin((nbinsX + 2) * iy + ix);
538  if(!binning::isValidIdBin(obj, btype_, iME, bin)) continue;
539  me->setBinContent(bin, _content);
540  me->setBinError(bin, _err);
541  if(isProfile) me->setBinEntries(bin, _entries);
542  }
543  }
544  }
545  }
546 
547  void
549  {
552  resetAll(0., 0., -1.);
553  }
554 
555  void
556  MESetDet2D::fill_(unsigned _iME, int _bin, double _w)
557  {
559  MonitorElement* me(mes_.at(_iME));
560  if(me->getBinEntries(_bin) < 0.){
561  me->setBinContent(_bin, 0.);
562  me->setBinEntries(_bin, 0.);
563  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
564  }
565  }
566 
567  MESet::fill_(_iME, _bin, _w);
568  }
569 
570  void
571  MESetDet2D::fill_(unsigned _iME, int _bin, double _y, double _w)
572  {
574  MonitorElement* me(mes_.at(_iME));
575  if(me->getBinEntries(_bin) < 0.){
576  me->setBinContent(_bin, 0.);
577  me->setBinEntries(_bin, 0.);
578  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
579  }
580  }
581 
582  MESet::fill_(_iME, _bin, _y, _w);
583  }
584 
585  void
586  MESetDet2D::fill_(unsigned _iME, double _x, double _wy, double _w)
587  {
589  MonitorElement* me(mes_.at(_iME));
590  int bin(me->getTProfile2D()->FindBin(_x, _wy));
591  if(me->getBinEntries(bin) < 0.){
592  me->setBinContent(bin, 0.);
593  me->setBinEntries(bin, 0.);
594  me->getTProfile2D()->SetEntries(me->getTProfile2D()->GetEntries() + 1.);
595  }
596  }
597 
598  MESet::fill_(_iME, _x, _wy, _w);
599  }
600 }
double getBinEntries(DetId const &, int=0) const override
Definition: MESetDet2D.cc:430
MonitorElement::Kind kind_
Definition: MESet.h:134
void setBinContent(int binx, double content)
set content of bin (1-D)
int stripId() const
get the tower id
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)
EcalElectronicsMapping const * getElectronicsMap()
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:522
MESet * clone(std::string const &="") const override
Definition: MESetDet2D.cc:29
int towerId() const
get the tower id
void setBinContent(DetId const &, double) override
Definition: MESetDet2D.cc:160
bool batchMode_
Definition: MESet.h:136
void setBinError(DetId const &, double) override
Definition: MESetDet2D.cc:214
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:556
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:377
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:278
unsigned memDCCId(unsigned)
Definition: DetId.h:18
double getBinContent(DetId const &, int=0) const override
Definition: MESetDet2D.cc:324
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:548
int getNbinsX(void) const
get # of bins in X-axis
int findBin(DetId const &) const
Definition: MESetDet2D.cc:491
binning::ObjectType otype_
Definition: MESet.h:132
void setBinEntries(DetId const &, double) override
Definition: MESetDet2D.cc:268
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