CMS 3D CMS Logo

PSMonitor.cc
Go to the documentation of this file.
1 #include <string>
2 #include <vector>
3 #include <map>
4 
19 
20 namespace {
23 
24  struct MEbinning {
25  int nbins;
26  double xmin;
27  double xmax;
28  };
29 
30  struct Histograms {
31  dqm::reco::MonitorElement* psColumnIndexVsLS;
32  };
33 } // namespace
34 
35 //
36 // class declaration
37 //
38 
39 class PSMonitor : public DQMGlobalEDAnalyzer<Histograms> {
40 public:
42  ~PSMonitor() override = default;
43  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
45 
46 protected:
47  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&, Histograms&) const override;
48  void dqmAnalyze(edm::Event const& event, edm::EventSetup const& setup, Histograms const&) const override;
49 
50 private:
51  void getHistoPSet(edm::ParameterSet& pset, MEbinning& mebinning);
52 
54 
56 
59 };
60 
61 // -----------------------------
62 // constructors and destructor
63 // -----------------------------
64 
66  : folderName_(config.getParameter<std::string>("folderName")),
67  ugtBXToken_(consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("ugtBXInputTag"))) {
68  edm::ParameterSet histoPSet = config.getParameter<edm::ParameterSet>("histoPSet");
69  edm::ParameterSet psColumnPSet = histoPSet.getParameter<edm::ParameterSet>("psColumnPSet");
70  edm::ParameterSet lsPSet = histoPSet.getParameter<edm::ParameterSet>("lsPSet");
71 
72  getHistoPSet(psColumnPSet, ps_binning_);
74 }
75 
77  mebinning.nbins = pset.getParameter<int32_t>("nbins");
78  mebinning.xmin = 0.;
79  mebinning.xmax = double(pset.getParameter<int32_t>("nbins"));
80 }
81 
83  edm::Run const& run,
84  edm::EventSetup const& setup,
85  Histograms& histograms) const {
86  std::string histname, histtitle;
87 
88  std::string currentFolder = folderName_;
89  booker.setCurrentFolder(currentFolder);
90 
91  int nbins;
92  double xmin, xmax;
93  std::vector<std::string> labels;
95  if (prescaleService.isAvailable() and not prescaleService->getLvl1Labels().empty()) {
96  labels = prescaleService->getLvl1Labels();
97  nbins = labels.size();
98  xmin = 0.;
99  xmax = double(labels.size());
100  } else {
104  labels.resize(nbins, "");
105  }
106 
107  histname = "psColumnIndexVsLS";
108  histtitle = "PS column index vs LS";
109  auto me =
110  booker.book2D(histname, histtitle, ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax, nbins, xmin, xmax);
111  me->setAxisTitle("LS", 1);
112  me->setAxisTitle("PS column index", 2);
113  histograms.psColumnIndexVsLS = me;
114 
115  int bin = 1;
116  for (auto const& l : labels) {
117  histograms.psColumnIndexVsLS->setBinLabel(bin, l, 2);
118  bin++;
119  }
120 }
121 
122 void PSMonitor::dqmAnalyze(edm::Event const& event, edm::EventSetup const& setup, Histograms const& histograms) const {
123  int ls = event.id().luminosityBlock();
124  int psColumn = -1;
125 
127  event.getByToken(ugtBXToken_, ugtBXhandle);
128  if (ugtBXhandle.isValid() and not ugtBXhandle->isEmpty(0)) {
129  psColumn = ugtBXhandle->at(0, 0).getPreScColumn();
130  }
131  histograms.psColumnIndexVsLS->Fill(ls, psColumn);
132 }
133 
135  pset.add<int>("nbins", value);
136 }
137 
140  desc.add<edm::InputTag>("ugtBXInputTag", edm::InputTag("hltGtStage2Digis"));
141  desc.add<std::string>("folderName", "HLT/PSMonitoring");
142 
144 
145  edm::ParameterSetDescription psColumnPSet;
146  fillHistoPSetDescription(psColumnPSet, 8);
147  histoPSet.add("psColumnPSet", psColumnPSet);
148 
151  histoPSet.add("lsPSet", lsPSet);
152 
153  desc.add("histoPSet", histoPSet);
154 
155  descriptions.add("psMonitoring", desc);
156 }
157 
158 // Define this as a plug-in
std::string folderName_
Definition: PSMonitor.cc:53
edm::EDGetTokenT< GlobalAlgBlkBxCollection > ugtBXToken_
Definition: PSMonitor.cc:55
void dqmAnalyze(edm::Event const &event, edm::EventSetup const &setup, Histograms const &) const override
Definition: PSMonitor.cc:122
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PSMonitor.cc:138
Definition: config.py:1
bool isEmpty(int bx) const
dqm::reco::DQMStore DQMStore
void getHistoPSet(edm::ParameterSet &pset, MEbinning &mebinning)
Definition: PSMonitor.cc:76
MEbinning ps_binning_
Definition: PSMonitor.cc:57
~PSMonitor() override=default
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: PSMonitor.cc:82
Definition: value.py:1
const T & at(int bx, unsigned i) const
def ls(path, rec=False)
Definition: eostools.py:349
dqm::legacy::MonitorElement MonitorElement
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:221
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset, int value)
Definition: PSMonitor.cc:134
bool isValid() const
Definition: HandleBase.h:70
PSMonitor(const edm::ParameterSet &)
Definition: PSMonitor.cc:65
HLT enums.
const VString_t & getLvl1Labels() const
bool isAvailable() const
Definition: Service.h:40
Definition: event.py:1
Definition: Run.h:45
MEbinning ls_binning_
Definition: PSMonitor.cc:58