CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/DQMOffline/Trigger/src/DQMOfflineHLTEventInfoClient.cc

Go to the documentation of this file.
00001 #include "DQMOffline/Trigger/interface/DQMOfflineHLTEventInfoClient.h"
00002 
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "DQMServices/Core/interface/QReport.h"
00009 #include "DQMServices/Core/interface/DQMStore.h"
00010 #include "DQMServices/Core/interface/MonitorElement.h"
00011 #include <stdio.h>
00012 #include <sstream>
00013 #include <math.h>
00014 #include <TProfile.h>
00015 #include <TProfile2D.h>
00016 #include <memory>
00017 #include <iostream>
00018 #include <iomanip>
00019 #include <map>
00020 #include <vector>
00021 #include <string>
00022 #include <fstream>
00023 #include "TROOT.h"
00024 #include "TRandom.h"
00025 #include <TH1F.h>
00026 #include <TH2F.h>
00027 
00028 using namespace edm;
00029 using namespace std;
00030 
00031 /*
00032 class DQMOfflineHLTEventInfoClient: public edm::EDAnalyzer {
00033 
00034 public:
00035 
00037   DQMOfflineHLTEventInfoClient(const edm::ParameterSet& ps);
00038   
00040   virtual ~DQMOfflineHLTEventInfoClient();
00041  
00042 protected:
00043 
00045   void beginJob();
00046 
00048   void beginRun(const edm::Run& r, const edm::EventSetup& c);
00049 
00051   void analyze(const edm::Event& e, const edm::EventSetup& c) ;
00052 
00053   void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00054                             const edm::EventSetup& context) ;
00055 
00057   void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00058                           const edm::EventSetup& c);
00059 
00061   void endRun(const edm::Run& r, const edm::EventSetup& c);
00062 
00064   void endJob();
00065 
00066 private:
00067 
00068   void initialize();
00069   edm::ParameterSet parameters_;
00070 
00071   DQMStore* dbe_;  
00072   bool verbose_;
00073   int counterLS_;      ///counter
00074   int counterEvt_;     ///counter
00075   int prescaleLS_;     ///units of lumi sections
00076   int prescaleEvt_;    ///prescale on number of events
00077   // -------- member data --------
00078 
00079   MonitorElement * reportSummary_;
00080   std::vector<MonitorElement*> reportSummaryContent_;
00081   MonitorElement * reportSummaryMap_;
00082 
00083 
00084 };
00085 */
00086 
00087 
00088 DQMOfflineHLTEventInfoClient::DQMOfflineHLTEventInfoClient(const edm::ParameterSet& ps)
00089 {
00090   parameters_=ps;
00091   initialize();
00092 }
00093 
00094 DQMOfflineHLTEventInfoClient::~DQMOfflineHLTEventInfoClient(){
00095  if(verbose_) cout <<"[TriggerDQM]: ending... " << endl;
00096 }
00097 
00098 //--------------------------------------------------------
00099 void DQMOfflineHLTEventInfoClient::initialize(){ 
00100 
00101   counterLS_=0; 
00102   counterEvt_=0; 
00103   
00104   // get back-end interface
00105   dbe_ = Service<DQMStore>().operator->();
00106   
00107   // base folder for the contents of this job
00108   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
00109   
00110   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00111   if(verbose_) cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00112   
00113   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00114   if(verbose_) cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00115   /*
00116   */
00117   
00118 }
00119 
00120 //--------------------------------------------------------
00121 void DQMOfflineHLTEventInfoClient::beginJob(){
00122 
00123   if(verbose_) cout <<"[TriggerDQM]: Begin Job" << endl;
00124   // get backendinterface  
00125   dbe_ = Service<DQMStore>().operator->();
00126 
00127   dbe_->setCurrentFolder("HLT/EventInfo");
00128 
00129   // reportSummary
00130   reportSummary_ = dbe_->get("HLT/EventInfo/reportSummary");
00131 
00132   if ( reportSummary_  ) {
00133       dbe_->removeElement(reportSummary_->getName()); 
00134    }
00135   
00136   reportSummary_ = dbe_->bookFloat("reportSummary");
00137   //initialize reportSummary to 1
00138   if (reportSummary_) reportSummary_->Fill(1);
00139 
00140   // CertificationSummary
00141   CertificationSummary_ = dbe_->get("HLT/EventInfo/CertificationSummary");
00142 
00143   if ( CertificationSummary_  ) {
00144       dbe_->removeElement(CertificationSummary_->getName()); 
00145    }
00146   
00147   CertificationSummary_ = dbe_->bookFloat("CertificationSummary");
00148   //initialize CertificationSummary to 1
00149   if (CertificationSummary_) CertificationSummary_->Fill(1);
00150 
00151   //initialize reportSummary to 1
00152   if (reportSummary_) reportSummary_->Fill(1);
00153 
00154   //  OK HERE
00155 
00156   // reportSummaryMap
00157   dbe_->setCurrentFolder("HLT/EventInfo");
00158 
00159   reportSummaryMap_ = dbe_->get("HLT/EventInfo/reportSummaryMap");
00160   if ( reportSummaryMap_  ) {
00161   dbe_->removeElement(reportSummaryMap_->getName());
00162   }
00163 
00164 
00165   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 6, 1, 7);
00166   reportSummaryMap_->setAxisTitle("", 1);
00167   reportSummaryMap_->setAxisTitle("", 2);
00168   reportSummaryMap_->setBinLabel(1,"Muon",2);
00169   reportSummaryMap_->setBinLabel(2,"Electron",2);
00170   reportSummaryMap_->setBinLabel(3,"Photon",2);
00171   reportSummaryMap_->setBinLabel(4,"JetMET",2);
00172   reportSummaryMap_->setBinLabel(5,"BJet",2);
00173   reportSummaryMap_->setBinLabel(6,"Tau",2);
00174   reportSummaryMap_->setBinLabel(1," ",1);
00175 
00176 
00177   CertificationSummaryMap_ = dbe_->get("HLT/EventInfo/CertificationSummaryMap");
00178   if ( CertificationSummaryMap_  ) {
00179   dbe_->removeElement(CertificationSummaryMap_->getName());
00180   }
00181 
00182 
00183   CertificationSummaryMap_ = dbe_->book2D("CertificationSummaryMap", "CertificationSummaryMap", 1, 1, 2, 6, 1, 7);
00184   CertificationSummaryMap_->setAxisTitle("", 1);
00185   CertificationSummaryMap_->setAxisTitle("", 2);
00186   CertificationSummaryMap_->setBinLabel(1,"Muon",2);
00187   CertificationSummaryMap_->setBinLabel(2,"Electron",2);
00188   CertificationSummaryMap_->setBinLabel(3,"Photon",2);
00189   CertificationSummaryMap_->setBinLabel(4,"JetMET",2);
00190   CertificationSummaryMap_->setBinLabel(5,"BJet",2);
00191   CertificationSummaryMap_->setBinLabel(6,"Tau",2);
00192   CertificationSummaryMap_->setBinLabel(1," ",1);
00193 
00194 }
00195 
00196 //--------------------------------------------------------
00197 void DQMOfflineHLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00198 }
00199 
00200 //--------------------------------------------------------
00201 void DQMOfflineHLTEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00202    // optionally reset histograms here
00203 }
00204 
00205 void DQMOfflineHLTEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00206                           const edm::EventSetup& c){
00207 }
00208 
00209 //--------------------------------------------------------
00210 void DQMOfflineHLTEventInfoClient::analyze(const Event& e, const EventSetup& context){
00211    
00212    counterEvt_++;
00213    if (prescaleEvt_<1) return;
00214    if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00215 
00216    if(verbose_) cout << "DQMOfflineHLTEventInfoClient::analyze" << endl;
00217 
00218 
00219 }
00220 
00221 //--------------------------------------------------------
00222 void DQMOfflineHLTEventInfoClient::endRun(const Run& r, const EventSetup& context){
00223 
00224   float summarySum = 0;
00225   float reportSummary = 0;
00226 
00227   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
00228   MonitorElement* HLT_Muon = dbe_->get("HLT_Muon");
00229   if(HLT_Muon) reportSummaryContent_.push_back(HLT_Muon);
00230 
00231   MonitorElement * HLT_Electron = dbe_->get("HLT_Electron");
00232   if(HLT_Electron) reportSummaryContent_.push_back(HLT_Electron);
00233 
00234   MonitorElement * HLT_Photon = dbe_->get("HLT_Photon");
00235   if(HLT_Photon) reportSummaryContent_.push_back(HLT_Photon);
00236 
00237   MonitorElement * HLT_Tau = dbe_->get("HLT_Tau");
00238   if(HLT_Tau) reportSummaryContent_.push_back(HLT_Tau);
00239 
00240 
00241   int nSubsystems = reportSummaryContent_.size();
00242 
00243   for (int m = 0; m < nSubsystems; m++) {    
00244     summarySum += (reportSummaryContent_[m])->getFloatValue();
00245   }
00246 
00247 
00248   if(nSubsystems > 0) {
00249     reportSummary = summarySum / nSubsystems;;
00250   }
00251   else {
00252     reportSummary = 1;
00253   }
00254 
00255   reportSummary_->Fill(reportSummary);
00256   CertificationSummary_->Fill(reportSummary);
00257 
00258   float muonValue = 1;
00259   if(HLT_Muon) muonValue = HLT_Muon->getFloatValue();
00260 
00261   float electronValue = 1;
00262   if(HLT_Electron) electronValue = HLT_Electron->getFloatValue();
00263 
00264   float photonValue = 1;
00265   if(HLT_Photon) photonValue = HLT_Photon->getFloatValue();
00266 
00267   float tauValue = 1;
00268   if(HLT_Tau) tauValue = HLT_Tau->getFloatValue();
00269 
00270   reportSummaryMap_->setBinContent(1,1,muonValue);//Muon
00271   reportSummaryMap_->setBinContent(1,2,electronValue);//Electron
00272   reportSummaryMap_->setBinContent(1,3,photonValue);//Photon
00273   reportSummaryMap_->setBinContent(1,4,1);//JetMET
00274   reportSummaryMap_->setBinContent(1,5,1);//BJet
00275   reportSummaryMap_->setBinContent(1,6,tauValue);//Tau
00276 
00277   CertificationSummaryMap_->setBinContent(1,1,muonValue);//Muon
00278   CertificationSummaryMap_->setBinContent(1,2,electronValue);//Electron
00279   CertificationSummaryMap_->setBinContent(1,3,photonValue);//Photon
00280   CertificationSummaryMap_->setBinContent(1,4,1);//JetMET
00281   CertificationSummaryMap_->setBinContent(1,5,1);//BJet
00282   CertificationSummaryMap_->setBinContent(1,6,tauValue);//Tau
00283 }
00284 
00285 //--------------------------------------------------------
00286 void DQMOfflineHLTEventInfoClient::endJob(){
00287 }
00288