File indexing completed on 2023-03-17 10:59:03
0001 #include <string>
0002
0003 #include "FWCore/Framework/interface/Event.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 #include "DataFormats/Histograms/interface/MonitorElementCollection.h"
0007
0008 template <typename BOOKERLIKE, typename ME, bool DOLUMI = false>
0009 class BookerFiller {
0010 public:
0011 BookerFiller(std::string folder, int howmany) {
0012 this->howmany = howmany;
0013 this->folder = folder;
0014 }
0015
0016 BookerFiller(){};
0017
0018 void bookall(BOOKERLIKE& ibooker) {
0019 mes_1D.clear();
0020 mes_2D.clear();
0021 mes_3D.clear();
0022
0023 for (int i = 0; i < howmany; i++) {
0024 ibooker.setCurrentFolder(folder);
0025 auto num = std::to_string(i);
0026
0027 mes_1D.push_back(ibooker.bookFloat("float" + num));
0028 mes_1D.push_back(ibooker.bookInt("int" + num));
0029 mes_1D.push_back(ibooker.book1D("th1f" + num, "1D Float Histogram " + num, 101, -0.5, 100.5));
0030 mes_1D.push_back(ibooker.book1S("th1s" + num, "1D Short Histogram " + num, 101, -0.5, 100.5));
0031 mes_1D.push_back(ibooker.book1I("th1i" + num, "1D Integer Histogram " + num, 101, -0.5, 100.5));
0032 mes_1D.push_back(ibooker.book1DD("th1d" + num, "1D Double Histogram " + num, 101, -0.5, 100.5));
0033
0034 mes_2D.push_back(ibooker.book2D("th2f" + num, "2D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0035 mes_2D.push_back(ibooker.book2S("th2s" + num, "2D Short Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0036 mes_2D.push_back(ibooker.book2DD("th2d" + num, "2D Double Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0037 mes_2D.push_back(ibooker.book2I("th2i" + num, "2D Integer Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0038 mes_2D.push_back(
0039 ibooker.bookProfile("tprofile" + num, "1D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0040
0041 mes_3D.push_back(
0042 ibooker.book3D("th3f" + num, "3D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
0043 mes_3D.push_back(ibooker.bookProfile2D(
0044 "thprofile2d" + num, "2D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
0045
0046 if (DOLUMI) {
0047 auto scope = typename BOOKERLIKE::UseLumiScope(ibooker);
0048 ibooker.setCurrentFolder(folder + "/lumi");
0049
0050 mes_1D.push_back(ibooker.bookFloat("float" + num));
0051 mes_1D.push_back(ibooker.bookInt("int" + num));
0052 mes_1D.push_back(ibooker.book1D("th1f" + num, "1D Float Histogram " + num, 101, -0.5, 100.5));
0053 mes_1D.push_back(ibooker.book1S("th1s" + num, "1D Short Histogram " + num, 101, -0.5, 100.5));
0054 mes_1D.push_back(ibooker.book1I("th1i" + num, "1D Integer Histogram " + num, 101, -0.5, 100.5));
0055 mes_1D.push_back(ibooker.book1DD("th1d" + num, "1D Double Histogram " + num, 101, -0.5, 100.5));
0056
0057 mes_2D.push_back(ibooker.book2D("th2f" + num, "2D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0058 mes_2D.push_back(ibooker.book2S("th2s" + num, "2D Short Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0059 mes_2D.push_back(ibooker.book2DD("th2d" + num, "2D Double Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0060 mes_2D.push_back(ibooker.book2I("th2i" + num, "2D Integer Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0061 mes_2D.push_back(
0062 ibooker.bookProfile("tprofile" + num, "1D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
0063
0064 mes_3D.push_back(
0065 ibooker.book3D("th3f" + num, "3D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
0066 mes_3D.push_back(ibooker.bookProfile2D(
0067 "thprofile2d" + num, "2D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
0068 }
0069 }
0070 }
0071
0072 void fillall(double x, double y, double z) const {
0073 for (auto me : mes_1D) {
0074 me->Fill(x);
0075 }
0076 for (auto me : mes_2D) {
0077 me->Fill(x, y);
0078 }
0079 for (auto me : mes_3D) {
0080 me->Fill(x, y, z);
0081 }
0082 }
0083
0084 std::vector<ME*> mes_1D;
0085 std::vector<ME*> mes_2D;
0086 std::vector<ME*> mes_3D;
0087 std::string folder;
0088 int howmany;
0089 };
0090
0091 #include "DQMServices/Core/interface/DQMEDAnalyzer.h"
0092 class TestDQMEDAnalyzer : public DQMEDAnalyzer {
0093 public:
0094 explicit TestDQMEDAnalyzer(const edm::ParameterSet& iConfig)
0095 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0096 myvalue_(iConfig.getParameter<double>("value")) {}
0097
0098 ~TestDQMEDAnalyzer() override{};
0099
0100 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0101 edm::ParameterSetDescription desc;
0102 desc.add<std::string>("folder", "Normal/test")->setComment("Where to put all the histograms");
0103 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0104 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0105 descriptions.add("test", desc);
0106 }
0107
0108 private:
0109 void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) override {
0110 mymes_.bookall(ibooker);
0111 }
0112
0113 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
0114 mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0115 }
0116
0117 BookerFiller<DQMStore::IBooker, MonitorElement, true> mymes_;
0118 double myvalue_;
0119 };
0120 DEFINE_FWK_MODULE(TestDQMEDAnalyzer);
0121
0122 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0123 class TestDQMOneEDAnalyzer : public DQMOneEDAnalyzer<> {
0124 public:
0125 explicit TestDQMOneEDAnalyzer(const edm::ParameterSet& iConfig)
0126 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0127 myvalue_(iConfig.getParameter<double>("value")) {}
0128
0129 ~TestDQMOneEDAnalyzer() override{};
0130
0131 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0132 edm::ParameterSetDescription desc;
0133 desc.add<std::string>("folder", "One/testone")->setComment("Where to put all the histograms");
0134 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0135 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0136 descriptions.add("testone", desc);
0137 }
0138
0139 private:
0140 void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) override {
0141 mymes_.bookall(ibooker);
0142 }
0143
0144 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
0145 mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0146 }
0147
0148 BookerFiller<DQMStore::IBooker, MonitorElement, true> mymes_;
0149 double myvalue_;
0150 };
0151 DEFINE_FWK_MODULE(TestDQMOneEDAnalyzer);
0152
0153 class TestDQMOneFillRunEDAnalyzer : public DQMOneEDAnalyzer<> {
0154 public:
0155 explicit TestDQMOneFillRunEDAnalyzer(const edm::ParameterSet& iConfig)
0156 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0157 myvalue_(iConfig.getParameter<double>("value")) {}
0158
0159 ~TestDQMOneFillRunEDAnalyzer() override{};
0160
0161 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0162 edm::ParameterSetDescription desc;
0163 desc.add<std::string>("folder", "One/testonefillrun")->setComment("Where to put all the histograms");
0164 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0165 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0166 descriptions.add("testonefillrun", desc);
0167 }
0168
0169 private:
0170 void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) override {
0171 mymes_.bookall(ibooker);
0172 }
0173
0174 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
0175 void dqmEndRun(edm::Run const& run, edm::EventSetup const&) override { mymes_.fillall(0, run.run(), myvalue_); }
0176
0177 BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
0178 double myvalue_;
0179 };
0180 DEFINE_FWK_MODULE(TestDQMOneFillRunEDAnalyzer);
0181
0182 class TestDQMOneLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
0183 public:
0184 explicit TestDQMOneLumiEDAnalyzer(const edm::ParameterSet& iConfig)
0185 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0186 myvalue_(iConfig.getParameter<double>("value")) {}
0187
0188 ~TestDQMOneLumiEDAnalyzer() override{};
0189
0190 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0191 edm::ParameterSetDescription desc;
0192 desc.add<std::string>("folder", "One/testonelumi")->setComment("Where to put all the histograms");
0193 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0194 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0195 descriptions.add("testonelumi", desc);
0196 }
0197
0198 private:
0199 void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) override {
0200 mymes_.bookall(ibooker);
0201 }
0202
0203 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
0204 mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0205 }
0206
0207 BookerFiller<DQMStore::IBooker, MonitorElement, true> mymes_;
0208 double myvalue_;
0209 };
0210 DEFINE_FWK_MODULE(TestDQMOneLumiEDAnalyzer);
0211
0212 class TestDQMOneLumiFillLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
0213 public:
0214 explicit TestDQMOneLumiFillLumiEDAnalyzer(const edm::ParameterSet& iConfig)
0215 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0216 myvalue_(iConfig.getParameter<double>("value")) {}
0217
0218 ~TestDQMOneLumiFillLumiEDAnalyzer() override{};
0219
0220 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0221 edm::ParameterSetDescription desc;
0222 desc.add<std::string>("folder", "One/testonelumifilllumi")->setComment("Where to put all the histograms");
0223 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0224 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0225 descriptions.add("testonelumifilllumi", desc);
0226 }
0227
0228 private:
0229 void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&) override {
0230 mymes_.bookall(ibooker);
0231 }
0232
0233 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
0234 void dqmBeginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const&) override {
0235 mymes_.fillall(lumi.luminosityBlock(), lumi.run(), myvalue_);
0236 }
0237
0238 BookerFiller<DQMStore::IBooker, MonitorElement, true> mymes_;
0239 double myvalue_;
0240 };
0241 DEFINE_FWK_MODULE(TestDQMOneLumiFillLumiEDAnalyzer);
0242
0243 #include "DQMServices/Core/interface/DQMGlobalEDAnalyzer.h"
0244 typedef BookerFiller<dqm::reco::DQMStore::IBooker, dqm::reco::MonitorElement> TestHistograms;
0245
0246 class TestDQMGlobalEDAnalyzer : public DQMGlobalEDAnalyzer<TestHistograms> {
0247 public:
0248 explicit TestDQMGlobalEDAnalyzer(const edm::ParameterSet& iConfig)
0249 : folder_(iConfig.getParameter<std::string>("folder")),
0250 howmany_(iConfig.getParameter<int>("howmany")),
0251 myvalue_(iConfig.getParameter<double>("value")) {}
0252 ~TestDQMGlobalEDAnalyzer() override{};
0253
0254 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0255 edm::ParameterSetDescription desc;
0256 desc.add<std::string>("folder", "Global/testglobal")->setComment("Where to put all the histograms");
0257 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0258 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0259 descriptions.add("testglobal", desc);
0260 }
0261
0262 private:
0263 void bookHistograms(DQMStore::IBooker& ibooker,
0264 edm::Run const&,
0265 edm::EventSetup const&,
0266 TestHistograms& h) const override {
0267 h.folder = this->folder_;
0268 h.howmany = this->howmany_;
0269 h.bookall(ibooker);
0270 }
0271
0272 void dqmAnalyze(edm::Event const& iEvent, edm::EventSetup const&, TestHistograms const& h) const override {
0273 h.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0274 }
0275
0276 private:
0277 std::string folder_;
0278 int howmany_;
0279 double myvalue_;
0280 };
0281 DEFINE_FWK_MODULE(TestDQMGlobalEDAnalyzer);
0282
0283 class TestDQMGlobalRunSummaryEDAnalyzer : public DQMGlobalRunSummaryEDAnalyzer<TestHistograms, int> {
0284 public:
0285 explicit TestDQMGlobalRunSummaryEDAnalyzer(const edm::ParameterSet& iConfig)
0286 : folder_(iConfig.getParameter<std::string>("folder")),
0287 howmany_(iConfig.getParameter<int>("howmany")),
0288 myvalue_(iConfig.getParameter<double>("value")) {}
0289 ~TestDQMGlobalRunSummaryEDAnalyzer() override{};
0290
0291 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0292 edm::ParameterSetDescription desc;
0293 desc.add<std::string>("folder", "Global/testglobal")->setComment("Where to put all the histograms");
0294 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0295 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0296 descriptions.add("testglobalrunsummary", desc);
0297 }
0298
0299 private:
0300 std::shared_ptr<int> globalBeginRunSummary(edm::Run const&, edm::EventSetup const&) const override {
0301 return std::make_shared<int>(0);
0302 }
0303
0304 void bookHistograms(DQMStore::IBooker& ibooker,
0305 edm::Run const&,
0306 edm::EventSetup const&,
0307 TestHistograms& h) const override {
0308 h.folder = this->folder_;
0309 h.howmany = this->howmany_;
0310 h.bookall(ibooker);
0311 }
0312
0313 void dqmAnalyze(edm::Event const& iEvent, edm::EventSetup const&, TestHistograms const& h) const override {
0314 h.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0315 }
0316
0317 void streamEndRunSummary(edm::StreamID, edm::Run const&, edm::EventSetup const&, int* runSummaryCache) const override {
0318 (*runSummaryCache) += 1;
0319 }
0320
0321 void globalEndRunSummary(edm::Run const&, edm::EventSetup const&, int* runSummaryCache) const override {}
0322
0323 void dqmEndRun(edm::Run const& run,
0324 edm::EventSetup const& setup,
0325 TestHistograms const& h,
0326 int const& runSummaryCache) const override {}
0327
0328 private:
0329 std::string folder_;
0330 int howmany_;
0331 double myvalue_;
0332 };
0333 DEFINE_FWK_MODULE(TestDQMGlobalRunSummaryEDAnalyzer);
0334
0335 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0336 class TestLegacyEDAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns> {
0337 public:
0338 typedef dqm::legacy::DQMStore DQMStore;
0339 typedef dqm::legacy::MonitorElement MonitorElement;
0340
0341 explicit TestLegacyEDAnalyzer(const edm::ParameterSet& iConfig)
0342 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0343 myvalue_(iConfig.getParameter<double>("value")) {
0344 usesResource("DQMStore");
0345 }
0346
0347 ~TestLegacyEDAnalyzer() override{};
0348
0349 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0350 edm::ParameterSetDescription desc;
0351 desc.add<std::string>("folder", "Legacy/testlegacy")->setComment("Where to put all the histograms");
0352 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0353 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0354 descriptions.add("testlegacy", desc);
0355 }
0356
0357 private:
0358 void beginRun(edm::Run const&, edm::EventSetup const&) override {
0359 edm::Service<DQMStore> store;
0360 mymes_.bookall(*store);
0361 }
0362 void endRun(edm::Run const&, edm::EventSetup const&) override {}
0363
0364 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
0365 mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
0366 }
0367
0368 BookerFiller<DQMStore, MonitorElement, true> mymes_;
0369 double myvalue_;
0370 };
0371 DEFINE_FWK_MODULE(TestLegacyEDAnalyzer);
0372
0373 class TestLegacyFillRunEDAnalyzer : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns> {
0374 public:
0375 typedef dqm::legacy::DQMStore DQMStore;
0376 typedef dqm::legacy::MonitorElement MonitorElement;
0377
0378 explicit TestLegacyFillRunEDAnalyzer(const edm::ParameterSet& iConfig)
0379 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0380 myvalue_(iConfig.getParameter<double>("value")) {
0381 usesResource("DQMStore");
0382 }
0383
0384 ~TestLegacyFillRunEDAnalyzer() override{};
0385
0386 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0387 edm::ParameterSetDescription desc;
0388 desc.add<std::string>("folder", "Legacy/testlegacyfillrun")->setComment("Where to put all the histograms");
0389 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0390 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0391 descriptions.add("testlegacyfillrun", desc);
0392 }
0393
0394 private:
0395 void beginRun(edm::Run const& run, edm::EventSetup const&) override {
0396 edm::Service<DQMStore> store;
0397 mymes_.bookall(*store);
0398 mymes_.fillall(0, run.run(), myvalue_);
0399 }
0400 void endRun(edm::Run const&, edm::EventSetup const&) override {}
0401
0402 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
0403
0404 BookerFiller<DQMStore, MonitorElement> mymes_;
0405 double myvalue_;
0406 };
0407 DEFINE_FWK_MODULE(TestLegacyFillRunEDAnalyzer);
0408
0409 class TestLegacyFillLumiEDAnalyzer
0410 : public edm::one::EDAnalyzer<edm::one::SharedResources, edm::one::WatchRuns, edm::one::WatchLuminosityBlocks> {
0411 public:
0412 typedef dqm::legacy::DQMStore DQMStore;
0413 typedef dqm::legacy::MonitorElement MonitorElement;
0414
0415 explicit TestLegacyFillLumiEDAnalyzer(const edm::ParameterSet& iConfig)
0416 : mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
0417 myvalue_(iConfig.getParameter<double>("value")) {
0418 usesResource("DQMStore");
0419 }
0420
0421 ~TestLegacyFillLumiEDAnalyzer() override{};
0422
0423 static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0424 edm::ParameterSetDescription desc;
0425 desc.add<std::string>("folder", "Legacy/testlegacyfilllumi")->setComment("Where to put all the histograms");
0426 desc.add<int>("howmany", 1)->setComment("How many copies of each ME to put");
0427 desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
0428 descriptions.add("testlegacyfilllumi", desc);
0429 }
0430
0431 private:
0432 void beginRun(edm::Run const&, edm::EventSetup const&) override {
0433 edm::Service<DQMStore> store;
0434 mymes_.bookall(*store);
0435 }
0436 void endRun(edm::Run const&, edm::EventSetup const&) override {}
0437
0438 void beginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const&) override {
0439 mymes_.fillall(lumi.luminosityBlock(), lumi.run(), myvalue_);
0440 }
0441 void endLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const&) override {}
0442
0443 void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
0444
0445 BookerFiller<DQMStore, MonitorElement, true> mymes_;
0446 double myvalue_;
0447 };
0448 DEFINE_FWK_MODULE(TestLegacyFillLumiEDAnalyzer);