CMS 3D CMS Logo

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