CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DataCertificationJetMET.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: DQMOffline/JetMET
4 // Class: DataCertificationJetMET
5 //
6 // Original Author: "Frank Chlebana"
7 // Created: Sun Oct 5 13:57:25 CDT 2008
8 //
9 
13 
14 // Some switches
15 //
16 // constructors and destructor
17 //
19 {
20  // now do what ever initialization is needed
21 }
22 
23 
25 {
26  // do anything here that needs to be done at desctruction time
27  // (e.g. close files, deallocate resources etc.)
28 }
29 
30 
31 //
32 // member functions
33 //
34 
35 // ------------ method called to for each event ------------
36 void
38 {
39  using namespace edm;
40  isData = iEvent.isRealData();
41 
42 }
43 
44 // ------------ method called once each job just before starting event loop ------------
45 void
47 {
48 
49  // -----------------------------------------
50  // verbose_ 0: suppress printouts
51  // 1: show printouts
52  verbose_ = conf_.getUntrackedParameter<int>("Verbose",0);
54 
55  jetTests[0][0] = conf_.getUntrackedParameter<bool>("caloBarrelJetMeanTest",true);
56  jetTests[0][1] = conf_.getUntrackedParameter<bool>("caloBarrelJetKSTest",false);
57  jetTests[1][0] = conf_.getUntrackedParameter<bool>("caloEndcapJetMeanTest",true);
58  jetTests[1][1] = conf_.getUntrackedParameter<bool>("caloEndcapJetKSTest",false);
59  jetTests[2][0] = conf_.getUntrackedParameter<bool>("caloForwardJetMeanTest",true);
60  jetTests[2][1] = conf_.getUntrackedParameter<bool>("caloForwardJetKSTest",false);
61  jetTests[3][0] = conf_.getUntrackedParameter<bool>("pfJetMeanTest",true);
62  jetTests[3][1] = conf_.getUntrackedParameter<bool>("pfJetKSTest",false);
63  jetTests[4][0] = conf_.getUntrackedParameter<bool>("jptJetMeanTest",true);
64  jetTests[4][1] = conf_.getUntrackedParameter<bool>("jptJetKSTest",false);
65 
66  metTests[0][0] = conf_.getUntrackedParameter<bool>("caloMETMeanTest",true);
67  metTests[0][1] = conf_.getUntrackedParameter<bool>("caloMETKSTest",false);
68  metTests[1][0] = conf_.getUntrackedParameter<bool>("calonohfMETMeanTest",true);
69  metTests[1][1] = conf_.getUntrackedParameter<bool>("calonohfMETKSTest",false);
70  metTests[2][0] = conf_.getUntrackedParameter<bool>("pfMETMeanTest",true);
71  metTests[2][1] = conf_.getUntrackedParameter<bool>("pfMETKSTest",false);
72  metTests[3][0] = conf_.getUntrackedParameter<bool>("tcMETMeanTest",true);
73  metTests[3][1] = conf_.getUntrackedParameter<bool>("tcMETKSTest",false);
74  metTests[4][0] = conf_.getUntrackedParameter<bool>("muMETMeanTest",true);
75  metTests[4][1] = conf_.getUntrackedParameter<bool>("muMETKSTest",false);
76 
77 
78  if (verbose_) std::cout << ">>> BeginJob (DataCertificationJetMET) <<<" << std::endl;
79 
80  // -----------------------------------------
81  //
83 }
84 
85 // ------------ method called once each job after finishing event loop ------------
86 void
88 {
89 
90  if (verbose_) std::cout << ">>> EndJob (DataCertificationJetMET) <<<" << std::endl;
91 
92  bool outputFile = conf_.getUntrackedParameter<bool>("OutputFile");
94  if (verbose_) std::cout << ">>> endJob " << outputFile << std:: endl;
95 
96  if(outputFile){
98  dbe_->save(outputFileName,
99  "", "","",
101  }
102 
103 }
104 
105 // ------------ method called just before starting a new lumi section ------------
106 void
108 {
109 
110  if (verbose_) std::cout << ">>> BeginLuminosityBlock (DataCertificationJetMET) <<<" << std::endl;
111  if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id() << std::endl;
112  if (verbose_) std::cout << ">>> run = " << lumiBlock.id().run() << std::endl;
113  if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id().luminosityBlock() << std::endl;
114 
115 }
116 
117 // ------------ method called just after a lumi section ends ------------
118 void
120 {
121 
122  if (verbose_) std::cout << ">>> EndLuminosityBlock (DataCertificationJetMET) <<<" << std::endl;
123  if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id() << std::endl;
124  if (verbose_) std::cout << ">>> run = " << lumiBlock.id().run() << std::endl;
125  if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id().luminosityBlock() << std::endl;
126 
127  if (verbose_) dbe_->showDirStructure();
128 
129 }
130 
131 // ------------ method called just before starting a new run ------------
132 void
134 {
135 
136  if (verbose_) std::cout << ">>> BeginRun (DataCertificationJetMET) <<<" << std::endl;
137  //if (verbose_) std::cout << ">>> run = " << run.id() << std::endl;
138 
139 }
140 
141 // ------------ method called right after a run ends ------------
142 void
144 {
145 
146  if (verbose_) std::cout << ">>> EndRun (DataCertificationJetMET) <<<" << std::endl;
147  //if (verbose_) std::cout << ">>> run = " << run.id() << std::endl;
148 
149  // -----------------------------------------
150 
151  std::vector<MonitorElement*> mes;
152  std::vector<std::string> subDirVec;
153  std::string RunDir;
154  std::string RunNum;
155  int RunNumber=0;
156 
157  std::string RefRunDir;
158 
159  if (verbose_) std::cout << "InMemory_ = " << InMemory_ << std::endl;
160 
161  if (InMemory_) {
162  //----------------------------------------------------------------
163  // Histograms are in memory (for standard full-chain mode)
164  //----------------------------------------------------------------
165 
166  mes = dbe_->getAllContents("");
167  if (verbose_) std::cout << "1 >>> found " << mes.size() << " monitoring elements!" << std::endl;
168 
169  dbe_->setCurrentFolder("JetMET");
170  subDirVec = dbe_->getSubdirs();
171  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
172  ic != subDirVec.end(); ic++) {
173  if (verbose_) std::cout << "-AAA- Dir = >>" << ic->c_str() << "<<" << std::endl;
174  }
175 
176  RunDir = "";
177  RunNumber = run.id().run();
178 
179  } else {
180  //----------------------------------------------------------------
181  // Open input files (for standalone mode)
182  //----------------------------------------------------------------
183 
184  mes = dbe_->getAllContents("");
185  if (verbose_) std::cout << "found " << mes.size() << " monitoring elements!" << std::endl;
186 
187  dbe_->setCurrentFolder("/");
188  std::string currDir = dbe_->pwd();
189  if (verbose_) std::cout << "--- Current Directory " << currDir << std::endl;
190 
191  subDirVec = dbe_->getSubdirs();
192 
193  // *** If the same file is read in then we have only one subdirectory
194  int ind = 0;
195  for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
196  ic != subDirVec.end(); ic++) {
197  RunDir = *ic;
198  RunNum = *ic;
199  if (verbose_) std::cout << "-XXX- Dir = >>" << ic->c_str() << "<<" << std::endl;
200  ind++;
201  }
202 
203  //
204  // Current
205  //
206  if (RunDir == "JetMET") {
207  RunDir = "";
208  if (verbose_) std::cout << "-XXX- RunDir = >>" << RunDir.c_str() << "<<" << std::endl;
209  }
210  RunNum.erase(0,4);
211  if (RunNum!="")
212  RunNumber = atoi(RunNum.c_str());
213  if (verbose_) std::cout << "--- >>" << RunNumber << "<<" << std::endl;
214 
215  }
216 
218 
219  //----------
220 
221  dbe_->setCurrentFolder("JetMET/EventInfo/");
222  MonitorElement* reportSummary = dbe_->bookFloat("reportSummary");
223  MonitorElement* CertificationSummary = dbe_->bookFloat("CertificationSummary");
224 
225  MonitorElement* reportSummaryMap = dbe_->book2D("reportSummaryMap","reportSummaryMap",3,0,3,5,0,5);
226  MonitorElement* CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","CertificationSummaryMap",3,0,3,5,0,5);
227  reportSummaryMap->getTH2F()->SetStats(kFALSE);
228  CertificationSummaryMap->getTH2F()->SetStats(kFALSE);
229  reportSummaryMap->getTH2F()->SetOption("colz");
230  CertificationSummaryMap->getTH2F()->SetOption("colz");
231 
232  reportSummaryMap->setBinLabel(1,"CaloTower");
233  reportSummaryMap->setBinLabel(2,"MET");
234  reportSummaryMap->setBinLabel(3,"Jet");
235 
236  CertificationSummaryMap->setBinLabel(1,"CaloTower");
237  CertificationSummaryMap->setBinLabel(2,"MET");
238  CertificationSummaryMap->setBinLabel(3,"Jet");
239 
240  reportSummary->Fill(1.);
241  CertificationSummary->Fill(1.);
242 
243 
244  if (RunDir=="Reference") RunDir="";
245  if (verbose_) std::cout << RunDir << std::endl;
246  dbe_->setCurrentFolder("JetMET/EventInfo/CertificationSummaryContents/");
247 
248  std::string refHistoName;
249  std::string newHistoName;
250 
251  //-----------------------------
252  // Jet DQM Data Certification
253  //-----------------------------
254  MonitorElement *meJetPt[5];
255  MonitorElement *meJetEta[5];
256  MonitorElement *meJetPhi[5];
257  MonitorElement *meJetEMFrac[4];
258  MonitorElement *meJetConstituents[4];
259  MonitorElement *meJetNTracks;
260 
261  RunDir = "";
262  if (RunDir == "") newHistoName = "JetMET/Jet/";
263  else newHistoName = RunDir+"/JetMET/Run summary/Jet/";
264  std::string cleaningdir = "";
265  if (isData)
266  cleaningdir = "Cleaned";
267  //Jet Phi histos
268  meJetPhi[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_Barrel");
269  meJetPhi[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_EndCap");
270  meJetPhi[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_Forward");
271  meJetPhi[3] = dbe_->get(newHistoName+"PFJets/Phi");
272  meJetPhi[4] = dbe_->get(newHistoName+"JPT/Phi");
273 
274  //Jet Eta histos
275  meJetEta[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
276  meJetEta[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
277  meJetEta[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
278  meJetEta[3] = dbe_->get(newHistoName+"PFJets/Eta");
279  meJetEta[4] = dbe_->get(newHistoName+"JPT/Eta");
280 
281  //Jet Pt histos
282  meJetPt[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_Barrel");
283  meJetPt[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_EndCap");
284  meJetPt[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_Forward");
285  meJetPt[3] = dbe_->get(newHistoName+"PFJets/Pt2");
286  meJetPt[4] = dbe_->get(newHistoName+"JPT/Pt2");
287 
289  meJetConstituents[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
290  meJetConstituents[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
291  meJetConstituents[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
292  meJetConstituents[3] = dbe_->get(newHistoName+"PFJets/Constituents");
293  //
295  meJetEMFrac[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
296  meJetEMFrac[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
297  meJetEMFrac[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
298  meJetEMFrac[3] = dbe_->get(newHistoName+"PFJets/EFrac");
299 
300  //JPT specific histos
301  meJetNTracks = dbe_->get(newHistoName+"JPT/nTracks");
302 
303  //------------------------------------------------------------------------------
304  //--- Extract quality test results and fill data certification results for Jets
305  //--- Tests for Calo Barrel, EndCap and Forward, as well as PF and JPT jets
306  //--- For Calo and PF jets:
307  //--- Look at mean of Constituents, EM Frac and Pt
308  //--- Look at Kolmogorov result for Eta, Phi, and Pt
309  //--- For JPT jets:
310  //--- Look at mean of Pt, AllPionsTrackNHits?, nTracks,
311  //--- Look at Kolmogorov result for Eta, Phi, and Pt
312  //------------------------------------------------------------------------------
313 
314 
315  // Five types of jets {AK5 Barrel, AK5 EndCap, AK5 Forward, PF, JPT}
316  //----------------------------------------------------------------------------
317  // Kolmogorov (KS) tests
318  const QReport* QReport_JetEta[5] = {0, 0, 0, 0, 0};
319  const QReport* QReport_JetPhi[5] = {0, 0, 0, 0, 0};
320 
321  // Mean and KS tests for Calo and PF jets
322  const QReport* QReport_JetConstituents[4][2] = {{0,0}, {0,0}, {0,0}, {0,0}};
323  const QReport* QReport_JetEFrac[4][2] = {{0,0}, {0,0}, {0,0}, {0,0}};
324  const QReport* QReport_JetPt[5][2] = {{0,0}, {0,0}, {0,0}, {0,0}, {0,0}};
325 
326  // Mean and KS tests for JPT jets
327  const QReport* QReport_JetNTracks[2] = {0, 0};
328 
329  float qr_Jet_NTracks[2] = {-1, -1};
330  float qr_Jet_Eta[5] = {-1, -1, -1, -1, -1};
331  float qr_Jet_Phi[5] = {-1, -1, -1, -1, -1};
332  float dc_Jet[5] = {-1, -1, -1, -1, -1};
333 
334  float qr_Jet_Constituents[4][2] = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
335  float qr_Jet_EFrac[4][2] = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
336  float qr_Jet_Pt[5][2] = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
337 
338 
339  // Loop
340  //----------------------------------------------------------------------------
341  for (int jtyp=0; jtyp<5; ++jtyp) {
342 
343  // Mean test results
344  if (jtyp < 4){
345  if (meJetConstituents[jtyp]) {
346  QReport_JetConstituents[jtyp][0] = meJetConstituents[jtyp]->getQReport("meanJetConstituentsTest");
347  QReport_JetConstituents[jtyp][1] = meJetConstituents[jtyp]->getQReport("KolmogorovTest");
348  }
349  if (meJetEMFrac[jtyp]) {
350  QReport_JetEFrac[jtyp][0] = meJetEMFrac[jtyp]->getQReport("meanEMFractionTest");
351  QReport_JetEFrac[jtyp][1] = meJetEMFrac[jtyp]->getQReport("KolmogorovTest");
352  }
353  }
354  else {
355  if (meJetNTracks) {
356  QReport_JetNTracks[0] = meJetNTracks->getQReport("meanNTracksTest");
357  QReport_JetNTracks[1] = meJetNTracks->getQReport("KolmogorovTest");
358  }
359  }
360  if (meJetPt[jtyp]) {
361  QReport_JetPt[jtyp][0] = meJetPt[jtyp]->getQReport("meanJetPtTest");
362  QReport_JetPt[jtyp][1] = meJetPt[jtyp]->getQReport("KolmogorovTest");
363  }
364  if (meJetPhi[jtyp])
365  QReport_JetPhi[jtyp] = meJetPhi[jtyp]->getQReport("KolmogorovTest");
366  if (meJetEta[jtyp])
367  QReport_JetEta[jtyp] = meJetEta[jtyp]->getQReport("KolmogorovTest");
368 
369  //Jet Pt test
370  if (QReport_JetPt[jtyp][0]){
371  if (QReport_JetPt[jtyp][0]->getStatus()==100 ||
372  QReport_JetPt[jtyp][0]->getStatus()==200)
373  qr_Jet_Pt[jtyp][0] = 1;
374  else if (QReport_JetPt[jtyp][0]->getStatus()==300)
375  qr_Jet_Pt[jtyp][0] = 0;
376  else
377  qr_Jet_Pt[jtyp][0] = -1;
378  }
379  else qr_Jet_Pt[jtyp][0] = -2;
380 
381  if (QReport_JetPt[jtyp][1]){
382  if (QReport_JetPt[jtyp][1]->getStatus()==100 ||
383  QReport_JetPt[jtyp][1]->getStatus()==200)
384  qr_Jet_Pt[jtyp][1] = 1;
385  else if (QReport_JetPt[jtyp][1]->getStatus()==300)
386  qr_Jet_Pt[jtyp][1] = 0;
387  else
388  qr_Jet_Pt[jtyp][1] = -1;
389  }
390  else qr_Jet_Pt[jtyp][1] = -2;
391 
392  //Jet Phi test
393  if (QReport_JetPhi[jtyp]){
394  if (QReport_JetPhi[jtyp]->getStatus()==100 ||
395  QReport_JetPhi[jtyp]->getStatus()==200)
396  qr_Jet_Phi[jtyp] = 1;
397  else if (QReport_JetPhi[jtyp]->getStatus()==300)
398  qr_Jet_Phi[jtyp] = 0;
399  else
400  qr_Jet_Phi[jtyp] = -1;
401  }
402  else qr_Jet_Phi[jtyp] = -2;
403 
404  //Jet Eta test
405  if (QReport_JetEta[jtyp]){
406  if (QReport_JetEta[jtyp]->getStatus()==100 ||
407  QReport_JetEta[jtyp]->getStatus()==200)
408  qr_Jet_Eta[jtyp] = 1;
409  else if (QReport_JetEta[jtyp]->getStatus()==300)
410  qr_Jet_Eta[jtyp] = 0;
411  else
412  qr_Jet_Eta[jtyp] = -1;
413  }
414  else qr_Jet_Eta[jtyp] = -2;
415 
416  if (jtyp < 4) {
417  //Jet Constituents test
418  if (QReport_JetConstituents[jtyp][0]){
419  if (QReport_JetConstituents[jtyp][0]->getStatus()==100 ||
420  QReport_JetConstituents[jtyp][0]->getStatus()==200)
421  qr_Jet_Constituents[jtyp][0] = 1;
422  else if (QReport_JetConstituents[jtyp][0]->getStatus()==300)
423  qr_Jet_Constituents[jtyp][0] = 0;
424  else
425  qr_Jet_Constituents[jtyp][0] = -1;
426  }
427  else qr_Jet_Constituents[jtyp][0] = -2;
428 
429  if (QReport_JetConstituents[jtyp][1]){
430  if (QReport_JetConstituents[jtyp][1]->getStatus()==100 ||
431  QReport_JetConstituents[jtyp][1]->getStatus()==200)
432  qr_Jet_Constituents[jtyp][1] = 1;
433  else if (QReport_JetConstituents[jtyp][1]->getStatus()==300)
434  qr_Jet_Constituents[jtyp][1] = 0;
435  else
436  qr_Jet_Constituents[jtyp][1] = -1;
437  }
438  else qr_Jet_Constituents[jtyp][1] = -2;
439 
440  //Jet EMFrac test
441  if (QReport_JetEFrac[jtyp][0]){
442  if (QReport_JetEFrac[jtyp][0]->getStatus()==100 ||
443  QReport_JetEFrac[jtyp][0]->getStatus()==200)
444  qr_Jet_EFrac[jtyp][0] = 1;
445  else if (QReport_JetEFrac[jtyp][0]->getStatus()==300)
446  qr_Jet_EFrac[jtyp][0] = 0;
447  else
448  qr_Jet_EFrac[jtyp][0] = -1;
449  }
450  else qr_Jet_EFrac[jtyp][0] = -2;
451 
452  if (QReport_JetEFrac[jtyp][1]){
453  if (QReport_JetEFrac[jtyp][1]->getStatus()==100 ||
454  QReport_JetEFrac[jtyp][1]->getStatus()==200)
455  qr_Jet_EFrac[jtyp][1] = 1;
456  else if (QReport_JetEFrac[jtyp][1]->getStatus()==300)
457  qr_Jet_EFrac[jtyp][1] = 0;
458  else
459  qr_Jet_EFrac[jtyp][1] = -1;
460  }
461  else qr_Jet_EFrac[jtyp][1] = -2;
462  }
463  else {
464  for (int ii = 0; ii < 2; ++ii) {
465  //Jet NTracks test
466  if (QReport_JetNTracks[ii]){
467  if (QReport_JetNTracks[ii]->getStatus()==100 ||
468  QReport_JetNTracks[ii]->getStatus()==200)
469  qr_Jet_NTracks[ii] = 1;
470  else if (QReport_JetNTracks[ii]->getStatus()==300)
471  qr_Jet_NTracks[ii] = 0;
472  else
473  qr_Jet_NTracks[ii] = -1;
474  }
475  else qr_Jet_NTracks[ii] = -2;
476  }
477  }
478 
479  if (verbose_) {
480  printf("====================Jet Type %d QTest Report Summary========================\n",jtyp);
481  printf("Eta: Phi: Pt 1: 2: Const/Ntracks 1: 2: EFrac/tracknhits 1: 2:\n");
482  if (jtyp<4) {
483  printf("%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f %2.2f\n", \
484  qr_Jet_Eta[jtyp], \
485  qr_Jet_Phi[jtyp], \
486  qr_Jet_Pt[jtyp][0], \
487  qr_Jet_Pt[jtyp][1], \
488  qr_Jet_Constituents[jtyp][0], \
489  qr_Jet_Constituents[jtyp][1], \
490  qr_Jet_EFrac[jtyp][0], \
491  qr_Jet_EFrac[jtyp][1]);
492  }
493  else {
494  printf("%2.2f %2.2f %2.2f %2.2f %2.2f %2.2f\n", \
495  qr_Jet_Eta[jtyp], \
496  qr_Jet_Phi[jtyp], \
497  qr_Jet_Pt[jtyp][0], \
498  qr_Jet_Pt[jtyp][1], \
499  qr_Jet_NTracks[0], \
500  qr_Jet_NTracks[1]);
501  }
502  printf("===========================================================================\n");
503  }
504  //certification result for Jet
505 
506  //Only apply certain tests, as defined in the config
507  for (int ttyp = 0; ttyp < 2; ++ttyp) {
508  if (!jetTests[jtyp][ttyp]) {
509  qr_Jet_Pt[jtyp][ttyp] = 1;
510  if (ttyp ==1) {
511  qr_Jet_Eta[jtyp] = 1;
512  qr_Jet_Phi[jtyp] = 1;
513  }
514  if (jtyp < 4) {
515  qr_Jet_EFrac[jtyp][ttyp] = 1;
516  qr_Jet_Constituents[jtyp][ttyp] = 1;
517  }
518  else{
519  qr_Jet_NTracks[ttyp] = 1;
520  }
521  }
522  }
523 
524 
525  if (jtyp < 4) {
526  if ( (qr_Jet_EFrac[jtyp][0] == 0) ||
527  (qr_Jet_EFrac[jtyp][1] == 0) ||
528  (qr_Jet_Constituents[jtyp][1] == 0) ||
529  (qr_Jet_Constituents[jtyp][0] == 0) ||
530  (qr_Jet_Eta[jtyp] == 0) ||
531  (qr_Jet_Phi[jtyp] == 0) ||
532  (qr_Jet_Pt[jtyp][0] == 0) ||
533  (qr_Jet_Pt[jtyp][1] == 0)
534  )
535  dc_Jet[jtyp] = 0;
536  else if ( (qr_Jet_EFrac[jtyp][0] == -1) &&
537  (qr_Jet_EFrac[jtyp][1] == -1) &&
538  (qr_Jet_Constituents[jtyp][1] == -1) &&
539  (qr_Jet_Constituents[jtyp][0] == -1) &&
540  (qr_Jet_Eta[jtyp] == -1) &&
541  (qr_Jet_Phi[jtyp] == -1) &&
542  (qr_Jet_Pt[jtyp][0] == -1) &&
543  (qr_Jet_Pt[jtyp][1] == -1 )
544  )
545  dc_Jet[jtyp] = -1;
546  else if ( (qr_Jet_EFrac[jtyp][0] == -2) &&
547  (qr_Jet_EFrac[jtyp][1] == -2) &&
548  (qr_Jet_Constituents[jtyp][1] == -2) &&
549  (qr_Jet_Constituents[jtyp][0] == -2) &&
550  (qr_Jet_Eta[jtyp] == -2) &&
551  (qr_Jet_Phi[jtyp] == -2) &&
552  (qr_Jet_Pt[jtyp][0] == -2) &&
553  (qr_Jet_Pt[jtyp][1] == -2)
554  )
555  dc_Jet[jtyp] = -2;
556  else
557  dc_Jet[jtyp] = 1;
558  }
559  else {
560  if ( (qr_Jet_NTracks[0] == 0) ||
561  (qr_Jet_NTracks[1] == 0) ||
562  (qr_Jet_Eta[jtyp] == 0) ||
563  (qr_Jet_Phi[jtyp] == 0) ||
564  (qr_Jet_Pt[jtyp][0] == 0) ||
565  (qr_Jet_Pt[jtyp][1] == 0)
566  )
567  dc_Jet[jtyp] = 0;
568  else if ( (qr_Jet_NTracks[0] == -1) &&
569  (qr_Jet_NTracks[1] == -1) &&
570  (qr_Jet_Eta[jtyp] == -1) &&
571  (qr_Jet_Phi[jtyp] == -1) &&
572  (qr_Jet_Pt[jtyp][0] == -1) &&
573  (qr_Jet_Pt[jtyp][1] == -1)
574  )
575  dc_Jet[jtyp] = -1;
576  else if ( (qr_Jet_NTracks[0] == -2) &&
577  (qr_Jet_NTracks[1] == -2) &&
578  (qr_Jet_Eta[jtyp] == -2) &&
579  (qr_Jet_Phi[jtyp] == -2) &&
580  (qr_Jet_Pt[jtyp][0] == -2) &&
581  (qr_Jet_Pt[jtyp][1] == -2)
582  )
583  dc_Jet[jtyp] = -2;
584  else
585  dc_Jet[jtyp] = 1;
586  }
587 
588  if (verbose_) std::cout<<"Certifying Jet algo: "<<jtyp<<" with value: "<<dc_Jet[jtyp]<<std::endl;
589  CertificationSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
590  reportSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
591  }
592 
593 
594  //-----------------------------
595  // MET DQM Data Certification
596  //-----------------------------
597 
598  //
599  // Prepare test histograms
600  //
601  MonitorElement *meMExy[4][2];
602  MonitorElement *meMEt[4];
603  MonitorElement *meSumEt[4];
604  MonitorElement *meMETPhi[4];
605  //MonitorElement *meMETEMFrac[5];
606  //MonitorElement *meMETEmEt[3][2];
607  //MonitorElement *meMETHadEt[3][2];
608 
609  RunDir = "";
610  if (RunDir == "") newHistoName = "JetMET/MET/";
611  else newHistoName = RunDir+"/JetMET/Run summary/MET/";
612 
613  if (isData)
614  cleaningdir = "BasicCleanup";
615  else
616  cleaningdir = "All";
617  //MEx/MEy monitor elements
618  meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
619  meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
620  // meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
621  // meMExy[1][1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
622  meMExy[1][0] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEx");
623  meMExy[1][1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEy");
624  meMExy[2][0] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEx");
625  meMExy[2][1] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEy");
626  meMExy[3][0] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
627  meMExy[3][1] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
628  //MET Phi monitor elements
629  meMETPhi[0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
630  // meMETPhi[1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
631  meMETPhi[1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMETPhi");
632  meMETPhi[2] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_METPhi");
633  meMETPhi[3] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
634  //MET monitor elements
635  meMEt[0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
636  // meMEt[1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
637  meMEt[1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMET");
638  meMEt[2] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MET");
639  meMEt[3] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
640  //SumET monitor elements
641  meSumEt[0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
642  // meSumEt[1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
643  meSumEt[1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfSumET");
644  meSumEt[2] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_SumET");
645  meSumEt[3] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
646 
647  //----------------------------------------------------------------------------
648  //--- Extract quality test results and fill data certification results for MET
649  //----------------------------------------------------------------------------
650 
651  // 4 types of MET {CaloMET, PfMET, TcMET, MuCorrMET} // It is 5 if CaloMETNoHF is included
652  // 2 types of tests Mean test/Kolmogorov test
653  const QReport * QReport_MExy[4][2][2];
654  const QReport * QReport_MEt[4][2];
655  const QReport * QReport_SumEt[4][2];
656  //2 types of tests phiQTest and Kolmogorov test
657  const QReport * QReport_METPhi[4][2];
658 
659 
660  float qr_MET_MExy[4][2][2] = {{{-999.}}};
661  float qr_MET_MEt[4][2] = {{-999.}};
662  float qr_MET_SumEt[4][2] = {{-999.}};
663  float qr_MET_METPhi[4][2] = {{-999.}};
664  float dc_MET[4] = {-999.};
665 
666 
667  // J.Piedra, 27/02/212
668  // Started the process to remove MuCorrMET --> loop up to 3 instead of 4
669  for (int mtyp = 0; mtyp < 3; ++mtyp){
670  //Mean test results
671  //std::cout<<"meMEx = :"<<meMExy[mtyp][0]<<std::endl;
672  //std::cout<<"meMEy = :"<<meMExy[mtyp][1]<<std::endl;
673  //std::cout<<"meMET = :"<<meMEt[mtyp]<<std::endl;
674  //std::cout<<"meMETPhi = :"<<meMExy[mtyp]<<std::endl;
675  //std::cout<<"meSumEt = :"<<meMExy[mtyp]<<std::endl;
676  if (meMExy[mtyp][0]) {
677  QReport_MExy[mtyp][0][0] = meMExy[mtyp][0]->getQReport("meanMExyTest");
678  QReport_MExy[mtyp][1][0] = meMExy[mtyp][0]->getQReport("KolmogorovTest");
679  }
680  if (meMExy[mtyp][1]) {
681  QReport_MExy[mtyp][0][1] = meMExy[mtyp][1]->getQReport("meanMExyTest");
682  QReport_MExy[mtyp][1][1] = meMExy[mtyp][1]->getQReport("KolmogorovTest");
683  }
684  if (meMEt[mtyp]) {
685  QReport_MEt[mtyp][0] = meMEt[mtyp]->getQReport("meanMETTest");
686  QReport_MEt[mtyp][1] = meMEt[mtyp]->getQReport("KolmogorovTest");
687  }
688 
689  if (meSumEt[mtyp]) {
690  QReport_SumEt[mtyp][0] = meSumEt[mtyp]->getQReport("meanSumETTest");
691  QReport_SumEt[mtyp][1] = meSumEt[mtyp]->getQReport("KolmogorovTest");
692  }
693 
694  if (meMETPhi[mtyp]) {
695  QReport_METPhi[mtyp][0] = meMETPhi[mtyp]->getQReport("phiQTest");
696  QReport_METPhi[mtyp][1] = meMETPhi[mtyp]->getQReport("KolmogorovTest");
697  }
698  for (int testtyp = 0; testtyp < 2; ++testtyp) {
699  //MEx test
700  if (QReport_MExy[mtyp][testtyp][0]){
701  if (QReport_MExy[mtyp][testtyp][0]->getStatus()==100 ||
702  QReport_MExy[mtyp][testtyp][0]->getStatus()==200)
703  qr_MET_MExy[mtyp][testtyp][0] = 1;
704  else if (QReport_MExy[mtyp][testtyp][0]->getStatus()==300)
705  qr_MET_MExy[mtyp][testtyp][0] = 0;
706  else
707  qr_MET_MExy[mtyp][testtyp][0] = -1;
708  }
709  else qr_MET_MExy[mtyp][testtyp][0] = -2;
710 
711  //MEy test
712  if (QReport_MExy[mtyp][testtyp][1]){
713  if (QReport_MExy[mtyp][testtyp][1]->getStatus()==100 ||
714  QReport_MExy[mtyp][testtyp][1]->getStatus()==200)
715  qr_MET_MExy[mtyp][testtyp][1] = 1;
716  else if (QReport_MExy[mtyp][testtyp][1]->getStatus()==300)
717  qr_MET_MExy[mtyp][testtyp][1] = 0;
718  else
719  qr_MET_MExy[mtyp][testtyp][1] = -1;
720  }
721  else qr_MET_MExy[mtyp][testtyp][1] = -2;
722 
723  //MEt test
724  if (QReport_MEt[mtyp][testtyp]){
725  if (QReport_MEt[mtyp][testtyp]->getStatus()==100 ||
726  QReport_MEt[mtyp][testtyp]->getStatus()==200)
727  qr_MET_MEt[mtyp][testtyp] = 1;
728  else if (QReport_MEt[mtyp][testtyp]->getStatus()==300)
729  qr_MET_MEt[mtyp][testtyp] = 0;
730  else
731  qr_MET_MEt[mtyp][testtyp] = -1;
732  }
733  else qr_MET_MEt[mtyp][testtyp] = -2;
734 
735  //SumEt test
736  if (QReport_SumEt[mtyp][testtyp]){
737  if (QReport_SumEt[mtyp][testtyp]->getStatus()==100 ||
738  QReport_SumEt[mtyp][testtyp]->getStatus()==200)
739  qr_MET_SumEt[mtyp][testtyp] = 1;
740  else if (QReport_SumEt[mtyp][testtyp]->getStatus()==300)
741  qr_MET_SumEt[mtyp][testtyp] = 0;
742  else
743  qr_MET_SumEt[mtyp][testtyp] = -1;
744  }
745  else qr_MET_SumEt[mtyp][testtyp] = -2;
746 
747  //METPhi test
748  if (QReport_METPhi[mtyp][testtyp]){
749  if (QReport_METPhi[mtyp][testtyp]->getStatus()==100 ||
750  QReport_METPhi[mtyp][testtyp]->getStatus()==200)
751  qr_MET_METPhi[mtyp][testtyp] = 1;
752  else if (QReport_METPhi[mtyp][testtyp]->getStatus()==300)
753  qr_MET_METPhi[mtyp][testtyp] = 0;
754  else
755  qr_MET_METPhi[mtyp][testtyp] = -1;
756  }
757  else qr_MET_METPhi[mtyp][testtyp] = -2;
758  }
759 
760  if (verbose_) {
761  //certification result for MET
762  printf("====================MET Type %d QTest Report Summary========================\n",mtyp);
763  printf("MEx test MEy test MEt test: SumEt test: METPhi test:\n");
764  for (int tt = 0; tt < 2; ++tt) {
765  printf("%2.2f %2.2f %2.2f %2.2f %2.2f\n",qr_MET_MExy[mtyp][tt][0], \
766  qr_MET_MExy[mtyp][tt][1], \
767  qr_MET_MEt[mtyp][tt], \
768  qr_MET_SumEt[mtyp][tt], \
769  qr_MET_METPhi[mtyp][tt]);
770  }
771  printf("===========================================================================\n");
772  }
773 
774 
775  //Only apply certain tests, as defined in the config
776  for (int ttyp = 0; ttyp < 2; ++ttyp) {
777  if (!metTests[mtyp][ttyp]) {
778  qr_MET_MExy[mtyp][ttyp][0] = 1;
779  qr_MET_MExy[mtyp][ttyp][1] = 1;
780  qr_MET_MEt[mtyp][ttyp] = 1;
781  qr_MET_SumEt[mtyp][ttyp] = 1;
782  qr_MET_METPhi[mtyp][ttyp] = 1;
783  }
784  }
785 
786 
787  if (
788  (qr_MET_MExy[mtyp][0][0] == 0) ||
789  (qr_MET_MExy[mtyp][0][1] == 0) ||
790  (qr_MET_MEt[mtyp][0] == 0) ||
791  (qr_MET_SumEt[mtyp][0] == 0) ||
792  (qr_MET_METPhi[mtyp][0] == 0) ||
793  (qr_MET_MExy[mtyp][1][0] == 0) ||
794  (qr_MET_MExy[mtyp][1][1] == 0) ||
795  (qr_MET_MEt[mtyp][1] == 0) ||
796  (qr_MET_SumEt[mtyp][1] == 0) ||
797  (qr_MET_METPhi[mtyp][1] == 0)
798  )
799  dc_MET[mtyp] = 0;
800  else if (
801  (qr_MET_MExy[mtyp][0][0] == -1) &&
802  (qr_MET_MExy[mtyp][0][1] == -1) &&
803  (qr_MET_MEt[mtyp][0] == -1) &&
804  (qr_MET_SumEt[mtyp][0] == -1) &&
805  (qr_MET_METPhi[mtyp][0] == -1) &&
806  (qr_MET_MExy[mtyp][1][0] == -1) &&
807  (qr_MET_MExy[mtyp][1][1] == -1) &&
808  (qr_MET_MEt[mtyp][1] == -1) &&
809  (qr_MET_SumEt[mtyp][1] == -1) &&
810  (qr_MET_METPhi[mtyp][1] == -1)
811  )
812  dc_MET[mtyp] = -1;
813  else if (
814  (qr_MET_MExy[mtyp][0][0] == -2) &&
815  (qr_MET_MExy[mtyp][0][1] == -2) &&
816  (qr_MET_MEt[mtyp][0] == -2) &&
817  (qr_MET_SumEt[mtyp][0] == -2) &&
818  (qr_MET_METPhi[mtyp][0] == -2) &&
819  (qr_MET_MExy[mtyp][1][0] == -2) &&
820  (qr_MET_MExy[mtyp][1][1] == -2) &&
821  (qr_MET_MEt[mtyp][1] == -2) &&
822  (qr_MET_SumEt[mtyp][1] == -2) &&
823  (qr_MET_METPhi[mtyp][1] == -2)
824  )
825  dc_MET[mtyp] = -2;
826  else
827  dc_MET[mtyp] = 1;
828 
829  if (verbose_) std::cout<<"Certifying MET algo: "<<mtyp<<" with value: "<<dc_MET[mtyp]<<std::endl;
830  CertificationSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
831  reportSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
832  }
833 
834 
835  //-----------------------------
836  // CaloTowers DQM Data Certification
837  //-----------------------------
838 
839  //
840  // Prepare test histograms
841  //
842  //MonitorElement *meCTOcc[3];
843  //MonitorElement *meCTEn[3];
844  //MonitorElement *meCT[3];
845  //MonitorElement *meCT[3];
846 
847  //RunDir = "";
848  //if (RunDir == "") newHistoName = "JetMET/MET/";
849  //else newHistoName = RunDir+"/JetMET/Run summary/MET/";
850 
851  //meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
852  //meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
853  //meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
854 
855  //----------------------------------------------------------------------------
856  //--- Extract quality test results and fill data certification results for MET
857  //----------------------------------------------------------------------------
858  // Commenting out unused but initialized variables. [Suchandra Dutta]
859  // float qr_CT_Occ[3] = {-2.};
860  float dc_CT[3] = {-2.};
861  dc_CT[0] = -2.;
862  dc_CT[1] = -2.;
863  dc_CT[2] = -2.;
864 
865  // qr_CT_Occ[0] = dc_CT[0];
866  // qr_CT_Occ[1] = dc_CT[1];
867  // qr_CT_Occ[2] = dc_CT[2];
868 
869  for (int cttyp = 0; cttyp < 3; ++cttyp) {
870 
871  if (verbose_) std::cout<<"Certifying CaloTowers with value: "<<dc_CT[cttyp]<<std::endl;
872  CertificationSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
873  reportSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
874  }
875  dbe_->setCurrentFolder("");
876 
877 }
878 
879 //define this as a plug-in
880 //DEFINE_FWK_MODULE(DataCertificationJetMET);
LuminosityBlockID id() const
T getUntrackedParameter(std::string const &, T const &) const
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to &lt;qtname&gt; (null pointer if QReport does not exist)
RunID const & id() const
Definition: RunBase.h:41
std::vector< std::string > getSubdirs(void) const
Definition: DQMStore.cc:1575
RunNumber_t run() const
Definition: RunID.h:43
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
int ii
Definition: cuy.py:588
bool isRealData() const
Definition: EventBase.h:60
MonitorElement * bookFloat(const char *name)
Book float.
Definition: DQMStore.cc:810
SaveReferenceTag
Definition: DQMStore.h:73
void Fill(long long x)
std::vector< MonitorElement * > getAllContents(const std::string &path, uint32_t runNumber=0, uint32_t lumi=0) const
Definition: DQMStore.cc:1837
virtual void endRun(const edm::Run &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
RunNumber_t run() const
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2297
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
LuminosityBlockNumber_t luminosityBlock() const
tuple cout
Definition: gather_cfg.py:121
void showDirStructure(void) const
Definition: DQMStore.cc:2962
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:1001
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: Run.h:41
const std::string & pwd(void) const
Definition: DQMStore.cc:557
DataCertificationJetMET(const edm::ParameterSet &)