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(EcalDQMSetupObjects const edso, DetId const &_id, double _w /* = 1.*/, double, double) {
43  if (!active_)
44  return;
45 
46  unsigned iME(binning::findPlotIndex(edso.electronicsMap, 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, edso.geometry), _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, edso.geometry), _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(edso.trigtowerMap->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]), edso.geometry), _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 
89  EcalDQMSetupObjects const edso, int _subdet, double _x /* = 1.*/, double _w /* = 1.*/, double) {
90  if (!active_)
91  return;
92 
93  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _subdet, btype_));
94  checkME_(iME);
95 
97  _x = phi(_x);
98 
99  mes_[iME]->Fill(_x, _w);
100  }
101 
102  void MESetProjection::fill(EcalDQMSetupObjects const edso, double _x, double _w /* = 1.*/, double) {
103  if (!active_)
104  return;
105  if (btype_ != binning::kProjEta)
106  return;
107 
108  unsigned iME;
109  if (_x < -etaBound)
110  iME = 0;
111  else if (_x < etaBound)
112  iME = 1;
113  else
114  iME = 2;
115 
116  if (otype_ == binning::kEcal2P && iME == 2)
117  iME = 0;
118 
119  checkME_(iME);
120 
121  mes_[iME]->Fill(_x, _w);
122  }
123 
124  void MESetProjection::setBinContent(EcalDQMSetupObjects const edso, DetId const &_id, double _content) {
125  if (!active_)
126  return;
127 
128  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
129  checkME_(iME);
130 
131  MonitorElement *me(mes_[iME]);
132 
133  if (isEndcapTTId(_id)) {
134  EcalTrigTowerDetId ttid(_id);
135  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
136  unsigned nIds(ids.size());
137  std::set<int> bins;
138  if (btype_ == binning::kProjEta) {
139  for (unsigned iId(0); iId < nIds; iId++) {
140  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]), edso.geometry)));
141  if (bins.find(bin) != bins.end())
142  continue;
143  me->setBinContent(bin, _content);
144  }
145  } else if (btype_ == binning::kProjPhi) {
146  for (unsigned iId(0); iId < nIds; iId++) {
147  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
148  if (bins.find(bin) != bins.end())
149  continue;
150  me->setBinContent(bin, _content);
151  }
152  }
153  return;
154  }
155 
156  double x(0.);
157  int subdet(_id.subdetId());
158  if (subdet == EcalBarrel) {
159  EBDetId ebid(_id);
160  if (btype_ == binning::kProjEta)
161  x = eta(ebid, edso.geometry);
162  else if (btype_ == binning::kProjPhi)
163  x = phi(ebid);
164  } else if (subdet == EcalEndcap) {
165  if (btype_ == binning::kProjEta)
166  x = eta(EEDetId(_id), edso.geometry);
167  else if (btype_ == binning::kProjPhi)
168  x = phi(EEDetId(_id));
169  } else if (subdet == EcalTriggerTower) {
170  EcalTrigTowerDetId ttid(_id);
171  if (btype_ == binning::kProjEta) {
172  int ieta(ttid.ieta());
173  if (ieta < 18 && ieta > 0)
174  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
175  else if (ieta > -18 && ieta < 0)
176  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
177  } else if (btype_ == binning::kProjPhi)
178  x = phi(ttid);
179  }
180 
181  int bin(me->getTH1()->FindBin(x));
182  me->setBinContent(bin, _content);
183  }
184 
185  void MESetProjection::setBinError(EcalDQMSetupObjects const edso, DetId const &_id, double _error) {
186  if (!active_)
187  return;
188 
189  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
190  checkME_(iME);
191 
192  MonitorElement *me(mes_[iME]);
193 
194  if (isEndcapTTId(_id)) {
195  EcalTrigTowerDetId ttid(_id);
196  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
197  unsigned nIds(ids.size());
198  std::set<int> bins;
199  if (btype_ == binning::kProjEta) {
200  for (unsigned iId(0); iId < nIds; iId++) {
201  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]), edso.geometry)));
202  if (bins.find(bin) != bins.end())
203  continue;
204  me->setBinError(bin, _error);
205  }
206  } else if (btype_ == binning::kProjPhi) {
207  for (unsigned iId(0); iId < nIds; iId++) {
208  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
209  if (bins.find(bin) != bins.end())
210  continue;
211  me->setBinError(bin, _error);
212  }
213  }
214  return;
215  }
216 
217  double x(0.);
218  int subdet(_id.subdetId());
219  if (subdet == EcalBarrel) {
220  EBDetId ebid(_id);
221  if (btype_ == binning::kProjEta)
222  x = eta(ebid, edso.geometry);
223  else if (btype_ == binning::kProjPhi)
224  x = phi(ebid);
225  } else if (subdet == EcalEndcap) {
226  if (btype_ == binning::kProjEta)
227  x = eta(EEDetId(_id), edso.geometry);
228  else if (btype_ == binning::kProjPhi)
229  x = phi(EEDetId(_id));
230  } else if (subdet == EcalTriggerTower) {
231  EcalTrigTowerDetId ttid(_id);
232  if (btype_ == binning::kProjEta) {
233  int ieta(ttid.ieta());
234  if (ieta < 18 && ieta > 0)
235  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
236  else if (ieta > -18 && ieta < 0)
237  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
238  } else if (btype_ == binning::kProjPhi)
239  x = phi(ttid);
240  }
241 
242  int bin(me->getTH1()->FindBin(x));
243  me->setBinError(bin, _error);
244  }
245 
246  void MESetProjection::setBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, double _entries) {
247  if (!active_)
248  return;
249 
250  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
251  checkME_(iME);
252 
253  MonitorElement *me(mes_[iME]);
254 
255  if (isEndcapTTId(_id)) {
256  EcalTrigTowerDetId ttid(_id);
257  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
258  unsigned nIds(ids.size());
259  std::set<int> bins;
260  if (btype_ == binning::kProjEta) {
261  for (unsigned iId(0); iId < nIds; iId++) {
262  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[iId]), edso.geometry)));
263  if (bins.find(bin) != bins.end())
264  continue;
265  me->setBinEntries(bin, _entries);
266  }
267  } else if (btype_ == binning::kProjPhi) {
268  for (unsigned iId(0); iId < nIds; iId++) {
269  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[iId]))));
270  if (bins.find(bin) != bins.end())
271  continue;
272  me->setBinEntries(bin, _entries);
273  }
274  }
275  return;
276  }
277 
278  double x(0.);
279  int subdet(_id.subdetId());
280  if (subdet == EcalBarrel) {
281  EBDetId ebid(_id);
282  if (btype_ == binning::kProjEta)
283  x = eta(ebid, edso.geometry);
284  else if (btype_ == binning::kProjPhi)
285  x = phi(ebid);
286  } else if (subdet == EcalEndcap) {
287  if (btype_ == binning::kProjEta)
288  x = eta(EEDetId(_id), edso.geometry);
289  else if (btype_ == binning::kProjPhi)
290  x = phi(EEDetId(_id));
291  } else if (subdet == EcalTriggerTower) {
292  EcalTrigTowerDetId ttid(_id);
293  if (btype_ == binning::kProjEta) {
294  int ieta(ttid.ieta());
295  if (ieta < 18 && ieta > 0)
296  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
297  else if (ieta > -18 && ieta < 0)
298  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
299  } else if (btype_ == binning::kProjPhi)
300  x = phi(ttid);
301  }
302 
303  int bin(me->getTH1()->FindBin(x));
304  me->setBinEntries(bin, _entries);
305  }
306 
307  double MESetProjection::getBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
308  if (!active_)
309  return 0.;
310 
311  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
312  checkME_(iME);
313 
314  MonitorElement *me(mes_[iME]);
315 
316  if (isEndcapTTId(_id)) {
317  EcalTrigTowerDetId ttid(_id);
318  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
319  if (btype_ == binning::kProjEta) {
320  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]), edso.geometry)));
321  return me->getBinContent(bin);
322  } else if (btype_ == binning::kProjPhi) {
323  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
324  return me->getBinContent(bin);
325  }
326  return 0.;
327  }
328 
329  double x(0.);
330  int subdet(_id.subdetId());
331  if (subdet == EcalBarrel) {
332  EBDetId ebid(_id);
333  if (btype_ == binning::kProjEta)
334  x = eta(ebid, edso.geometry);
335  else if (btype_ == binning::kProjPhi)
336  x = phi(ebid);
337  } else if (subdet == EcalEndcap) {
338  if (btype_ == binning::kProjEta)
339  x = eta(EEDetId(_id), edso.geometry);
340  else if (btype_ == binning::kProjPhi)
341  x = phi(EEDetId(_id));
342  } else if (subdet == EcalTriggerTower) {
343  EcalTrigTowerDetId ttid(_id);
344  if (btype_ == binning::kProjEta) {
345  int ieta(ttid.ieta());
346  if (ieta < 18 && ieta > 0)
347  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
348  else if (ieta > -18 && ieta < 0)
349  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
350  } else if (btype_ == binning::kProjPhi)
351  x = phi(ttid);
352  }
353 
354  int bin(me->getTH1()->FindBin(x));
355  return me->getBinContent(bin);
356  }
357 
358  double MESetProjection::getBinError(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
359  if (!active_)
360  return 0.;
361 
362  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
363  checkME_(iME);
364 
365  MonitorElement *me(mes_[iME]);
366 
367  if (isEndcapTTId(_id)) {
368  EcalTrigTowerDetId ttid(_id);
369  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
370  if (btype_ == binning::kProjEta) {
371  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]), edso.geometry)));
372  return me->getBinError(bin);
373  } else if (btype_ == binning::kProjPhi) {
374  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
375  return me->getBinError(bin);
376  }
377  return 0.;
378  }
379 
380  double x(0.);
381  int subdet(_id.subdetId());
382  if (subdet == EcalBarrel) {
383  EBDetId ebid(_id);
384  if (btype_ == binning::kProjEta)
385  x = eta(ebid, edso.geometry);
386  else if (btype_ == binning::kProjPhi)
387  x = phi(ebid);
388  } else if (subdet == EcalEndcap) {
389  if (btype_ == binning::kProjEta)
390  x = eta(EEDetId(_id), edso.geometry);
391  else if (btype_ == binning::kProjPhi)
392  x = phi(EEDetId(_id));
393  } else if (subdet == EcalTriggerTower) {
394  EcalTrigTowerDetId ttid(_id);
395  if (btype_ == binning::kProjEta) {
396  int ieta(ttid.ieta());
397  if (ieta < 18 && ieta > 0)
398  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
399  else if (ieta > -18 && ieta < 0)
400  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
401  } else if (btype_ == binning::kProjPhi)
402  x = phi(ttid);
403  }
404 
405  int bin(me->getTH1()->FindBin(x));
406  return me->getBinError(bin);
407  }
408 
409  double MESetProjection::getBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, int) const {
410  if (!active_)
411  return 0.;
412 
413  unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
414  checkME_(iME);
415 
416  MonitorElement *me(mes_[iME]);
417 
418  if (isEndcapTTId(_id)) {
419  EcalTrigTowerDetId ttid(_id);
420  std::vector<DetId> ids(edso.trigtowerMap->constituentsOf(ttid));
421  if (btype_ == binning::kProjEta) {
422  int bin(me->getTH1()->FindBin(eta(EEDetId(ids[0]), edso.geometry)));
423  return me->getBinEntries(bin);
424  } else if (btype_ == binning::kProjPhi) {
425  int bin(me->getTH1()->FindBin(phi(EEDetId(ids[0]))));
426  return me->getBinEntries(bin);
427  }
428  return 0.;
429  }
430 
431  double x(0.);
432  int subdet(_id.subdetId());
433  if (subdet == EcalBarrel) {
434  EBDetId ebid(_id);
435  if (btype_ == binning::kProjEta)
436  x = eta(ebid, edso.geometry);
437  else if (btype_ == binning::kProjPhi)
438  x = phi(ebid);
439  } else if (subdet == EcalEndcap) {
440  if (btype_ == binning::kProjEta)
441  x = eta(EEDetId(_id), edso.geometry);
442  else if (btype_ == binning::kProjPhi)
443  x = phi(EEDetId(_id));
444  } else if (subdet == EcalTriggerTower) {
445  EcalTrigTowerDetId ttid(_id);
446  if (btype_ == binning::kProjEta) {
447  int ieta(ttid.ieta());
448  if (ieta < 18 && ieta > 0)
449  x = (ieta * 5 - 2.5) * EBDetId::crystalUnitToEta;
450  else if (ieta > -18 && ieta < 0)
451  x = (ieta * 5 + 2.5) * EBDetId::crystalUnitToEta;
452  } else if (btype_ == binning::kProjPhi)
453  x = phi(ttid);
454  }
455 
456  int bin(me->getTH1()->FindBin(x));
457  return me->getBinEntries(bin);
458  }
459 
460 } // namespace ecaldqm
MonitorElement::Kind kind_
Definition: MESet.h:158
int ieta() const
get the tower ieta
std::vector< DetId > constituentsOf(const EcalTrigTowerDetId &id) const
Get the constituent detids for this tower id.
double const etaBound
void throw_(std::string const &_message) const
Definition: MESet.h:149
double getBinContent(EcalDQMSetupObjects const, DetId const &, int=0) const override
MESet * clone(std::string const &="") const override
void fill(EcalDQMSetupObjects const, DetId const &, double=1., double=0., double=0.) override
void setBinContent(EcalDQMSetupObjects const, DetId const &, double) override
bool isEndcapTTId(DetId const &)
double getBinEntries(EcalDQMSetupObjects const, DetId const &, int=0) const override
MESetProjection(std::string const &, binning::ObjectType, binning::BinningType, MonitorElement::Kind, binning::AxisSpecs const *=nullptr)
static const float crystalUnitToEta
Definition: EBDetId.h:153
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
EcalElectronicsMapping const * electronicsMap
Definition: MESet.h:34
virtual void checkME_(unsigned _iME) const
Definition: MESet.h:141
virtual void fill_(unsigned, int, double)
Definition: MESet.cc:252
Definition: DetId.h:17
unsigned findPlotIndex(EcalElectronicsMapping const *, ObjectType, DetId const &)
void setBinEntries(EcalDQMSetupObjects const, DetId const &, double) override
EcalTrigTowerConstituentsMap const * trigtowerMap
Definition: MESet.h:35
bool active_
Definition: MESet.h:163
float x
CaloGeometry const * geometry
Definition: MESet.h:36
binning::ObjectType otype_
Definition: MESet.h:156
double eta(EBDetId const &, CaloGeometry const *)
void setBinError(EcalDQMSetupObjects const, DetId const &, double) override
binning::BinningType btype_
Definition: MESet.h:157
double getBinError(EcalDQMSetupObjects const, DetId const &, int=0) const override
std::string path_
Definition: MESet.h:155
double phi(EBDetId const &)
std::vector< MonitorElement * > mes_
Definition: MESet.h:153