CMS 3D CMS Logo

HLTOverallSummary.cc
Go to the documentation of this file.
1 #include <iostream>
2 
3 
4 
7 //
8 // Original Author: Jason Slaunwhite
9 //
10 // Created: Thu Jan 22 13:42:28CET 2009
11 //
12 
13 // system include files
14 #include <memory>
15 #include <vector>
16 
18 //
24 
25 //root include files
26 #include "TFile.h"
27 #include "TH1.h"
28 #include "TH2.h"
29 #include "TTree.h"
30 #include "TVector3.h"
31 #include "TProfile.h"
32 //
33 
34 
35 // user include files
38 
40 
43 
44 
45 //DQM services
49 
50 
51 
52 using namespace std;
53 
54 
55 //
56 // class decleration
57 //
58 
60 
61  public:
62  explicit HLTOverallSummary(const edm::ParameterSet& pset);
63  ~HLTOverallSummary() override;
64 
65 
66  void beginJob() override ;
67  void analyze(const edm::Event&, const edm::EventSetup&) override;
68  void endJob() override ;
69  void beginRun(const edm::Run&, const edm::EventSetup&) override ;
70  void endRun(const edm::Run&, const edm::EventSetup&) override ;
71 
72 
73 
74  private:
75 
78 
79  bool verbose_;
80 
81  // ----------member data ---------------------------
82 };
83 
84 
85 
87 
88 {
89 
90  using namespace edm;
91  dbe_ = nullptr;
93  if (!dbe_) {
94  LogInfo ("HLTMuonVal") << "Can't find DQMStore, no results will be saved"
95  << endl;
96  } else {
97  dbe_->setVerbose(0);
98  }
99 
100  parameters_ = pset;
101  verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
102 
103  if(verbose_) LogInfo ("HLTMuonVal") << ">>> Constructor (HLTOverallSummary) <<<" << endl;
104 
105 }
106 
107 
109 
110 
111 //
112 // member functions
113 //
114 
115 // ------------ method called to for each event ------------
116 void
118 {
119  using namespace edm;
120 
121  if(verbose_) LogInfo ("HLTMuonVal") << ">>> Analyze (HLTOverallSummary) <<<" << std::endl;
122 
123 }
124 
125 // ------------ method called once each job just before starting event loop ------------
126 void
128 {
129 }
130 
131 // ------------ method called once each job just after ending the event loop ------------
132 void
134 {
135 }
136 
137 // ------------ method called just before starting a new run ------------
138 void
140 {
141 
142  using namespace edm;
143  if(verbose_) LogInfo ("HLTMuonVal") << ">>> BeginRun (HLTOverallSummary) <<<" << std::endl;
144  if(verbose_) LogInfo ("HLTMuonVal") << ">>> "<< run.id() << std::endl;
145 
146 }
147 
148 // ------------ method called right after a run ends ------------
149 void
151 {
152 
153  using namespace edm;
154  if(verbose_) LogInfo ("HLTMuonVal") << ">>> EndRun (HLTOverallSummary) <<<" << std::endl;
155 
156  if(!dbe_) {
157  LogInfo ("HLTMuonVal") << "No dqmstore... skipping processing step" << endl;
158  return;
159  }
160 
161  std::vector<string> histoNameVector;
162 
163 
164  //booking histograms according to naming conventions
165 
166  float defaultValueIfNotFound = 1.0;
167 
168  dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContent");
169 
170 
171  //============ Unpack information ==========
172 
173 
174  MonitorElement* muonQualityBit = nullptr;
175  muonQualityBit = dbe_->get("HLT_Muon");
176 
177  if (!muonQualityBit) {
178  LogInfo ("HLTMuonVal") << "Can't find muonQuality bit... making a bit, setting it to zero" << endl;
179 
180  muonQualityBit = dbe_->bookFloat("HLT_Muon");
181  muonQualityBit->Fill(defaultValueIfNotFound);
182 
183  }
184 
185  MonitorElement* eleQualityBit = nullptr;
186  eleQualityBit = dbe_->get("HLT_Electron");
187 
188  if (!eleQualityBit) {
189  LogInfo ("HLTMuonVal") << "Can't find eleQuality bit... making a bit, setting it to zero" << endl;
190 
191  eleQualityBit = dbe_->bookFloat("HLT_Electron");
192  eleQualityBit->Fill(defaultValueIfNotFound);
193  }
194 
195  MonitorElement* photonQualityBit = nullptr;
196  photonQualityBit = dbe_->get("HLT_Photon");
197 
198  if (!photonQualityBit) {
199  LogInfo ("HLTMuonVal") << "Can't find photonQuality bit... making a bit, setting it to zero" << endl;
200 
201  photonQualityBit = dbe_->bookFloat("HLT_Photon");
202  photonQualityBit->Fill(defaultValueIfNotFound);
203  }
204 
205 
206  //============ Book new storage locations =============
207 
208  dbe_->setCurrentFolder("HLT/EventInfo");
209  MonitorElement* hltQualityBit = dbe_->bookFloat("reportSummary");
210 
211  MonitorElement* hltQualitySummaryWord = dbe_->bookInt ("HLT_SUMMARY_WORD");
212 
213  //for now these will hold values from eta/phi tests for spikes/holes
214  MonitorElement* reportSummaryMap = dbe_->book2D("reportSummaryMap","HLT: ReportSummaryMap",3,-0.5,2.5,1,-0.5,0.5);
215  MonitorElement* CertificationSummaryMap = dbe_->book2D("certificationSummaryMap","HLT: CertificationSummaryMap",3,-0.5,2.5,1,-0.5,0.5);
216 
217  TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
218 
219  reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Muon");
220  reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Electron");
221  reportSummaryMapTH2->GetXaxis()->SetBinLabel(3,"Photon");
222 
223  reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"Quality");
224 
225 
226  TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
227 
228  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Muon");
229  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Electron");
230  CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3,"Photon");
231  CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"Quality");
232 
233 
234 
235  //=================== Interpret bits and store result
236 
237  float photonValue = photonQualityBit->getFloatValue();
238 
239  float electronValue = eleQualityBit->getFloatValue();
240 
241  float muonValue = muonQualityBit->getFloatValue();
242 
243  float hltOverallValue = 1.0;
244 
245  if ( (photonValue > 0.99)
246  && (electronValue > 0.99)
247  && (muonValue > 0.99) ) {
248 
249  hltOverallValue = 1.0;
250 
251  } else {
252 
253  hltOverallValue = 0.0;
254 
255  }
256 
257  hltQualityBit->Fill(hltOverallValue);
258 
259  unsigned int hltSummaryValue = 0x0; //
260 
261  unsigned int ELECTRON_MASK = 0x1;
262  unsigned int PHOTON_MASK = 0x2;
263  unsigned int MUON_MASK = 0x4;
264 
265  if (electronValue > 0.99) hltSummaryValue = hltSummaryValue | ELECTRON_MASK;
266  if (photonValue > 0.99) hltSummaryValue = hltSummaryValue | PHOTON_MASK;
267  if (muonValue > 0.99) hltSummaryValue = hltSummaryValue | MUON_MASK;
268 
269  hltQualitySummaryWord->Fill(hltSummaryValue);
270 
271  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1,1), muonValue);
272  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2,1), electronValue);
273  reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3,1), photonValue);
274 
275  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1,1), muonValue);
276  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2,1), electronValue);
277  CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3,1), photonValue);
278 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 }
289 
290 
void beginJob() override
RunID const & id() const
Definition: RunBase.h:39
void endRun(const edm::Run &, const edm::EventSetup &) override
def analyze(function, filename, filter=None)
Definition: Profiling.py:11
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void analyze(const edm::Event &, const edm::EventSetup &) override
void beginJob()
Definition: Breakpoints.cc:15
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
double getFloatValue(void) const
void beginRun(const edm::Run &, const edm::EventSetup &) override
~HLTOverallSummary() override
DQMStore * dbe_
HLT enums.
edm::ParameterSet parameters_
HLTOverallSummary(const edm::ParameterSet &pset)
void endJob() override
TH2F * getTH2F(void) const
Definition: Run.h:42