CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DQM/HLTEvF/plugins/HLTEventInfoClient.cc

Go to the documentation of this file.
00001 #include "DQM/HLTEvF/interface/HLTEventInfoClient.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 "TRandom.h"
00012 #include <TF1.h>
00013 #include <stdio.h>
00014 #include <sstream>
00015 #include <math.h>
00016 #include <TProfile.h>
00017 #include <TProfile2D.h>
00018 #include <memory>
00019 #include <iostream>
00020 #include <iomanip>
00021 #include <map>
00022 #include <vector>
00023 #include <string>
00024 #include <fstream>
00025 #include "TROOT.h"
00026 
00027 using namespace edm;
00028 using namespace std;
00029 
00030 HLTEventInfoClient::HLTEventInfoClient(const edm::ParameterSet& ps)
00031 {
00032   parameters_=ps;
00033   initialize();
00034 }
00035 
00036 HLTEventInfoClient::~HLTEventInfoClient(){
00037  if(verbose_) std::cout <<"[TriggerDQM]: ending... " << std::endl;
00038 }
00039 
00040 //--------------------------------------------------------
00041 void HLTEventInfoClient::initialize(){ 
00042 
00043   counterLS_=0; 
00044   counterEvt_=0; 
00045   
00046   // get back-end interface
00047   dbe_ = Service<DQMStore>().operator->();
00048   
00049   // base folder for the contents of this job
00050   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
00051   
00052   monitorDir_ = parameters_.getUntrackedParameter<std::string>("monitorDir","");
00053   if(verbose_) std::cout << "Monitor dir = " << monitorDir_ << std::endl;
00054     
00055   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00056   if(verbose_) std::cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< std::endl;
00057   
00058   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00059   if(verbose_) std::cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< std::endl;
00060   
00061 
00062       
00063 }
00064 
00065 //--------------------------------------------------------
00066 void HLTEventInfoClient::beginJob(){
00067 
00068   if(verbose_) std::cout <<"[TriggerDQM]: Begin Job" << std::endl;
00069   // get backendinterface  
00070   dbe_ = Service<DQMStore>().operator->();
00071 
00072   dbe_->setCurrentFolder("HLT/EventInfo");
00073 
00074 //  sprintf(histo, "reportSummary");
00075   reportSummary_ = dbe_->get("HLT/EventInfo/reportSumamry");
00076   if ( reportSummary_ ) {
00077       dbe_->removeElement(reportSummary_->getName()); 
00078    }
00079   
00080   reportSummary_ = dbe_->bookFloat("reportSummary");
00081 
00082   int nSubsystems = 20;
00083 
00084  //initialize reportSummary to 1
00085   if (reportSummary_) reportSummary_->Fill(1);
00086 
00087   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
00088 
00089   
00090   char histo[100];
00091   
00092   for (int n = 0; n < nSubsystems; n++) {    
00093 
00094   switch(n){
00095   case 0 :   sprintf(histo,"hlt_dqm_EGamma");   break;
00096   case 1 :   sprintf(histo,"hlt_dqm_Muon");     break;
00097   case 2 :   sprintf(histo,"hlt_dqm_JetMet");   break;
00098   case 3 :   sprintf(histo,"hlt_dqm_BJets");    break;
00099   case 4 :   sprintf(histo,"hlt_dqm_Tau");      break;
00100   case 5 :   sprintf(histo,"hlt_dqm_Test1");    break;
00101   case 6 :   sprintf(histo,"hlt_dqm_Test2");    break;
00102   case 7 :   sprintf(histo,"hlt_dqm_Test3");    break;
00103   case 8 :   sprintf(histo,"hlt_dqm_Test4");    break;
00104   case 9 :   sprintf(histo,"hlt_dqm_Test5");    break;
00105   case 10 :  sprintf(histo,"hlt_dqm_Test6");    break;
00106   case 11 :  sprintf(histo,"hlt_dqm_Test7");    break;
00107   case 12 :  sprintf(histo,"hlt_dqm_Test8");    break;
00108   case 13 :  sprintf(histo,"hlt_dqm_Test9");    break;
00109   case 14 :  sprintf(histo,"hlt_dqm_Test10");   break;
00110   case 15 :  sprintf(histo,"hlt_dqm_Test11");   break;
00111   case 16 :  sprintf(histo,"hlt_dqm_Test12");   break;
00112   case 17 :  sprintf(histo,"hlt_dqm_Test13");   break;
00113   case 18 :  sprintf(histo,"hlt_dqm_Test14");   break;
00114   case 19 :  sprintf(histo,"hlt_dqm_Test15");   break;
00115   }
00116   
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137 
00138   
00139 //  if( reportSummaryContent_[i] = dbe_->get("HLT/EventInfo/reportSummaryContents/" + histo) ) 
00140 //  {
00141 //       dbe_->removeElement(reportSummaryContent_[i]->getName());
00142 //   }
00143   
00144    reportSummaryContent_[n] = dbe_->bookFloat(histo);
00145   }
00146 
00147   //initialize reportSummaryContents to 1
00148   for (int k = 0; k < nSubsystems; k++) {
00149     summaryContent[k] = 1;
00150     reportSummaryContent_[k]->Fill(1.);
00151   }  
00152 
00153 
00154   dbe_->setCurrentFolder("HLT/EventInfo");
00155 
00156   reportSummaryMap_ = dbe_->get("HLT/EventInfo/reportSummaryMap");
00157   if ( reportSummaryMap_ ) {
00158   dbe_->removeElement(reportSummaryMap_->getName());
00159   }
00160 
00161 
00162   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 5, 1, 6);
00163   reportSummaryMap_->setAxisTitle("", 1);
00164   reportSummaryMap_->setAxisTitle("", 2);
00165   reportSummaryMap_->setBinLabel(1,"EGAMMA",2);
00166   reportSummaryMap_->setBinLabel(2,"MUON",2);
00167   reportSummaryMap_->setBinLabel(3,"JETMET",2);
00168   reportSummaryMap_->setBinLabel(4,"BJETS",2);
00169   reportSummaryMap_->setBinLabel(5,"TAU",2);
00170   reportSummaryMap_->setBinLabel(1," ",1);
00171 
00172 }
00173 
00174 //--------------------------------------------------------
00175 void HLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00176 }
00177 
00178 //--------------------------------------------------------
00179 void HLTEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00180    // optionally reset histograms here
00181 }
00182 
00183 void HLTEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00184                           const edm::EventSetup& c){
00185 
00186   MonitorElement *Muon_QHist = dbe_->get("HLT/HLTMonMuon/Summary/Ratio_HLT_L1MuOpen");
00187 
00188   float muonResult = 0;
00189 
00190   if(Muon_QHist){
00191     const QReport *Muon_QReport = Muon_QHist->getQReport("CompareHist_Shape");
00192     if(Muon_QReport) muonResult = Muon_QReport->getQTresult();
00193   }
00194 
00195   int nSubsystems = 20;
00196   for (int k = 0; k < nSubsystems; k++) {
00197     // mask all HLT applications
00198     //if(k == 1 && muonResult != -1){
00199     //  summaryContent[k] = muonResult;
00200     //  reportSummaryContent_[k]->Fill(muonResult);
00201     //}else{
00202       summaryContent[k] = 1;
00203       reportSummaryContent_[k]->Fill(1.);
00204     //}
00205   }
00206   summarySum = 0;
00207 
00208   for (int m = 0; m < nSubsystems; m++) {    
00209     summarySum += summaryContent[m];
00210   }
00211 
00212 
00213   reportSummary = summarySum / nSubsystems;;
00214   if (reportSummary_) reportSummary_->Fill(reportSummary);
00215 
00216 
00217   reportSummaryMap_->setBinContent(1,1,summaryContent[0]);//Egamma
00218   reportSummaryMap_->setBinContent(1,2,summaryContent[1]);//Muon
00219   reportSummaryMap_->setBinContent(1,3,summaryContent[2]);//JetMet
00220   reportSummaryMap_->setBinContent(1,4,summaryContent[3]);//BJets
00221   reportSummaryMap_->setBinContent(1,5,summaryContent[4]);//Taus
00222 
00223 }
00224 
00225 //--------------------------------------------------------
00226 void HLTEventInfoClient::analyze(const Event& e, const EventSetup& context){
00227    
00228    counterEvt_++;
00229    if (prescaleEvt_<1) return;
00230    if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00231 
00232    if(verbose_) std::cout << "HLTEventInfoClient::analyze" << std::endl;
00233 
00234 
00235 }
00236 
00237 //--------------------------------------------------------
00238 void HLTEventInfoClient::endRun(const Run& r, const EventSetup& context){
00239 }
00240 
00241 //--------------------------------------------------------
00242 void HLTEventInfoClient::endJob(){
00243 }
00244 
00245 
00246 
00247 TH1F * HLTEventInfoClient::get1DHisto(std::string meName, DQMStore * dbi)
00248 {
00249 
00250   MonitorElement * me_ = dbi->get(meName);
00251 
00252   if (!me_) { 
00253     if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
00254     return NULL;
00255   }
00256 
00257   return me_->getTH1F();
00258 }
00259 
00260 TH2F * HLTEventInfoClient::get2DHisto(std::string meName, DQMStore * dbi)
00261 {
00262 
00263 
00264   MonitorElement * me_ = dbi->get(meName);
00265 
00266   if (!me_) { 
00267     if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
00268     return NULL;
00269   }
00270 
00271   return me_->getTH2F();
00272 }
00273 
00274 
00275 
00276 TProfile2D *  HLTEventInfoClient::get2DProfile(std::string meName, DQMStore * dbi)
00277 {
00278 
00279 
00280   MonitorElement * me_ = dbi->get(meName);
00281 
00282   if (!me_) { 
00283      if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
00284    return NULL;
00285   }
00286 
00287   return me_->getTProfile2D();
00288 }
00289 
00290 
00291 TProfile *  HLTEventInfoClient::get1DProfile(std::string meName, DQMStore * dbi)
00292 {
00293 
00294 
00295   MonitorElement * me_ = dbi->get(meName);
00296 
00297   if (!me_) { 
00298     if(verbose_) std::cout << "ME NOT FOUND." << std::endl;
00299     return NULL;
00300   }
00301 
00302   return me_->getTProfile();
00303 }
00304 
00305 
00306 
00307 
00308 
00309 
00310 
00311