CMS 3D CMS Logo

MESetProjection.cc
Go to the documentation of this file.
2 
4 
5 namespace ecaldqm {
7  binning::ObjectType _otype,
10  binning::AxisSpecs const *_yaxis /* = 0*/)
11  : MESetEcal(_fullPath, _otype, _btype, _kind, 1, nullptr, _yaxis) {
12  switch (kind_) {
15  break;
16  default:
17  throw_("Unsupported MonitorElement kind");
18  }
19 
20  switch (btype_) {
21  case binning::kProjEta:
22  case binning::kProjPhi:
23  break;
24  default:
25  throw_("Unsupported binning");
26  }
27  }
28 
30 
32 
33  MESet *MESetProjection::clone(std::string const &_path /* = ""*/) const {
35  if (!_path.empty())
36  path_ = _path;
37  MESet *copy(new MESetProjection(*this));
38  path_ = path;
39  return copy;
40  }
41 
42  void MESetProjection::fill(DetId const &_id, double _w /* = 1.*/, double, double) {
43  if (!active_)
44  return;
45 
46  unsigned iME(binning::findPlotIndex(otype_, _id));
47  checkME_(iME);
48 
49  int subdet(_id.subdetId());
50 
51  if (subdet == EcalBarrel) {
52  EBDetId ebid(_id);
54  fill_(iME, eta(ebid), _w, 0.);
55  else if (btype_ == binning::kProjPhi)
56  fill_(iME, phi(ebid), _w, 0.);
57  } else if (subdet == EcalEndcap) {
58  EEDetId eeid(_id);
60  fill_(iME, eta(eeid), _w, 0.);
61  if (btype_ == binning::kProjPhi) {
62  fill_(iME, phi(eeid), _w, 0.);
63  }
64  } else if (isEndcapTTId(_id)) {
65  EcalTrigTowerDetId ttid(_id);
66  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
67  unsigned nIds(ids.size());
68  if (btype_ == binning::kProjEta) {
69  for (unsigned iId(0); iId < nIds; iId++)
70  fill_(iME, eta(EEDetId(ids[iId])), _w / nIds, 0.);
71  } else if (btype_ == binning::kProjPhi) {
72  for (unsigned iId(0); iId < nIds; iId++)
73  fill_(iME, phi(EEDetId(ids[iId])), _w / nIds, 0.);
74  }
75  } else if (subdet == EcalTriggerTower) {
76  EcalTrigTowerDetId ttid(_id);
77  if (btype_ == binning::kProjEta) {
78  int ieta(ttid.ieta());
79  if (ieta < 18 && ieta > 0)
80  fill_(iME, (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta, _w, 0.);
81  else if (ieta > -18 && ieta < 0)
82  fill_(iME, (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta, _w, 0.);
83  } else if (btype_ == binning::kProjPhi)
84  fill_(iME, phi(ttid), _w, 0.);
85  }
86  }
87 
88  void MESetProjection::fill(int _subdet, double _x /* = 1.*/, double _w /* = 1.*/, double) {
89  if (!active_)
90  return;
91 
92  unsigned iME(binning::findPlotIndex(otype_, _subdet, btype_));
93  checkME_(iME);
94 
96  _x = phi(_x);
97 
98  mes_[iME]->Fill(_x, _w);
99  }
100 
101  void MESetProjection::fill(double _x, double _w /* = 1.*/, double) {
102  if (!active_)
103  return;
104  if (btype_ != binning::kProjEta)
105  return;
106 
107  unsigned iME;
108  if (_x < -etaBound)
109  iME = 0;
110  else if (_x < etaBound)
111  iME = 1;
112  else
113  iME = 2;
114 
115  if (otype_ == binning::kEcal2P && iME == 2)
116  iME = 0;
117 
118  checkME_(iME);
119 
120  mes_[iME]->Fill(_x, _w);
121  }
122 
123  void MESetProjection::setBinContent(DetId const &_id, double _content) {
124  if (!active_)
125  return;
126 
127  unsigned iME(binning::findPlotIndex(otype_, _id));
128  checkME_(iME);
129 
130  MonitorElement *me(mes_[iME]);
131 
132  if (isEndcapTTId(_id)) {
133  EcalTrigTowerDetId ttid(_id);
134  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
135  unsigned nIds(ids.size());
136  std::set<int> bins;
137  if (btype_ == binning::kProjEta) {
138  for (unsigned iId(0); iId < nIds; iId++) {
139  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]))));
140  if (bins.find(bin) != bins.end())
141  continue;
142  me->setBinContent(bin, _content);
143  }
144  } else if (btype_ == binning::kProjPhi) {
145  for (unsigned iId(0); iId < nIds; iId++) {
146  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
147  if (bins.find(bin) != bins.end())
148  continue;
149  me->setBinContent(bin, _content);
150  }
151  }
152  return;
153  }
154 
155  double x(0.);
156  int subdet(_id.subdetId());
157  if (subdet == EcalBarrel) {
158  EBDetId ebid(_id);
159  if (btype_ == binning::kProjEta)
160  x = eta(ebid);
161  else if (btype_ == binning::kProjPhi)
162  x = phi(ebid);
163  } else if (subdet == EcalEndcap) {
164  if (btype_ == binning::kProjEta)
165  x = eta(EEDetId(_id));
166  else if (btype_ == binning::kProjPhi)
167  x = phi(EEDetId(_id));
168  } else if (subdet == EcalTriggerTower) {
169  EcalTrigTowerDetId ttid(_id);
170  if (btype_ == binning::kProjEta) {
171  int ieta(ttid.ieta());
172  if (ieta < 18 && ieta > 0)
173  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
174  else if (ieta > -18 && ieta < 0)
175  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
176  } else if (btype_ == binning::kProjPhi)
177  x = phi(ttid);
178  }
179 
180  int bin(me->getTH1()->FindBin(x));
181  me->setBinContent(bin, _content);
182  }
183 
184  void MESetProjection::setBinError(DetId const &_id, double _error) {
185  if (!active_)
186  return;
187 
188  unsigned iME(binning::findPlotIndex(otype_, _id));
189  checkME_(iME);
190 
191  MonitorElement *me(mes_[iME]);
192 
193  if (isEndcapTTId(_id)) {
194  EcalTrigTowerDetId ttid(_id);
195  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
196  unsigned nIds(ids.size());
197  std::set<int> bins;
198  if (btype_ == binning::kProjEta) {
199  for (unsigned iId(0); iId < nIds; iId++) {
200  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]))));
201  if (bins.find(bin) != bins.end())
202  continue;
203  me->setBinError(bin, _error);
204  }
205  } else if (btype_ == binning::kProjPhi) {
206  for (unsigned iId(0); iId < nIds; iId++) {
207  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
208  if (bins.find(bin) != bins.end())
209  continue;
210  me->setBinError(bin, _error);
211  }
212  }
213  return;
214  }
215 
216  double x(0.);
217  int subdet(_id.subdetId());
218  if (subdet == EcalBarrel) {
219  EBDetId ebid(_id);
220  if (btype_ == binning::kProjEta)
221  x = eta(ebid);
222  else if (btype_ == binning::kProjPhi)
223  x = phi(ebid);
224  } else if (subdet == EcalEndcap) {
225  if (btype_ == binning::kProjEta)
226  x = eta(EEDetId(_id));
227  else if (btype_ == binning::kProjPhi)
228  x = phi(EEDetId(_id));
229  } else if (subdet == EcalTriggerTower) {
230  EcalTrigTowerDetId ttid(_id);
231  if (btype_ == binning::kProjEta) {
232  int ieta(ttid.ieta());
233  if (ieta < 18 && ieta > 0)
234  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
235  else if (ieta > -18 && ieta < 0)
236  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
237  } else if (btype_ == binning::kProjPhi)
238  x = phi(ttid);
239  }
240 
241  int bin(me->getTH1()->FindBin(x));
242  me->setBinError(bin, _error);
243  }
244 
245  void MESetProjection::setBinEntries(DetId const &_id, double _entries) {
246  if (!active_)
247  return;
248 
249  unsigned iME(binning::findPlotIndex(otype_, _id));
250  checkME_(iME);
251 
252  MonitorElement *me(mes_[iME]);
253 
254  if (isEndcapTTId(_id)) {
255  EcalTrigTowerDetId ttid(_id);
256  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
257  unsigned nIds(ids.size());
258  std::set<int> bins;
259  if (btype_ == binning::kProjEta) {
260  for (unsigned iId(0); iId < nIds; iId++) {
261  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]))));
262  if (bins.find(bin) != bins.end())
263  continue;
264  me->setBinEntries(bin, _entries);
265  }
266  } else if (btype_ == binning::kProjPhi) {
267  for (unsigned iId(0); iId < nIds; iId++) {
268  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
269  if (bins.find(bin) != bins.end())
270  continue;
271  me->setBinEntries(bin, _entries);
272  }
273  }
274  return;
275  }
276 
277  double x(0.);
278  int subdet(_id.subdetId());
279  if (subdet == EcalBarrel) {
280  EBDetId ebid(_id);
281  if (btype_ == binning::kProjEta)
282  x = eta(ebid);
283  else if (btype_ == binning::kProjPhi)
284  x = phi(ebid);
285  } else if (subdet == EcalEndcap) {
286  if (btype_ == binning::kProjEta)
287  x = eta(EEDetId(_id));
288  else if (btype_ == binning::kProjPhi)
289  x = phi(EEDetId(_id));
290  } else if (subdet == EcalTriggerTower) {
291  EcalTrigTowerDetId ttid(_id);
292  if (btype_ == binning::kProjEta) {
293  int ieta(ttid.ieta());
294  if (ieta < 18 && ieta > 0)
295  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
296  else if (ieta > -18 && ieta < 0)
297  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
298  } else if (btype_ == binning::kProjPhi)
299  x = phi(ttid);
300  }
301 
302  int bin(me->getTH1()->FindBin(x));
303  me->setBinEntries(bin, _entries);
304  }
305 
306  double MESetProjection::getBinContent(DetId const &_id, int) const {
307  if (!active_)
308  return 0.;
309 
310  unsigned iME(binning::findPlotIndex(otype_, _id));
311  checkME_(iME);
312 
313  MonitorElement *me(mes_[iME]);
314 
315  if (isEndcapTTId(_id)) {
316  EcalTrigTowerDetId ttid(_id);
317  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
318  if (btype_ == binning::kProjEta) {
319  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]))));
320  return me->getBinContent(bin);
321  } else if (btype_ == binning::kProjPhi) {
322  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
323  return me->getBinContent(bin);
324  }
325  return 0.;
326  }
327 
328  double x(0.);
329  int subdet(_id.subdetId());
330  if (subdet == EcalBarrel) {
331  EBDetId ebid(_id);
332  if (btype_ == binning::kProjEta)
333  x = eta(ebid);
334  else if (btype_ == binning::kProjPhi)
335  x = phi(ebid);
336  } else if (subdet == EcalEndcap) {
337  if (btype_ == binning::kProjEta)
338  x = eta(EEDetId(_id));
339  else if (btype_ == binning::kProjPhi)
340  x = phi(EEDetId(_id));
341  } else if (subdet == EcalTriggerTower) {
342  EcalTrigTowerDetId ttid(_id);
343  if (btype_ == binning::kProjEta) {
344  int ieta(ttid.ieta());
345  if (ieta < 18 && ieta > 0)
346  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
347  else if (ieta > -18 && ieta < 0)
348  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
349  } else if (btype_ == binning::kProjPhi)
350  x = phi(ttid);
351  }
352 
353  int bin(me->getTH1()->FindBin(x));
354  return me->getBinContent(bin);
355  }
356 
357  double MESetProjection::getBinError(DetId const &_id, int) const {
358  if (!active_)
359  return 0.;
360 
361  unsigned iME(binning::findPlotIndex(otype_, _id));
362  checkME_(iME);
363 
364  MonitorElement *me(mes_[iME]);
365 
366  if (isEndcapTTId(_id)) {
367  EcalTrigTowerDetId ttid(_id);
368  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
369  if (btype_ == binning::kProjEta) {
370  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]))));
371  return me->getBinError(bin);
372  } else if (btype_ == binning::kProjPhi) {
373  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
374  return me->getBinError(bin);
375  }
376  return 0.;
377  }
378 
379  double x(0.);
380  int subdet(_id.subdetId());
381  if (subdet == EcalBarrel) {
382  EBDetId ebid(_id);
383  if (btype_ == binning::kProjEta)
384  x = eta(ebid);
385  else if (btype_ == binning::kProjPhi)
386  x = phi(ebid);
387  } else if (subdet == EcalEndcap) {
388  if (btype_ == binning::kProjEta)
389  x = eta(EEDetId(_id));
390  else if (btype_ == binning::kProjPhi)
391  x = phi(EEDetId(_id));
392  } else if (subdet == EcalTriggerTower) {
393  EcalTrigTowerDetId ttid(_id);
394  if (btype_ == binning::kProjEta) {
395  int ieta(ttid.ieta());
396  if (ieta < 18 && ieta > 0)
397  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
398  else if (ieta > -18 && ieta < 0)
399  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
400  } else if (btype_ == binning::kProjPhi)
401  x = phi(ttid);
402  }
403 
404  int bin(me->getTH1()->FindBin(x));
405  return me->getBinError(bin);
406  }
407 
408  double MESetProjection::getBinEntries(DetId const &_id, int) const {
409  if (!active_)
410  return 0.;
411 
412  unsigned iME(binning::findPlotIndex(otype_, _id));
413  checkME_(iME);
414 
415  MonitorElement *me(mes_[iME]);
416 
417  if (isEndcapTTId(_id)) {
418  EcalTrigTowerDetId ttid(_id);
419  std::vector<DetId> ids(getTrigTowerMap()->constituentsOf(ttid));
420  if (btype_ == binning::kProjEta) {
421  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]))));
422  return me->getBinEntries(bin);
423  } else if (btype_ == binning::kProjPhi) {
424  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
425  return me->getBinEntries(bin);
426  }
427  return 0.;
428  }
429 
430  double x(0.);
431  int subdet(_id.subdetId());
432  if (subdet == EcalBarrel) {
433  EBDetId ebid(_id);
434  if (btype_ == binning::kProjEta)
435  x = eta(ebid);
436  else if (btype_ == binning::kProjPhi)
437  x = phi(ebid);
438  } else if (subdet == EcalEndcap) {
439  if (btype_ == binning::kProjEta)
440  x = eta(EEDetId(_id));
441  else if (btype_ == binning::kProjPhi)
442  x = phi(EEDetId(_id));
443  } else if (subdet == EcalTriggerTower) {
444  EcalTrigTowerDetId ttid(_id);
445  if (btype_ == binning::kProjEta) {
446  int ieta(ttid.ieta());
447  if (ieta < 18 && ieta > 0)
448  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
449  else if (ieta > -18 && ieta < 0)
450  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
451  } else if (btype_ == binning::kProjPhi)
452  x = phi(ttid);
453  }
454 
455  int bin(me->getTH1()->FindBin(x));
456  return me->getBinEntries(bin);
457  }
458 
459 } // namespace ecaldqm
EBDetId::crystalUnitToEta
static const float crystalUnitToEta
Definition: EBDetId.h:153
ecaldqm::MESet::throw_
void throw_(std::string const &_message) const
Definition: MESet.h:121
ecaldqm::MESetProjection::MESetProjection
MESetProjection(std::string const &, binning::ObjectType, binning::BinningType, MonitorElement::Kind, binning::AxisSpecs const *=nullptr)
Definition: MESetProjection.cc:6
ecaldqm
Definition: DQWorker.h:24
ecaldqm::MESet::fill_
virtual void fill_(unsigned, int, double)
Definition: MESet.cc:246
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
MonitorElementData::Kind::TH1F
ecaldqm::MESetProjection::getBinError
double getBinError(DetId const &, int=0) const override
Definition: MESetProjection.cc:357
EBDetId
Definition: EBDetId.h:17
ecaldqm::MESetEcal
Definition: MESetEcal.h:15
ecaldqm::MESetProjection::setBinError
void setBinError(DetId const &, double) override
Definition: MESetProjection.cc:184
ecaldqm::binning::kEcal2P
Definition: MESetBinningUtils.h:32
ecaldqm::isEndcapTTId
bool isEndcapTTId(DetId const &)
Definition: EcalDQMCommonUtils.cc:270
dqm::legacy::MonitorElement
Definition: MonitorElement.h:461
ecaldqm::binning::kProjEta
Definition: MESetBinningUtils.h:47
EcalTrigTowerDetId
Definition: EcalTrigTowerDetId.h:14
ecaldqm::etaBound
const double etaBound
MESetProjection.h
EcalBarrel
Definition: EcalSubdetector.h:10
ecaldqm::binning::kProjPhi
Definition: MESetBinningUtils.h:48
DetId
Definition: DetId.h:17
ecaldqm::MESetProjection::fill
void fill(DetId const &, double=1., double=0., double=0.) override
Definition: MESetProjection.cc:42
ecaldqm::MESet::otype_
binning::ObjectType otype_
Definition: MESet.h:126
ecaldqm::MESet::active_
bool active_
Definition: MESet.h:133
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalEndcap
Definition: EcalSubdetector.h:10
LEDCalibrationChannels.ieta
ieta
Definition: LEDCalibrationChannels.py:63
ecaldqm::MESetProjection
Definition: MESetProjection.h:12
ecaldqm::binning::ObjectType
ObjectType
Definition: MESetBinningUtils.h:17
ecaldqm::MESet::btype_
binning::BinningType btype_
Definition: MESet.h:127
MonitorElementData::Kind
Kind
Definition: MonitorElementCollection.h:129
ecaldqm::MESet::path_
std::string path_
Definition: MESet.h:125
ecaldqm::binning::findPlotIndex
unsigned findPlotIndex(ObjectType, DetId const &)
Definition: MESetBinningUtils.cc:299
ecaldqm::binning::AxisSpecs
Definition: MESetBinningUtils.h:72
ecaldqm::MESetProjection::clone
MESet * clone(std::string const &="") const override
Definition: MESetProjection.cc:33
EcalTrigTowerDetId::ieta
int ieta() const
get the tower ieta
Definition: EcalTrigTowerDetId.h:44
ecaldqm::getTrigTowerMap
const EcalTrigTowerConstituentsMap * getTrigTowerMap()
Definition: EcalDQMCommonUtils.cc:458
ecaldqm::MESetProjection::getBinEntries
double getBinEntries(DetId const &, int=0) const override
Definition: MESetProjection.cc:408
ecaldqm::MESet::mes_
std::vector< MonitorElement * > mes_
Definition: MESet.h:123
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
EcalTriggerTower
Definition: EcalSubdetector.h:10
ecaldqm::MESet::checkME_
virtual void checkME_(unsigned _iME) const
Definition: MESet.h:113
ecaldqm::MESetProjection::~MESetProjection
~MESetProjection() override
Definition: MESetProjection.cc:31
ecaldqm::MESetProjection::getBinContent
double getBinContent(DetId const &, int=0) const override
Definition: MESetProjection.cc:306
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
trigObjTnPSource_cfi.bins
bins
Definition: trigObjTnPSource_cfi.py:20
ecaldqm::binning::BinningType
BinningType
Definition: MESetBinningUtils.h:40
ecaldqm::MESetProjection::setBinContent
void setBinContent(DetId const &, double) override
Definition: MESetProjection.cc:123
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:56
ecaldqm::MESet::kind_
MonitorElement::Kind kind_
Definition: MESet.h:128
ecaldqm::MESetProjection::setBinEntries
void setBinEntries(DetId const &, double) override
Definition: MESetProjection.cc:245
btvTracks_cfi._content
_content
Definition: btvTracks_cfi.py:5
MonitorElementData::Kind::TPROFILE
EcalDQMCommonUtils.h
ecaldqm::phi
double phi(EBDetId const &)
Definition: EcalDQMCommonUtils.cc:215
ecaldqm::MESet
Definition: MESet.h:27
ecaldqm::eta
double eta(EBDetId const &)
Definition: EcalDQMCommonUtils.cc:209