CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DQMOffline/Trigger/src/HLTMuonCertSummary.cc

Go to the documentation of this file.
00001 #include <iostream>
00002 
00003 
00004 
00007 //
00008 // Original Author: Jason Slaunwhite
00009 //           
00010 //         Created:  Thu Jan 22 13:42:28CET 2009
00011 // $Id: HLTMuonCertSummary.cc,v 1.6 2010/07/20 02:58:28 wmtan Exp $
00012 //
00013 
00014 // system include files
00015 #include <memory>
00016 #include <vector>
00017 
00018 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00019 //
00020 #include "FWCore/Framework/interface/MakerMacros.h"
00021 #include "FWCore/Framework/interface/Run.h"
00022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00023 #include "FWCore/Utilities/interface/Exception.h"
00024 #include "FWCore/ServiceRegistry/interface/Service.h"
00025 
00026 //root include files
00027 #include "TFile.h"
00028 #include "TH1.h"
00029 #include "TH2.h"
00030 #include "TTree.h"
00031 #include "TVector3.h"
00032 #include "TProfile.h"
00033 //
00034 
00035 
00036 // user include files
00037 #include "FWCore/Framework/interface/Frameworkfwd.h"
00038 #include "FWCore/Framework/interface/EDAnalyzer.h"
00039 
00040 #include "FWCore/Framework/interface/Event.h"
00041 
00042 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00043 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00044 
00045 
00046 //DQM services
00047 #include "DQMServices/Core/interface/DQMStore.h"
00048 #include "FWCore/ServiceRegistry/interface/Service.h"
00049 #include "DQMServices/Core/interface/MonitorElement.h"
00050 
00051 
00052 
00053 using namespace std;
00054 
00055 
00056 //
00057 // class decleration
00058 //
00059 
00060 class HLTMuonCertSummary : public edm::EDAnalyzer {
00061 
00062    public:
00063       explicit HLTMuonCertSummary(const edm::ParameterSet& pset);
00064       ~HLTMuonCertSummary();
00065 
00066 
00067       virtual void beginJob() ;
00068       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00069       virtual void endJob() ;
00070       virtual void beginRun(const edm::Run&, const edm::EventSetup&) ;
00071       virtual void endRun(const edm::Run&, const edm::EventSetup&) ;
00072 
00073 
00074 
00075    private:
00076 
00077       DQMStore *dbe_;
00078       edm::ParameterSet parameters_;
00079 
00080       bool verbose_;
00081 
00082  // ----------member data ---------------------------
00083 };
00084 
00085 
00086 
00087 HLTMuonCertSummary::HLTMuonCertSummary(const edm::ParameterSet& pset)
00088 
00089 {
00090 
00091   using namespace edm;
00092   dbe_ = 0;
00093   dbe_ = edm::Service<DQMStore>().operator->();
00094   if (!dbe_) {
00095     LogInfo ("DQMGenericClient") << "Can't find DQMStore, no results will be saved"
00096                            << endl;
00097   } else {
00098     dbe_->setVerbose(0);
00099   }
00100   
00101   parameters_ = pset;
00102   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
00103   
00104   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> Constructor (HLTMuonCertSummary) <<<" << endl;
00105 
00106 }
00107 
00108 
00109 HLTMuonCertSummary::~HLTMuonCertSummary()
00110 {
00111 }
00112 
00113 
00114 //
00115 // member functions
00116 //
00117 
00118 // ------------ method called to for each event  ------------
00119 void
00120 HLTMuonCertSummary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00121 {
00122    using namespace edm;
00123 
00124    if(verbose_) LogInfo ("HLTMuonVal")  << ">>> Analyze (HLTMuonCertSummary) <<<" << std::endl;
00125 
00126 }
00127 
00128 // ------------ method called once each job just before starting event loop  ------------
00129 void 
00130 HLTMuonCertSummary::beginJob()
00131 {
00132 }
00133 
00134 // ------------ method called once each job just after ending the event loop  ------------
00135 void 
00136 HLTMuonCertSummary::endJob() 
00137 {
00138 }
00139 
00140 // ------------ method called just before starting a new run  ------------
00141 void 
00142 HLTMuonCertSummary::beginRun(const edm::Run& run, const edm::EventSetup& c)
00143 {
00144 
00145   using namespace edm;
00146   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> BeginRun (HLTMuonCertSummary) <<<" << std::endl;
00147   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> "<< run.id() << std::endl;
00148 
00149 }
00150 
00151 // ------------ method called right after a run ends ------------
00152 void 
00153 HLTMuonCertSummary::endRun(const edm::Run& run, const edm::EventSetup& c)
00154 {
00155 
00156   using namespace edm;
00157   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> EndRun (HLTMuonCertSummary) <<<" << std::endl;
00158 
00159   if(!dbe_) {
00160     LogInfo ("DQMGenericClient") << "No dqmstore... skipping processing step" << endl;
00161     return;
00162   }
00163   
00164   std::vector<string> histoNameVector;
00165 
00166  
00167   //booking histograms according to naming conventions
00168 
00169 
00170 
00171   dbe_->setCurrentFolder("HLT/EventInfo/muonQuality");  
00172 
00173   MonitorElement*  reportSummary = dbe_->bookFloat("HLT_MUON_REPORT_SUMMARY");
00174 
00175   int SummaryBitResult = 100;
00176   
00177   MonitorElement*  CertificationSummary = dbe_->bookFloat("HLT_MUON_CERTIFICATION_SUMMARY");
00178 
00179   
00180 
00181   //for now these will hold values from eta/phi tests for spikes/holes
00182   MonitorElement*  reportSummaryMap = dbe_->book2D("HLT_MUON_ReportSummaryMap","HLT_MUON: ReportSummaryMap",6,-0.5,5.5,1,-0.5,0.5);
00183   MonitorElement*  CertificationSummaryMap = dbe_->book2D("HLT_MUON_CertificationSummaryMap","HLT_MUON: CertificationSummaryMap",6,-0.5,5.5,1,-0.5,0.5);
00184 
00185   TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
00186 
00187   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"PhiEtaOccAll");
00188   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"PhiEtaOccMatch");
00189   reportSummaryMapTH2->GetXaxis()->SetBinLabel(3,"PhiEtaEff");
00190   reportSummaryMapTH2->GetXaxis()->SetBinLabel(4,"PhiEff");
00191   reportSummaryMapTH2->GetXaxis()->SetBinLabel(5,"EtaEff");
00192   reportSummaryMapTH2->GetXaxis()->SetBinLabel(6,"PtEff");
00193   
00194   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"HLT_Mu5_allMuons");
00195 
00196 
00197   TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
00198 
00199   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"PhiEtaOccAll");    
00200   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"PhiEtaOccMatch");  
00201   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3,"PhiEtaEff");       
00202   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(4,"PhiEff");          
00203   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(5,"EtaEff");          
00204   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(6,"PtEff");             
00205                                                                    
00206   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"HLT_Mu5_allMuons");
00207 
00208 
00209   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_All");
00210   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recPhiVsRecEta_L3Filtered");
00211   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhiVsEta_L3Filtered");
00212   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPt_L3Filtered");
00213   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffPhi_L3Filtered");
00214   histoNameVector.push_back("HLT/Muon/Distributions/HLT_Mu5/allMuons/recEffEta_L3Filtered");
00215   
00216   // to do:  what do we want in certification contents?
00217   //  dbe_->setCurrentFolder("Egamma/EventInfo/CertificationContents/"); 
00218 
00219 
00220   //   //looping over histograms to be tested
00221   if(verbose_) LogInfo ("HLTMuonVal")  << "\n>>> looping over histograms to be tested <<<\n\n";
00222   
00223   for(std::vector<string>::iterator it=histoNameVector.begin();it!=histoNameVector.end();++it){
00224 
00225     string HistoName = (*it);
00226     if(verbose_) LogInfo ("HLTMuonVal")  << ">>> " << HistoName;        
00227     
00228 
00229     MonitorElement * TestHist=0;
00230 
00231     TestHist = dbe_->get(HistoName);
00232 
00233     bool validMe = TestHist!=0;
00234     if(verbose_)  LogInfo ("HLTMuonVal")  << " is valid? " << validMe << "\n";
00235     if(!validMe) continue;
00236 
00237     string histNameNoPath =  TestHist->getName();
00238     
00239     if(verbose_)  LogInfo ("HLTMuonVal")  << ">>> TestHist Name: " << histNameNoPath << "\n\n";
00240 
00241   
00242 
00243     //get QReports associated to each ME
00244     std::vector<QReport *> myQReports = TestHist->getQReports();  
00245     if(verbose_)  LogInfo ("HLTMuonVal") << TestHist->getName() <<": myQReports.size() = " << myQReports.size() << "\n\n";
00246     for(uint i=0;i!=myQReports.size();++i) {
00247       
00248       std::string qtname = myQReports[i]->getQRName() ; // get QT name
00249       float qtresult = myQReports[i]->getQTresult(); // get QT result value
00250       int qtstatus = myQReports[i]->getStatus() ; // get QT status value 
00251       
00252       if(verbose_) LogInfo ("HLTMuonVal")  << "\tTest " << i << ":  qtname: " << qtname   << "\n";
00253       if(verbose_) LogInfo ("HLTMuonVal")  << "\tTest " << i << ":  qtresult: " << qtresult  << std::endl;
00254       if(verbose_) LogInfo ("HLTMuonVal")  << "\tTest " << i << ":  qtstatus: " << qtstatus    << "\n\n";
00255 
00256       
00257       //book and fill float for each test done
00258       dbe_->setCurrentFolder("HLT/EventInfo/muonQuality/");  
00259       MonitorElement * qValueInt  = dbe_->bookFloat(histNameNoPath+"_HLT_Mu5_"+qtname);
00260       qValueInt->Fill(qtstatus);
00261 
00262       // We're assuming that you want all of the bits to go into the decision
00263 
00264 
00265       if (HistoName.find("recPhiVsRecEta_All") != std::string::npos) {
00266         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1,1), qtstatus);
00267         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1,1), qtstatus );
00268         if ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
00269         if ( (qtstatus == 300) ) SummaryBitResult = 300;
00270 
00271       }
00272 
00273       if (HistoName.find("recPhiVsRecEta_L3Filtered") != std::string::npos) {
00274         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2,1), qtstatus);
00275         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2,1), qtstatus);
00276         if  ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
00277         if (qtstatus == 300 ) SummaryBitResult = 300;
00278 
00279       }
00280       
00281       if (HistoName.find("recEffPhiVsEta_L3Filtered") != std::string::npos) {
00282         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3,1), qtstatus );
00283         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3,1), qtstatus);
00284         if ( (qtstatus == 200) && (SummaryBitResult < 300)) SummaryBitResult = 200;
00285         if (qtstatus == 300 ) SummaryBitResult = 300;
00286       }
00287 
00288       if (HistoName.find("recEffPhi_L3Filtered") != std::string::npos) {
00289         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(4,1), qtstatus);
00290         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(4,1), qtstatus);
00291       }
00292 
00293       if (HistoName.find("recEffEta_L3Filtered") != std::string::npos) {
00294         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(5,1), qtstatus);
00295         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(5,1), qtstatus);
00296       }
00297       
00298       if (HistoName.find("recEffPt_L3Filtered") != std::string::npos) {
00299         reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(6,1), qtstatus);
00300         CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(6,1), qtstatus);
00301       }
00302       
00303 
00304     }
00305   }
00306 
00307 
00308   reportSummary->Fill(SummaryBitResult);
00309   CertificationSummary->Fill(SummaryBitResult);
00310 
00311 
00312 
00313   // Set the final bits
00314 
00315   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
00316   MonitorElement* muonHLTQualityBinaryBit = dbe_->bookFloat ("HLT_Muon");
00317   
00318   if (SummaryBitResult == 100){
00319     muonHLTQualityBinaryBit->Fill(1);
00320   } else {
00321     muonHLTQualityBinaryBit->Fill(0);
00322   }
00323   
00324 
00325 
00326 }
00327 
00328 
00329 DEFINE_FWK_MODULE(HLTMuonCertSummary);