CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DQM/EcalCommon/src/MESetNonObject.cc

Go to the documentation of this file.
00001 #include "DQM/EcalCommon/interface/MESetNonObject.h"
00002 
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 namespace ecaldqm
00006 {
00007   MESetNonObject::MESetNonObject(std::string const& _fullpath, MEData const& _data, bool _readOnly/* = false*/) :
00008     MESet(_fullpath, _data, _readOnly)
00009   {
00010   }
00011 
00012   void
00013   MESetNonObject::book()
00014   {
00015     dqmStore_->setCurrentFolder(dir_);
00016 
00017     mes_.clear();
00018 
00019     MonitorElement* me(0);
00020 
00021     BinService::AxisSpecs* xaxis(data_->xaxis);
00022     BinService::AxisSpecs* yaxis(data_->yaxis);
00023     BinService::AxisSpecs* zaxis(data_->zaxis);
00024 
00025     switch(data_->kind) {
00026     case MonitorElement::DQM_KIND_REAL :
00027       me = dqmStore_->bookFloat(name_);
00028       break;
00029 
00030     case MonitorElement::DQM_KIND_TH1F :
00031       {
00032         if(!xaxis)
00033           throw cms::Exception("InvalidCall") << "No xaxis found for MESetNonObject" << std::endl;
00034 
00035         if(!xaxis->edges)
00036           me = dqmStore_->book1D(name_, name_, xaxis->nbins, xaxis->low, xaxis->high);
00037         else{
00038           float* edges(new float[xaxis->nbins + 1]);
00039           for(int i(0); i < xaxis->nbins + 1; i++)
00040             edges[i] = xaxis->edges[i];
00041           me = dqmStore_->book1D(name_, name_, xaxis->nbins, edges);
00042           delete [] edges;
00043         }
00044       }
00045       break;
00046 
00047     case MonitorElement::DQM_KIND_TPROFILE :
00048       {
00049         if(!xaxis)
00050           throw cms::Exception("InvalidCall") << "No xaxis found for MESetNonObject" << std::endl;
00051 
00052         double ylow, yhigh;
00053         if(!yaxis){
00054           ylow = -std::numeric_limits<double>::max();
00055           yhigh = std::numeric_limits<double>::max();
00056         }
00057         else{
00058           ylow = yaxis->low;
00059           yhigh = yaxis->high;
00060         }
00061         if(xaxis->edges)
00062           me = dqmStore_->bookProfile(name_, name_, xaxis->nbins, xaxis->edges, ylow, yhigh, "");
00063         else
00064           me = dqmStore_->bookProfile(name_, name_, xaxis->nbins, xaxis->low, xaxis->high, ylow, yhigh, "");
00065 
00066       }
00067       break;
00068 
00069     case MonitorElement::DQM_KIND_TH2F :
00070       {
00071         if(!xaxis || !yaxis)
00072           throw cms::Exception("InvalidCall") << "No x/yaxis found for MESetNonObject" << std::endl;
00073 
00074         if(!xaxis->edges || !yaxis->edges)
00075           me = dqmStore_->book2D(name_, name_, xaxis->nbins, xaxis->low, xaxis->high, yaxis->nbins, yaxis->low, yaxis->high);
00076         else{
00077           float* xedges(new float[xaxis->nbins + 1]);
00078           for(int i(0); i < xaxis->nbins + 1; i++)
00079             xedges[i] = xaxis->edges[i];
00080           float* yedges(new float[yaxis->nbins + 1]);
00081           for(int i(0); i < yaxis->nbins + 1; i++)
00082             yedges[i] = yaxis->edges[i];
00083           me = dqmStore_->book2D(name_, name_, xaxis->nbins, xedges, yaxis->nbins, yedges);
00084           delete [] xedges;
00085           delete [] yedges;
00086         }
00087       }
00088       break;
00089 
00090     case MonitorElement::DQM_KIND_TPROFILE2D :
00091       {
00092         if(!xaxis || !yaxis)
00093           throw cms::Exception("InvalidCall") << "No x/yaxis found for MESetNonObject" << std::endl;
00094         double high(0.), low(0.);
00095         if(zaxis){
00096           low = zaxis->low;
00097           high = zaxis->high;
00098         }
00099         else{
00100           low = -std::numeric_limits<double>::max();
00101           high = std::numeric_limits<double>::max();
00102         }
00103 
00104         me = dqmStore_->bookProfile2D(name_, name_, xaxis->nbins, xaxis->low, xaxis->high, yaxis->nbins, yaxis->low, yaxis->high, low, high, "");
00105       }
00106       break;
00107 
00108     default :
00109       throw cms::Exception("InvalidCall") << "MESetNonObject of type " << data_->kind << " not implemented" << std::endl;
00110     }
00111 
00112     mes_.push_back(me);
00113 
00114     active_ = true;
00115   }
00116 
00117   bool
00118   MESetNonObject::retrieve() const
00119   {
00120     mes_.clear();
00121 
00122     MonitorElement* me(dqmStore_->get(dir_ + "/" + name_));
00123     if(!me) return false;
00124 
00125     mes_.push_back(me);
00126 
00127     active_ = true;
00128     return true;
00129   }
00130 
00131   MESetNonObject::~MESetNonObject()
00132   {
00133   }
00134 
00135   void
00136   MESetNonObject::fill(double _x, double _wy/* = 1.*/, double _w/* = 1.*/)
00137   {
00138     if(mes_.size() == 0 || !mes_[0]) return;
00139 
00140     switch(data_->kind) {
00141     case MonitorElement::DQM_KIND_REAL :
00142       mes_[0]->Fill(_x);
00143       break;
00144     case MonitorElement::DQM_KIND_TH1F :
00145     case MonitorElement::DQM_KIND_TPROFILE :
00146       mes_[0]->Fill(_x, _wy);
00147       break;
00148     case MonitorElement::DQM_KIND_TH2F :
00149     case MonitorElement::DQM_KIND_TPROFILE2D :
00150       mes_[0]->Fill(_x, _wy, _w);
00151       break;
00152     default :
00153       break;
00154     }
00155   }
00156 
00157 }