Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-29 01:21:17

0001 #include "DQM/EcalCommon/interface/EcalDQMonitor.h"
0002 
0003 #include "DQM/EcalCommon/interface/EcalDQMCommonUtils.h"
0004 
0005 #include "FWCore/Framework/interface/ESHandle.h"
0006 #include "FWCore/Framework/interface/EventSetup.h"
0007 #include "FWCore/Framework/interface/LuminosityBlock.h"
0008 #include "FWCore/Framework/interface/Run.h"
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0011 
0012 #include "Geometry/EcalMapping/interface/EcalMappingRcd.h"
0013 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0014 #include "Geometry/Records/interface/CaloTopologyRecord.h"
0015 #include "Geometry/Records/interface/IdealGeometryRecord.h"
0016 
0017 #include "FWCore/Framework/interface/ConsumesCollector.h"
0018 
0019 #include <ctime>
0020 #include <sstream>
0021 
0022 namespace ecaldqm {
0023   EcalDQMonitor::EcalDQMonitor(edm::ParameterSet const &_ps)
0024       : workers_(),
0025         moduleName_(_ps.getUntrackedParameter<std::string>("moduleName")),
0026         verbosity_(_ps.getUntrackedParameter<int>("verbosity")) {
0027     std::vector<std::string> workerNames(_ps.getUntrackedParameter<std::vector<std::string>>("workers"));
0028     edm::ParameterSet const &workerParams(_ps.getUntrackedParameterSet("workerParameters"));
0029     edm::ParameterSet const &commonParams(_ps.getUntrackedParameterSet("commonParameters"));
0030 
0031     std::for_each(workerNames.begin(), workerNames.end(), [&](std::string const &name) {
0032       if (verbosity_ > 0)
0033         edm::LogInfo("EcalDQM") << moduleName_ << ": Setting up " << name << std::endl;
0034       try {
0035         DQWorker *worker(WorkerFactoryStore::singleton()->getWorker(
0036             name, verbosity_, commonParams, workerParams.getUntrackedParameterSet(name)));
0037         if (worker->onlineMode())
0038           worker->setTime(time(nullptr));
0039         workers_.push_back(worker);
0040       } catch (std::exception &) {
0041         edm::LogError("EcalDQM") << "Worker " << name << " not defined";
0042         throw;
0043       }
0044     });
0045   }
0046 
0047   EcalDQMonitor::~EcalDQMonitor() noexcept(false) {
0048     if (verbosity_ > 2)
0049       edm::LogInfo("EcalDQM") << moduleName_ << ": Deleting workers";
0050 
0051     executeOnWorkers_([](DQWorker *worker) { delete worker; }, "Dtor");
0052   }
0053 
0054   /*static*/
0055   void EcalDQMonitor::fillDescriptions(edm::ParameterSetDescription &_desc) {
0056     _desc.addUntracked<std::string>("moduleName", "Ecal Monitor Module");
0057     _desc.addUntracked<std::vector<std::string>>("workers");
0058     _desc.addUntracked<int>("verbosity", 0);
0059 
0060     edm::ParameterSetDescription commonParameters;
0061     commonParameters.addUntracked<bool>("onlineMode", false);
0062     commonParameters.addUntracked<bool>("willConvertToEDM", true);
0063     _desc.addUntracked("commonParameters", commonParameters);
0064   }
0065 
0066   void EcalDQMonitor::ecaldqmBeginRun(edm::Run const &_run, edm::EventSetup const &_es) {
0067     executeOnWorkers_(
0068         [&_run, &_es](DQWorker *worker) {
0069           if (worker->onlineMode())
0070             worker->setTime(time(nullptr));
0071           worker->setRunNumber(_run.run());
0072           worker->beginRun(_run, _es);
0073         },
0074         "beginRun");
0075 
0076     if (verbosity_ > 0)
0077       edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginRun";
0078   }
0079 
0080   void EcalDQMonitor::ecaldqmEndRun(edm::Run const &_run, edm::EventSetup const &_es) {
0081     executeOnWorkers_(
0082         [&_run, &_es](DQWorker *worker) {
0083           if (worker->onlineMode())
0084             worker->setTime(time(nullptr));
0085           worker->setRunNumber(_run.run());
0086           worker->endRun(_run, _es);
0087         },
0088         "endRun");
0089 
0090     if (verbosity_ > 0)
0091       edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndRun";
0092   }
0093 
0094   void EcalDQMonitor::ecaldqmBeginLuminosityBlock(edm::LuminosityBlock const &_lumi, edm::EventSetup const &_es) const {
0095     executeOnWorkers_(
0096         [&_lumi, &_es](DQWorker *worker) {
0097           if (worker->onlineMode())
0098             worker->setTime(time(nullptr));
0099           worker->setLumiNumber(_lumi.luminosityBlock());
0100           worker->beginLuminosityBlock(_lumi, _es);
0101         },
0102         "beginLumi");
0103 
0104     if (verbosity_ > 1)
0105       edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmBeginLuminosityBlock";
0106   }
0107 
0108   void EcalDQMonitor::ecaldqmEndLuminosityBlock(edm::LuminosityBlock const &_lumi, edm::EventSetup const &_es) {
0109     executeOnWorkers_(
0110         [&_lumi, &_es](DQWorker *worker) {
0111           if (worker->onlineMode())
0112             worker->setTime(time(nullptr));
0113           worker->setLumiNumber(_lumi.luminosityBlock());
0114           worker->endLuminosityBlock(_lumi, _es);
0115         },
0116         "endLumi");
0117 
0118     if (verbosity_ > 2)
0119       edm::LogInfo("EcalDQM") << moduleName_ << "::ecaldqmEndLuminosityBlock";
0120   }
0121 }  // namespace ecaldqm