Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:13:50

0001 #include "FWCore/Framework/interface/Frameworkfwd.h"
0002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0003 
0004 #include "DQMServices/Core/interface/DQMEDHarvester.h"
0005 #include "FWCore/Framework/interface/MakerMacros.h"
0006 
0007 class TestHarvester : public DQMEDHarvester {
0008 private:
0009   std::string folder_;
0010   std::string whathappened;
0011 
0012 public:
0013   explicit TestHarvester(const edm::ParameterSet &iConfig)
0014       : DQMEDHarvester(iConfig), folder_(iConfig.getParameter<std::string>("folder")) {}
0015   ~TestHarvester() override {}
0016 
0017   void beginRun(const edm::Run &run, const edm::EventSetup &iSetup) override {
0018     whathappened += "beginRun(" + std::to_string(run.run()) + ") ";
0019   }
0020   void dqmEndRun(DQMStore::IBooker &ib,
0021                  DQMStore::IGetter &ig,
0022                  const edm::Run &run,
0023                  const edm::EventSetup &iSetup) override {
0024     whathappened += "endRun(" + std::to_string(run.run()) + ") ";
0025     ig.setCurrentFolder(folder_);
0026     MonitorElement *out = ib.bookString("runsummary", "missing");
0027     out->Fill(whathappened);
0028   }
0029 
0030   void dqmEndJob(DQMStore::IBooker &ib, DQMStore::IGetter &ig) override {
0031     whathappened += "endJob() ";
0032     ig.setCurrentFolder(folder_);
0033     MonitorElement *out = ib.bookString("harvestingsummary", "missing");
0034     out->Fill(whathappened);
0035   }
0036   void dqmEndLuminosityBlock(DQMStore::IBooker &ib,
0037                              DQMStore::IGetter &ig,
0038                              edm::LuminosityBlock const &lumi,
0039                              edm::EventSetup const &) override {
0040     whathappened += "endLumi(" + std::to_string(lumi.run()) + "," + std::to_string(lumi.luminosityBlock()) + ") ";
0041   }
0042   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0043     edm::ParameterSetDescription desc;
0044     desc.add<std::string>("folder", "Harvesting/")->setComment("Where to put all the histograms");
0045     descriptions.add("testharvester", desc);
0046   }
0047 };
0048 
0049 DEFINE_FWK_MODULE(TestHarvester);
0050 
0051 #include "FWCore/Framework/interface/EDAnalyzer.h"
0052 class TestLegacyHarvester : public edm::EDAnalyzer {
0053 private:
0054   std::string folder_;
0055   std::string whathappened;
0056 
0057 public:
0058   typedef dqm::legacy::DQMStore DQMStore;
0059   typedef dqm::legacy::MonitorElement MonitorElement;
0060 
0061   explicit TestLegacyHarvester(const edm::ParameterSet &iConfig)
0062       : folder_(iConfig.getParameter<std::string>("folder")) {}
0063   ~TestLegacyHarvester() override {}
0064 
0065   void beginRun(const edm::Run &run, const edm::EventSetup &iSetup) override {
0066     whathappened += "beginRun(" + std::to_string(run.run()) + ") ";
0067   }
0068   void endRun(const edm::Run &run, const edm::EventSetup &iSetup) override {
0069     edm::Service<DQMStore> store;
0070     whathappened += "endRun(" + std::to_string(run.run()) + ") ";
0071     store->setCurrentFolder(folder_);
0072     MonitorElement *out = store->bookString("runsummary", "missing");
0073     out->Fill(whathappened);
0074   }
0075 
0076   void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &) override {
0077     whathappened += "endLumi(" + std::to_string(lumi.run()) + "," + std::to_string(lumi.luminosityBlock()) + ") ";
0078   }
0079   static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0080     edm::ParameterSetDescription desc;
0081     desc.add<std::string>("folder", "LegacyHarvester/")->setComment("Where to put all the histograms");
0082     descriptions.add("testlegacyharvester", desc);
0083   }
0084 
0085   void analyze(edm::Event const &, edm::EventSetup const &) override {}
0086 };
0087 
0088 DEFINE_FWK_MODULE(TestLegacyHarvester);