CMS 3D CMS Logo

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