CMS 3D CMS Logo

L1TEMUEventInfoClient.cc

Go to the documentation of this file.
00001 #include "DQM/L1TMonitorClient/interface/L1TEMUEventInfoClient.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 "TRandom.h"
00011 #include <TF1.h>
00012 #include <stdio.h>
00013 #include <sstream>
00014 #include <math.h>
00015 #include <TProfile.h>
00016 #include <TProfile2D.h>
00017 #include <memory>
00018 #include <iostream>
00019 #include <vector>
00020 #include <iomanip>
00021 #include <string>
00022 #include <fstream>
00023 #include "TROOT.h"
00024 
00025 using namespace edm;
00026 using namespace std;
00027 
00028 L1TEMUEventInfoClient::L1TEMUEventInfoClient(const edm::ParameterSet& ps)
00029 {
00030   parameters_=ps;
00031   initialize();
00032 }
00033 
00034 L1TEMUEventInfoClient::~L1TEMUEventInfoClient(){
00035  if(verbose_) cout <<"[TriggerDQM]: ending... " << endl;
00036 }
00037 
00038 //--------------------------------------------------------
00039 void L1TEMUEventInfoClient::initialize(){ 
00040 
00041   counterLS_=0; 
00042   counterEvt_=0; 
00043   
00044   // get back-end interface
00045   dbe_ = Service<DQMStore>().operator->();
00046   
00047   // base folder for the contents of this job
00048   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
00049   
00050   monitorDir_ = parameters_.getUntrackedParameter<string>("monitorDir","");
00051   if(verbose_) cout << "Monitor dir = " << monitorDir_ << endl;
00052     
00053   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00054   if(verbose_) cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00055   
00056   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00057   if(verbose_) cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00058   
00059   //tbd should revert to regular order as defined in hardwarevalidation
00060   // + use std labels defined in traits therein
00061   std::string syslabel   [nsysmon_]=
00062     {"DTTF","DTTPG","CSCTF","CSCTPG","RPC","GMT", "ECAL","HCAL","RCT","GCT","GT"};
00063   std::string syslabelext[nsysmon_]=
00064     {"DTF","DTP","CTF","CTP","RPC","GMT", "ETP","HTP","RCT","GCT","GLT"};
00065   std::vector<unsigned int> sysmask(0,nsysmon_); 
00066   sysmask = parameters_.getUntrackedParameter<std::vector<unsigned int> >("maskedSystems", sysmask);
00067 
00068   for(int i=0; i<nsysmon_; i++) {
00069     syslabel_[i] = syslabel[i];
00070     syslabelext_[i] = syslabelext[i];
00071     sysmask_[i] = sysmask[i];
00072   }
00073   
00074 }
00075 
00076 //--------------------------------------------------------
00077 void L1TEMUEventInfoClient::beginJob(const EventSetup& context){
00078 
00079   if(verbose_) cout <<"[TriggerDQM]: Begin Job" << endl;
00080   // get backendinterface  
00081   dbe_ = Service<DQMStore>().operator->();
00082 
00083   dbe_->setCurrentFolder("L1TEMU/EventInfo");
00084 
00085 //  sprintf(histo, "reportSummary");
00086   if ( reportSummary_ = dbe_->get("L1TEMU/EventInfo/reportSumamry") ) {
00087       dbe_->removeElement(reportSummary_->getName()); 
00088    }
00089   
00090   reportSummary_ = dbe_->bookFloat("reportSummary");
00091 
00092   //initialize reportSummary to 1
00093   if (reportSummary_) reportSummary_->Fill(1);
00094 
00095   dbe_->setCurrentFolder("L1TEMU/EventInfo/reportSummaryContents");
00096 
00097   char lbl[100];  
00098 
00099   for (int i=0; i<nsys_; i++) {    
00100     
00101     if(i<nsysmon_)
00102       sprintf(lbl,"L1TEMU_%s",syslabelext_[i].data());
00103     else 
00104       sprintf(lbl,"L1TEMU_dummy%d",i-nsysmon_+1);
00105 
00106     reportSummaryContent_[i] = dbe_->bookFloat(lbl);
00107     //if(reportSummaryContent_[i] = dbe_->get("L1T/EventInfo/reportSummaryContents/" + histo)) dbe_->removeElement(reportSummaryContent_[i]->getName());
00108   }
00109 
00110   //initialize reportSummaryContents to 1
00111   for (int k=0; k<nsys_; k++) {
00112     summaryContent[k] = 1;
00113     reportSummaryContent_[k]->Fill(1.);
00114   }  
00115 
00116   dbe_->setCurrentFolder("L1TEMU/EventInfo");
00117 
00118   if ( reportSummaryMap_ = dbe_->get("L1TEMU/EventInfo/reportSummaryMap") ) {
00119     dbe_->removeElement(reportSummaryMap_->getName());
00120   }
00121 
00122   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 11, 1, nsysmon_+1);
00123   for(int i=0; i<nsysmon_; i++) {
00124     reportSummaryMap_->setBinLabel(i+1,syslabelext_[i],2);
00125   }
00126   reportSummaryMap_->setAxisTitle("", 1);
00127   reportSummaryMap_->setAxisTitle("", 2);
00128   reportSummaryMap_->setBinLabel(1," ",1);
00129 
00130 }
00131 
00132 //--------------------------------------------------------
00133 void L1TEMUEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00134 }
00135 
00136 //--------------------------------------------------------
00137 void L1TEMUEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00138    // optionally reset histograms here
00139 }
00140 
00141 void L1TEMUEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00142                           const edm::EventSetup& c){
00143 
00144   for (int i = 0; i < nsys_; i++) {
00145     summaryContent[i] = 1;    
00146     reportSummaryContent_[i]->Fill(1.);
00147   }
00148   summarySum = 0;
00149 
00150   MonitorElement* QHist[nsysmon_];   
00151   std::string lbl("");  
00152   for(int i=0; i<nsysmon_; i++) {
00153     lbl.clear();
00154     lbl+="L1TEMU/"; lbl+=syslabel_[i]; lbl+="/"; 
00155     lbl+=syslabelext_[i]; lbl+="ErrorFlag";
00156     QHist[i]=dbe_->get(lbl.data());
00157     float pv = -1.;
00158     if(!sysmask_[i])
00159       pv = setSummary(QHist[i]);
00160     summaryContent[i] = pv;
00161     reportSummaryContent_[i]->Fill(pv);
00162   }
00163 
00164   for (int i = 0; i < nsys_; i++) {    
00165     if(summaryContent[i] != -1)  summarySum += summaryContent[i];
00166   }
00167   
00168   reportSummary = summarySum / nsys_;
00169   if (reportSummary_) reportSummary_->Fill(reportSummary);
00170 
00171    //12x1 summary map
00172   for (int i=0; i< 11; i++)
00173     reportSummaryMap_->setBinContent(1,i+1,summaryContent[i]);
00174 
00175 }
00176 
00177 //--------------------------------------------------------
00178 void L1TEMUEventInfoClient::analyze(const Event& e, const EventSetup& context){
00179    
00180    counterEvt_++;
00181    if (prescaleEvt_<1) return;
00182    if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00183 
00184    if(verbose_) cout << "L1TEMUEventInfoClient::analyze" << endl;
00185 }
00186 
00187 //--------------------------------------------------------
00188 void L1TEMUEventInfoClient::endRun(const Run& r, const EventSetup& context){
00189 }
00190 
00191 //--------------------------------------------------------
00192 void L1TEMUEventInfoClient::endJob(){
00193 }
00194 
00195 //set subsystem pv in summary map
00196 Float_t L1TEMUEventInfoClient::setSummary(MonitorElement* QHist) {
00197   bool isempty = QHist->getEntries()==0;
00198   //errflag bins: agree, loc agree, loc disagree, data only, emul only
00199   if(!isempty)
00200     for(int i=1; i<5; i++) 
00201       if(QHist->getBinContent(i)>0) 
00202         {isempty=false;continue;}
00203   return isempty ? -1. : 
00204     (QHist->getBinContent(1)) / (QHist->getEntries());
00205 }
00206 
00207 TH1F * L1TEMUEventInfoClient::get1DHisto(string meName, DQMStore * dbi)
00208 {
00209 
00210   MonitorElement * me_ = dbi->get(meName);
00211 
00212   if (!me_) { 
00213     if(verbose_) cout << "ME NOT FOUND." << endl;
00214     return NULL;
00215   }
00216 
00217   return me_->getTH1F();
00218 }
00219 
00220 TH2F * L1TEMUEventInfoClient::get2DHisto(string meName, DQMStore * dbi)
00221 {
00222 
00223 
00224   MonitorElement * me_ = dbi->get(meName);
00225 
00226   if (!me_) { 
00227     if(verbose_) cout << "ME NOT FOUND." << endl;
00228     return NULL;
00229   }
00230 
00231   return me_->getTH2F();
00232 }
00233 
00234 
00235 
00236 TProfile2D *  L1TEMUEventInfoClient::get2DProfile(string meName, DQMStore * dbi)
00237 {
00238 
00239 
00240   MonitorElement * me_ = dbi->get(meName);
00241 
00242   if (!me_) { 
00243      if(verbose_) cout << "ME NOT FOUND." << endl;
00244    return NULL;
00245   }
00246 
00247   return me_->getTProfile2D();
00248 }
00249 
00250 
00251 TProfile *  L1TEMUEventInfoClient::get1DProfile(string meName, DQMStore * dbi)
00252 {
00253 
00254 
00255   MonitorElement * me_ = dbi->get(meName);
00256 
00257   if (!me_) { 
00258     if(verbose_) cout << "ME NOT FOUND." << endl;
00259     return NULL;
00260   }
00261 
00262   return me_->getTProfile();
00263 }
00264 
00265 
00266 
00267 
00268 
00269 
00270 
00271 

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