CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQMOffline/EGamma/plugins/PhotonDataCertification.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 #include "DQMOffline/EGamma/plugins/PhotonDataCertification.h"
00004 #include "FWCore/Framework/interface/Run.h"
00005 
00008 //
00009 // Original Author:  Louis James Antonelli
00010 //         Created:  Thu Jan 22 13:42:28CET 2009
00011 // $Id: PhotonDataCertification.cc,v 1.1 2011/04/08 15:55:00 chamont Exp $
00012 //
00013 
00014 
00015 
00016 
00017 using namespace std;
00018 
00019 PhotonDataCertification::PhotonDataCertification(const edm::ParameterSet& pset)
00020 
00021 {
00022 
00023   dbe_ = 0;
00024   dbe_ = edm::Service<DQMStore>().operator->();
00025   dbe_->setVerbose(0);
00026   parameters_ = pset;
00027   verbose_ = parameters_.getParameter<bool>("verbose");
00028 
00029   if(verbose_) cout << ">>> Constructor (PhotonDataCertification) <<<" << endl;
00030 
00031 }
00032 
00033 
00034 PhotonDataCertification::~PhotonDataCertification()
00035 {
00036 }
00037 
00038 
00039 //
00040 // member functions
00041 //
00042 
00043 // ------------ method called to for each event  ------------
00044 void
00045 PhotonDataCertification::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00046 {
00047    using namespace edm;
00048 
00049    if(verbose_) std::cout << ">>> Analyze (PhotonDataCertification) <<<" << std::endl;
00050 
00051 }
00052 
00053 // ------------ method called once each job just before starting event loop  ------------
00054 void
00055 PhotonDataCertification::beginJob()
00056 {
00057 }
00058 
00059 // ------------ method called once each job just after ending the event loop  ------------
00060 void
00061 PhotonDataCertification::endJob()
00062 {
00063 }
00064 
00065 // ------------ method called just before starting a new run  ------------
00066 void
00067 PhotonDataCertification::beginRun(const edm::Run& run, const edm::EventSetup& c)
00068 {
00069 
00070   if(verbose_) std::cout << ">>> BeginRun (PhotonDataCertification) <<<" << std::endl;
00071   if(verbose_) std::cout << ">>> "<< run.id() << std::endl;
00072 
00073 }
00074 
00075 // ------------ method called right after a run ends ------------
00076 void
00077 PhotonDataCertification::endRun(const edm::Run& run, const edm::EventSetup& c)
00078 {
00079   if(verbose_) std::cout << ">>> EndRun (PhotonDataCertification) <<<" << std::endl;
00080 
00081   std::vector<string> histoNameVector;
00082 
00083 
00084   //booking histograms according to naming conventions
00085 
00086   if(!dbe_) return;
00087 
00088   dbe_->setCurrentFolder("Egamma/EventInfo/");
00089 
00090   MonitorElement*  reportSummary = dbe_->bookFloat("reportSummary");
00091   MonitorElement*  CertificationSummary = dbe_->bookFloat("CertificationSummary");
00092 
00093   //for now these will hold values from eta/phi tests for spikes/holes
00094   MonitorElement*  reportSummaryMap = dbe_->book2D("reportSummaryMap","reportSummaryMap",2,0,2,2,0,2);
00095   MonitorElement*  CertificationSummaryMap = dbe_->book2D("CertificationSummaryMap","CertificationSummaryMap",2,0,2,2,0,2);
00096 
00097   TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
00098 
00099   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Eta");
00100   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Phi");
00101   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"SpikeTest");
00102   reportSummaryMapTH2->GetYaxis()->SetBinLabel(2,"HoleTest");
00103 
00104   TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
00105 
00106   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Eta");
00107   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Phi");
00108   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"SpikeTest");
00109   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(2,"HoleTest");
00110 
00111 
00112 
00113   //histograms to be tested and results put into Egamma/EventInfo/reportSummaryContents
00114   histoNameVector.push_back("nPhoAllEcal");
00115   histoNameVector.push_back("r9AllEcal");
00116   histoNameVector.push_back("phoEta");
00117   histoNameVector.push_back("phoPhi");
00118 
00119 
00120 //   histoNameVector.push_back("phoEtAllEcal");
00121 //   histoNameVector.push_back("EfficiencyVsEtHLT");
00122 //   histoNameVector.push_back("EfficiencyVsEtaHLT");
00123 //   histoNameVector.push_back("EfficiencyVsEtLoose");
00124 //   histoNameVector.push_back("EfficiencyVsEtaLoose");
00125 
00126 
00127   // to do:  what do we want in certification contents?
00128   //  dbe_->setCurrentFolder("Egamma/EventInfo/CertificationContents/");
00129 
00130 
00131   //looping over histograms to be tested
00132   if(verbose_) std::cout << "\n>>> looping over histograms to be tested <<<\n\n";
00133   for(std::vector<string>::iterator it=histoNameVector.begin();it!=histoNameVector.end();++it){
00134 
00135     string HistoName = (*it);
00136     if(verbose_) std::cout << ">>> " << HistoName;
00137 
00138     MonitorElement * TestHist=0;
00139 
00140     if(HistoName.find("Efficiency")!=std::string::npos){
00141       TestHist = dbe_->get("Egamma/PhotonAnalyzer/Efficiencies/"+HistoName);
00142     }
00143     else{
00144       TestHist = dbe_->get("Egamma/PhotonAnalyzer/GoodCandidatePhotons/Et above 0 GeV/"+HistoName);
00145     }
00146     bool validMe = TestHist!=0;
00147     if(verbose_)  std::cout << " is valid? " << validMe << "\n";
00148     if(!validMe) continue;
00149 
00150     if(verbose_)  std::cout << ">>> TestHist Name: " << TestHist->getName() << "\n\n";
00151 
00152 
00153 
00154     //get QReports associated to each ME
00155     std::vector<QReport *> myQReports = TestHist->getQReports();
00156     if(verbose_)  cout << TestHist->getName() <<": myQReports.size() = " << myQReports.size() << "\n\n";
00157     for(uint i=0;i!=myQReports.size();++i) {
00158 
00159       std::string qtname = myQReports[i]->getQRName() ; // get QT name
00160       float qtresult = myQReports[i]->getQTresult(); // get QT result value
00161       int qtstatus = myQReports[i]->getStatus() ; // get QT status value
00162 
00163       if(verbose_) std::cout << "\tTest " << i << ":  qtname: " << qtname   << "\n";
00164       if(verbose_) std::cout << "\tTest " << i << ":  qtresult: " << qtresult  << std::endl;
00165       if(verbose_) std::cout << "\tTest " << i << ":  qtstatus: " << qtstatus    << "\n\n";
00166 
00167 
00168       //book and fill float for each test done
00169       dbe_->setCurrentFolder("Egamma/EventInfo/reportSummaryContents/");
00170       MonitorElement * Float  = dbe_->bookFloat(HistoName+"_"+qtname);
00171       Float->Fill(qtresult);
00172 
00173     }
00174   }
00175 
00176 
00177 
00178   //filling summaries based on geometric spikes/holes
00179 
00180   float etaSpikeTestResult=0;
00181   float phiSpikeTestResult=0;
00182   float etaHoleTestResult=0;
00183   float phiHoleTestResult=0;
00184 
00185   if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_SpikeTest")!=0)
00186     etaSpikeTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_SpikeTest")->getFloatValue();
00187   else  etaSpikeTestResult = -1;
00188 
00189   if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_SpikeTest")!=0)
00190     phiSpikeTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_SpikeTest")->getFloatValue();
00191   else  phiSpikeTestResult = -1;
00192 
00193   if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_HoleTest")!=0)
00194     etaHoleTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoEta_HoleTest")->getFloatValue();
00195   else  etaHoleTestResult = -1;
00196 
00197   if(dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_HoleTest")!=0)
00198     phiHoleTestResult = dbe_->get("Egamma/EventInfo/reportSummaryContents/phoPhi_HoleTest")->getFloatValue();
00199   else  phiHoleTestResult = -1;
00200 
00201 
00202 
00203   if(verbose_) std::cout << ">>>  Results of tests to be put into Summary Maps  <<<\n\n";
00204   if(verbose_) std::cout << "\tetaSpikeTestResult= " << etaSpikeTestResult << "\n";
00205   if(verbose_) std::cout << "\tphiSpikeTestResult= " << phiSpikeTestResult << "\n";
00206   if(verbose_) std::cout << "\tetaHoleTestResult= " << etaHoleTestResult << "\n";
00207   if(verbose_) std::cout << "\tphiHoleTestResult= " << phiHoleTestResult << "\n\n";
00208 
00209 
00210   //fill reportSummary & CertificationSummary with average of hole/spike tests
00211   float reportSummaryFloat = (etaSpikeTestResult+etaHoleTestResult+phiSpikeTestResult+phiHoleTestResult)/4.;
00212   if(reportSummaryFloat<0) reportSummaryFloat = -1;
00213   reportSummary->Fill(reportSummaryFloat);
00214   CertificationSummary->Fill(reportSummaryFloat);
00215 
00216   reportSummaryMap->Fill(0,0,etaSpikeTestResult);
00217   reportSummaryMap->Fill(0,1,etaHoleTestResult);
00218   reportSummaryMap->Fill(1,0,phiSpikeTestResult);
00219   reportSummaryMap->Fill(1,1,phiHoleTestResult);
00220 
00221   CertificationSummaryMap->Fill(0,0,etaSpikeTestResult);
00222   CertificationSummaryMap->Fill(0,1,etaHoleTestResult);
00223   CertificationSummaryMap->Fill(1,0,phiSpikeTestResult);
00224   CertificationSummaryMap->Fill(1,1,phiHoleTestResult);
00225 
00226 
00227 
00228 
00229 }