CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DQM/EcalCommon/src/DQWorker.cc

Go to the documentation of this file.
00001 #include "DQM/EcalCommon/interface/DQWorker.h"
00002 
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 
00005 #include "DQM/EcalCommon/interface/MESet.h"
00006 #include "DQM/EcalCommon/interface/MESetNonObject.h"
00007 #include "DQM/EcalCommon/interface/MESetChannel.h"
00008 #include "DQM/EcalCommon/interface/MESetEcal.h"
00009 #include "DQM/EcalCommon/interface/MESetDet0D.h"
00010 #include "DQM/EcalCommon/interface/MESetDet1D.h"
00011 #include "DQM/EcalCommon/interface/MESetDet2D.h"
00012 #include "DQM/EcalCommon/interface/MESetTrend.h"
00013 
00014 namespace ecaldqm{
00015 
00016   std::map<std::string, std::vector<MEData> > DQWorker::meData;
00017 
00018   DQWorker::DQWorker(const edm::ParameterSet &, const edm::ParameterSet& _paths, std::string const& _name) :
00019     name_(_name),
00020     MEs_(0),
00021     initialized_(false),
00022     verbosity_(0)
00023   {
00024     using namespace std;
00025 
00026     map<string, vector<MEData> >::iterator dItr(meData.find(name_));
00027     if(dItr == meData.end())
00028       throw cms::Exception("InvalidCall") << "MonitorElement setup data not found for " << name_ << std::endl;
00029 
00030     vector<MEData> const& vData(dItr->second);
00031     MEs_.resize(vData.size());
00032 
00033     for(unsigned iME(0); iME < MEs_.size(); iME++){
00034       MEData& data(meData[name_].at(iME));
00035       string fullpath(_paths.getUntrackedParameter<string>(data.pathName));
00036 
00037       MEs_.at(iME) = createMESet_(fullpath, data);
00038     }
00039   }
00040 
00041   DQWorker::~DQWorker()
00042   {
00043     for(unsigned iME(0); iME < MEs_.size(); iME++)
00044       delete MEs_[iME];
00045   }
00046 
00047   void
00048   DQWorker::bookMEs()
00049   {
00050     for(unsigned iME(0); iME < MEs_.size(); iME++)
00051       if(MEs_[iME]) MEs_[iME]->book();
00052   }
00053 
00054   void
00055   DQWorker::reset()
00056   {
00057     for(unsigned iME(0); iME < MEs_.size(); iME++)
00058       if(MEs_[iME]) MEs_[iME]->clear();
00059 
00060     initialized_ = false;
00061   }
00062 
00063   /*static*/
00064   void
00065   DQWorker::setMEData(std::vector<MEData>&)
00066   {
00067   }
00068 
00069   MESet*
00070   DQWorker::createMESet_(std::string const& _fullpath, MEData const& _data, bool _readOnly/* = false*/) const
00071   {
00072     BinService::ObjectType otype(_data.otype);
00073     BinService::BinningType btype(_data.btype);
00074     MonitorElement::Kind kind(_data.kind);
00075 
00076     if(otype == BinService::nObjType)
00077       return new MESetNonObject(_fullpath, _data, _readOnly);
00078 
00079     if(otype == BinService::kChannel)
00080       return new MESetChannel(_fullpath, _data, _readOnly);
00081 
00082     if(btype == BinService::kTrend)
00083       return new MESetTrend(_fullpath, _data, _readOnly);
00084 
00085     unsigned logicalDimensions;
00086     switch(kind){
00087     case MonitorElement::DQM_KIND_REAL:
00088       logicalDimensions = 0;
00089       break;
00090     case MonitorElement::DQM_KIND_TH1F:
00091     case MonitorElement::DQM_KIND_TPROFILE:
00092       logicalDimensions = 1;
00093       break;
00094     case MonitorElement::DQM_KIND_TH2F:
00095     case MonitorElement::DQM_KIND_TPROFILE2D:
00096       logicalDimensions = 2;
00097       break;
00098     default:
00099       throw cms::Exception("InvalidCall") << "Histogram type " << kind << " not supported" << std::endl;
00100     }
00101 
00102     // example case: Ecal/TriggerPrimitives/EmulMatching/TrigPrimTask matching index
00103     if(logicalDimensions == 2 && _data.yaxis && btype != BinService::kUser) logicalDimensions = 1;
00104 
00105     // for EventInfo summary contents
00106     if(btype == BinService::kReport){
00107       if(logicalDimensions != 0)
00108         throw cms::Exception("InvalidCall") << "Report can only be a DQM_KIND_REAL" << std::endl;
00109     }
00110 
00111     if(btype == BinService::kUser)
00112       return new MESetEcal(_fullpath, _data, logicalDimensions, _readOnly);
00113 
00114     if(logicalDimensions == 0)
00115       return new MESetDet0D(_fullpath, _data, _readOnly);
00116 
00117     if(logicalDimensions == 1)
00118       return new MESetDet1D(_fullpath, _data, _readOnly);
00119 
00120     if(logicalDimensions == 2)
00121       return new MESetDet2D(_fullpath, _data, _readOnly);
00122 
00123     return 0;
00124   }
00125 
00126 
00127 
00128   std::map<std::string, WorkerFactory> SetWorker::workerFactories_;
00129 
00130   WorkerFactory
00131   SetWorker::findFactory(const std::string &_name)
00132   {
00133     if(workerFactories_.find(_name) != workerFactories_.end()) return workerFactories_[_name];
00134     return NULL;
00135   }
00136 
00137 }
00138