CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/src/DQM/EcalCommon/src/MESetDet1D.cc

Go to the documentation of this file.
00001 #include "DQM/EcalCommon/interface/MESetDet1D.h"
00002 
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00006 
00007 namespace ecaldqm
00008 {
00009 
00010   MESetDet1D::MESetDet1D(std::string const& _fullpath, MEData const& _data, bool _readOnly/* = false*/) :
00011     MESetEcal(_fullpath, _data, 1, _readOnly)
00012   {
00013   }
00014 
00015   MESetDet1D::~MESetDet1D()
00016   {
00017   }
00018 
00019   void
00020   MESetDet1D::fill(DetId const& _id, double _wy/* = 1.*/, double _w/* = 1.*/, double)
00021   {
00022     find_(_id);
00023 
00024     fill_(_wy, _w);
00025   }
00026 
00027   void
00028   MESetDet1D::fill(unsigned _dcctccid, double _wy/* = 1.*/, double _w/* = 1.*/, double)
00029   {
00030     find_(_dcctccid);
00031 
00032     fill_(_wy, _w);
00033   }
00034 
00035   double
00036   MESetDet1D::getBinContent(DetId const& _id, int _bin/* = 0*/) const
00037   {
00038     find_(_id);
00039 
00040     if(cache_.second.size() == 0) return 0.;
00041 
00042     int bin(cache_.second[0]);
00043 
00044     if(_bin > 0 && (data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D)){
00045       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00046       bin += (_bin - 1) * nbinsX;
00047     }
00048 
00049     return getBinContent_(cache_.first, bin);
00050   }
00051 
00052   double
00053   MESetDet1D::getBinContent(unsigned _dcctccid, int _bin/* = 0*/) const
00054   {
00055     find_(_dcctccid);
00056 
00057     if(cache_.second.size() == 0) return 0.;
00058 
00059     int bin(cache_.second[0]);
00060 
00061     if(_bin > 0 && (data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D)){
00062       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00063       bin += (_bin - 1) * nbinsX;
00064     }
00065 
00066     return getBinContent_(cache_.first, bin);
00067   }
00068 
00069   double
00070   MESetDet1D::getBinError(DetId const& _id, int _bin/* = 0*/) const
00071   {
00072     find_(_id);
00073 
00074     if(cache_.second.size() == 0) return 0.;
00075 
00076     int bin(cache_.second[0]);
00077 
00078     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00079       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00080       bin += (_bin - 1) * nbinsX;
00081     }
00082 
00083     return getBinError_(cache_.first, bin);
00084   }
00085 
00086   double
00087   MESetDet1D::getBinError(unsigned _dcctccid, int _bin/* = 0*/) const
00088   {
00089     find_(_dcctccid);
00090 
00091     if(cache_.second.size() == 0) return 0.;
00092 
00093     int bin(cache_.second[0]);
00094 
00095     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00096       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00097       bin += (_bin - 1) * nbinsX;
00098     }
00099 
00100     return getBinError_(cache_.first, bin);
00101   }
00102 
00103   double
00104   MESetDet1D::getBinEntries(DetId const& _id, int _bin/* = 0*/) const
00105   {
00106     find_(_id);
00107 
00108     if(cache_.second.size() == 0) return 0.;
00109 
00110     int bin(cache_.second[0]);
00111 
00112     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00113       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00114       bin += (_bin - 1) * nbinsX;
00115     }
00116 
00117     return getBinEntries_(cache_.first, bin);
00118   }
00119 
00120   double
00121   MESetDet1D::getBinEntries(unsigned _dcctccid, int _bin/* = 0*/) const
00122   {
00123     find_(_dcctccid);
00124 
00125     if(cache_.second.size() == 0) return 0.;
00126 
00127     int bin(cache_.second[0]);
00128 
00129     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00130       int nbinsX(mes_[cache_.first]->getTH1()->GetNbinsX());
00131       bin += (_bin - 1) * nbinsX;
00132     }
00133 
00134     return getBinEntries_(cache_.first, bin);
00135   }
00136 
00137   void
00138   MESetDet1D::find_(uint32_t _id) const
00139   {
00140     if(_id == cacheId_) return;
00141 
00142     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00143       DetId id(_id);
00144       if(id.det() == DetId::Ecal)
00145         cache_ = binService_->findBinsNoMap(data_->otype, data_->btype, id);
00146       else
00147         cache_ = binService_->findBins(data_->otype, data_->btype, _id);
00148     }
00149     else{
00150       DetId id(_id);
00151       if(id.det() == DetId::Ecal)
00152         cache_ = binService_->findBins(data_->otype, data_->btype, id);
00153       else
00154         cache_ = binService_->findBins(data_->otype, data_->btype, unsigned(_id));
00155     }
00156 
00157     if(cache_.first >= mes_.size() || !mes_[cache_.first])
00158       throw cms::Exception("InvalidCall") << "ME array index overflow" << std::endl;
00159 
00160     // some TTs are apparently empty..!
00161 //     if(cache_.second.size() == 0)
00162 //       throw cms::Exception("InvalidCall") << "No bins to get content from" << std::endl;
00163 
00164     cacheId_ = _id;
00165   }
00166 
00167   void
00168   MESetDet1D::fill_(double _wy, double _w)
00169   {
00170     if(data_->kind == MonitorElement::DQM_KIND_TH2F || data_->kind == MonitorElement::DQM_KIND_TPROFILE2D){
00171       std::vector<int> bins(cache_.second);
00172       TH1* h(mes_[cache_.first]->getTH1());
00173       int iy(h->GetYaxis()->FindBin(_wy));
00174       int nbinsX(h->GetNbinsX());
00175       for(unsigned iBin(0); iBin < bins.size(); iBin++)
00176         bins[iBin] += (iy - 1) * nbinsX;
00177 
00178       for(unsigned iBin(0); iBin < bins.size(); iBin++)
00179         MESet::fill_(cache_.first, bins[iBin], _w);
00180     }
00181     else
00182       MESetEcal::fill_(_wy);
00183   }
00184 
00185 }
00186