CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQMOffline/JetMET/src/DataCertificationJetMET.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DQMOffline/JetMET
00004 // Class:      DataCertificationJetMET
00005 // 
00006 // Original Author:  "Frank Chlebana"
00007 //         Created:  Sun Oct  5 13:57:25 CDT 2008
00008 // $Id: DataCertificationJetMET.cc,v 1.49 2010/09/28 15:42:41 sturdy Exp $
00009 //
00010 
00011 #include "DQMOffline/JetMET/interface/DataCertificationJetMET.h"
00012 #include "FWCore/Framework/interface/LuminosityBlock.h"
00013 #include "FWCore/Framework/interface/Run.h"
00014 
00015 // Some switches
00016 //
00017 // constructors and destructor
00018 //
00019 DataCertificationJetMET::DataCertificationJetMET(const edm::ParameterSet& iConfig):conf_(iConfig)
00020 {
00021   // now do what ever initialization is needed
00022 }
00023 
00024 
00025 DataCertificationJetMET::~DataCertificationJetMET()
00026 { 
00027    // do anything here that needs to be done at desctruction time
00028    // (e.g. close files, deallocate resources etc.)
00029 }
00030 
00031 
00032 //
00033 // member functions
00034 //
00035 
00036 // ------------ method called to for each event  ------------
00037 void
00038 DataCertificationJetMET::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00039 {
00040   using namespace edm;
00041   isData = iEvent.isRealData();
00042    
00043 }
00044 
00045 // ------------ method called once each job just before starting event loop  ------------
00046 void 
00047 DataCertificationJetMET::beginJob(void)
00048 {
00049 
00050   // -----------------------------------------
00051   // verbose_ 0: suppress printouts
00052   //          1: show printouts
00053   verbose_ = conf_.getUntrackedParameter<int>("Verbose",0);
00054   metFolder        = conf_.getUntrackedParameter<std::string>("metFolder");
00055 
00056   jetTests[0][0] = conf_.getUntrackedParameter<bool>("caloBarrelJetMeanTest",true);
00057   jetTests[0][1] = conf_.getUntrackedParameter<bool>("caloBarrelJetKSTest",false);
00058   jetTests[1][0] = conf_.getUntrackedParameter<bool>("caloEndcapJetMeanTest",true);
00059   jetTests[1][1] = conf_.getUntrackedParameter<bool>("caloEndcapJetKSTest",false);
00060   jetTests[2][0] = conf_.getUntrackedParameter<bool>("caloForwardJetMeanTest",true);
00061   jetTests[2][1] = conf_.getUntrackedParameter<bool>("caloForwardJetKSTest",false);
00062   jetTests[3][0] = conf_.getUntrackedParameter<bool>("pfJetMeanTest",true);
00063   jetTests[3][1] = conf_.getUntrackedParameter<bool>("pfJetKSTest",false);
00064   jetTests[4][0] = conf_.getUntrackedParameter<bool>("jptJetMeanTest",true);
00065   jetTests[4][1] = conf_.getUntrackedParameter<bool>("jptJetKSTest",false);
00066 
00067   metTests[0][0] = conf_.getUntrackedParameter<bool>("caloMETMeanTest",true);
00068   metTests[0][1] = conf_.getUntrackedParameter<bool>("caloMETKSTest",false);
00069   metTests[1][0] = conf_.getUntrackedParameter<bool>("calonohfMETMeanTest",true);
00070   metTests[1][1] = conf_.getUntrackedParameter<bool>("calonohfMETKSTest",false);
00071   metTests[2][0] = conf_.getUntrackedParameter<bool>("pfMETMeanTest",true);
00072   metTests[2][1] = conf_.getUntrackedParameter<bool>("pfMETKSTest",false);
00073   metTests[3][0] = conf_.getUntrackedParameter<bool>("tcMETMeanTest",true);
00074   metTests[3][1] = conf_.getUntrackedParameter<bool>("tcMETKSTest",false);
00075   metTests[4][0] = conf_.getUntrackedParameter<bool>("muMETMeanTest",true);
00076   metTests[4][1] = conf_.getUntrackedParameter<bool>("muMETKSTest",false);
00077   
00078   
00079   if (verbose_) std::cout << ">>> BeginJob (DataCertificationJetMET) <<<" << std::endl;
00080 
00081   // -----------------------------------------
00082   //
00083   dbe_ = edm::Service<DQMStore>().operator->();
00084 }
00085 
00086 // ------------ method called once each job after finishing event loop  ------------
00087 void 
00088 DataCertificationJetMET::endJob()
00089 {
00090 
00091   if (verbose_) std::cout << ">>> EndJob (DataCertificationJetMET) <<<" << std::endl;
00092 
00093   bool outputFile            = conf_.getUntrackedParameter<bool>("OutputFile");
00094   std::string outputFileName = conf_.getUntrackedParameter<std::string>("OutputFileName");
00095   if (verbose_) std::cout << ">>> endJob " << outputFile << std:: endl;
00096 
00097   if(outputFile){
00098     dbe_->showDirStructure();
00099     dbe_->save(outputFileName,
00100                "", "","",
00101                (DQMStore::SaveReferenceTag) DQMStore::SaveWithReference);
00102   }
00103 
00104 }
00105  
00106 // ------------ method called just before starting a new lumi section  ------------
00107 void 
00108 DataCertificationJetMET::beginLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& c)
00109 {
00110 
00111   if (verbose_) std::cout << ">>> BeginLuminosityBlock (DataCertificationJetMET) <<<" << std::endl;
00112   if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id()                   << std::endl;
00113   if (verbose_) std::cout << ">>> run       = " << lumiBlock.id().run()             << std::endl;
00114   if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id().luminosityBlock() << std::endl;
00115 
00116 }
00117 
00118 // ------------ method called just after a lumi section ends  ------------
00119 void 
00120 DataCertificationJetMET::endLuminosityBlock(const edm::LuminosityBlock& lumiBlock, const edm::EventSetup& c)
00121 {
00122 
00123   if (verbose_) std::cout << ">>> EndLuminosityBlock (DataCertificationJetMET) <<<" << std::endl;
00124   if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id()                   << std::endl;
00125   if (verbose_) std::cout << ">>> run       = " << lumiBlock.id().run()             << std::endl;
00126   if (verbose_) std::cout << ">>> lumiBlock = " << lumiBlock.id().luminosityBlock() << std::endl;
00127 
00128   if (verbose_) dbe_->showDirStructure();  
00129 
00130 }
00131 
00132 // ------------ method called just before starting a new run  ------------
00133 void 
00134 DataCertificationJetMET::beginRun(const edm::Run& run, const edm::EventSetup& c)
00135 {
00136 
00137   if (verbose_) std::cout << ">>> BeginRun (DataCertificationJetMET) <<<" << std::endl;
00138   //if (verbose_) std::cout << ">>> run = " << run.id() << std::endl;
00139 
00140 }
00141 
00142 // ------------ method called right after a run ends ------------
00143 void 
00144 DataCertificationJetMET::endRun(const edm::Run& run, const edm::EventSetup& c)
00145 {
00146   
00147   if (verbose_) std::cout << ">>> EndRun (DataCertificationJetMET) <<<" << std::endl;
00148   //if (verbose_) std::cout << ">>> run = " << run.id() << std::endl;
00149 
00150   // -----------------------------------------
00151 
00152   std::vector<MonitorElement*> mes;
00153   std::vector<std::string> subDirVec;
00154   std::string RunDir;
00155   std::string RunNum;
00156   int         RunNumber=0;
00157 
00158   std::string RefRunDir;
00159 
00160   if (verbose_) std::cout << "InMemory_           = " << InMemory_    << std::endl;
00161 
00162   if (InMemory_) {
00163     //----------------------------------------------------------------
00164     // Histograms are in memory (for standard full-chain mode)
00165     //----------------------------------------------------------------
00166 
00167     mes = dbe_->getAllContents("");
00168     if (verbose_) std::cout << "1 >>> found " <<  mes.size() << " monitoring elements!" << std::endl;
00169 
00170     dbe_->setCurrentFolder("JetMET");
00171     subDirVec = dbe_->getSubdirs();
00172     for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
00173          ic != subDirVec.end(); ic++) {    
00174       if (verbose_) std::cout << "-AAA- Dir = >>" << ic->c_str() << "<<" << std::endl;
00175     }
00176 
00177     RunDir    = "";
00178     RunNumber = run.id().run();
00179 
00180   } else {
00181     //----------------------------------------------------------------
00182     // Open input files (for standalone mode)
00183     //----------------------------------------------------------------
00184 
00185     mes = dbe_->getAllContents("");
00186     if (verbose_) std::cout << "found " << mes.size() << " monitoring elements!" << std::endl;
00187     
00188     dbe_->setCurrentFolder("/");
00189     std::string currDir = dbe_->pwd();
00190     if (verbose_) std::cout << "--- Current Directory " << currDir << std::endl;
00191 
00192     subDirVec = dbe_->getSubdirs();
00193 
00194     // *** If the same file is read in then we have only one subdirectory
00195     int ind = 0;
00196     for (std::vector<std::string>::const_iterator ic = subDirVec.begin();
00197          ic != subDirVec.end(); ic++) {
00198       RunDir = *ic;
00199       RunNum = *ic;
00200       if (verbose_) std::cout << "-XXX- Dir = >>" << ic->c_str() << "<<" << std::endl;
00201       ind++;
00202     }
00203 
00204     //
00205     // Current
00206     //
00207     if (RunDir == "JetMET") {
00208       RunDir = "";
00209       if (verbose_) std::cout << "-XXX- RunDir = >>" << RunDir.c_str() << "<<" << std::endl;
00210     }
00211     RunNum.erase(0,4);
00212     if (RunNum!="")
00213     RunNumber = atoi(RunNum.c_str());
00214     if (verbose_) std::cout << "--- >>" << RunNumber << "<<" << std::endl;
00215 
00216   }
00217 
00218   if (verbose_) dbe_->showDirStructure();
00219 
00220   //----------
00221 
00222   dbe_->setCurrentFolder("JetMET/EventInfo/");    
00223   MonitorElement*  reportSummary = dbe_->bookFloat("reportSummary");
00224   MonitorElement*  CertificationSummary = dbe_->bookFloat("CertificationSummary");
00225 
00226   MonitorElement*  reportSummaryMap = dbe_->book2D("reportSummaryMap","reportSummaryMap",3,0,3,5,0,5);
00227   MonitorElement*  CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","CertificationSummaryMap",3,0,3,5,0,5);
00228   reportSummaryMap->getTH2F()->SetStats(kFALSE);
00229   CertificationSummaryMap->getTH2F()->SetStats(kFALSE);
00230   reportSummaryMap->getTH2F()->SetOption("colz");
00231   CertificationSummaryMap->getTH2F()->SetOption("colz");
00232 
00233   reportSummaryMap->setBinLabel(1,"CaloTower");
00234   reportSummaryMap->setBinLabel(2,"MET");
00235   reportSummaryMap->setBinLabel(3,"Jet");
00236 
00237   CertificationSummaryMap->setBinLabel(1,"CaloTower");
00238   CertificationSummaryMap->setBinLabel(2,"MET");
00239   CertificationSummaryMap->setBinLabel(3,"Jet");
00240 
00241   reportSummary->Fill(1.);
00242   CertificationSummary->Fill(1.);
00243 
00244 
00245   if (RunDir=="Reference") RunDir="";
00246   if (verbose_) std::cout << RunDir << std::endl;
00247   dbe_->setCurrentFolder("JetMET/EventInfo/CertificationSummaryContents/");    
00248 
00249   std::string refHistoName;
00250   std::string newHistoName;
00251   
00252   //-----------------------------
00253   // Jet DQM Data Certification
00254   //-----------------------------
00255   MonitorElement *meJetPt[5];
00256   MonitorElement *meJetEta[5];
00257   MonitorElement *meJetPhi[5];
00258   MonitorElement *meJetEMFrac[4];
00259   MonitorElement *meJetConstituents[4];
00260   MonitorElement *meJetNTracks;
00261  
00262   RunDir = "";
00263   if (RunDir == "") newHistoName = "JetMET/Jet/";
00264   else              newHistoName = RunDir+"/JetMET/Run summary/Jet/";
00265   std::string cleaningdir = "";
00266   if (isData)
00267     cleaningdir = "Cleaned";
00268   //Jet Phi histos
00269   meJetPhi[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_Barrel");
00270   meJetPhi[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_EndCap");
00271   meJetPhi[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Phi_Forward");
00272   meJetPhi[3] = dbe_->get(newHistoName+"PFJets/Phi");
00273   meJetPhi[4] = dbe_->get(newHistoName+"JPT/Phi");
00274 
00275   //Jet Eta histos
00276   meJetEta[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
00277   meJetEta[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
00278   meJetEta[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Eta");
00279   meJetEta[3] = dbe_->get(newHistoName+"PFJets/Eta");
00280   meJetEta[4] = dbe_->get(newHistoName+"JPT/Eta");
00281 
00282   //Jet Pt histos
00283   meJetPt[0]  = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_Barrel");
00284   meJetPt[1]  = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_EndCap");
00285   meJetPt[2]  = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Pt_Forward");
00286   meJetPt[3]  = dbe_->get(newHistoName+"PFJets/Pt2");
00287   meJetPt[4]  = dbe_->get(newHistoName+"JPT/Pt2");
00288 
00290   meJetConstituents[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
00291   meJetConstituents[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
00292   meJetConstituents[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/Constituents");
00293   meJetConstituents[3] = dbe_->get(newHistoName+"PFJets/Constituents");
00294   //
00296   meJetEMFrac[0] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
00297   meJetEMFrac[1] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
00298   meJetEMFrac[2] = dbe_->get(newHistoName+cleaningdir+"AntiKtJets/EFrac");
00299   meJetEMFrac[3] = dbe_->get(newHistoName+"PFJets/EFrac");
00300 
00301   //JPT specific histos
00302   meJetNTracks = dbe_->get(newHistoName+"JPT/nTracks");
00303                                    
00304   //------------------------------------------------------------------------------
00305   //--- Extract quality test results and fill data certification results for Jets
00306   //--- Tests for Calo Barrel, EndCap and Forward, as well as PF and JPT jets
00307   //--- For Calo and PF jets:
00308   //--- Look at mean of Constituents, EM Frac and Pt
00309   //--- Look at Kolmogorov result for Eta, Phi, and Pt
00310   //--- For JPT jets:
00311   //--- Look at mean of Pt, AllPionsTrackNHits?, nTracks, 
00312   //--- Look at Kolmogorov result for Eta, Phi, and Pt
00313   //------------------------------------------------------------------------------
00314 
00315   //5 types of Jets {AK5 Barrel, AK5 EndCap, AK5 Forward, PF, JPT}
00316   //--- Method 1
00317   //--Kolmogorov test
00318   const QReport * QReport_JetEta[5];
00319   const QReport * QReport_JetPhi[5];
00320   //--Mean and KS tests
00321   //for Calo and PF jets
00322   const QReport * QReport_JetConstituents[4][2];
00323   const QReport * QReport_JetEFrac[4][2];
00324   const QReport * QReport_JetPt[5][2];
00325   //for JPT jets
00326   const QReport * QReport_JetNTracks[2];
00327 
00328 
00329   float qr_Jet_NTracks[2]         = {-1.};
00330   float qr_Jet_Constituents[4][2] = {{-1.}};
00331   float qr_Jet_EFrac[4][2]        = {{-1.}};
00332   float qr_Jet_Eta[5]             = {-1.};
00333   float qr_Jet_Phi[5]             = {-1.};
00334   float qr_Jet_Pt[5][2]           = {{-1.}};
00335   float dc_Jet[5]                 = {-1.};
00336 
00337   for (int jtyp = 0; jtyp < 5; ++jtyp){
00338     //Mean test results
00339     if (jtyp < 4){
00340       if (meJetConstituents[jtyp]) {
00341           QReport_JetConstituents[jtyp][0] = meJetConstituents[jtyp]->getQReport("meanJetConstituentsTest");
00342           QReport_JetConstituents[jtyp][1] = meJetConstituents[jtyp]->getQReport("KolmogorovTest");
00343       }
00344       if (meJetEMFrac[jtyp]) {
00345         QReport_JetEFrac[jtyp][0]        = meJetEMFrac[jtyp]->getQReport("meanEMFractionTest");
00346         QReport_JetEFrac[jtyp][1]        = meJetEMFrac[jtyp]->getQReport("KolmogorovTest");
00347       }
00348     }
00349     else {
00350       if (meJetNTracks) {
00351         QReport_JetNTracks[0]    = meJetNTracks->getQReport("meanNTracksTest");
00352         QReport_JetNTracks[1]    = meJetNTracks->getQReport("KolmogorovTest");
00353       }
00354     }
00355     if (meJetPt[jtyp]) {
00356       QReport_JetPt[jtyp][0] = meJetPt[jtyp]->getQReport("meanJetPtTest");
00357       QReport_JetPt[jtyp][1] = meJetPt[jtyp]->getQReport("KolmogorovTest");
00358     }
00359     if (meJetPhi[jtyp])
00360       QReport_JetPhi[jtyp]   = meJetPhi[jtyp]->getQReport("KolmogorovTest");
00361     if (meJetEta[jtyp])
00362       QReport_JetEta[jtyp]   = meJetEta[jtyp]->getQReport("KolmogorovTest");
00363     
00364     //Jet Pt test
00365     if (QReport_JetPt[jtyp][0]){
00366       if (QReport_JetPt[jtyp][0]->getStatus()==100 ||
00367           QReport_JetPt[jtyp][0]->getStatus()==200)
00368         qr_Jet_Pt[jtyp][0] = 1;
00369       else if (QReport_JetPt[jtyp][0]->getStatus()==300)
00370         qr_Jet_Pt[jtyp][0] = 0;
00371       else 
00372         qr_Jet_Pt[jtyp][0] = -1;
00373     }
00374     else qr_Jet_Pt[jtyp][0] = -2;
00375     
00376     if (QReport_JetPt[jtyp][1]){
00377       if (QReport_JetPt[jtyp][1]->getStatus()==100 ||
00378           QReport_JetPt[jtyp][1]->getStatus()==200) 
00379         qr_Jet_Pt[jtyp][1] = 1;
00380       else if (QReport_JetPt[jtyp][1]->getStatus()==300) 
00381         qr_Jet_Pt[jtyp][1] = 0;
00382       else
00383         qr_Jet_Pt[jtyp][1] = -1;
00384     }
00385     else qr_Jet_Pt[jtyp][1] = -2;
00386     
00387     //Jet Phi test
00388     if (QReport_JetPhi[jtyp]){
00389       if (QReport_JetPhi[jtyp]->getStatus()==100 ||
00390           QReport_JetPhi[jtyp]->getStatus()==200) 
00391         qr_Jet_Phi[jtyp] = 1;
00392       else if (QReport_JetPhi[jtyp]->getStatus()==300)
00393         qr_Jet_Phi[jtyp] = 0;
00394       else
00395         qr_Jet_Phi[jtyp] = -1;
00396     }
00397     else qr_Jet_Phi[jtyp] = -2;
00398 
00399     //Jet Eta test
00400     if (QReport_JetEta[jtyp]){
00401       if (QReport_JetEta[jtyp]->getStatus()==100 ||
00402           QReport_JetEta[jtyp]->getStatus()==200) 
00403         qr_Jet_Eta[jtyp] = 1;
00404       else if (QReport_JetEta[jtyp]->getStatus()==300) 
00405         qr_Jet_Eta[jtyp] = 0;
00406       else
00407         qr_Jet_Eta[jtyp] = -1;
00408     }
00409     else qr_Jet_Eta[jtyp] = -2;
00410 
00411     if (jtyp < 4) {
00412       //Jet Constituents test
00413       if (QReport_JetConstituents[jtyp][0]){
00414         if (QReport_JetConstituents[jtyp][0]->getStatus()==100 ||
00415             QReport_JetConstituents[jtyp][0]->getStatus()==200) 
00416           qr_Jet_Constituents[jtyp][0] = 1;
00417         else if (QReport_JetConstituents[jtyp][0]->getStatus()==300) 
00418           qr_Jet_Constituents[jtyp][0] = 0;
00419         else
00420           qr_Jet_Constituents[jtyp][0] = -1;
00421       }
00422       else qr_Jet_Constituents[jtyp][0] = -2;
00423 
00424       if (QReport_JetConstituents[jtyp][1]){
00425         if (QReport_JetConstituents[jtyp][1]->getStatus()==100 ||
00426             QReport_JetConstituents[jtyp][1]->getStatus()==200) 
00427           qr_Jet_Constituents[jtyp][1] = 1;
00428         else if (QReport_JetConstituents[jtyp][1]->getStatus()==300) 
00429           qr_Jet_Constituents[jtyp][1] = 0;
00430         else
00431           qr_Jet_Constituents[jtyp][1] = -1;
00432       }
00433       else qr_Jet_Constituents[jtyp][1] = -2;
00434 
00435       //Jet EMFrac test
00436       if (QReport_JetEFrac[jtyp][0]){
00437         if (QReport_JetEFrac[jtyp][0]->getStatus()==100 ||
00438             QReport_JetEFrac[jtyp][0]->getStatus()==200) 
00439           qr_Jet_EFrac[jtyp][0] = 1;
00440         else if (QReport_JetEFrac[jtyp][0]->getStatus()==300) 
00441           qr_Jet_EFrac[jtyp][0] = 0;
00442         else
00443           qr_Jet_EFrac[jtyp][0] = -1;
00444       }
00445       else qr_Jet_EFrac[jtyp][0] = -2;
00446       
00447       if (QReport_JetEFrac[jtyp][1]){
00448         if (QReport_JetEFrac[jtyp][1]->getStatus()==100 ||
00449             QReport_JetEFrac[jtyp][1]->getStatus()==200) 
00450           qr_Jet_EFrac[jtyp][1] = 1;
00451         else if (QReport_JetEFrac[jtyp][1]->getStatus()==300) 
00452           qr_Jet_EFrac[jtyp][1] = 0;
00453         else
00454           qr_Jet_EFrac[jtyp][1] = -1;
00455       }
00456       else qr_Jet_EFrac[jtyp][1] = -2;
00457     }
00458     else {
00459       for (int ii = 0; ii < 2; ++ii) {
00460         //Jet NTracks test
00461         if (QReport_JetNTracks[ii]){
00462           if (QReport_JetNTracks[ii]->getStatus()==100 ||
00463               QReport_JetNTracks[ii]->getStatus()==200) 
00464             qr_Jet_NTracks[ii] = 1;
00465           else if (QReport_JetNTracks[ii]->getStatus()==300) 
00466             qr_Jet_NTracks[ii] = 0;
00467           else
00468             qr_Jet_NTracks[ii] = -1;
00469         }
00470         else qr_Jet_NTracks[ii] = -2;
00471       }
00472     }
00473     
00474     if (verbose_) {
00475       printf("====================Jet Type %d QTest Report Summary========================\n",jtyp);
00476       printf("Eta:    Phi:   Pt 1:    2:    Const/Ntracks 1:    2:    EFrac/tracknhits 1:    2:\n");
00477       if (jtyp<4) {
00478         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n", \
00479                qr_Jet_Eta[jtyp],                                        \
00480                qr_Jet_Phi[jtyp],                                        \
00481                qr_Jet_Pt[jtyp][0],                                      \
00482                qr_Jet_Pt[jtyp][1],                                      \
00483                qr_Jet_Constituents[jtyp][0],                            \
00484                qr_Jet_Constituents[jtyp][1],                            \
00485                qr_Jet_EFrac[jtyp][0],                                   \
00486                qr_Jet_EFrac[jtyp][1]);
00487       }
00488       else {
00489         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",  \
00490                qr_Jet_Eta[jtyp],                                        \
00491                qr_Jet_Phi[jtyp],                                        \
00492                qr_Jet_Pt[jtyp][0],                                      \
00493                qr_Jet_Pt[jtyp][1],                                      \
00494                qr_Jet_NTracks[0],                                       \
00495                qr_Jet_NTracks[1]);
00496       }
00497       printf("===========================================================================\n");
00498     }
00499     //certification result for Jet
00500 
00501     //Only apply certain tests, as defined in the config
00502     for (int ttyp = 0; ttyp < 2;  ++ttyp) {
00503       if (!jetTests[jtyp][ttyp]) {
00504         qr_Jet_Pt[jtyp][ttyp]           = 1;
00505         if (ttyp ==1) {
00506           qr_Jet_Eta[jtyp]          = 1;
00507           qr_Jet_Phi[jtyp]          = 1;
00508         }
00509         if (jtyp < 4) {
00510           qr_Jet_EFrac[jtyp][ttyp]        = 1;
00511           qr_Jet_Constituents[jtyp][ttyp] = 1;
00512         }
00513         else{
00514           qr_Jet_NTracks[ttyp] = 1;
00515         }
00516       }
00517     }
00518     
00519     
00520     if (jtyp < 4) {
00521       if ( (qr_Jet_EFrac[jtyp][0]        == 0) ||
00522            (qr_Jet_EFrac[jtyp][1]        == 0) ||
00523            (qr_Jet_Constituents[jtyp][1] == 0) || 
00524            (qr_Jet_Constituents[jtyp][0] == 0) ||
00525            (qr_Jet_Eta[jtyp]             == 0) ||
00526            (qr_Jet_Phi[jtyp]             == 0) ||
00527            (qr_Jet_Pt[jtyp][0]           == 0) ||
00528            (qr_Jet_Pt[jtyp][1]           == 0)
00529            )
00530         dc_Jet[jtyp] = 0;
00531       else if ( (qr_Jet_EFrac[jtyp][0]        == -1) &&
00532                 (qr_Jet_EFrac[jtyp][1]        == -1) &&
00533                 (qr_Jet_Constituents[jtyp][1] == -1) && 
00534                 (qr_Jet_Constituents[jtyp][0] == -1) &&
00535                 (qr_Jet_Eta[jtyp]             == -1) &&
00536                 (qr_Jet_Phi[jtyp]             == -1) &&
00537                 (qr_Jet_Pt[jtyp][0]           == -1) &&
00538                 (qr_Jet_Pt[jtyp][1]           == -1 )
00539                 )
00540         dc_Jet[jtyp] = -1;
00541       else if ( (qr_Jet_EFrac[jtyp][0]   == -2) &&
00542            (qr_Jet_EFrac[jtyp][1]        == -2) &&
00543            (qr_Jet_Constituents[jtyp][1] == -2) && 
00544            (qr_Jet_Constituents[jtyp][0] == -2) &&
00545            (qr_Jet_Eta[jtyp]             == -2) &&
00546            (qr_Jet_Phi[jtyp]             == -2) &&
00547            (qr_Jet_Pt[jtyp][0]           == -2) &&
00548            (qr_Jet_Pt[jtyp][1]           == -2)
00549            )
00550         dc_Jet[jtyp] = -2;
00551       else
00552         dc_Jet[jtyp] = 1;
00553     }
00554     else {
00555       if ( (qr_Jet_NTracks[0]  == 0) || 
00556            (qr_Jet_NTracks[1]  == 0) ||
00557            (qr_Jet_Eta[jtyp]   == 0) ||
00558            (qr_Jet_Phi[jtyp]   == 0) ||
00559            (qr_Jet_Pt[jtyp][0] == 0) ||
00560            (qr_Jet_Pt[jtyp][1] == 0)
00561            )
00562         dc_Jet[jtyp] = 0;
00563       else if ( (qr_Jet_NTracks[0]  == -1) && 
00564                 (qr_Jet_NTracks[1]  == -1) &&
00565                 (qr_Jet_Eta[jtyp]   == -1) &&
00566                 (qr_Jet_Phi[jtyp]   == -1) &&
00567                 (qr_Jet_Pt[jtyp][0] == -1) &&
00568                 (qr_Jet_Pt[jtyp][1] == -1)
00569                 )
00570         dc_Jet[jtyp] = -1;
00571       else if ( (qr_Jet_NTracks[0] == -2) &&
00572            (qr_Jet_NTracks[1]      == -2) &&
00573            (qr_Jet_Eta[jtyp]       == -2) &&
00574            (qr_Jet_Phi[jtyp]       == -2) &&
00575            (qr_Jet_Pt[jtyp][0]     == -2) &&
00576            (qr_Jet_Pt[jtyp][1]     == -2)
00577            )
00578         dc_Jet[jtyp] = -2;
00579       else
00580         dc_Jet[jtyp] = 1;
00581     }
00582     
00583     if (verbose_) std::cout<<"Certifying Jet algo: "<<jtyp<<" with value: "<<dc_Jet[jtyp]<<std::endl;
00584     CertificationSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
00585     reportSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
00586   }
00587 
00588 
00589   //-----------------------------
00590   // MET DQM Data Certification
00591   //-----------------------------
00592 
00593   //
00594   // Prepare test histograms
00595   //
00596   MonitorElement *meMExy[5][2];
00597   MonitorElement *meMEt[5];
00598   MonitorElement *meSumEt[5];
00599   MonitorElement *meMETPhi[5];
00600   //MonitorElement *meMETEMFrac[5];
00601   //MonitorElement *meMETEmEt[3][2];
00602   //MonitorElement *meMETHadEt[3][2];
00603  
00604   RunDir = "";
00605   if (RunDir == "") newHistoName = "JetMET/MET/";
00606   else              newHistoName = RunDir+"/JetMET/Run summary/MET/";
00607 
00608   if (isData)
00609     cleaningdir = "BasicCleanup";
00610   else
00611     cleaningdir = "All";
00612   //MEx/MEy monitor elements
00613   meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00614   meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00615   meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00616   meMExy[1][1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00617   meMExy[2][0] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEx");
00618   meMExy[2][1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEy");
00619   meMExy[3][0] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEx");
00620   meMExy[3][1] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEy");
00621   meMExy[4][0] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00622   meMExy[4][1] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00623   //MET Phi monitor elements
00624   meMETPhi[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00625   meMETPhi[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00626   meMETPhi[2]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMETPhi");
00627   meMETPhi[3]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_METPhi");
00628   meMETPhi[4]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00629   //MET monitor elements
00630   meMEt[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00631   meMEt[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00632   meMEt[2]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMET");
00633   meMEt[3]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MET");
00634   meMEt[4]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00635   //SumET monitor elements
00636   meSumEt[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00637   meSumEt[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00638   meSumEt[2]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfSumET");
00639   meSumEt[3]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_SumET");
00640   meSumEt[4]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00641                                    
00642   //----------------------------------------------------------------------------
00643   //--- Extract quality test results and fill data certification results for MET
00644   //----------------------------------------------------------------------------
00645 
00646   //5 types of MET {CaloMET, CaloMETNoHF, PfMET, TcMET, MuCorrMET}
00647   //2 types of tests Mean test/Kolmogorov test
00648   const QReport * QReport_MExy[5][2][2];
00649   const QReport * QReport_MEt[5][2];
00650   const QReport * QReport_SumEt[5][2];
00651   //2 types of tests phiQTest and Kolmogorov test
00652   const QReport * QReport_METPhi[5][2];
00653 
00654 
00655   float qr_MET_MExy[5][2][2] = {{{-999.}}};
00656   float qr_MET_MEt[5][2]     = {{-999.}};
00657   float qr_MET_SumEt[5][2]   = {{-999.}};
00658   float qr_MET_METPhi[5][2]  = {{-999.}};
00659   float dc_MET[5]            = {-999.};
00660 
00661   for (int mtyp = 0; mtyp < 5; ++mtyp){
00662     //Mean test results
00663     //std::cout<<"meMEx = :"<<meMExy[mtyp][0]<<std::endl;
00664     //std::cout<<"meMEy = :"<<meMExy[mtyp][1]<<std::endl;
00665     //std::cout<<"meMET = :"<<meMEt[mtyp]<<std::endl;
00666     //std::cout<<"meMETPhi = :"<<meMExy[mtyp]<<std::endl;
00667     //std::cout<<"meSumEt = :"<<meMExy[mtyp]<<std::endl;
00668     if (meMExy[mtyp][0]) {
00669       QReport_MExy[mtyp][0][0] = meMExy[mtyp][0]->getQReport("meanMExyTest");
00670       QReport_MExy[mtyp][1][0] = meMExy[mtyp][0]->getQReport("KolmogorovTest");
00671     }
00672     if (meMExy[mtyp][1]) {
00673       QReport_MExy[mtyp][0][1] = meMExy[mtyp][1]->getQReport("meanMExyTest");
00674       QReport_MExy[mtyp][1][1] = meMExy[mtyp][1]->getQReport("KolmogorovTest");
00675     }
00676     if (meMEt[mtyp]) {
00677       QReport_MEt[mtyp][0]     = meMEt[mtyp]->getQReport("meanMETTest");
00678       QReport_MEt[mtyp][1]     = meMEt[mtyp]->getQReport("KolmogorovTest");
00679     }
00680 
00681     if (meSumEt[mtyp]) {
00682       QReport_SumEt[mtyp][0]   = meSumEt[mtyp]->getQReport("meanSumETTest");
00683       QReport_SumEt[mtyp][1]   = meSumEt[mtyp]->getQReport("KolmogorovTest");
00684     }
00685 
00686     if (meMETPhi[mtyp]) {
00687       QReport_METPhi[mtyp][0]  = meMETPhi[mtyp]->getQReport("phiQTest");
00688       QReport_METPhi[mtyp][1]  = meMETPhi[mtyp]->getQReport("KolmogorovTest");
00689     }    
00690     for (int testtyp = 0; testtyp < 2; ++testtyp) {
00691       //MEx test
00692       if (QReport_MExy[mtyp][testtyp][0]){
00693         if (QReport_MExy[mtyp][testtyp][0]->getStatus()==100 ||
00694             QReport_MExy[mtyp][testtyp][0]->getStatus()==200) 
00695           qr_MET_MExy[mtyp][testtyp][0] = 1;
00696         else if (QReport_MExy[mtyp][testtyp][0]->getStatus()==300) 
00697           qr_MET_MExy[mtyp][testtyp][0] = 0;
00698         else
00699           qr_MET_MExy[mtyp][testtyp][0] = -1;
00700       }
00701       else qr_MET_MExy[mtyp][testtyp][0] = -2;
00702 
00703       //MEy test
00704       if (QReport_MExy[mtyp][testtyp][1]){
00705         if (QReport_MExy[mtyp][testtyp][1]->getStatus()==100 ||
00706             QReport_MExy[mtyp][testtyp][1]->getStatus()==200) 
00707           qr_MET_MExy[mtyp][testtyp][1] = 1;
00708         else if (QReport_MExy[mtyp][testtyp][1]->getStatus()==300) 
00709           qr_MET_MExy[mtyp][testtyp][1] = 0;
00710         else
00711           qr_MET_MExy[mtyp][testtyp][1] = -1;
00712       }
00713       else qr_MET_MExy[mtyp][testtyp][1] = -2;
00714 
00715       //MEt test
00716       if (QReport_MEt[mtyp][testtyp]){
00717         if (QReport_MEt[mtyp][testtyp]->getStatus()==100 ||
00718             QReport_MEt[mtyp][testtyp]->getStatus()==200) 
00719           qr_MET_MEt[mtyp][testtyp] = 1;
00720         else if (QReport_MEt[mtyp][testtyp]->getStatus()==300) 
00721           qr_MET_MEt[mtyp][testtyp] = 0;
00722         else
00723           qr_MET_MEt[mtyp][testtyp] = -1;
00724       }
00725       else qr_MET_MEt[mtyp][testtyp] = -2;
00726 
00727       //SumEt test
00728       if (QReport_SumEt[mtyp][testtyp]){
00729         if (QReport_SumEt[mtyp][testtyp]->getStatus()==100 ||
00730             QReport_SumEt[mtyp][testtyp]->getStatus()==200) 
00731           qr_MET_SumEt[mtyp][testtyp] = 1;
00732         else if (QReport_SumEt[mtyp][testtyp]->getStatus()==300) 
00733           qr_MET_SumEt[mtyp][testtyp] = 0;
00734         else
00735           qr_MET_SumEt[mtyp][testtyp] = -1;
00736       }
00737       else qr_MET_SumEt[mtyp][testtyp] = -2;
00738 
00739       //METPhi test
00740       if (QReport_METPhi[mtyp][testtyp]){
00741         if (QReport_METPhi[mtyp][testtyp]->getStatus()==100 ||
00742             QReport_METPhi[mtyp][testtyp]->getStatus()==200) 
00743           qr_MET_METPhi[mtyp][testtyp] = 1;
00744         else if (QReport_METPhi[mtyp][testtyp]->getStatus()==300) 
00745           qr_MET_METPhi[mtyp][testtyp] = 0;
00746         else
00747           qr_MET_METPhi[mtyp][testtyp] = -1;
00748       }
00749       else qr_MET_METPhi[mtyp][testtyp] = -2;
00750     }
00751 
00752     if (verbose_) {
00753       //certification result for MET
00754       printf("====================MET Type %d QTest Report Summary========================\n",mtyp);
00755       printf("MEx test    MEy test    MEt test:    SumEt test:    METPhi test:\n");
00756       for (int tt = 0; tt < 2; ++tt) {
00757         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",qr_MET_MExy[mtyp][tt][0], \
00758                qr_MET_MExy[mtyp][tt][1],                                \
00759                qr_MET_MEt[mtyp][tt],                                    \
00760                qr_MET_SumEt[mtyp][tt],                                  \
00761                qr_MET_METPhi[mtyp][tt]);
00762       }
00763       printf("===========================================================================\n");
00764     }
00765 
00766 
00767     //Only apply certain tests, as defined in the config
00768     for (int ttyp = 0; ttyp < 2;  ++ttyp) {
00769       if (!metTests[mtyp][ttyp]) {
00770         qr_MET_MExy[mtyp][ttyp][0]   = 1;
00771         qr_MET_MExy[mtyp][ttyp][1]   = 1;
00772         qr_MET_MEt[mtyp][ttyp]       = 1;
00773         qr_MET_SumEt[mtyp][ttyp]     = 1;
00774         qr_MET_METPhi[mtyp][ttyp]    = 1;
00775       }
00776     }
00777     
00778 
00779     if ( 
00780         (qr_MET_MExy[mtyp][0][0] == 0) ||
00781         (qr_MET_MExy[mtyp][0][1] == 0) ||
00782         (qr_MET_MEt[mtyp][0]     == 0) ||
00783         (qr_MET_SumEt[mtyp][0]   == 0) ||
00784         (qr_MET_METPhi[mtyp][0]  == 0) ||
00785         (qr_MET_MExy[mtyp][1][0] == 0) ||
00786         (qr_MET_MExy[mtyp][1][1] == 0) ||
00787         (qr_MET_MEt[mtyp][1]     == 0) ||
00788         (qr_MET_SumEt[mtyp][1]   == 0) ||
00789         (qr_MET_METPhi[mtyp][1]  == 0)
00790         )
00791       dc_MET[mtyp] = 0;
00792     else if (
00793              (qr_MET_MExy[mtyp][0][0] == -1) &&
00794              (qr_MET_MExy[mtyp][0][1] == -1) &&
00795              (qr_MET_MEt[mtyp][0]     == -1) &&
00796              (qr_MET_SumEt[mtyp][0]   == -1) &&
00797              (qr_MET_METPhi[mtyp][0]  == -1) &&
00798              (qr_MET_MExy[mtyp][1][0] == -1) &&
00799              (qr_MET_MExy[mtyp][1][1] == -1) &&
00800              (qr_MET_MEt[mtyp][1]     == -1) &&
00801              (qr_MET_SumEt[mtyp][1]   == -1) &&
00802              (qr_MET_METPhi[mtyp][1]  == -1)
00803              )
00804       dc_MET[mtyp] = -1;
00805     else if ( 
00806         (qr_MET_MExy[mtyp][0][0] == -2) &&
00807         (qr_MET_MExy[mtyp][0][1] == -2) &&
00808         (qr_MET_MEt[mtyp][0]     == -2) &&
00809         (qr_MET_SumEt[mtyp][0]   == -2) &&
00810         (qr_MET_METPhi[mtyp][0]  == -2) &&
00811         (qr_MET_MExy[mtyp][1][0] == -2) &&
00812         (qr_MET_MExy[mtyp][1][1] == -2) &&
00813         (qr_MET_MEt[mtyp][1]     == -2) &&
00814         (qr_MET_SumEt[mtyp][1]   == -2) &&
00815         (qr_MET_METPhi[mtyp][1]  == -2)
00816         )
00817       dc_MET[mtyp] = -2;
00818     else
00819       dc_MET[mtyp] = 1;
00820 
00821     if (verbose_) std::cout<<"Certifying MET algo: "<<mtyp<<" with value: "<<dc_MET[mtyp]<<std::endl;
00822     CertificationSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
00823     reportSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
00824   }
00825 
00826 
00827   //-----------------------------
00828   // CaloTowers DQM Data Certification
00829   //-----------------------------
00830 
00831   //
00832   // Prepare test histograms
00833   //
00834   //MonitorElement *meCTOcc[3];
00835   //MonitorElement *meCTEn[3];
00836   //MonitorElement *meCT[3];
00837   //MonitorElement *meCT[3];
00838  
00839   //RunDir = "";
00840   //if (RunDir == "") newHistoName = "JetMET/MET/";
00841   //else              newHistoName = RunDir+"/JetMET/Run summary/MET/";
00842 
00843   //meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00844   //meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00845   //meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00846                                    
00847   //----------------------------------------------------------------------------
00848   //--- Extract quality test results and fill data certification results for MET
00849   //----------------------------------------------------------------------------
00850 
00851   float qr_CT_Occ[3] = {-2.};
00852   float dc_CT[3]     = {-2.};
00853   dc_CT[0]  = -2.;
00854   dc_CT[1]  = -2.;
00855   dc_CT[2]  = -2.;
00856 
00857   qr_CT_Occ[0]  = dc_CT[0];
00858   qr_CT_Occ[1]  = dc_CT[1];
00859   qr_CT_Occ[2]  = dc_CT[2];
00860 
00861   for (int cttyp = 0; cttyp < 3; ++cttyp) {
00862     
00863     if (verbose_) std::cout<<"Certifying CaloTowers with value: "<<dc_CT[cttyp]<<std::endl;
00864     CertificationSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
00865     reportSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
00866   }
00867   dbe_->setCurrentFolder("");  
00868 
00869 }
00870 
00871 //define this as a plug-in
00872 //DEFINE_FWK_MODULE(DataCertificationJetMET);