CMS 3D CMS Logo

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