File indexing completed on 2024-04-06 12:10:12
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/one/EDAnalyzer.h"
0052 class TestLegacyHarvester
0053 : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
0054 private:
0055 std::string folder_;
0056 std::string whathappened;
0057
0058 public:
0059 typedef dqm::legacy::DQMStore DQMStore;
0060 typedef dqm::legacy::MonitorElement MonitorElement;
0061
0062 explicit TestLegacyHarvester(const edm::ParameterSet &iConfig)
0063 : folder_(iConfig.getParameter<std::string>("folder")) {
0064 usesResource("DQMStore");
0065 }
0066 ~TestLegacyHarvester() override {}
0067
0068 void beginRun(const edm::Run &run, const edm::EventSetup &iSetup) override {
0069 whathappened += "beginRun(" + std::to_string(run.run()) + ") ";
0070 }
0071 void endRun(const edm::Run &run, const edm::EventSetup &iSetup) override {
0072 edm::Service<DQMStore> store;
0073 whathappened += "endRun(" + std::to_string(run.run()) + ") ";
0074 store->setCurrentFolder(folder_);
0075 MonitorElement *out = store->bookString("runsummary", "missing");
0076 out->Fill(whathappened);
0077 }
0078
0079 void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &) override {}
0080 void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &) override {
0081 whathappened += "endLumi(" + std::to_string(lumi.run()) + "," + std::to_string(lumi.luminosityBlock()) + ") ";
0082 }
0083 static void fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
0084 edm::ParameterSetDescription desc;
0085 desc.add<std::string>("folder", "LegacyHarvester/")->setComment("Where to put all the histograms");
0086 descriptions.add("testlegacyharvester", desc);
0087 }
0088
0089 void analyze(edm::Event const &, edm::EventSetup const &) override {}
0090 };
0091
0092 DEFINE_FWK_MODULE(TestLegacyHarvester);