Skip to content

Commit

Permalink
Add lumi histos.
Browse files Browse the repository at this point in the history
  • Loading branch information
schneiml committed Dec 12, 2019
1 parent 78074b8 commit fb2181c
Showing 1 changed file with 99 additions and 86 deletions.
185 changes: 99 additions & 86 deletions DQMServices/Demo/plugins/TestDQMEDAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

template<typename BOOKERLIKE, typename ME>
template <typename BOOKERLIKE, typename ME, bool DOLUMI = false>
class BookerFiller {
public:
public:
BookerFiller(std::string folder, int howmany) {
this->howmany = howmany;
this->folder = folder;
}

BookerFiller() {};
BookerFiller(){};

void bookall(BOOKERLIKE& ibooker) {
ibooker.setCurrentFolder(folder);
for (int i = 0; i < howmany; i++) {
ibooker.setCurrentFolder(folder);
auto num = std::to_string(i);
// this doe *not* test most of the booking API, just one ME of each kind.
// this does *not* test most of the booking API, just one ME of each kind.
mes_1D.push_back(ibooker.bookFloat("float" + num));
mes_1D.push_back(ibooker.bookInt("int" + num));
mes_1D.push_back(ibooker.book1D("th1f" + num, "1D Float Histogram " + num, 101, -0.5, 100.5));
Expand All @@ -28,10 +28,44 @@ class BookerFiller {
mes_2D.push_back(ibooker.book2D("th2f" + num, "2D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.push_back(ibooker.book2S("th2s" + num, "2D Short Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.push_back(ibooker.book2DD("th2d" + num, "2D Double Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.push_back(ibooker.bookProfile("tprofile" + num, "1D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));

mes_3D.push_back(ibooker.book3D("th3f" + num, "3D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
mes_3D.push_back(ibooker.bookProfile2D("thprofile2d" + num, "2D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
mes_2D.push_back(
ibooker.bookProfile("tprofile" + num, "1D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));

mes_3D.push_back(
ibooker.book3D("th3f" + num, "3D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
mes_3D.push_back(ibooker.bookProfile2D(
"thprofile2d" + num, "2D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));

if (DOLUMI) {
ibooker.setCurrentFolder(folder + "/lumi");
mes_1D.push_back(ibooker.bookFloat("float" + num));
mes_1D.back()->setLumiFlag();
mes_1D.push_back(ibooker.bookInt("int" + num));
mes_1D.back()->setLumiFlag();
mes_1D.push_back(ibooker.book1D("th1f" + num, "1D Float Histogram " + num, 101, -0.5, 100.5));
mes_1D.back()->setLumiFlag();
mes_1D.push_back(ibooker.book1S("th1s" + num, "1D Short Histogram " + num, 101, -0.5, 100.5));
mes_1D.back()->setLumiFlag();
mes_1D.push_back(ibooker.book1DD("th1d" + num, "1D Double Histogram " + num, 101, -0.5, 100.5));
mes_1D.back()->setLumiFlag();

mes_2D.push_back(ibooker.book2D("th2f" + num, "2D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.back()->setLumiFlag();
mes_2D.push_back(ibooker.book2S("th2s" + num, "2D Short Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.back()->setLumiFlag();
mes_2D.push_back(ibooker.book2DD("th2d" + num, "2D Double Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.back()->setLumiFlag();
mes_2D.push_back(
ibooker.bookProfile("tprofile" + num, "1D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5));
mes_2D.back()->setLumiFlag();

mes_3D.push_back(
ibooker.book3D("th3f" + num, "3D Float Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
mes_3D.back()->setLumiFlag();
mes_3D.push_back(ibooker.bookProfile2D(
"thprofile2d" + num, "2D Profile Histogram " + num, 101, -0.5, 100.5, 11, -0.5, 10.5, 3, -0.5, 2.5));
mes_3D.back()->setLumiFlag();
}
}
}

Expand All @@ -45,7 +79,6 @@ class BookerFiller {
for (auto me : mes_3D) {
me->Fill(x, y, z);
}

}

std::vector<ME*> mes_1D;
Expand All @@ -59,11 +92,10 @@ class BookerFiller {
class TestDQMEDAnalyzer : public DQMEDAnalyzer {
public:
explicit TestDQMEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestDQMEDAnalyzer() override {};
~TestDQMEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -82,8 +114,7 @@ class TestDQMEDAnalyzer : public DQMEDAnalyzer {
mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}


BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
BookerFiller<DQMStore::IBooker, MonitorElement, /* DOLUMI */ true> mymes_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestDQMEDAnalyzer);
Expand All @@ -92,11 +123,10 @@ DEFINE_FWK_MODULE(TestDQMEDAnalyzer);
class TestDQMOneEDAnalyzer : public DQMOneEDAnalyzer<> {
public:
explicit TestDQMOneEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestDQMOneEDAnalyzer() override {};
~TestDQMOneEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -115,7 +145,6 @@ class TestDQMOneEDAnalyzer : public DQMOneEDAnalyzer<> {
mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}


BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
double myvalue_;
};
Expand All @@ -124,11 +153,10 @@ DEFINE_FWK_MODULE(TestDQMOneEDAnalyzer);
class TestDQMOneFillRunEDAnalyzer : public DQMOneEDAnalyzer<> {
public:
explicit TestDQMOneFillRunEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestDQMOneFillRunEDAnalyzer() override {};
~TestDQMOneFillRunEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -143,11 +171,8 @@ class TestDQMOneFillRunEDAnalyzer : public DQMOneEDAnalyzer<> {
mymes_.bookall(ibooker);
}

void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
}
void dqmBeginRun(edm::Run const& run, edm::EventSetup const&) {
mymes_.fillall(0, run.run(), myvalue_);
}
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
void dqmBeginRun(edm::Run const& run, edm::EventSetup const&) { mymes_.fillall(0, run.run(), myvalue_); }

BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
double myvalue_;
Expand All @@ -157,11 +182,10 @@ DEFINE_FWK_MODULE(TestDQMOneFillRunEDAnalyzer);
class TestDQMOneLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
public:
explicit TestDQMOneLumiEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestDQMOneLumiEDAnalyzer() override {};
~TestDQMOneLumiEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -180,20 +204,18 @@ class TestDQMOneLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}


BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
BookerFiller<DQMStore::IBooker, MonitorElement, /* DOLUMI */ true> mymes_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestDQMOneLumiEDAnalyzer);

class TestDQMOneLumiFillLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
public:
explicit TestDQMOneLumiFillLumiEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestDQMOneLumiFillLumiEDAnalyzer() override {};
~TestDQMOneLumiFillLumiEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -208,15 +230,12 @@ class TestDQMOneLumiFillLumiEDAnalyzer : public DQMOneLumiEDAnalyzer<> {
mymes_.bookall(ibooker);
}

void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
}
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}
void dqmBeginLuminosityBlock(edm::LuminosityBlock const& lumi, edm::EventSetup const&) {
mymes_.fillall(lumi.luminosityBlock(), lumi.run(), myvalue_);
}



BookerFiller<DQMStore::IBooker, MonitorElement> mymes_;
BookerFiller<DQMStore::IBooker, MonitorElement, /* DOLUMI */ true> mymes_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestDQMOneLumiFillLumiEDAnalyzer);
Expand All @@ -225,13 +244,12 @@ DEFINE_FWK_MODULE(TestDQMOneLumiFillLumiEDAnalyzer);
typedef BookerFiller<dqm::reco::DQMStore::IBooker, dqm::reco::MonitorElement> TestHistograms;

class TestDQMGlobalEDAnalyzer : public DQMGlobalEDAnalyzer<TestHistograms> {
public:
explicit TestDQMGlobalEDAnalyzer(const edm::ParameterSet& iConfig)
: folder_(iConfig.getParameter<std::string>("folder"))
, howmany_(iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
~TestDQMGlobalEDAnalyzer() override {};
public:
explicit TestDQMGlobalEDAnalyzer(const edm::ParameterSet& iConfig)
: folder_(iConfig.getParameter<std::string>("folder")),
howmany_(iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}
~TestDQMGlobalEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -240,22 +258,25 @@ class TestDQMGlobalEDAnalyzer : public DQMGlobalEDAnalyzer<TestHistograms> {
desc.add<double>("value", 1)->setComment("Which value to use on the third axis (first two are lumi and run)");
descriptions.add("testglobal", desc);
}
private:
void bookHistograms(DQMStore::IBooker& ibooker, edm::Run const&, edm::EventSetup const&, TestHistograms& h) const override {
h.folder = this->folder_;
h.howmany = this->howmany_;
h.bookall(ibooker);
}

void dqmAnalyze(edm::Event const& iEvent, edm::EventSetup const&, TestHistograms const& h) const override {
h.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}
private:
void bookHistograms(DQMStore::IBooker& ibooker,
edm::Run const&,
edm::EventSetup const&,
TestHistograms& h) const override {
h.folder = this->folder_;
h.howmany = this->howmany_;
h.bookall(ibooker);
}

void dqmAnalyze(edm::Event const& iEvent, edm::EventSetup const&, TestHistograms const& h) const override {
h.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}

private:
std::string folder_;
int howmany_;
double myvalue_;
private:
std::string folder_;
int howmany_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestDQMGlobalEDAnalyzer);

Expand All @@ -266,11 +287,10 @@ class TestLegacyEDAnalyzer : public edm::EDAnalyzer {
typedef dqm::legacy::MonitorElement MonitorElement;

explicit TestLegacyEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestLegacyEDAnalyzer() override {};
~TestLegacyEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -290,8 +310,7 @@ class TestLegacyEDAnalyzer : public edm::EDAnalyzer {
mymes_.fillall(iEvent.luminosityBlock(), iEvent.run(), myvalue_);
}


BookerFiller<DQMStore, MonitorElement> mymes_;
BookerFiller<DQMStore, MonitorElement, /* DOLUMI */ true> mymes_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestLegacyEDAnalyzer);
Expand All @@ -302,11 +321,10 @@ class TestLegacyFillRunEDAnalyzer : public edm::EDAnalyzer {
typedef dqm::legacy::MonitorElement MonitorElement;

explicit TestLegacyFillRunEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestLegacyFillRunEDAnalyzer() override {};
~TestLegacyFillRunEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -323,9 +341,7 @@ class TestLegacyFillRunEDAnalyzer : public edm::EDAnalyzer {
mymes_.fillall(0, run.run(), myvalue_);
}

void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
}

void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}

BookerFiller<DQMStore, MonitorElement> mymes_;
double myvalue_;
Expand All @@ -338,11 +354,10 @@ class TestLegacyFillLumiEDAnalyzer : public edm::EDAnalyzer {
typedef dqm::legacy::MonitorElement MonitorElement;

explicit TestLegacyFillLumiEDAnalyzer(const edm::ParameterSet& iConfig)
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany"))
, myvalue_(iConfig.getParameter<double>("value")) {
}
: mymes_(iConfig.getParameter<std::string>("folder"), iConfig.getParameter<int>("howmany")),
myvalue_(iConfig.getParameter<double>("value")) {}

~TestLegacyFillLumiEDAnalyzer() override {};
~TestLegacyFillLumiEDAnalyzer() override{};

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -362,11 +377,9 @@ class TestLegacyFillLumiEDAnalyzer : public edm::EDAnalyzer {
mymes_.fillall(lumi.luminosityBlock(), lumi.run(), myvalue_);
}

void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {
}
void analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) override {}


BookerFiller<DQMStore, MonitorElement> mymes_;
BookerFiller<DQMStore, MonitorElement, /* DOLUMI */ true> mymes_;
double myvalue_;
};
DEFINE_FWK_MODULE(TestLegacyFillLumiEDAnalyzer);

0 comments on commit fb2181c

Please sign in to comment.