CMS 3D CMS Logo

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_) cout <<"[TriggerDQM]: ending... " << 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<string>("monitorDir","");
00053   if(verbose_) cout << "Monitor dir = " << monitorDir_ << endl;
00054     
00055   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00056   if(verbose_) cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00057   
00058   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00059   if(verbose_) cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00060   
00061 
00062       
00063 }
00064 
00065 //--------------------------------------------------------
00066 void HLTEventInfoClient::beginJob(const EventSetup& context){
00067 
00068   if(verbose_) cout <<"[TriggerDQM]: Begin Job" << endl;
00069   // get backendinterface  
00070   dbe_ = Service<DQMStore>().operator->();
00071 
00072   dbe_->setCurrentFolder("HLT/EventInfo");
00073 
00074 //  sprintf(histo, "reportSummary");
00075   if ( reportSummary_ = dbe_->get("HLT/EventInfo/reportSumamry") ) {
00076       dbe_->removeElement(reportSummary_->getName()); 
00077    }
00078   
00079   reportSummary_ = dbe_->bookFloat("reportSummary");
00080 
00081   int nSubsystems = 20;
00082 
00083  //initialize reportSummary to 1
00084   if (reportSummary_) reportSummary_->Fill(1);
00085 
00086   dbe_->setCurrentFolder("HLT/EventInfo/reportSummaryContents");
00087 
00088   
00089   char histo[100];
00090   
00091   for (int n = 0; n < nSubsystems; n++) {    
00092 
00093   switch(n){
00094   case 0 :   sprintf(histo,"hlt_dqm_EGamma");   break;
00095   case 1 :   sprintf(histo,"hlt_dqm_Muon");     break;
00096   case 2 :   sprintf(histo,"hlt_dqm_JetMet");   break;
00097   case 3 :   sprintf(histo,"hlt_dqm_BJets");    break;
00098   case 4 :   sprintf(histo,"hlt_dqm_Tau");      break;
00099   case 5 :   sprintf(histo,"hlt_dqm_Test1");    break;
00100   case 6 :   sprintf(histo,"hlt_dqm_Test2");    break;
00101   case 7 :   sprintf(histo,"hlt_dqm_Test3");    break;
00102   case 8 :   sprintf(histo,"hlt_dqm_Test4");    break;
00103   case 9 :   sprintf(histo,"hlt_dqm_Test5");    break;
00104   case 10 :  sprintf(histo,"hlt_dqm_Test6");    break;
00105   case 11 :  sprintf(histo,"hlt_dqm_Test7");    break;
00106   case 12 :  sprintf(histo,"hlt_dqm_Test8");    break;
00107   case 13 :  sprintf(histo,"hlt_dqm_Test9");    break;
00108   case 14 :  sprintf(histo,"hlt_dqm_Test10");   break;
00109   case 15 :  sprintf(histo,"hlt_dqm_Test11");   break;
00110   case 16 :  sprintf(histo,"hlt_dqm_Test12");   break;
00111   case 17 :  sprintf(histo,"hlt_dqm_Test13");   break;
00112   case 18 :  sprintf(histo,"hlt_dqm_Test14");   break;
00113   case 19 :  sprintf(histo,"hlt_dqm_Test15");   break;
00114   }
00115   
00116 
00117 
00118 
00119 
00120 
00121 
00122 
00123 
00124 
00125 
00126 
00127 
00128 
00129 
00130 
00131 
00132 
00133 
00134 
00135 
00136 
00137   
00138 //  if( reportSummaryContent_[i] = dbe_->get("HLT/EventInfo/reportSummaryContents/" + histo) ) 
00139 //  {
00140 //       dbe_->removeElement(reportSummaryContent_[i]->getName());
00141 //   }
00142   
00143    reportSummaryContent_[n] = dbe_->bookFloat(histo);
00144   }
00145 
00146   //initialize reportSummaryContents to 1
00147   for (int k = 0; k < nSubsystems; k++) {
00148     summaryContent[k] = 1;
00149     reportSummaryContent_[k]->Fill(1.);
00150   }  
00151 
00152 
00153   dbe_->setCurrentFolder("HLT/EventInfo");
00154 
00155   if ( reportSummaryMap_ = dbe_->get("HLT/EventInfo/reportSummaryMap") ) {
00156   dbe_->removeElement(reportSummaryMap_->getName());
00157   }
00158 
00159 
00160   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 5, 1, 6);
00161   reportSummaryMap_->setAxisTitle("", 1);
00162   reportSummaryMap_->setAxisTitle("", 2);
00163   reportSummaryMap_->setBinLabel(1,"EGAMMA",2);
00164   reportSummaryMap_->setBinLabel(2,"MUON",2);
00165   reportSummaryMap_->setBinLabel(3,"JETMET",2);
00166   reportSummaryMap_->setBinLabel(4,"BJETS",2);
00167   reportSummaryMap_->setBinLabel(5,"TAU",2);
00168   reportSummaryMap_->setBinLabel(1," ",1);
00169 
00170 }
00171 
00172 //--------------------------------------------------------
00173 void HLTEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00174 }
00175 
00176 //--------------------------------------------------------
00177 void HLTEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00178    // optionally reset histograms here
00179 }
00180 
00181 void HLTEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00182                           const edm::EventSetup& c){
00183 
00184   int nSubsystems = 20;
00185   for (int k = 0; k < nSubsystems; k++) {
00186     summaryContent[k] = 1;
00187     reportSummaryContent_[k]->Fill(1.);
00188   }
00189   summarySum = 0;
00190 
00191   for (int m = 0; m < nSubsystems; m++) {    
00192     summarySum += summaryContent[m];
00193   }
00194 
00195 
00196   reportSummary = summarySum / nSubsystems;;
00197   if (reportSummary_) reportSummary_->Fill(reportSummary);
00198 
00199 
00200   reportSummaryMap_->setBinContent(1,1,summaryContent[0]);//Egamma
00201   reportSummaryMap_->setBinContent(1,2,summaryContent[1]);//Muon
00202   reportSummaryMap_->setBinContent(1,3,summaryContent[2]);//JetMet
00203   reportSummaryMap_->setBinContent(1,4,summaryContent[3]);//BJets
00204   reportSummaryMap_->setBinContent(1,5,summaryContent[4]);//Taus
00205 
00206 }
00207 
00208 //--------------------------------------------------------
00209 void HLTEventInfoClient::analyze(const Event& e, const EventSetup& context){
00210    
00211    counterEvt_++;
00212    if (prescaleEvt_<1) return;
00213    if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00214 
00215    if(verbose_) cout << "HLTEventInfoClient::analyze" << endl;
00216 
00217 
00218 }
00219 
00220 //--------------------------------------------------------
00221 void HLTEventInfoClient::endRun(const Run& r, const EventSetup& context){
00222 }
00223 
00224 //--------------------------------------------------------
00225 void HLTEventInfoClient::endJob(){
00226 }
00227 
00228 
00229 
00230 TH1F * HLTEventInfoClient::get1DHisto(string meName, DQMStore * dbi)
00231 {
00232 
00233   MonitorElement * me_ = dbi->get(meName);
00234 
00235   if (!me_) { 
00236     if(verbose_) cout << "ME NOT FOUND." << endl;
00237     return NULL;
00238   }
00239 
00240   return me_->getTH1F();
00241 }
00242 
00243 TH2F * HLTEventInfoClient::get2DHisto(string meName, DQMStore * dbi)
00244 {
00245 
00246 
00247   MonitorElement * me_ = dbi->get(meName);
00248 
00249   if (!me_) { 
00250     if(verbose_) cout << "ME NOT FOUND." << endl;
00251     return NULL;
00252   }
00253 
00254   return me_->getTH2F();
00255 }
00256 
00257 
00258 
00259 TProfile2D *  HLTEventInfoClient::get2DProfile(string meName, DQMStore * dbi)
00260 {
00261 
00262 
00263   MonitorElement * me_ = dbi->get(meName);
00264 
00265   if (!me_) { 
00266      if(verbose_) cout << "ME NOT FOUND." << endl;
00267    return NULL;
00268   }
00269 
00270   return me_->getTProfile2D();
00271 }
00272 
00273 
00274 TProfile *  HLTEventInfoClient::get1DProfile(string meName, DQMStore * dbi)
00275 {
00276 
00277 
00278   MonitorElement * me_ = dbi->get(meName);
00279 
00280   if (!me_) { 
00281     if(verbose_) cout << "ME NOT FOUND." << endl;
00282     return NULL;
00283   }
00284 
00285   return me_->getTProfile();
00286 }
00287 
00288 
00289 
00290 
00291 
00292 
00293 
00294 

Generated on Tue Jun 9 17:33:07 2009 for CMSSW by  doxygen 1.5.4