CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/DQMOffline/Trigger/src/HLTOverallSummary.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: HLTOverallSummary.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 HLTOverallSummary : public edm::EDAnalyzer {
00061 
00062    public:
00063       explicit HLTOverallSummary(const edm::ParameterSet& pset);
00064       ~HLTOverallSummary();
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 HLTOverallSummary::HLTOverallSummary(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 ("HLTMuonVal") << "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 (HLTOverallSummary) <<<" << endl;
00105 
00106 }
00107 
00108 
00109 HLTOverallSummary::~HLTOverallSummary()
00110 {
00111 }
00112 
00113 
00114 //
00115 // member functions
00116 //
00117 
00118 // ------------ method called to for each event  ------------
00119 void
00120 HLTOverallSummary::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00121 {
00122    using namespace edm;
00123 
00124    if(verbose_) LogInfo ("HLTMuonVal")  << ">>> Analyze (HLTOverallSummary) <<<" << std::endl;
00125 
00126 }
00127 
00128 // ------------ method called once each job just before starting event loop  ------------
00129 void 
00130 HLTOverallSummary::beginJob()
00131 {
00132 }
00133 
00134 // ------------ method called once each job just after ending the event loop  ------------
00135 void 
00136 HLTOverallSummary::endJob() 
00137 {
00138 }
00139 
00140 // ------------ method called just before starting a new run  ------------
00141 void 
00142 HLTOverallSummary::beginRun(const edm::Run& run, const edm::EventSetup& c)
00143 {
00144 
00145   using namespace edm;
00146   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> BeginRun (HLTOverallSummary) <<<" << 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 HLTOverallSummary::endRun(const edm::Run& run, const edm::EventSetup& c)
00154 {
00155 
00156   using namespace edm;
00157   if(verbose_) LogInfo ("HLTMuonVal")  << ">>> EndRun (HLTOverallSummary) <<<" << std::endl;
00158 
00159   if(!dbe_) {
00160     LogInfo ("HLTMuonVal") << "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   float defaultValueIfNotFound = 1.0;
00170 
00171   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContent");
00172 
00173 
00174   //============ Unpack information ==========
00175   
00176 
00177   MonitorElement*  muonQualityBit = 0;
00178   muonQualityBit = dbe_->get("HLT_Muon");
00179 
00180   if (!muonQualityBit) {
00181     LogInfo ("HLTMuonVal") << "Can't find muonQuality bit... making a bit, setting it to zero" << endl;
00182 
00183     muonQualityBit = dbe_->bookFloat("HLT_Muon");
00184     muonQualityBit->Fill(defaultValueIfNotFound);
00185       
00186   }
00187                       
00188   MonitorElement*  eleQualityBit = 0;
00189   eleQualityBit = dbe_->get("HLT_Electron");
00190 
00191   if (!eleQualityBit) {
00192     LogInfo ("HLTMuonVal") << "Can't find eleQuality bit... making a bit, setting it to zero" << endl;
00193 
00194     eleQualityBit = dbe_->bookFloat("HLT_Electron");
00195     eleQualityBit->Fill(defaultValueIfNotFound);      
00196   }
00197 
00198   MonitorElement*  photonQualityBit = 0;
00199   photonQualityBit = dbe_->get("HLT_Photon");
00200 
00201   if (!photonQualityBit) {
00202     LogInfo ("HLTMuonVal") << "Can't find photonQuality bit... making a bit, setting it to zero" << endl;
00203 
00204     photonQualityBit = dbe_->bookFloat("HLT_Photon");
00205     photonQualityBit->Fill(defaultValueIfNotFound);      
00206   }
00207 
00208 
00209   //============ Book new storage locations =============
00210 
00211   dbe_->setCurrentFolder("HLT/EventInfo");
00212   MonitorElement*  hltQualityBit = dbe_->bookFloat("reportSummary");
00213 
00214   MonitorElement* hltQualitySummaryWord = dbe_->bookInt ("HLT_SUMMARY_WORD");
00215 
00216   //for now these will hold values from eta/phi tests for spikes/holes
00217   MonitorElement*  reportSummaryMap = dbe_->book2D("reportSummaryMap","HLT: ReportSummaryMap",3,-0.5,2.5,1,-0.5,0.5);
00218   MonitorElement*  CertificationSummaryMap = dbe_->book2D("certificationSummaryMap","HLT: CertificationSummaryMap",3,-0.5,2.5,1,-0.5,0.5);
00219 
00220   TH2 * reportSummaryMapTH2 = reportSummaryMap->getTH2F();
00221 
00222   reportSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Muon");
00223   reportSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Electron");
00224   reportSummaryMapTH2->GetXaxis()->SetBinLabel(3,"Photon");
00225   
00226   reportSummaryMapTH2->GetYaxis()->SetBinLabel(1,"Quality");
00227 
00228 
00229   TH2 * CertificationSummaryMapTH2 = CertificationSummaryMap->getTH2F();
00230 
00231   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(1,"Muon");    
00232   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(2,"Electron");  
00233   CertificationSummaryMapTH2->GetXaxis()->SetBinLabel(3,"Photon");                                                                          
00234   CertificationSummaryMapTH2->GetYaxis()->SetBinLabel(1,"Quality");
00235 
00236 
00237 
00238   //=================== Interpret bits and store result
00239 
00240   float photonValue = photonQualityBit->getFloatValue();
00241   
00242   float electronValue = eleQualityBit->getFloatValue();
00243 
00244   float muonValue = muonQualityBit->getFloatValue();
00245 
00246   float hltOverallValue = 1.0;
00247   
00248   if ( (photonValue > 0.99)
00249        && (electronValue > 0.99)
00250        && (muonValue > 0.99) ) {
00251 
00252     hltOverallValue = 1.0;
00253 
00254   } else {
00255     
00256     hltOverallValue = 0.0;
00257     
00258   }
00259 
00260   hltQualityBit->Fill(hltOverallValue);
00261 
00262   unsigned int hltSummaryValue = 0x0; //
00263 
00264   unsigned int ELECTRON_MASK = 0x1;
00265   unsigned int PHOTON_MASK = 0x2;  
00266   unsigned int MUON_MASK = 0x4;
00267 
00268   if (electronValue > 0.99) hltSummaryValue = hltSummaryValue | ELECTRON_MASK;    
00269   if (photonValue > 0.99) hltSummaryValue = hltSummaryValue | PHOTON_MASK;
00270   if (muonValue > 0.99) hltSummaryValue = hltSummaryValue | MUON_MASK;
00271 
00272   hltQualitySummaryWord->Fill(hltSummaryValue);
00273 
00274   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(1,1), muonValue);
00275   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(2,1), electronValue);
00276   reportSummaryMapTH2->SetBinContent(reportSummaryMapTH2->GetBin(3,1), photonValue);
00277 
00278   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(1,1), muonValue);
00279   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(2,1), electronValue);
00280   CertificationSummaryMapTH2->SetBinContent(CertificationSummaryMapTH2->GetBin(3,1), photonValue);
00281 
00282   
00283 
00284 
00285   
00286   
00287     
00288        
00289   
00290 
00291 }
00292 
00293 
00294 DEFINE_FWK_MODULE(HLTOverallSummary);