test
CMS 3D CMS Logo

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