Go to the documentation of this file.00001 #include "DQM/EcalCommon/interface/EcalDQMonitorClient.h"
00002
00003 #include "DQM/EcalCommon/interface/DQWorkerClient.h"
00004 #include "DQM/EcalCommon/interface/MESet.h"
00005 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
00006
00007 #include "FWCore/Framework/interface/ESHandle.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 #include "FWCore/Framework/interface/EventSetupRecordKey.h"
00010 #include "FWCore/Framework/interface/Run.h"
00011 #include "FWCore/Framework/interface/Event.h"
00012
00013 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00015 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
00016
00017 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
00018 #include "Geometry/Records/interface/IdealGeometryRecord.h"
00019
00020 #include "CondFormats/EcalObjects/interface/EcalDQMChannelStatus.h"
00021 #include "CondFormats/EcalObjects/interface/EcalDQMTowerStatus.h"
00022 #include "CondFormats/DataRecord/interface/EcalDQMChannelStatusRcd.h"
00023 #include "CondFormats/DataRecord/interface/EcalDQMTowerStatusRcd.h"
00024
00025 using namespace ecaldqm;
00026
00027 EcalDQMonitorClient::EcalDQMonitorClient(const edm::ParameterSet &_ps) :
00028 EcalDQMonitor(_ps),
00029 workers_(0),
00030 runAtEndLumi_(_ps.getUntrackedParameter<bool>("runAtEndLumi", false)),
00031 lumiStatus_(-1)
00032 {
00033 using namespace std;
00034
00035 const edm::ParameterSet& clientParams(_ps.getUntrackedParameterSet("clientParameters"));
00036 const edm::ParameterSet& mePaths(_ps.getUntrackedParameterSet("mePaths"));
00037
00038 vector<string> clientNames(_ps.getUntrackedParameter<vector<string> >("clients"));
00039
00040 WorkerFactory factory(0);
00041
00042 for(vector<string>::iterator cItr(clientNames.begin()); cItr != clientNames.end(); ++cItr){
00043 if (!(factory = SetWorker::findFactory(*cItr))) continue;
00044
00045 if(verbosity_ > 0) cout << moduleName_ << ": Setting up " << *cItr << endl;
00046
00047 DQWorker* worker(factory(clientParams, mePaths.getUntrackedParameterSet(*cItr)));
00048 if(worker->getName() != *cItr){
00049 delete worker;
00050 continue;
00051 }
00052 DQWorkerClient* client(static_cast<DQWorkerClient*>(worker));
00053 client->setVerbosity(verbosity_);
00054
00055 workers_.push_back(client);
00056 }
00057 }
00058
00059 EcalDQMonitorClient::~EcalDQMonitorClient()
00060 {
00061 for(std::vector<DQWorkerClient*>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr)
00062 delete *wItr;
00063 }
00064
00065
00066 void
00067 EcalDQMonitorClient::fillDescriptions(edm::ConfigurationDescriptions &_descs)
00068 {
00069 edm::ParameterSetDescription desc;
00070 desc.setUnknown();
00071 _descs.addDefault(desc);
00072 }
00073
00074 void
00075 EcalDQMonitorClient::beginRun(const edm::Run &_run, const edm::EventSetup &_es)
00076 {
00077
00078 edm::ESHandle<EcalElectronicsMapping> elecMapHandle;
00079 _es.get<EcalMappingRcd>().get(elecMapHandle);
00080 ecaldqm::setElectronicsMap(elecMapHandle.product());
00081
00082
00083 edm::ESHandle<EcalTrigTowerConstituentsMap> ttMapHandle;
00084 _es.get<IdealGeometryRecord>().get(ttMapHandle);
00085 ecaldqm::setTrigTowerMap(ttMapHandle.product());
00086
00087 if(_es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMChannelStatusRcd>())){
00088 edm::ESHandle<EcalDQMChannelStatus> cStHndl;
00089 _es.get<EcalDQMChannelStatusRcd>().get(cStHndl);
00090 DQWorkerClient::channelStatus = cStHndl.product();
00091 }
00092
00093 if(_es.find(edm::eventsetup::EventSetupRecordKey::makeKey<EcalDQMTowerStatusRcd>())){
00094 edm::ESHandle<EcalDQMTowerStatus> tStHndl;
00095 _es.get<EcalDQMTowerStatusRcd>().get(tStHndl);
00096 DQWorkerClient::towerStatus = tStHndl.product();
00097 }
00098
00099 for(std::vector<DQWorkerClient*>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr){
00100 DQWorkerClient* client(*wItr);
00101 if(verbosity_ > 1) std::cout << moduleName_ << ": Booking MEs for " << client->getName() << std::endl;
00102 client->bookMEs();
00103 client->beginRun(_run, _es);
00104 }
00105
00106 lumiStatus_ = -1;
00107
00108 if(verbosity_ > 0)
00109 std::cout << moduleName_ << ": Starting run " << _run.run() << std::endl;
00110 }
00111
00112 void
00113 EcalDQMonitorClient::endRun(const edm::Run &_run, const edm::EventSetup &_es)
00114 {
00115 if(lumiStatus_ == 0)
00116 runWorkers();
00117
00118 for(std::vector<DQWorkerClient *>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr){
00119 (*wItr)->endRun(_run, _es);
00120 }
00121 }
00122
00123 void
00124 EcalDQMonitorClient::beginLuminosityBlock(const edm::LuminosityBlock &_lumi, const edm::EventSetup &_es)
00125 {
00126 for(std::vector<DQWorkerClient *>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr)
00127 (*wItr)->beginLuminosityBlock(_lumi, _es);
00128
00129 lumiStatus_ = 0;
00130 }
00131
00132 void
00133 EcalDQMonitorClient::endLuminosityBlock(const edm::LuminosityBlock &_lumi, const edm::EventSetup &_es)
00134 {
00135 for(std::vector<DQWorkerClient *>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr)
00136 (*wItr)->endLuminosityBlock(_lumi, _es);
00137
00138 if(runAtEndLumi_){
00139 runWorkers();
00140 lumiStatus_ = 1;
00141 }
00142 }
00143
00144 void
00145 EcalDQMonitorClient::runWorkers()
00146 {
00147 if(verbosity_ > 0)
00148 std::cout << "EcalDQMonitorClient: Starting worker modules.." << std::endl;
00149
00150 for(std::vector<DQWorkerClient *>::iterator wItr(workers_.begin()); wItr != workers_.end(); ++wItr){
00151 DQWorkerClient* client(*wItr);
00152 if(!client->isInitialized())
00153 client->initialize();
00154
00155 if(client->isInitialized())
00156 client->producePlots();
00157 }
00158
00159 if(verbosity_ > 0)
00160 std::cout << " done." << std::endl;
00161 }