CMS 3D CMS Logo

DQMOfflineHLTEventInfoClient.cc
Go to the documentation of this file.
2 
10 #include <cstdio>
11 #include <sstream>
12 #include <cmath>
13 #include <TProfile.h>
14 #include <TProfile2D.h>
15 #include <memory>
16 #include <iostream>
17 #include <iomanip>
18 #include <map>
19 #include <vector>
20 #include <string>
21 #include <fstream>
22 #include "TROOT.h"
23 #include "TRandom.h"
24 #include <TH1F.h>
25 #include <TH2F.h>
26 
27 using namespace edm;
28 using namespace std;
29 
30 /*
31 class DQMOfflineHLTEventInfoClient: public edm::EDAnalyzer {
32 
33 public:
34 
36  DQMOfflineHLTEventInfoClient(const edm::ParameterSet& ps);
37 
39  virtual ~DQMOfflineHLTEventInfoClient();
40 
41 protected:
42 
44  void beginJob();
45 
47  void beginRun(const edm::Run& r, const edm::EventSetup& c);
48 
50  void analyze(const edm::Event& e, const edm::EventSetup& c) ;
51 
52  void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
53  const edm::EventSetup& context) ;
54 
56  void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
57  const edm::EventSetup& c);
58 
60  void endRun(const edm::Run& r, const edm::EventSetup& c);
61 
63  void endJob();
64 
65 private:
66 
67  void initialize();
68  edm::ParameterSet parameters_;
69 
70  DQMStore* dbe_;
71  bool verbose_;
72  int counterLS_; ///counter
73  int counterEvt_; ///counter
74  int prescaleLS_; ///units of lumi sections
75  int prescaleEvt_; ///prescale on number of events
76  // -------- member data --------
77 
78  MonitorElement * reportSummary_;
79  std::vector<MonitorElement*> reportSummaryContent_;
80  MonitorElement * reportSummaryMap_;
81 
82 
83 };
84 */
85 
87  parameters_ = ps;
88  initialize();
89 }
90 
92  if (verbose_)
93  cout << "[TriggerDQM]: ending... " << endl;
94 }
95 
96 //--------------------------------------------------------
98  counterLS_ = 0;
99  counterEvt_ = 0;
100 
101  // get back-end interface
103 
104  // base folder for the contents of this job
105  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
106 
107  prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
108  if (verbose_)
109  cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)" << endl;
110 
111  prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
112  if (verbose_)
113  cout << "DQM event prescale = " << prescaleEvt_ << " events(s)" << endl;
114  /*
115  */
116 }
117 
118 //--------------------------------------------------------
120  if (verbose_)
121  cout << "[TriggerDQM]: Begin Job" << endl;
122  // get backendinterface
124 
125  dbe_->setCurrentFolder("HLT/EventInfo");
126 
127  reportSummary_ = dbe_->bookFloat("reportSummary");
128  //initialize reportSummary to 1
129  if (reportSummary_)
130  reportSummary_->Fill(1);
131 
132  // CertificationSummary
133  CertificationSummary_ = dbe_->bookFloat("CertificationSummary");
134  //initialize CertificationSummary to 1
135  if (CertificationSummary_)
136  CertificationSummary_->Fill(1);
137 
138  //initialize reportSummary to 1
139  if (reportSummary_)
140  reportSummary_->Fill(1);
141 
142  // OK HERE
143 
144  // reportSummaryMap
145  dbe_->setCurrentFolder("HLT/EventInfo");
146 
147  reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 6, 1, 7);
148  reportSummaryMap_->setAxisTitle("", 1);
149  reportSummaryMap_->setAxisTitle("", 2);
150  reportSummaryMap_->setBinLabel(1, "Muon", 2);
151  reportSummaryMap_->setBinLabel(2, "Electron", 2);
152  reportSummaryMap_->setBinLabel(3, "Photon", 2);
153  reportSummaryMap_->setBinLabel(4, "JetMET", 2);
154  reportSummaryMap_->setBinLabel(5, "BJet", 2);
155  reportSummaryMap_->setBinLabel(6, "Tau", 2);
156  reportSummaryMap_->setBinLabel(1, " ", 1);
157 
158  CertificationSummaryMap_ = dbe_->book2D("CertificationSummaryMap", "CertificationSummaryMap", 1, 1, 2, 6, 1, 7);
159  CertificationSummaryMap_->setAxisTitle("", 1);
160  CertificationSummaryMap_->setAxisTitle("", 2);
161  CertificationSummaryMap_->setBinLabel(1, "Muon", 2);
162  CertificationSummaryMap_->setBinLabel(2, "Electron", 2);
163  CertificationSummaryMap_->setBinLabel(3, "Photon", 2);
164  CertificationSummaryMap_->setBinLabel(4, "JetMET", 2);
165  CertificationSummaryMap_->setBinLabel(5, "BJet", 2);
166  CertificationSummaryMap_->setBinLabel(6, "Tau", 2);
167  CertificationSummaryMap_->setBinLabel(1, " ", 1);
168 }
169 
170 //--------------------------------------------------------
172 
173 //--------------------------------------------------------
174 
175 //--------------------------------------------------------
177  counterEvt_++;
178  if (prescaleEvt_ < 1)
179  return;
180  if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
181  return;
182 
183  if (verbose_)
184  cout << "DQMOfflineHLTEventInfoClient::analyze" << endl;
185 }
186 
187 //--------------------------------------------------------
188 void DQMOfflineHLTEventInfoClient::endRun(const Run& r, const EventSetup& context) {
189  float summarySum = 0;
190  float reportSummary = 0;
191 
192  dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
193  MonitorElement* HLT_Muon = dbe_->get("HLT_Muon");
194  if (HLT_Muon)
195  reportSummaryContent_.push_back(HLT_Muon);
196 
197  MonitorElement* HLT_Electron = dbe_->get("HLT_Electron");
198  if (HLT_Electron)
199  reportSummaryContent_.push_back(HLT_Electron);
200 
201  MonitorElement* HLT_Photon = dbe_->get("HLT_Photon");
202  if (HLT_Photon)
203  reportSummaryContent_.push_back(HLT_Photon);
204 
205  MonitorElement* HLT_Tau = dbe_->get("HLT_Tau");
206  if (HLT_Tau)
207  reportSummaryContent_.push_back(HLT_Tau);
208 
209  int nSubsystems = reportSummaryContent_.size();
210 
211  for (int m = 0; m < nSubsystems; m++) {
212  summarySum += (reportSummaryContent_[m])->getFloatValue();
213  }
214 
215  if (nSubsystems > 0) {
216  reportSummary = summarySum / nSubsystems;
217  ;
218  } else {
219  reportSummary = 1;
220  }
221 
222  reportSummary_->Fill(reportSummary);
223  CertificationSummary_->Fill(reportSummary);
224 
225  float muonValue = 1;
226  if (HLT_Muon)
227  muonValue = HLT_Muon->getFloatValue();
228 
229  float electronValue = 1;
230  if (HLT_Electron)
231  electronValue = HLT_Electron->getFloatValue();
232 
233  float photonValue = 1;
234  if (HLT_Photon)
235  photonValue = HLT_Photon->getFloatValue();
236 
237  float tauValue = 1;
238  if (HLT_Tau)
239  tauValue = HLT_Tau->getFloatValue();
240 
241  reportSummaryMap_->setBinContent(1, 1, muonValue); //Muon
242  reportSummaryMap_->setBinContent(1, 2, electronValue); //Electron
243  reportSummaryMap_->setBinContent(1, 3, photonValue); //Photon
244  reportSummaryMap_->setBinContent(1, 4, 1); //JetMET
245  reportSummaryMap_->setBinContent(1, 5, 1); //BJet
246  reportSummaryMap_->setBinContent(1, 6, tauValue); //Tau
247 
248  CertificationSummaryMap_->setBinContent(1, 1, muonValue); //Muon
249  CertificationSummaryMap_->setBinContent(1, 2, electronValue); //Electron
250  CertificationSummaryMap_->setBinContent(1, 3, photonValue); //Photon
251  CertificationSummaryMap_->setBinContent(1, 4, 1); //JetMET
252  CertificationSummaryMap_->setBinContent(1, 5, 1); //BJet
253  CertificationSummaryMap_->setBinContent(1, 6, tauValue); //Tau
254 }
255 
256 //--------------------------------------------------------
static AlgebraicMatrix initialize()
MonitorElement * book2D(char_string const &name, char_string const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1178
void beginRun(const edm::Run &r, const edm::EventSetup &c) override
BeginRun.
dqm::legacy::DQMStore * dbe_
void endRun(const edm::Run &r, const edm::EventSetup &c) override
EndRun.
void Fill(long long x)
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
DQMOfflineHLTEventInfoClient(const edm::ParameterSet &ps)
Constructor.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Fake Analyze.
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
HLT enums.
virtual double getFloatValue() const
MonitorElement * bookFloat(char_string const &name)
Book float.
Definition: DQMStore.cc:1087
Definition: Run.h:45
~DQMOfflineHLTEventInfoClient() override
Destructor.
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)