Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:07:14

0001 #include "DQM/EcalCommon/interface/MESetDet1D.h"
0002 
0003 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0004 
0005 namespace ecaldqm {
0006 
0007   MESetDet1D::MESetDet1D(std::string const &_fullPath,
0008                          binning::ObjectType _otype,
0009                          binning::BinningType _btype,
0010                          MonitorElement::Kind _kind,
0011                          binning::AxisSpecs const *_yaxis /* = 0*/)
0012       : MESetEcal(_fullPath, _otype, _btype, _kind, 1, nullptr, _yaxis, nullptr) {
0013     switch (kind_) {
0014       case MonitorElement::Kind::TH1F:
0015       case MonitorElement::Kind::TPROFILE:
0016       case MonitorElement::Kind::TH2F:
0017       case MonitorElement::Kind::TPROFILE2D:
0018         break;
0019       default:
0020         throw_("Unsupported MonitorElement kind");
0021     }
0022   }
0023 
0024   MESetDet1D::MESetDet1D(MESetDet1D const &_orig) : MESetEcal(_orig) {}
0025 
0026   MESetDet1D::~MESetDet1D() {}
0027 
0028   MESet *MESetDet1D::clone(std::string const &_path /* = ""*/) const {
0029     std::string path(path_);
0030     if (!_path.empty())
0031       path_ = _path;
0032     MESet *copy(new MESetDet1D(*this));
0033     path_ = path;
0034     return copy;
0035   }
0036 
0037   void MESetDet1D::book(DQMStore::IBooker &_ibooker, const EcalElectronicsMapping *electronicsMap) {
0038     MESetEcal::book(_ibooker, electronicsMap);
0039 
0040     if (btype_ == binning::kDCC) {
0041       for (unsigned iME(0); iME < mes_.size(); iME++) {
0042         MonitorElement *me(mes_[iME]);
0043 
0044         binning::ObjectType actualObject(binning::getObject(otype_, iME));
0045         if (actualObject == binning::kEB) {
0046           for (int iBin(1); iBin <= me->getNbinsX(); iBin++)
0047             me->setBinLabel(iBin, binning::channelName(electronicsMap, iBin + kEBmLow));
0048         } else if (actualObject == binning::kEE) {
0049           for (int iBin(1); iBin <= me->getNbinsX() / 2; iBin++) {
0050             me->setBinLabel(iBin, binning::channelName(electronicsMap, iBin));
0051             me->setBinLabel(iBin + me->getNbinsX() / 2, binning::channelName(electronicsMap, iBin + 45));
0052           }
0053         } else if (actualObject == binning::kEEm) {
0054           for (int iBin(1); iBin <= me->getNbinsX(); iBin++)
0055             me->setBinLabel(iBin, binning::channelName(electronicsMap, iBin));
0056         } else if (actualObject == binning::kEEp) {
0057           for (int iBin(1); iBin <= me->getNbinsX(); iBin++)
0058             me->setBinLabel(iBin, binning::channelName(electronicsMap, iBin + 45));
0059         }
0060       }
0061     } else if (btype_ == binning::kTriggerTower) {
0062       for (unsigned iME(0); iME < mes_.size(); iME++) {
0063         MonitorElement *me(mes_[iME]);
0064 
0065         binning::ObjectType actualObject(binning::getObject(otype_, iME));
0066         unsigned dccid(0);
0067         if (actualObject == binning::kSM && (iME <= kEEmHigh || iME >= kEEpLow))
0068           dccid = iME + 1;
0069         else if (actualObject == binning::kEESM)
0070           dccid = iME <= kEEmHigh ? iME + 1 : iME + 37;
0071 
0072         if (dccid > 0) {
0073           std::stringstream ss;
0074           std::pair<unsigned, unsigned> inner(innerTCCs(iME + 1));
0075           std::pair<unsigned, unsigned> outer(outerTCCs(iME + 1));
0076           ss << "TCC" << inner.first << " TT1";
0077           me->setBinLabel(1, ss.str());
0078           ss.str("");
0079           ss << "TCC" << inner.second << " TT1";
0080           me->setBinLabel(1 + nTTInner, ss.str());
0081           ss.str("");
0082           ss << "TCC" << outer.first << " TT1";
0083           me->setBinLabel(1 + 2 * nTTInner, ss.str());
0084           ss.str("");
0085           ss << "TCC" << outer.second << " TT1";
0086           me->setBinLabel(1 + 2 * nTTInner + nTTOuter, ss.str());
0087           // Bins are numbered:
0088           // inner1:(1)-->(nTTInner)
0089           // inner2:(1+nTTInner)-->(1+nTTInner + nTTInner-1 = 2*nTTInner)
0090           // outer1:(1+2*nTTInner)-->(1+2*nTTInner+nTTOuter-1=2*nTTInner+nTTOuter)
0091           // outer2:(1+2*nTTInner+nTTOuter)-->(1+2*nTTInner+nTTOuter + nTTOuter-1
0092           // = 2*nTTInner+2*nTTOuter)
0093           int offset(0);
0094           for (int iBin(4); iBin <= (2 * nTTOuter + 2 * nTTInner); iBin += 4) {
0095             if (iBin == 4 + nTTInner)
0096               offset = nTTInner;
0097             else if (iBin == 4 + 2 * nTTInner)
0098               offset = 2 * nTTInner;
0099             else if (iBin == 4 + 2 * nTTInner + nTTOuter)
0100               offset = 2 * nTTInner + nTTOuter;
0101             ss.str("");
0102             ss << iBin - offset;
0103             me->setBinLabel(iBin, ss.str());
0104           }
0105         }
0106       }
0107     }
0108   }
0109 
0110   void MESetDet1D::fill(
0111       EcalDQMSetupObjects const edso, DetId const &_id, double _wy /* = 1.*/, double _w /* = 1.*/, double) {
0112     if (!active_)
0113       return;
0114 
0115     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0116     checkME_(iME);
0117 
0118     binning::ObjectType obj(binning::getObject(otype_, iME));
0119     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0120 
0121     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D)
0122       fill_(iME, xbin, _wy, _w);
0123     else
0124       fill_(iME, xbin, _wy);
0125   }
0126 
0127   void MESetDet1D::fill(
0128       EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _wy /* = 1.*/, double _w /* = 1.*/, double) {
0129     if (!active_)
0130       return;
0131 
0132     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0133     checkME_(iME);
0134 
0135     binning::ObjectType obj(binning::getObject(otype_, iME));
0136     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0137 
0138     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D)
0139       fill_(iME, xbin, _wy, _w);
0140     else
0141       fill_(iME, xbin, _wy);
0142   }
0143 
0144   void MESetDet1D::fill(
0145       EcalDQMSetupObjects const edso, int _dcctccid, double _wy /* = 1.*/, double _w /* = 1.*/, double) {
0146     if (!active_)
0147       return;
0148 
0149     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0150     checkME_(iME);
0151 
0152     binning::ObjectType obj(binning::getObject(otype_, iME));
0153     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0154 
0155     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D)
0156       fill_(iME, xbin, _wy, _w);
0157     else
0158       fill_(iME, xbin, _wy);
0159   }
0160 
0161   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso, DetId const &_id, double _content) {
0162     if (!active_)
0163       return;
0164 
0165     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0166     checkME_(iME);
0167 
0168     MonitorElement *me(mes_[iME]);
0169 
0170     binning::ObjectType obj(binning::getObject(otype_, iME));
0171     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0172 
0173     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0174       int nbinsY(me->getTH1()->GetNbinsY());
0175       for (int iY(1); iY <= nbinsY; iY++)
0176         me->setBinContent(xbin, iY, _content);
0177     } else
0178       me->setBinContent(xbin, _content);
0179   }
0180 
0181   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _content) {
0182     if (!active_)
0183       return;
0184 
0185     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0186     checkME_(iME);
0187 
0188     MonitorElement *me(mes_[iME]);
0189 
0190     binning::ObjectType obj(binning::getObject(otype_, iME));
0191     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0192 
0193     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0194       int nbinsY(me->getTH1()->GetNbinsY());
0195       for (int iY(1); iY <= nbinsY; iY++)
0196         me->setBinContent(xbin, iY, _content);
0197     } else
0198       me->setBinContent(xbin, _content);
0199   }
0200 
0201   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso, int _dcctccid, double _content) {
0202     if (!active_)
0203       return;
0204 
0205     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0206     checkME_(iME);
0207 
0208     MonitorElement *me(mes_[iME]);
0209 
0210     binning::ObjectType obj(binning::getObject(otype_, iME));
0211     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0212 
0213     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0214       int nbinsY(me->getTH1()->GetNbinsY());
0215       for (int iY(1); iY <= nbinsY; iY++)
0216         me->setBinContent(xbin, iY, _content);
0217     } else
0218       me->setBinContent(xbin, _content);
0219   }
0220 
0221   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin, double _content) {
0222     if (!active_)
0223       return;
0224     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0225       return;
0226 
0227     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0228     checkME_(iME);
0229 
0230     MonitorElement *me(mes_[iME]);
0231 
0232     binning::ObjectType obj(binning::getObject(otype_, iME));
0233     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0234     me->setBinContent(xbin, _ybin, _content);
0235   }
0236 
0237   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso,
0238                                  EcalElectronicsId const &_id,
0239                                  int _ybin,
0240                                  double _content) {
0241     if (!active_)
0242       return;
0243     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0244       return;
0245 
0246     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0247     checkME_(iME);
0248 
0249     MonitorElement *me(mes_[iME]);
0250 
0251     binning::ObjectType obj(binning::getObject(otype_, iME));
0252     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0253     me->setBinContent(xbin, _ybin, _content);
0254   }
0255 
0256   void MESetDet1D::setBinContent(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin, double _content) {
0257     if (!active_)
0258       return;
0259     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0260       return;
0261 
0262     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
0263     checkME_(iME);
0264 
0265     MonitorElement *me(mes_[iME]);
0266 
0267     binning::ObjectType obj(binning::getObject(otype_, iME));
0268     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0269     me->setBinContent(xbin, _ybin, _content);
0270   }
0271 
0272   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, DetId const &_id, double _error) {
0273     if (!active_)
0274       return;
0275 
0276     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0277     checkME_(iME);
0278 
0279     MonitorElement *me(mes_[iME]);
0280 
0281     binning::ObjectType obj(binning::getObject(otype_, iME));
0282     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0283 
0284     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0285       int nbinsY(me->getTH1()->GetNbinsY());
0286       for (int iY(1); iY <= nbinsY; iY++)
0287         me->setBinError(xbin, iY, _error);
0288     } else
0289       me->setBinError(xbin, _error);
0290   }
0291 
0292   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _error) {
0293     if (!active_)
0294       return;
0295 
0296     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0297     checkME_(iME);
0298 
0299     MonitorElement *me(mes_[iME]);
0300 
0301     binning::ObjectType obj(binning::getObject(otype_, iME));
0302     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0303 
0304     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0305       int nbinsY(me->getTH1()->GetNbinsY());
0306       for (int iY(1); iY <= nbinsY; iY++)
0307         me->setBinError(xbin, iY, _error);
0308     } else
0309       me->setBinError(xbin, _error);
0310   }
0311 
0312   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, int _dcctccid, double _error) {
0313     if (!active_)
0314       return;
0315 
0316     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0317     checkME_(iME);
0318 
0319     MonitorElement *me(mes_[iME]);
0320 
0321     binning::ObjectType obj(binning::getObject(otype_, iME));
0322     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0323 
0324     if (kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D) {
0325       int nbinsY(me->getTH1()->GetNbinsY());
0326       for (int iY(1); iY <= nbinsY; iY++)
0327         me->setBinError(xbin, iY, _error);
0328     } else
0329       me->setBinError(xbin, _error);
0330   }
0331 
0332   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin, double _error) {
0333     if (!active_)
0334       return;
0335     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0336       return;
0337 
0338     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0339     checkME_(iME);
0340 
0341     MonitorElement *me(mes_[iME]);
0342 
0343     binning::ObjectType obj(binning::getObject(otype_, iME));
0344     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0345     me->setBinError(xbin, _ybin, _error);
0346   }
0347 
0348   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, int _ybin, double _error) {
0349     if (!active_)
0350       return;
0351     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0352       return;
0353 
0354     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0355     checkME_(iME);
0356 
0357     MonitorElement *me(mes_[iME]);
0358 
0359     binning::ObjectType obj(binning::getObject(otype_, iME));
0360     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0361     me->setBinError(xbin, _ybin, _error);
0362   }
0363 
0364   void MESetDet1D::setBinError(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin, double _error) {
0365     if (!active_)
0366       return;
0367     if (kind_ != MonitorElement::Kind::TH2F && kind_ != MonitorElement::Kind::TPROFILE2D)
0368       return;
0369 
0370     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
0371     checkME_(iME);
0372 
0373     MonitorElement *me(mes_[iME]);
0374 
0375     binning::ObjectType obj(binning::getObject(otype_, iME));
0376     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0377     me->setBinError(xbin, _ybin, _error);
0378   }
0379 
0380   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, double _entries) {
0381     if (!active_)
0382       return;
0383     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0384       return;
0385 
0386     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0387     checkME_(iME);
0388 
0389     MonitorElement *me(mes_[iME]);
0390 
0391     binning::ObjectType obj(binning::getObject(otype_, iME));
0392     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0393 
0394     if (kind_ == MonitorElement::Kind::TPROFILE2D) {
0395       int nbinsX(me->getTH1()->GetNbinsX());
0396       int nbinsY(me->getTH1()->GetNbinsY());
0397       for (int iY(1); iY <= nbinsY; iY++)
0398         me->setBinEntries((nbinsX + 2) * iY + xbin, _entries);
0399     } else
0400       me->setBinEntries(xbin, _entries);
0401   }
0402 
0403   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _entries) {
0404     if (!active_)
0405       return;
0406     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0407       return;
0408 
0409     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0410     checkME_(iME);
0411 
0412     MonitorElement *me(mes_[iME]);
0413 
0414     binning::ObjectType obj(binning::getObject(otype_, iME));
0415     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0416 
0417     if (kind_ == MonitorElement::Kind::TPROFILE2D) {
0418       int nbinsX(me->getTH1()->GetNbinsX());
0419       int nbinsY(me->getTH1()->GetNbinsY());
0420       for (int iY(1); iY <= nbinsY; iY++)
0421         me->setBinEntries((nbinsX + 2) * iY + xbin, _entries);
0422     } else
0423       me->setBinEntries(xbin, _entries);
0424   }
0425 
0426   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso, int _dcctccid, double _entries) {
0427     if (!active_)
0428       return;
0429     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0430       return;
0431 
0432     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0433     checkME_(iME);
0434 
0435     MonitorElement *me(mes_[iME]);
0436 
0437     binning::ObjectType obj(binning::getObject(otype_, iME));
0438     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0439 
0440     if (kind_ == MonitorElement::Kind::TPROFILE2D) {
0441       int nbinsX(me->getTH1()->GetNbinsX());
0442       int nbinsY(me->getTH1()->GetNbinsY());
0443       for (int iY(1); iY <= nbinsY; iY++)
0444         me->setBinEntries((nbinsX + 2) * iY + xbin, _entries);
0445     } else
0446       me->setBinEntries(xbin, _entries);
0447   }
0448 
0449   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin, double _entries) {
0450     if (!active_)
0451       return;
0452     if (kind_ != MonitorElement::Kind::TPROFILE2D)
0453       return;
0454 
0455     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0456     checkME_(iME);
0457 
0458     MonitorElement *me(mes_[iME]);
0459 
0460     binning::ObjectType obj(binning::getObject(otype_, iME));
0461     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0462     int nbinsX(me->getTH1()->GetNbinsX());
0463     me->setBinEntries((nbinsX + 2) * _ybin + xbin, _entries);
0464   }
0465 
0466   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso,
0467                                  EcalElectronicsId const &_id,
0468                                  int _ybin,
0469                                  double _entries) {
0470     if (!active_)
0471       return;
0472     if (kind_ != MonitorElement::Kind::TPROFILE2D)
0473       return;
0474 
0475     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0476     checkME_(iME);
0477 
0478     MonitorElement *me(mes_[iME]);
0479 
0480     binning::ObjectType obj(binning::getObject(otype_, iME));
0481     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0482     int nbinsX(me->getTH1()->GetNbinsX());
0483     me->setBinEntries((nbinsX + 2) * _ybin + xbin, _entries);
0484   }
0485 
0486   void MESetDet1D::setBinEntries(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin, double _entries) {
0487     if (!active_)
0488       return;
0489     if (kind_ != MonitorElement::Kind::TPROFILE2D)
0490       return;
0491 
0492     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
0493     checkME_(iME);
0494 
0495     MonitorElement *me(mes_[iME]);
0496 
0497     binning::ObjectType obj(binning::getObject(otype_, iME));
0498     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0499     int nbinsX(me->getTH1()->GetNbinsX());
0500     me->setBinEntries((nbinsX + 2) * _ybin + xbin, _entries);
0501   }
0502 
0503   double MESetDet1D::getBinContent(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin /* = 0*/) const {
0504     if (!active_)
0505       return 0.;
0506 
0507     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0508     checkME_(iME);
0509 
0510     MonitorElement *me(mes_[iME]);
0511 
0512     binning::ObjectType obj(binning::getObject(otype_, iME));
0513     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0514     int nbinsX(me->getTH1()->GetNbinsX());
0515 
0516     return me->getBinContent((nbinsX + 2) * _ybin + xbin);
0517   }
0518 
0519   double MESetDet1D::getBinContent(EcalDQMSetupObjects const edso,
0520                                    EcalElectronicsId const &_id,
0521                                    int _ybin /* = 0*/) const {
0522     if (!active_)
0523       return 0.;
0524 
0525     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0526     checkME_(iME);
0527 
0528     MonitorElement *me(mes_[iME]);
0529 
0530     binning::ObjectType obj(binning::getObject(otype_, iME));
0531     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0532     int nbinsX(me->getTH1()->GetNbinsX());
0533 
0534     return me->getBinContent((nbinsX + 2) * _ybin + xbin);
0535   }
0536 
0537   double MESetDet1D::getBinContent(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin /* = 0*/) const {
0538     if (!active_)
0539       return 0.;
0540 
0541     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0542     checkME_(iME);
0543 
0544     MonitorElement *me(mes_[iME]);
0545 
0546     binning::ObjectType obj(binning::getObject(otype_, iME));
0547     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0548     int nbinsX(me->getTH1()->GetNbinsX());
0549 
0550     return me->getBinContent((nbinsX + 2) * _ybin + xbin);
0551   }
0552 
0553   double MESetDet1D::getBinError(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin /* = 0*/) const {
0554     if (!active_)
0555       return 0.;
0556 
0557     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0558     checkME_(iME);
0559 
0560     MonitorElement *me(mes_[iME]);
0561 
0562     binning::ObjectType obj(binning::getObject(otype_, iME));
0563     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0564     int nbinsX(me->getTH1()->GetNbinsX());
0565 
0566     return me->getBinError((nbinsX + 2) * _ybin + xbin);
0567   }
0568 
0569   double MESetDet1D::getBinError(EcalDQMSetupObjects const edso,
0570                                  EcalElectronicsId const &_id,
0571                                  int _ybin /* = 0*/) const {
0572     if (!active_)
0573       return 0.;
0574 
0575     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0576     checkME_(iME);
0577 
0578     MonitorElement *me(mes_[iME]);
0579 
0580     binning::ObjectType obj(binning::getObject(otype_, iME));
0581     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0582     int nbinsX(me->getTH1()->GetNbinsX());
0583 
0584     return me->getBinError((nbinsX + 2) * _ybin + xbin);
0585   }
0586 
0587   double MESetDet1D::getBinError(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin /* = 0*/) const {
0588     if (!active_)
0589       return 0.;
0590 
0591     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0592     checkME_(iME);
0593 
0594     MonitorElement *me(mes_[iME]);
0595 
0596     binning::ObjectType obj(binning::getObject(otype_, iME));
0597     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0598     int nbinsX(me->getTH1()->GetNbinsX());
0599 
0600     return me->getBinError((nbinsX + 2) * _ybin + xbin);
0601   }
0602 
0603   double MESetDet1D::getBinEntries(EcalDQMSetupObjects const edso, DetId const &_id, int _ybin /* = 0*/) const {
0604     if (!active_)
0605       return 0.;
0606     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0607       return 0.;
0608 
0609     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0610     checkME_(iME);
0611 
0612     MonitorElement *me(mes_[iME]);
0613 
0614     binning::ObjectType obj(binning::getObject(otype_, iME));
0615     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0616     int nbinsX(me->getTH1()->GetNbinsX());
0617 
0618     return me->getBinEntries((nbinsX + 2) * _ybin + xbin);
0619   }
0620 
0621   double MESetDet1D::getBinEntries(EcalDQMSetupObjects const edso,
0622                                    EcalElectronicsId const &_id,
0623                                    int _ybin /* = 0*/) const {
0624     if (!active_)
0625       return 0.;
0626     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0627       return 0.;
0628 
0629     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0630     checkME_(iME);
0631 
0632     MonitorElement *me(mes_[iME]);
0633 
0634     binning::ObjectType obj(binning::getObject(otype_, iME));
0635     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0636     int nbinsX(me->getTH1()->GetNbinsX());
0637 
0638     return me->getBinEntries((nbinsX + 2) * _ybin + xbin);
0639   }
0640 
0641   double MESetDet1D::getBinEntries(EcalDQMSetupObjects const edso, int _dcctccid, int _ybin /* = 0*/) const {
0642     if (!active_)
0643       return 0.;
0644     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0645       return 0.;
0646 
0647     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid, btype_));
0648     checkME_(iME);
0649 
0650     MonitorElement *me(mes_[iME]);
0651 
0652     binning::ObjectType obj(binning::getObject(otype_, iME));
0653     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0654     int nbinsX(me->getTH1()->GetNbinsX());
0655 
0656     return me->getBinEntries((nbinsX + 2) * _ybin + xbin);
0657   }
0658 
0659   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, DetId const &_id) const {
0660     if (!active_)
0661       return -1;
0662     if (kind_ == MonitorElement::Kind::TPROFILE || kind_ == MonitorElement::Kind::TPROFILE2D)
0663       return -1;
0664 
0665     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0666     checkME_(iME);
0667 
0668     binning::ObjectType obj(binning::getObject(otype_, iME));
0669     return binning::findBin1D(edso.electronicsMap, obj, btype_, _id);
0670   }
0671 
0672   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id) const {
0673     if (!active_)
0674       return -1;
0675     if (kind_ == MonitorElement::Kind::TPROFILE || kind_ == MonitorElement::Kind::TPROFILE2D)
0676       return -1;
0677 
0678     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0679     checkME_(iME);
0680 
0681     binning::ObjectType obj(binning::getObject(otype_, iME));
0682     return binning::findBin1D(edso.electronicsMap, obj, btype_, _id);
0683   }
0684 
0685   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, int _dcctccid) const {
0686     if (!active_)
0687       return -1;
0688     if (kind_ == MonitorElement::Kind::TPROFILE || kind_ == MonitorElement::Kind::TPROFILE2D)
0689       return -1;
0690 
0691     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
0692     checkME_(iME);
0693 
0694     binning::ObjectType obj(binning::getObject(otype_, iME));
0695     return binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid);
0696   }
0697 
0698   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, DetId const &_id, double _y, double) const {
0699     if (!active_)
0700       return -1;
0701     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0702       return -1;
0703 
0704     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0705     checkME_(iME);
0706 
0707     MonitorElement *me(mes_[iME]);
0708 
0709     binning::ObjectType obj(binning::getObject(otype_, iME));
0710     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0711     int nbinsX(me->getTH1()->GetNbinsX());
0712     return xbin + (nbinsX + 2) * me->getTH1()->GetYaxis()->FindBin(_y);
0713   }
0714 
0715   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, EcalElectronicsId const &_id, double _y, double) const {
0716     if (!active_)
0717       return -1;
0718     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0719       return -1;
0720 
0721     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _id));
0722     checkME_(iME);
0723 
0724     MonitorElement *me(mes_[iME]);
0725 
0726     binning::ObjectType obj(binning::getObject(otype_, iME));
0727     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _id));
0728     int nbinsX(me->getTH1()->GetNbinsX());
0729     return xbin + (nbinsX + 2) * me->getTH1()->GetYaxis()->FindBin(_y);
0730   }
0731 
0732   int MESetDet1D::findBin(EcalDQMSetupObjects const edso, int _dcctccid, double _y, double) const {
0733     if (!active_)
0734       return -1;
0735     if (kind_ != MonitorElement::Kind::TPROFILE && kind_ != MonitorElement::Kind::TPROFILE2D)
0736       return -1;
0737 
0738     unsigned iME(binning::findPlotIndex(edso.electronicsMap, otype_, _dcctccid));
0739     checkME_(iME);
0740 
0741     MonitorElement *me(mes_[iME]);
0742 
0743     binning::ObjectType obj(binning::getObject(otype_, iME));
0744     int xbin(binning::findBin1D(edso.electronicsMap, obj, btype_, _dcctccid));
0745     int nbinsX(me->getTH1()->GetNbinsX());
0746     return xbin + (nbinsX + 2) * me->getTH1()->GetYaxis()->FindBin(_y);
0747   }
0748 
0749   void MESetDet1D::reset(EcalElectronicsMapping const *,
0750                          double _content /* = 0.*/,
0751                          double _err /* = 0.*/,
0752                          double _entries /* = 0.*/) {
0753     unsigned nME(binning::getNObjects(otype_));
0754 
0755     bool isProfile(kind_ == MonitorElement::Kind::TPROFILE || kind_ == MonitorElement::Kind::TPROFILE2D);
0756     bool is2D(kind_ == MonitorElement::Kind::TH2F || kind_ == MonitorElement::Kind::TPROFILE2D);
0757 
0758     for (unsigned iME(0); iME < nME; iME++) {
0759       MonitorElement *me(mes_[iME]);
0760 
0761       int nbinsX(me->getTH1()->GetNbinsX());
0762       int nbinsY(me->getTH1()->GetNbinsY());
0763       for (int ix(1); ix <= nbinsX; ix++) {
0764         for (int iy(1); iy <= nbinsY; iy++) {
0765           int bin(is2D ? (nbinsX + 2) * iy + ix : ix);
0766           me->setBinContent(bin, _content);
0767           me->setBinError(bin, _err);
0768           if (isProfile)
0769             me->setBinEntries(bin, _entries);
0770         }
0771       }
0772     }
0773   }
0774 }  // namespace ecaldqm