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 }
32 
33 //
34 // class declaration
35 //
36 
37 class PSMonitor : public DQMGlobalEDAnalyzer<Histograms>
38 {
39 public:
40  PSMonitor( const edm::ParameterSet& );
41  ~PSMonitor() override = default;
42  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
43  static void fillHistoPSetDescription(edm::ParameterSetDescription & pset, int value);
44 
45 protected:
46 
47  void bookHistograms(DQMStore::ConcurrentBooker &, 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 
52  void getHistoPSet(edm::ParameterSet& pset, MEbinning& mebinning);
53 
55 
57 
58  MEbinning ps_binning_;
59  MEbinning ls_binning_;
60 };
61 
62 
63 
64 // -----------------------------
65 // constructors and destructor
66 // -----------------------------
67 
69  folderName_ (config.getParameter<std::string>("FolderName"))
70  , ugtBXToken_ (consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("ugtBXInputTag")))
71 {
72  edm::ParameterSet histoPSet = config.getParameter<edm::ParameterSet>("histoPSet");
73  edm::ParameterSet psColumnPSet = histoPSet.getParameter<edm::ParameterSet>("psColumnPSet");
74  edm::ParameterSet lsPSet = histoPSet.getParameter<edm::ParameterSet>("lsPSet");
75 
76  getHistoPSet(psColumnPSet, ps_binning_);
77  getHistoPSet(lsPSet, ls_binning_);
78 
79 }
80 
81 void PSMonitor::getHistoPSet(edm::ParameterSet& pset, MEbinning& mebinning)
82 {
83  mebinning.nbins = pset.getParameter<int32_t>("nbins");
84  mebinning.xmin = 0.;
85  mebinning.xmax = double(pset.getParameter<int32_t>("nbins"));
86 }
87 
88 
90 {
91 
92  std::string histname, histtitle;
93 
94  std::string currentFolder = folderName_ ;
95  booker.setCurrentFolder(currentFolder);
96 
97  std::vector<std::string> const& psLabels = edm::Service<edm::service::PrescaleService>()->getLvl1Labels();
98  int nbins = ( !psLabels.empty() ? psLabels.size() : ps_binning_.nbins );
99  double xmin = ( !psLabels.empty() ? 0. : ps_binning_.xmin );
100  double xmax = ( !psLabels.empty() ? double(psLabels.size()) : ps_binning_.xmax );
101 
102  histname = "psColumnIndexVsLS"; histtitle = "PS column index vs LS";
103  histograms.psColumnIndexVsLS = booker.book2D(histname, histtitle,
104  ls_binning_.nbins, ls_binning_.xmin, ls_binning_.xmax,
105  nbins, xmin, xmax);
106  histograms.psColumnIndexVsLS.setAxisTitle("LS", 1);
107  histograms.psColumnIndexVsLS.setAxisTitle("PS column index", 2);
108 
109  int ibin = 1;
110  for ( auto l : psLabels ) {
111  histograms.psColumnIndexVsLS.setBinLabel(ibin, l, 2);
112  ibin++;
113  }
114 
115 }
116 
117 void PSMonitor::dqmAnalyze(edm::Event const& event, edm::EventSetup const& setup, Histograms const& histograms) const
118 {
119  int ls = event.id().luminosityBlock();
120  int psColumn = -1;
121 
123  event.getByToken(ugtBXToken_, ugtBXhandle);
124  if (ugtBXhandle.isValid() and not ugtBXhandle->isEmpty(0)) {
125  psColumn = ugtBXhandle->at(0, 0).getPreScColumn();
126  }
127  histograms.psColumnIndexVsLS.fill(ls, psColumn);
128 }
129 
131 {
132  pset.add<int>("nbins", value);
133 }
134 
136 {
138  desc.add<edm::InputTag>( "ugtBXInputTag", edm::InputTag("hltGtStage2Digis") );
139  desc.add<std::string> ( "FolderName", "HLT/PSMonitoring" );
140 
142 
143  edm::ParameterSetDescription psColumnPSet;
144  fillHistoPSetDescription(psColumnPSet, 8);
145  histoPSet.add<edm::ParameterSetDescription>("psColumnPSet", psColumnPSet);
146 
148  fillHistoPSetDescription(lsPSet, 2500);
149  histoPSet.add<edm::ParameterSetDescription>("lsPSet", lsPSet);
150 
151  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
152 
153  descriptions.add("psMonitoring", desc);
154 }
155 
156 // Define this as a plug-in
T getParameter(std::string const &) const
std::string folderName_
Definition: PSMonitor.cc:54
edm::EDGetTokenT< GlobalAlgBlkBxCollection > ugtBXToken_
Definition: PSMonitor.cc:56
void dqmAnalyze(edm::Event const &event, edm::EventSetup const &setup, Histograms const &) const override
Definition: PSMonitor.cc:117
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
void bookHistograms(DQMStore::ConcurrentBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: PSMonitor.cc:89
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PSMonitor.cc:135
bool isEmpty(int bx) const
Definition: config.py:1
void bookHistograms(fwlite::EventContainer &eventCont)
void getHistoPSet(edm::ParameterSet &pset, MEbinning &mebinning)
Definition: PSMonitor.cc:81
ConcurrentMonitorElement book2D(Args &&...args)
Definition: DQMStore.h:244
MEbinning ps_binning_
Definition: PSMonitor.cc:58
const int getPreScColumn() const
Definition: GlobalAlgBlk.h:70
Definition: value.py:1
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
def ls(path, rec=False)
Definition: eostools.py:348
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset, int value)
Definition: PSMonitor.cc:130
PSMonitor(const edm::ParameterSet &)
Definition: PSMonitor.cc:68
HLT enums.
Definition: event.py:1
Definition: Run.h:43
MEbinning ls_binning_
Definition: PSMonitor.cc:59
const T & at(int bx, unsigned i) const