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