CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch2/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.53 2012/07/10 08:14:16 piedra 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 
00316   // Five types of jets {AK5 Barrel, AK5 EndCap, AK5 Forward, PF, JPT}
00317   //----------------------------------------------------------------------------
00318   // Kolmogorov (KS) tests
00319   const QReport* QReport_JetEta[5] = {0, 0, 0, 0, 0};
00320   const QReport* QReport_JetPhi[5] = {0, 0, 0, 0, 0};
00321 
00322   // Mean and KS tests for Calo and PF jets
00323   const QReport* QReport_JetConstituents[4][2] = {{0,0}, {0,0}, {0,0}, {0,0}};
00324   const QReport* QReport_JetEFrac[4][2]        = {{0,0}, {0,0}, {0,0}, {0,0}};
00325   const QReport* QReport_JetPt[5][2]           = {{0,0}, {0,0}, {0,0}, {0,0}, {0,0}};
00326 
00327   // Mean and KS tests for JPT jets
00328   const QReport* QReport_JetNTracks[2] = {0, 0};
00329 
00330   float qr_Jet_NTracks[2] = {-1, -1};
00331   float qr_Jet_Eta[5]     = {-1, -1, -1, -1, -1};
00332   float qr_Jet_Phi[5]     = {-1, -1, -1, -1, -1};
00333   float dc_Jet[5]         = {-1, -1, -1, -1, -1};
00334 
00335   float qr_Jet_Constituents[4][2] = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
00336   float qr_Jet_EFrac[4][2]        = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
00337   float qr_Jet_Pt[5][2]           = {{-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}, {-1,-1}};
00338 
00339 
00340   // Loop
00341   //----------------------------------------------------------------------------
00342   for (int jtyp=0; jtyp<5; ++jtyp) {
00343 
00344     // Mean test results
00345     if (jtyp < 4){
00346       if (meJetConstituents[jtyp]) {
00347           QReport_JetConstituents[jtyp][0] = meJetConstituents[jtyp]->getQReport("meanJetConstituentsTest");
00348           QReport_JetConstituents[jtyp][1] = meJetConstituents[jtyp]->getQReport("KolmogorovTest");
00349       }
00350       if (meJetEMFrac[jtyp]) {
00351         QReport_JetEFrac[jtyp][0]        = meJetEMFrac[jtyp]->getQReport("meanEMFractionTest");
00352         QReport_JetEFrac[jtyp][1]        = meJetEMFrac[jtyp]->getQReport("KolmogorovTest");
00353       }
00354     }
00355     else {
00356       if (meJetNTracks) {
00357         QReport_JetNTracks[0]    = meJetNTracks->getQReport("meanNTracksTest");
00358         QReport_JetNTracks[1]    = meJetNTracks->getQReport("KolmogorovTest");
00359       }
00360     }
00361     if (meJetPt[jtyp]) {
00362       QReport_JetPt[jtyp][0] = meJetPt[jtyp]->getQReport("meanJetPtTest");
00363       QReport_JetPt[jtyp][1] = meJetPt[jtyp]->getQReport("KolmogorovTest");
00364     }
00365     if (meJetPhi[jtyp])
00366       QReport_JetPhi[jtyp]   = meJetPhi[jtyp]->getQReport("KolmogorovTest");
00367     if (meJetEta[jtyp])
00368       QReport_JetEta[jtyp]   = meJetEta[jtyp]->getQReport("KolmogorovTest");
00369     
00370     //Jet Pt test
00371     if (QReport_JetPt[jtyp][0]){
00372       if (QReport_JetPt[jtyp][0]->getStatus()==100 ||
00373           QReport_JetPt[jtyp][0]->getStatus()==200)
00374         qr_Jet_Pt[jtyp][0] = 1;
00375       else if (QReport_JetPt[jtyp][0]->getStatus()==300)
00376         qr_Jet_Pt[jtyp][0] = 0;
00377       else 
00378         qr_Jet_Pt[jtyp][0] = -1;
00379     }
00380     else qr_Jet_Pt[jtyp][0] = -2;
00381     
00382     if (QReport_JetPt[jtyp][1]){
00383       if (QReport_JetPt[jtyp][1]->getStatus()==100 ||
00384           QReport_JetPt[jtyp][1]->getStatus()==200) 
00385         qr_Jet_Pt[jtyp][1] = 1;
00386       else if (QReport_JetPt[jtyp][1]->getStatus()==300) 
00387         qr_Jet_Pt[jtyp][1] = 0;
00388       else
00389         qr_Jet_Pt[jtyp][1] = -1;
00390     }
00391     else qr_Jet_Pt[jtyp][1] = -2;
00392     
00393     //Jet Phi test
00394     if (QReport_JetPhi[jtyp]){
00395       if (QReport_JetPhi[jtyp]->getStatus()==100 ||
00396           QReport_JetPhi[jtyp]->getStatus()==200) 
00397         qr_Jet_Phi[jtyp] = 1;
00398       else if (QReport_JetPhi[jtyp]->getStatus()==300)
00399         qr_Jet_Phi[jtyp] = 0;
00400       else
00401         qr_Jet_Phi[jtyp] = -1;
00402     }
00403     else qr_Jet_Phi[jtyp] = -2;
00404 
00405     //Jet Eta test
00406     if (QReport_JetEta[jtyp]){
00407       if (QReport_JetEta[jtyp]->getStatus()==100 ||
00408           QReport_JetEta[jtyp]->getStatus()==200) 
00409         qr_Jet_Eta[jtyp] = 1;
00410       else if (QReport_JetEta[jtyp]->getStatus()==300) 
00411         qr_Jet_Eta[jtyp] = 0;
00412       else
00413         qr_Jet_Eta[jtyp] = -1;
00414     }
00415     else qr_Jet_Eta[jtyp] = -2;
00416 
00417     if (jtyp < 4) {
00418       //Jet Constituents test
00419       if (QReport_JetConstituents[jtyp][0]){
00420         if (QReport_JetConstituents[jtyp][0]->getStatus()==100 ||
00421             QReport_JetConstituents[jtyp][0]->getStatus()==200) 
00422           qr_Jet_Constituents[jtyp][0] = 1;
00423         else if (QReport_JetConstituents[jtyp][0]->getStatus()==300) 
00424           qr_Jet_Constituents[jtyp][0] = 0;
00425         else
00426           qr_Jet_Constituents[jtyp][0] = -1;
00427       }
00428       else qr_Jet_Constituents[jtyp][0] = -2;
00429 
00430       if (QReport_JetConstituents[jtyp][1]){
00431         if (QReport_JetConstituents[jtyp][1]->getStatus()==100 ||
00432             QReport_JetConstituents[jtyp][1]->getStatus()==200) 
00433           qr_Jet_Constituents[jtyp][1] = 1;
00434         else if (QReport_JetConstituents[jtyp][1]->getStatus()==300) 
00435           qr_Jet_Constituents[jtyp][1] = 0;
00436         else
00437           qr_Jet_Constituents[jtyp][1] = -1;
00438       }
00439       else qr_Jet_Constituents[jtyp][1] = -2;
00440 
00441       //Jet EMFrac test
00442       if (QReport_JetEFrac[jtyp][0]){
00443         if (QReport_JetEFrac[jtyp][0]->getStatus()==100 ||
00444             QReport_JetEFrac[jtyp][0]->getStatus()==200) 
00445           qr_Jet_EFrac[jtyp][0] = 1;
00446         else if (QReport_JetEFrac[jtyp][0]->getStatus()==300) 
00447           qr_Jet_EFrac[jtyp][0] = 0;
00448         else
00449           qr_Jet_EFrac[jtyp][0] = -1;
00450       }
00451       else qr_Jet_EFrac[jtyp][0] = -2;
00452       
00453       if (QReport_JetEFrac[jtyp][1]){
00454         if (QReport_JetEFrac[jtyp][1]->getStatus()==100 ||
00455             QReport_JetEFrac[jtyp][1]->getStatus()==200) 
00456           qr_Jet_EFrac[jtyp][1] = 1;
00457         else if (QReport_JetEFrac[jtyp][1]->getStatus()==300) 
00458           qr_Jet_EFrac[jtyp][1] = 0;
00459         else
00460           qr_Jet_EFrac[jtyp][1] = -1;
00461       }
00462       else qr_Jet_EFrac[jtyp][1] = -2;
00463     }
00464     else {
00465       for (int ii = 0; ii < 2; ++ii) {
00466         //Jet NTracks test
00467         if (QReport_JetNTracks[ii]){
00468           if (QReport_JetNTracks[ii]->getStatus()==100 ||
00469               QReport_JetNTracks[ii]->getStatus()==200) 
00470             qr_Jet_NTracks[ii] = 1;
00471           else if (QReport_JetNTracks[ii]->getStatus()==300) 
00472             qr_Jet_NTracks[ii] = 0;
00473           else
00474             qr_Jet_NTracks[ii] = -1;
00475         }
00476         else qr_Jet_NTracks[ii] = -2;
00477       }
00478     }
00479     
00480     if (verbose_) {
00481       printf("====================Jet Type %d QTest Report Summary========================\n",jtyp);
00482       printf("Eta:    Phi:   Pt 1:    2:    Const/Ntracks 1:    2:    EFrac/tracknhits 1:    2:\n");
00483       if (jtyp<4) {
00484         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n", \
00485                qr_Jet_Eta[jtyp],                                        \
00486                qr_Jet_Phi[jtyp],                                        \
00487                qr_Jet_Pt[jtyp][0],                                      \
00488                qr_Jet_Pt[jtyp][1],                                      \
00489                qr_Jet_Constituents[jtyp][0],                            \
00490                qr_Jet_Constituents[jtyp][1],                            \
00491                qr_Jet_EFrac[jtyp][0],                                   \
00492                qr_Jet_EFrac[jtyp][1]);
00493       }
00494       else {
00495         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",  \
00496                qr_Jet_Eta[jtyp],                                        \
00497                qr_Jet_Phi[jtyp],                                        \
00498                qr_Jet_Pt[jtyp][0],                                      \
00499                qr_Jet_Pt[jtyp][1],                                      \
00500                qr_Jet_NTracks[0],                                       \
00501                qr_Jet_NTracks[1]);
00502       }
00503       printf("===========================================================================\n");
00504     }
00505     //certification result for Jet
00506 
00507     //Only apply certain tests, as defined in the config
00508     for (int ttyp = 0; ttyp < 2;  ++ttyp) {
00509       if (!jetTests[jtyp][ttyp]) {
00510         qr_Jet_Pt[jtyp][ttyp]           = 1;
00511         if (ttyp ==1) {
00512           qr_Jet_Eta[jtyp]          = 1;
00513           qr_Jet_Phi[jtyp]          = 1;
00514         }
00515         if (jtyp < 4) {
00516           qr_Jet_EFrac[jtyp][ttyp]        = 1;
00517           qr_Jet_Constituents[jtyp][ttyp] = 1;
00518         }
00519         else{
00520           qr_Jet_NTracks[ttyp] = 1;
00521         }
00522       }
00523     }
00524     
00525     
00526     if (jtyp < 4) {
00527       if ( (qr_Jet_EFrac[jtyp][0]        == 0) ||
00528            (qr_Jet_EFrac[jtyp][1]        == 0) ||
00529            (qr_Jet_Constituents[jtyp][1] == 0) || 
00530            (qr_Jet_Constituents[jtyp][0] == 0) ||
00531            (qr_Jet_Eta[jtyp]             == 0) ||
00532            (qr_Jet_Phi[jtyp]             == 0) ||
00533            (qr_Jet_Pt[jtyp][0]           == 0) ||
00534            (qr_Jet_Pt[jtyp][1]           == 0)
00535            )
00536         dc_Jet[jtyp] = 0;
00537       else if ( (qr_Jet_EFrac[jtyp][0]        == -1) &&
00538                 (qr_Jet_EFrac[jtyp][1]        == -1) &&
00539                 (qr_Jet_Constituents[jtyp][1] == -1) && 
00540                 (qr_Jet_Constituents[jtyp][0] == -1) &&
00541                 (qr_Jet_Eta[jtyp]             == -1) &&
00542                 (qr_Jet_Phi[jtyp]             == -1) &&
00543                 (qr_Jet_Pt[jtyp][0]           == -1) &&
00544                 (qr_Jet_Pt[jtyp][1]           == -1 )
00545                 )
00546         dc_Jet[jtyp] = -1;
00547       else if ( (qr_Jet_EFrac[jtyp][0]   == -2) &&
00548            (qr_Jet_EFrac[jtyp][1]        == -2) &&
00549            (qr_Jet_Constituents[jtyp][1] == -2) && 
00550            (qr_Jet_Constituents[jtyp][0] == -2) &&
00551            (qr_Jet_Eta[jtyp]             == -2) &&
00552            (qr_Jet_Phi[jtyp]             == -2) &&
00553            (qr_Jet_Pt[jtyp][0]           == -2) &&
00554            (qr_Jet_Pt[jtyp][1]           == -2)
00555            )
00556         dc_Jet[jtyp] = -2;
00557       else
00558         dc_Jet[jtyp] = 1;
00559     }
00560     else {
00561       if ( (qr_Jet_NTracks[0]  == 0) || 
00562            (qr_Jet_NTracks[1]  == 0) ||
00563            (qr_Jet_Eta[jtyp]   == 0) ||
00564            (qr_Jet_Phi[jtyp]   == 0) ||
00565            (qr_Jet_Pt[jtyp][0] == 0) ||
00566            (qr_Jet_Pt[jtyp][1] == 0)
00567            )
00568         dc_Jet[jtyp] = 0;
00569       else if ( (qr_Jet_NTracks[0]  == -1) && 
00570                 (qr_Jet_NTracks[1]  == -1) &&
00571                 (qr_Jet_Eta[jtyp]   == -1) &&
00572                 (qr_Jet_Phi[jtyp]   == -1) &&
00573                 (qr_Jet_Pt[jtyp][0] == -1) &&
00574                 (qr_Jet_Pt[jtyp][1] == -1)
00575                 )
00576         dc_Jet[jtyp] = -1;
00577       else if ( (qr_Jet_NTracks[0] == -2) &&
00578            (qr_Jet_NTracks[1]      == -2) &&
00579            (qr_Jet_Eta[jtyp]       == -2) &&
00580            (qr_Jet_Phi[jtyp]       == -2) &&
00581            (qr_Jet_Pt[jtyp][0]     == -2) &&
00582            (qr_Jet_Pt[jtyp][1]     == -2)
00583            )
00584         dc_Jet[jtyp] = -2;
00585       else
00586         dc_Jet[jtyp] = 1;
00587     }
00588     
00589     if (verbose_) std::cout<<"Certifying Jet algo: "<<jtyp<<" with value: "<<dc_Jet[jtyp]<<std::endl;
00590     CertificationSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
00591     reportSummaryMap->Fill(2, 4-jtyp, dc_Jet[jtyp]);
00592   }
00593 
00594 
00595   //-----------------------------
00596   // MET DQM Data Certification
00597   //-----------------------------
00598 
00599   //
00600   // Prepare test histograms
00601   //
00602   MonitorElement *meMExy[4][2];
00603   MonitorElement *meMEt[4];
00604   MonitorElement *meSumEt[4];
00605   MonitorElement *meMETPhi[4];
00606   //MonitorElement *meMETEMFrac[5];
00607   //MonitorElement *meMETEmEt[3][2];
00608   //MonitorElement *meMETHadEt[3][2];
00609  
00610   RunDir = "";
00611   if (RunDir == "") newHistoName = "JetMET/MET/";
00612   else              newHistoName = RunDir+"/JetMET/Run summary/MET/";
00613 
00614   if (isData)
00615     cleaningdir = "BasicCleanup";
00616   else
00617     cleaningdir = "All";
00618   //MEx/MEy monitor elements
00619   meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00620   meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00621   //  meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00622   //  meMExy[1][1] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00623   meMExy[1][0] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEx");
00624   meMExy[1][1] = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMEy");
00625   meMExy[2][0] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEx");
00626   meMExy[2][1] = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MEy");
00627   meMExy[3][0] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00628   meMExy[3][1] = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00629   //MET Phi monitor elements
00630   meMETPhi[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00631   //  meMETPhi[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00632   meMETPhi[1]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMETPhi");
00633   meMETPhi[2]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_METPhi");
00634   meMETPhi[3]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMETPhi");
00635   //MET monitor elements
00636   meMEt[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00637   //  meMEt[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00638   meMEt[1]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfMET");
00639   meMEt[2]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_MET");
00640   meMEt[3]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMET");
00641   //SumET monitor elements
00642   meSumEt[0]  = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00643   //  meSumEt[1]  = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00644   meSumEt[1]  = dbe_->get(newHistoName+"PfMET/"+cleaningdir+"/"+metFolder+"/METTask_PfSumET");
00645   meSumEt[2]  = dbe_->get(newHistoName+"TcMET/"+cleaningdir+"/"+metFolder+"/METTask_SumET");
00646   meSumEt[3]  = dbe_->get(newHistoName+"MuCorrMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloSumET");
00647                                    
00648   //----------------------------------------------------------------------------
00649   //--- Extract quality test results and fill data certification results for MET
00650   //----------------------------------------------------------------------------
00651 
00652   // 4 types of MET {CaloMET, PfMET, TcMET, MuCorrMET}  // It is 5 if CaloMETNoHF is included
00653   // 2 types of tests Mean test/Kolmogorov test
00654   const QReport * QReport_MExy[4][2][2];
00655   const QReport * QReport_MEt[4][2];
00656   const QReport * QReport_SumEt[4][2];
00657   //2 types of tests phiQTest and Kolmogorov test
00658   const QReport * QReport_METPhi[4][2];
00659 
00660 
00661   float qr_MET_MExy[4][2][2] = {{{-999.}}};
00662   float qr_MET_MEt[4][2]     = {{-999.}};
00663   float qr_MET_SumEt[4][2]   = {{-999.}};
00664   float qr_MET_METPhi[4][2]  = {{-999.}};
00665   float dc_MET[4]            = {-999.};
00666 
00667 
00668   // J.Piedra, 27/02/212
00669   // Started the process to remove MuCorrMET --> loop up to 3 instead of 4
00670   for (int mtyp = 0; mtyp < 3; ++mtyp){
00671     //Mean test results
00672     //std::cout<<"meMEx = :"<<meMExy[mtyp][0]<<std::endl;
00673     //std::cout<<"meMEy = :"<<meMExy[mtyp][1]<<std::endl;
00674     //std::cout<<"meMET = :"<<meMEt[mtyp]<<std::endl;
00675     //std::cout<<"meMETPhi = :"<<meMExy[mtyp]<<std::endl;
00676     //std::cout<<"meSumEt = :"<<meMExy[mtyp]<<std::endl;
00677     if (meMExy[mtyp][0]) {
00678       QReport_MExy[mtyp][0][0] = meMExy[mtyp][0]->getQReport("meanMExyTest");
00679       QReport_MExy[mtyp][1][0] = meMExy[mtyp][0]->getQReport("KolmogorovTest");
00680     }
00681     if (meMExy[mtyp][1]) {
00682       QReport_MExy[mtyp][0][1] = meMExy[mtyp][1]->getQReport("meanMExyTest");
00683       QReport_MExy[mtyp][1][1] = meMExy[mtyp][1]->getQReport("KolmogorovTest");
00684     }
00685     if (meMEt[mtyp]) {
00686       QReport_MEt[mtyp][0]     = meMEt[mtyp]->getQReport("meanMETTest");
00687       QReport_MEt[mtyp][1]     = meMEt[mtyp]->getQReport("KolmogorovTest");
00688     }
00689 
00690     if (meSumEt[mtyp]) {
00691       QReport_SumEt[mtyp][0]   = meSumEt[mtyp]->getQReport("meanSumETTest");
00692       QReport_SumEt[mtyp][1]   = meSumEt[mtyp]->getQReport("KolmogorovTest");
00693     }
00694 
00695     if (meMETPhi[mtyp]) {
00696       QReport_METPhi[mtyp][0]  = meMETPhi[mtyp]->getQReport("phiQTest");
00697       QReport_METPhi[mtyp][1]  = meMETPhi[mtyp]->getQReport("KolmogorovTest");
00698     }    
00699     for (int testtyp = 0; testtyp < 2; ++testtyp) {
00700       //MEx test
00701       if (QReport_MExy[mtyp][testtyp][0]){
00702         if (QReport_MExy[mtyp][testtyp][0]->getStatus()==100 ||
00703             QReport_MExy[mtyp][testtyp][0]->getStatus()==200) 
00704           qr_MET_MExy[mtyp][testtyp][0] = 1;
00705         else if (QReport_MExy[mtyp][testtyp][0]->getStatus()==300) 
00706           qr_MET_MExy[mtyp][testtyp][0] = 0;
00707         else
00708           qr_MET_MExy[mtyp][testtyp][0] = -1;
00709       }
00710       else qr_MET_MExy[mtyp][testtyp][0] = -2;
00711 
00712       //MEy test
00713       if (QReport_MExy[mtyp][testtyp][1]){
00714         if (QReport_MExy[mtyp][testtyp][1]->getStatus()==100 ||
00715             QReport_MExy[mtyp][testtyp][1]->getStatus()==200) 
00716           qr_MET_MExy[mtyp][testtyp][1] = 1;
00717         else if (QReport_MExy[mtyp][testtyp][1]->getStatus()==300) 
00718           qr_MET_MExy[mtyp][testtyp][1] = 0;
00719         else
00720           qr_MET_MExy[mtyp][testtyp][1] = -1;
00721       }
00722       else qr_MET_MExy[mtyp][testtyp][1] = -2;
00723 
00724       //MEt test
00725       if (QReport_MEt[mtyp][testtyp]){
00726         if (QReport_MEt[mtyp][testtyp]->getStatus()==100 ||
00727             QReport_MEt[mtyp][testtyp]->getStatus()==200) 
00728           qr_MET_MEt[mtyp][testtyp] = 1;
00729         else if (QReport_MEt[mtyp][testtyp]->getStatus()==300) 
00730           qr_MET_MEt[mtyp][testtyp] = 0;
00731         else
00732           qr_MET_MEt[mtyp][testtyp] = -1;
00733       }
00734       else qr_MET_MEt[mtyp][testtyp] = -2;
00735 
00736       //SumEt test
00737       if (QReport_SumEt[mtyp][testtyp]){
00738         if (QReport_SumEt[mtyp][testtyp]->getStatus()==100 ||
00739             QReport_SumEt[mtyp][testtyp]->getStatus()==200) 
00740           qr_MET_SumEt[mtyp][testtyp] = 1;
00741         else if (QReport_SumEt[mtyp][testtyp]->getStatus()==300) 
00742           qr_MET_SumEt[mtyp][testtyp] = 0;
00743         else
00744           qr_MET_SumEt[mtyp][testtyp] = -1;
00745       }
00746       else qr_MET_SumEt[mtyp][testtyp] = -2;
00747 
00748       //METPhi test
00749       if (QReport_METPhi[mtyp][testtyp]){
00750         if (QReport_METPhi[mtyp][testtyp]->getStatus()==100 ||
00751             QReport_METPhi[mtyp][testtyp]->getStatus()==200) 
00752           qr_MET_METPhi[mtyp][testtyp] = 1;
00753         else if (QReport_METPhi[mtyp][testtyp]->getStatus()==300) 
00754           qr_MET_METPhi[mtyp][testtyp] = 0;
00755         else
00756           qr_MET_METPhi[mtyp][testtyp] = -1;
00757       }
00758       else qr_MET_METPhi[mtyp][testtyp] = -2;
00759     }
00760 
00761     if (verbose_) {
00762       //certification result for MET
00763       printf("====================MET Type %d QTest Report Summary========================\n",mtyp);
00764       printf("MEx test    MEy test    MEt test:    SumEt test:    METPhi test:\n");
00765       for (int tt = 0; tt < 2; ++tt) {
00766         printf("%2.2f    %2.2f    %2.2f    %2.2f    %2.2f\n",qr_MET_MExy[mtyp][tt][0], \
00767                qr_MET_MExy[mtyp][tt][1],                                \
00768                qr_MET_MEt[mtyp][tt],                                    \
00769                qr_MET_SumEt[mtyp][tt],                                  \
00770                qr_MET_METPhi[mtyp][tt]);
00771       }
00772       printf("===========================================================================\n");
00773     }
00774 
00775 
00776     //Only apply certain tests, as defined in the config
00777     for (int ttyp = 0; ttyp < 2;  ++ttyp) {
00778       if (!metTests[mtyp][ttyp]) {
00779         qr_MET_MExy[mtyp][ttyp][0]   = 1;
00780         qr_MET_MExy[mtyp][ttyp][1]   = 1;
00781         qr_MET_MEt[mtyp][ttyp]       = 1;
00782         qr_MET_SumEt[mtyp][ttyp]     = 1;
00783         qr_MET_METPhi[mtyp][ttyp]    = 1;
00784       }
00785     }
00786     
00787 
00788     if ( 
00789         (qr_MET_MExy[mtyp][0][0] == 0) ||
00790         (qr_MET_MExy[mtyp][0][1] == 0) ||
00791         (qr_MET_MEt[mtyp][0]     == 0) ||
00792         (qr_MET_SumEt[mtyp][0]   == 0) ||
00793         (qr_MET_METPhi[mtyp][0]  == 0) ||
00794         (qr_MET_MExy[mtyp][1][0] == 0) ||
00795         (qr_MET_MExy[mtyp][1][1] == 0) ||
00796         (qr_MET_MEt[mtyp][1]     == 0) ||
00797         (qr_MET_SumEt[mtyp][1]   == 0) ||
00798         (qr_MET_METPhi[mtyp][1]  == 0)
00799         )
00800       dc_MET[mtyp] = 0;
00801     else if (
00802              (qr_MET_MExy[mtyp][0][0] == -1) &&
00803              (qr_MET_MExy[mtyp][0][1] == -1) &&
00804              (qr_MET_MEt[mtyp][0]     == -1) &&
00805              (qr_MET_SumEt[mtyp][0]   == -1) &&
00806              (qr_MET_METPhi[mtyp][0]  == -1) &&
00807              (qr_MET_MExy[mtyp][1][0] == -1) &&
00808              (qr_MET_MExy[mtyp][1][1] == -1) &&
00809              (qr_MET_MEt[mtyp][1]     == -1) &&
00810              (qr_MET_SumEt[mtyp][1]   == -1) &&
00811              (qr_MET_METPhi[mtyp][1]  == -1)
00812              )
00813       dc_MET[mtyp] = -1;
00814     else if ( 
00815         (qr_MET_MExy[mtyp][0][0] == -2) &&
00816         (qr_MET_MExy[mtyp][0][1] == -2) &&
00817         (qr_MET_MEt[mtyp][0]     == -2) &&
00818         (qr_MET_SumEt[mtyp][0]   == -2) &&
00819         (qr_MET_METPhi[mtyp][0]  == -2) &&
00820         (qr_MET_MExy[mtyp][1][0] == -2) &&
00821         (qr_MET_MExy[mtyp][1][1] == -2) &&
00822         (qr_MET_MEt[mtyp][1]     == -2) &&
00823         (qr_MET_SumEt[mtyp][1]   == -2) &&
00824         (qr_MET_METPhi[mtyp][1]  == -2)
00825         )
00826       dc_MET[mtyp] = -2;
00827     else
00828       dc_MET[mtyp] = 1;
00829 
00830     if (verbose_) std::cout<<"Certifying MET algo: "<<mtyp<<" with value: "<<dc_MET[mtyp]<<std::endl;
00831     CertificationSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
00832     reportSummaryMap->Fill(1, 4-mtyp, dc_MET[mtyp]);
00833   }
00834 
00835 
00836   //-----------------------------
00837   // CaloTowers DQM Data Certification
00838   //-----------------------------
00839 
00840   //
00841   // Prepare test histograms
00842   //
00843   //MonitorElement *meCTOcc[3];
00844   //MonitorElement *meCTEn[3];
00845   //MonitorElement *meCT[3];
00846   //MonitorElement *meCT[3];
00847  
00848   //RunDir = "";
00849   //if (RunDir == "") newHistoName = "JetMET/MET/";
00850   //else              newHistoName = RunDir+"/JetMET/Run summary/MET/";
00851 
00852   //meMExy[0][0] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00853   //meMExy[0][1] = dbe_->get(newHistoName+"CaloMET/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEy");
00854   //meMExy[1][0] = dbe_->get(newHistoName+"CaloMETNoHF/"+cleaningdir+"/"+metFolder+"/METTask_CaloMEx");
00855                                    
00856   //----------------------------------------------------------------------------
00857   //--- Extract quality test results and fill data certification results for MET
00858   //----------------------------------------------------------------------------
00859   // Commenting out unused but initialized variables. [Suchandra Dutta]
00860   //  float qr_CT_Occ[3] = {-2.};
00861   float dc_CT[3]     = {-2.};
00862   dc_CT[0]  = -2.;
00863   dc_CT[1]  = -2.;
00864   dc_CT[2]  = -2.;
00865 
00866   //  qr_CT_Occ[0]  = dc_CT[0];
00867   //  qr_CT_Occ[1]  = dc_CT[1];
00868   //  qr_CT_Occ[2]  = dc_CT[2];
00869 
00870   for (int cttyp = 0; cttyp < 3; ++cttyp) {
00871     
00872     if (verbose_) std::cout<<"Certifying CaloTowers with value: "<<dc_CT[cttyp]<<std::endl;
00873     CertificationSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
00874     reportSummaryMap->Fill(0, 4-cttyp, dc_CT[cttyp]);
00875   }
00876   dbe_->setCurrentFolder("");  
00877 
00878 }
00879 
00880 //define this as a plug-in
00881 //DEFINE_FWK_MODULE(DataCertificationJetMET);