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 
57  MEbinning ps_binning_;
58  MEbinning ls_binning_;
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 
76 void PSMonitor::getHistoPSet(edm::ParameterSet& pset, MEbinning& mebinning) {
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 {
101  nbins = ps_binning_.nbins;
102  xmin = ps_binning_.xmin;
103  xmax = ps_binning_.xmax;
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<edm::ParameterSetDescription>("psColumnPSet", psColumnPSet);
148 
152 
153  desc.add<edm::ParameterSetDescription>("histoPSet", histoPSet);
154 
155  descriptions.add("psMonitoring", desc);
156 }
157 
158 // Define this as a plug-in
ConfigurationDescriptions.h
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
eostools.ls
def ls(path, rec=False)
Definition: eostools.py:349
dqm::impl::MonitorElement
Definition: MonitorElement.h:98
MessageLogger.h
edm::Run
Definition: Run.h:45
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
PSMonitor::dqmAnalyze
void dqmAnalyze(edm::Event const &event, edm::EventSetup const &setup, Histograms const &) const override
Definition: PSMonitor.cc:122
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89285
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
dqm::implementation::NavigatorBase::setCurrentFolder
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
BXVector::isEmpty
bool isEmpty(int bx) const
edm::Handle
Definition: AssociativeIterator.h:50
PrescaleService.h
edm::Service::isAvailable
bool isAvailable() const
Definition: Service.h:40
PSMonitor
Definition: PSMonitor.cc:39
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PSMonitor::getHistoPSet
void getHistoPSet(edm::ParameterSet &pset, MEbinning &mebinning)
Definition: PSMonitor.cc:76
BXVector
Definition: BXVector.h:15
config
Definition: config.py:1
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
dqm::legacy::DQMStore
Definition: DQMStore.h:727
LumiMonitor_cff.lsPSet
lsPSet
Definition: LumiMonitor_cff.py:33
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
Service.h
PSMonitor::bookHistograms
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &, Histograms &) const override
Definition: PSMonitor.cc:82
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
ParameterSetDescription.h
EDGetToken.h
PSMonitor::ls_binning_
MEbinning ls_binning_
Definition: PSMonitor.cc:58
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
HLT_Fake2_cff.psColumn
psColumn
Definition: HLT_Fake2_cff.py:185
Event.h
edm::service::PrescaleService::getLvl1Labels
const VString_t & getLvl1Labels() const
Definition: PrescaleService.h:39
BXVector::at
const T & at(int bx, unsigned i) const
PSMonitor::~PSMonitor
~PSMonitor() override=default
edm::Service
Definition: Service.h:30
LumiMonitor_cff.histoPSet
histoPSet
Definition: LumiMonitor_cff.py:12
value
Definition: value.py:1
GlobalAlgBlk.h
edm::EventSetup
Definition: EventSetup.h:58
histograms
Definition: histograms.py:1
PSMonitor::fillHistoPSetDescription
static void fillHistoPSetDescription(edm::ParameterSetDescription &pset, int value)
Definition: PSMonitor.cc:134
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
PSMonitor::folderName_
std::string folderName_
Definition: PSMonitor.cc:53
Registry.h
GetLumi.h
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
PSMonitor::ps_binning_
MEbinning ps_binning_
Definition: PSMonitor.cc:57
Frameworkfwd.h
TrackerOfflineValidation_Dqm_cff.xmax
xmax
Definition: TrackerOfflineValidation_Dqm_cff.py:11
relativeConstraints.value
value
Definition: relativeConstraints.py:53
dqm::implementation::IBooker::book2D
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:177
phase2tkutil::DQMStore
dqm::reco::DQMStore DQMStore
Definition: TrackerPhase2DQMUtil.h:16
MonitorElement
dqm::legacy::MonitorElement MonitorElement
Definition: SiPixelSCurveCalibrationAnalysis.h:55
dqm::implementation::IBooker
Definition: DQMStore.h:43
DQMGlobalEDAnalyzer
Definition: DQMGlobalEDAnalyzer.h:76
ParameterSet.h
TrackerOfflineValidation_Dqm_cff.xmin
xmin
Definition: TrackerOfflineValidation_Dqm_cff.py:10
PSMonitor::PSMonitor
PSMonitor(const edm::ParameterSet &)
Definition: PSMonitor.cc:65
hlt_dqm_clientPB-live_cfg.me
me
Definition: hlt_dqm_clientPB-live_cfg.py:61
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PSMonitor::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PSMonitor.cc:138
edm::InputTag
Definition: InputTag.h:15
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
PSMonitor::ugtBXToken_
edm::EDGetTokenT< GlobalAlgBlkBxCollection > ugtBXToken_
Definition: PSMonitor.cc:55
DQMGlobalEDAnalyzer.h