CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/L1TMonitorClient/src/L1TEventInfoClient.cc

Go to the documentation of this file.
00001 #include "DQM/L1TMonitorClient/interface/L1TEventInfoClient.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 L1TEventInfoClient::L1TEventInfoClient(const edm::ParameterSet& ps)
00031 {
00032   parameters_=ps;
00033   initialize();
00034 }
00035 
00036 L1TEventInfoClient::~L1TEventInfoClient(){
00037  if(verbose_) cout <<"[TriggerDQM]: ending... " << endl;
00038 }
00039 
00040 //--------------------------------------------------------
00041 void L1TEventInfoClient::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   thresholdLS_ = parameters_.getUntrackedParameter<int>("thresholdLS", 1);
00062   if(verbose_) cout << "Minimum LS required to perform QTests = " << thresholdLS_ << " lumi section(s)"<< endl;
00063 
00064   GCT_NonIsoEm_threshold_ = parameters_.getUntrackedParameter<double>("GCT_NonIsoEm_threshold",100000);
00065   GCT_IsoEm_threshold_ = parameters_.getUntrackedParameter<double>("GCT_IsoEm_threshold",1000000);
00066   GCT_TauJets_threshold_ = parameters_.getUntrackedParameter<double>("GCT_TauJets_threshold",100000);
00067   GCT_AllJets_threshold_ = parameters_.getUntrackedParameter<double>("GCT_AllJets_threshold",100000);
00068   GMT_Muons_threshold_ = parameters_.getUntrackedParameter<double>("GMT_Muons_threshold",100000);
00069 
00070   if(verbose_){
00071     cout << " Thresholds are as follows:" << endl;
00072     cout << " \t GCT_NonIsoEm_threshold_: " << GCT_NonIsoEm_threshold_ << endl;
00073     cout << " \t GCT_IsoEm_threshold_:    " << GCT_IsoEm_threshold_ << endl;
00074     cout << " \t GCT_TauJets_threshold_:  " << GCT_TauJets_threshold_ << endl;
00075     cout << " \t GCT_AllJets_threshold_:  " << GCT_AllJets_threshold_ << endl;
00076     cout << " \t GMT_Muons_threshold_:    " << GMT_Muons_threshold_ << endl;
00077   }
00078 
00079   std::vector<string> emptyMask;
00080 
00081   dataMask = parameters_.getUntrackedParameter<std::vector<string> >("dataMaskedSystems", emptyMask);
00082   emulMask = parameters_.getUntrackedParameter<std::vector<string> >("emulatorMaskedSystems", emptyMask);
00083 
00084   s_mapDataValues["EMPTY"]    = data_empty;
00085   s_mapDataValues["ALL"]      = data_all;
00086   s_mapDataValues["GT"]       = data_gt;
00087   s_mapDataValues["MUONS"]    = data_muons;
00088   s_mapDataValues["JETS"]     = data_jets;
00089   s_mapDataValues["TAUJETS"]  = data_taujets;
00090   s_mapDataValues["ISOEM"]    = data_isoem;
00091   s_mapDataValues["NONISOEM"] = data_nonisoem;
00092   s_mapDataValues["MET"]      = data_met;
00093 
00094   s_mapEmulValues["EMPTY"]  = emul_empty;
00095   s_mapEmulValues["ALL"]    = emul_all;
00096   s_mapEmulValues["DTTF"]   = emul_dtf;
00097   s_mapEmulValues["DTTPG"]  = emul_dtp;
00098   s_mapEmulValues["CSCTF"]  = emul_ctf;
00099   s_mapEmulValues["CSCTPG"] = emul_ctp;
00100   s_mapEmulValues["RPC"]    = emul_rpc;
00101   s_mapEmulValues["GMT"]    = emul_gmt;
00102   s_mapEmulValues["ECAL"]   = emul_etp;
00103   s_mapEmulValues["HCAL"]   = emul_htp;
00104   s_mapEmulValues["RCT"]    = emul_rct;
00105   s_mapEmulValues["GCT"]    = emul_gct;
00106   s_mapEmulValues["GLT"]    = emul_glt;
00107 
00108 }
00109 
00110 //--------------------------------------------------------
00111 void L1TEventInfoClient::beginJob(void){
00112 
00113   if(verbose_) cout <<"[TriggerDQM]: Begin Job" << endl;
00114   // get backendinterface  
00115   dbe_ = Service<DQMStore>().operator->();
00116 
00117   dbe_->setCurrentFolder("L1T/EventInfo");
00118 
00119   if( (reportSummary_ = dbe_->get("L1T/EventInfo/reportSumamry")) ) {
00120       dbe_->removeElement(reportSummary_->getName()); 
00121    }
00122   
00123   reportSummary_ = dbe_->bookFloat("reportSummary");
00124 
00125   //initialize reportSummary to 1
00126   if (reportSummary_) reportSummary_->Fill(1);
00127 
00128   dbe_->setCurrentFolder("L1T/EventInfo/reportSummaryContents");
00129 
00130   
00131   char histo[100];
00132   
00133   for (int n = 0; n < nsys_; n++) {    
00134 
00135     switch(n){
00136     case 0 :   sprintf(histo,"L1T_MET");      break;
00137     case 1 :   sprintf(histo,"L1T_NonIsoEM"); break;
00138     case 2 :   sprintf(histo,"L1T_IsoEM");    break;
00139     case 3 :   sprintf(histo,"L1T_TauJets");  break;
00140     case 4 :   sprintf(histo,"L1T_Jets");     break;
00141     case 5 :   sprintf(histo,"L1T_Muons");    break;
00142     case 6 :   sprintf(histo,"L1T_GT");       break;
00143     case 7 :   sprintf(histo,"L1TEMU_GLT");   break;
00144     case 8 :   sprintf(histo,"L1TEMU_GMT");   break;
00145     case 9 :   sprintf(histo,"L1TEMU_RPC");   break;
00146     case 10:   sprintf(histo,"L1TEMU_CTP");   break;
00147     case 11:   sprintf(histo,"L1TEMU_CTF");   break;
00148     case 12:   sprintf(histo,"L1TEMU_DTP");   break;
00149     case 13:   sprintf(histo,"L1TEMU_DTF");   break;
00150     case 14:   sprintf(histo,"L1TEMU_HTP");   break;
00151     case 15:   sprintf(histo,"L1TEMU_ETP");   break;
00152     case 16:   sprintf(histo,"L1TEMU_GCT");   break;
00153     case 17:   sprintf(histo,"L1TEMU_RCT");   break;
00154     }  
00155     
00156     reportSummaryContent_[n] = dbe_->bookFloat(histo);
00157   }
00158 
00159   //initialize reportSummaryContents to 0
00160   for (int k = 0; k < nsys_; k++) {
00161     summaryContent[k] = 0;
00162     reportSummaryContent_[k]->Fill(0.);
00163   }  
00164 
00165 
00166   dbe_->setCurrentFolder("L1T/EventInfo");
00167 
00168   if( (reportSummaryMap_ = dbe_->get("L1T/EventInfo/reportSummaryMap")) ){
00169     dbe_->removeElement(reportSummaryMap_->getName());
00170   }
00171 
00172   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 2, 1, 3, 11, 1, 12);
00173   reportSummaryMap_->setAxisTitle("", 1);
00174   reportSummaryMap_->setAxisTitle("", 2);
00175 
00176   reportSummaryMap_->setBinLabel(1," ",1);
00177   reportSummaryMap_->setBinLabel(2," ",1);
00178 
00179   reportSummaryMap_->setBinLabel(1," ",2);
00180   reportSummaryMap_->setBinLabel(2," ",2);
00181   reportSummaryMap_->setBinLabel(3," ",2);
00182   reportSummaryMap_->setBinLabel(4," ",2);
00183   reportSummaryMap_->setBinLabel(5," ",2);
00184   reportSummaryMap_->setBinLabel(6," ",2);
00185   reportSummaryMap_->setBinLabel(7," ",2);
00186   reportSummaryMap_->setBinLabel(8," ",2);
00187   reportSummaryMap_->setBinLabel(9," ",2);
00188   reportSummaryMap_->setBinLabel(10," ",2);
00189   reportSummaryMap_->setBinLabel(11," ",2);
00190 
00191 }
00192 
00193 //--------------------------------------------------------
00194 void L1TEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00195 }
00196 
00197 //--------------------------------------------------------
00198 void L1TEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00199    // optionally reset histograms here
00200 }
00201 
00202 void L1TEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00203                           const edm::EventSetup& c){   
00204 
00205 
00206   counterLS_++;
00207 
00208   MonitorElement *GMT_QHist = dbe_->get("L1T/L1TGMT/GMT_etaphi");
00209   MonitorElement *GCT_IsoEm_QHist = dbe_->get("L1T/L1TGCT/IsoEmRankEtaPhi");
00210   MonitorElement *GCT_NonIsoEm_QHist = dbe_->get("L1T/L1TGCT/NonIsoEmRankEtaPhi");
00211   MonitorElement *GCT_AllJets_QHist = dbe_->get("L1T/L1TGCT/AllJetsEtEtaPhi");
00212   MonitorElement *GCT_TauJets_QHist = dbe_->get("L1T/L1TGCT/TauJetsEtEtaPhi");
00213   MonitorElement *GT_AlgoBits_QHist = dbe_->get("L1T/L1TGT/algo_bits");
00214   MonitorElement *GT_TechBits_QHist = dbe_->get("L1T/L1TGT/tt_bits");
00215 
00216 
00217 
00218   for (int k = 0; k < nsys_; k++) {
00219     summaryContent[k] = 0;
00220     reportSummaryContent_[k]->Fill(0.);
00221   }
00222   summarySum = 0;
00223 
00224   
00225   int GCT_IsoEm_nXCh = 0,GCT_IsoEm_nYCh=0,GCT_NonIsoEm_nXCh = 0,GCT_NonIsoEm_nYCh=0,GCT_AllJets_nXCh = 0,GCT_AllJets_nYCh=0,GCT_TauJets_nXCh = 0,GCT_TauJets_nYCh=0,GMT_nXCh=0,GMT_nYCh=0;
00226 
00227 
00228   if(GCT_IsoEm_QHist){
00229     GCT_IsoEm_nXCh = GCT_IsoEm_QHist->getNbinsX(); 
00230     GCT_IsoEm_nYCh = GCT_IsoEm_QHist->getNbinsY();
00231   }
00232   if(GCT_NonIsoEm_QHist){
00233     GCT_NonIsoEm_nXCh = GCT_NonIsoEm_QHist->getNbinsX(); 
00234     GCT_NonIsoEm_nYCh = GCT_NonIsoEm_QHist->getNbinsY();
00235   }
00236   if(GCT_AllJets_QHist){
00237     GCT_AllJets_nXCh = GCT_AllJets_QHist->getNbinsX(); 
00238     GCT_AllJets_nYCh = GCT_AllJets_QHist->getNbinsY();
00239   }
00240   if(GCT_TauJets_QHist){
00241     GCT_TauJets_nXCh = GCT_TauJets_QHist->getNbinsX(); 
00242     GCT_TauJets_nYCh = GCT_TauJets_QHist->getNbinsY();
00243   }
00244   if(GMT_QHist){
00245     GMT_nXCh = GMT_QHist->getNbinsX(); 
00246     GMT_nYCh = GMT_QHist->getNbinsY();
00247   }
00248 
00249 
00250   int GCT_IsoEm_nCh=0,GCT_NonIsoEm_nCh=0,GCT_AllJets_nCh=0,GCT_TauJets_nCh=0,GMT_nCh=0,GT_AlgoBits_nCh=0,GT_TechBits_nCh=0;
00251   
00252   if(GCT_IsoEm_nYCh) 
00253     GCT_IsoEm_nCh = GCT_IsoEm_nXCh*GCT_IsoEm_nYCh;
00254   if(GCT_NonIsoEm_nYCh) 
00255     GCT_NonIsoEm_nCh = GCT_NonIsoEm_nXCh*GCT_NonIsoEm_nYCh;
00256   if(GCT_AllJets_nYCh) 
00257     GCT_AllJets_nCh = GCT_AllJets_nXCh*GCT_AllJets_nYCh;
00258   if(GCT_TauJets_nYCh) 
00259     GCT_TauJets_nCh = GCT_TauJets_nXCh*GCT_TauJets_nYCh;
00260   if(GMT_nYCh) 
00261     GMT_nCh = GMT_nXCh*GMT_nYCh;
00262   if(GT_AlgoBits_QHist) GT_AlgoBits_nCh = GT_AlgoBits_QHist->getNbinsX(); 
00263   if(GT_TechBits_QHist) GT_TechBits_nCh = GT_TechBits_QHist->getNbinsX(); 
00264 
00265 
00266 
00267 
00268 
00269   //
00270   // 00  MET Quality Tests
00271   //
00272 
00273 
00274 
00275   // GCT uninstrumented regions for IsoEm, NonIsoEm, and TauJets
00276   int nCh_no_inst = 144;
00277 
00278   //
00279   // 01  NonIsoEM Quality Tests
00280   //
00281   if (GCT_NonIsoEm_QHist){
00282     const QReport *GCT_NonIsoEm_DeadCh_QReport = GCT_NonIsoEm_QHist->getQReport("DeadChannels_GCT_2D_loose");
00283     const QReport *GCT_NonIsoEm_HotCh_QReport  = GCT_NonIsoEm_QHist->getQReport("HotChannels_GCT_2D");
00284 
00285     int GCT_NonIsoEm_nBadCh = 0;
00286 
00287     if (GCT_NonIsoEm_DeadCh_QReport) {
00288       int GCT_NonIsoEm_nDeadCh = GCT_NonIsoEm_DeadCh_QReport->getBadChannels().size();
00289       if( verbose_ ) cout << "  GCT_NonIsoEm_nDeadCh: "  << GCT_NonIsoEm_nDeadCh 
00290                           << ", GCT_NonIsoEm_nCh: " << GCT_NonIsoEm_nCh 
00291                           << ", GCT_NonIsoEm_DeadCh_efficiency: " << 1 - (float)GCT_NonIsoEm_nDeadCh/(float)GCT_NonIsoEm_nCh 
00292                           << " GCT_NonIsoEm_DeadCh QTResult = " << GCT_NonIsoEm_DeadCh_QReport->getQTresult() << std::endl;
00293 
00294       GCT_NonIsoEm_nBadCh+=GCT_NonIsoEm_nDeadCh;
00295     } 
00296 
00297     if (GCT_NonIsoEm_HotCh_QReport) {
00298       int GCT_NonIsoEm_nHotCh = GCT_NonIsoEm_HotCh_QReport->getBadChannels().size();
00299       if( verbose_ ) cout << "  GCT_NonIsoEm_nHotCh: "  << GCT_NonIsoEm_nHotCh 
00300                           << ", GCT_NonIsoEm_nCh: " << GCT_NonIsoEm_nCh 
00301                           << ", GCT_NonIsoEm_HotCh_efficiency: " << 1 - (float)GCT_NonIsoEm_nHotCh/(float)GCT_NonIsoEm_nCh 
00302                           << " GCT_NonIsoEm_HotCh QTResult = " << GCT_NonIsoEm_HotCh_QReport->getQTresult() << std::endl;
00303 
00304       GCT_NonIsoEm_nBadCh+=GCT_NonIsoEm_nHotCh;
00305     }
00306 
00307     if( verbose_ ) std::cout << "    GCT_NonIsoEm total efficiency = " << 1 - (float)GCT_NonIsoEm_nBadCh/(float)GCT_NonIsoEm_nCh << std::endl;
00308 
00309     double GCT_NonIsoEm_nentries = GCT_NonIsoEm_QHist->getEntries();
00310     float nonisoResult = -1;
00311     if( (counterLS_>=1000 && GCT_NonIsoEm_nentries==0) ) nonisoResult = 0;
00312     if( (GCT_NonIsoEm_nentries>GCT_NonIsoEm_threshold_) ) nonisoResult = 1 - (float)(GCT_NonIsoEm_nBadCh-nCh_no_inst)/(float)(GCT_NonIsoEm_nCh-nCh_no_inst);
00313     summaryContent[1] = ( nonisoResult < (1.0+1e-10) ) ? nonisoResult : 1.0;
00314   }
00315 
00316 
00317 
00318 
00319   //
00320   // 02  IsoEM Quality Tests
00321   //
00322   if (GCT_IsoEm_QHist){
00323     const QReport *GCT_IsoEm_DeadCh_QReport = GCT_IsoEm_QHist->getQReport("DeadChannels_GCT_2D_loose");
00324     const QReport *GCT_IsoEm_HotCh_QReport = GCT_IsoEm_QHist->getQReport("HotChannels_GCT_2D");
00325 
00326     int GCT_IsoEm_nBadCh = 0;
00327 
00328     if (GCT_IsoEm_DeadCh_QReport) {
00329       int GCT_IsoEm_nDeadCh = GCT_IsoEm_DeadCh_QReport->getBadChannels().size();
00330       if( verbose_ ) cout << "  GCT_IsoEm_nDeadCh: "  << GCT_IsoEm_nDeadCh 
00331                           << ", GCT_IsoEm_nCh: " << GCT_IsoEm_nCh 
00332                           << ", GCT_IsoEm_DeadCh_efficiency: " << 1 - (float)GCT_IsoEm_nDeadCh/(float)GCT_IsoEm_nCh 
00333                           << " GCT_IsoEm_DeadCh QTResult = " << GCT_IsoEm_DeadCh_QReport->getQTresult() << std::endl;
00334 
00335       GCT_IsoEm_nBadCh+=GCT_IsoEm_nDeadCh;
00336     } 
00337 
00338     if (GCT_IsoEm_HotCh_QReport) {
00339       int GCT_IsoEm_nHotCh = GCT_IsoEm_HotCh_QReport->getBadChannels().size();
00340       if( verbose_ ) cout << "  GCT_IsoEm_nHotCh: "  << GCT_IsoEm_nHotCh 
00341                           << ", GCT_IsoEm_nCh: " << GCT_IsoEm_nCh 
00342                           << ", GCT_IsoEm_HotCh_efficiency: " << 1 - (float)GCT_IsoEm_nHotCh/(float)GCT_IsoEm_nCh 
00343                           << " GCT_IsoEm_HotCh QTResult = " << GCT_IsoEm_HotCh_QReport->getQTresult() << std::endl;
00344 
00345       GCT_IsoEm_nBadCh+=GCT_IsoEm_nHotCh;
00346     }
00347 
00348     if( verbose_ ) std::cout << "    GCT_IsoEm total efficiency = " << 1 - (float)GCT_IsoEm_nBadCh/(float)GCT_IsoEm_nCh << std::endl;
00349 
00350     double GCT_IsoEm_nentries = GCT_IsoEm_QHist->getEntries();
00351     float isoResult = -1;
00352     if( (counterLS_>=thresholdLS_ && GCT_IsoEm_nentries==0) ) isoResult = 0;
00353     if( (GCT_IsoEm_nentries>GCT_IsoEm_threshold_) ) isoResult = 1 - (float)(GCT_IsoEm_nBadCh-nCh_no_inst)/(float)(GCT_IsoEm_nCh-nCh_no_inst);
00354     summaryContent[2] = ( isoResult < (1.0+1e-10) ) ? isoResult : 1.0;
00355   }
00356 
00357 
00358 
00359 
00360   //
00361   // 03  TauJets Quality Tests
00362   //
00363   if (GCT_TauJets_QHist){
00364     const QReport *GCT_TauJets_DeadCh_QReport = GCT_TauJets_QHist->getQReport("DeadChannels_GCT_2D_loose");
00365     const QReport *GCT_TauJets_HotCh_QReport = GCT_TauJets_QHist->getQReport("HotChannels_GCT_2D");
00366 
00367     int GCT_TauJets_nBadCh = 0;
00368 
00369     if (GCT_TauJets_DeadCh_QReport) {
00370       int GCT_TauJets_nDeadCh = GCT_TauJets_DeadCh_QReport->getBadChannels().size();
00371       if( verbose_ ) cout << "  GCT_TauJets_nDeadCh: "  << GCT_TauJets_nDeadCh 
00372                           << ", GCT_TauJets_nCh: " << GCT_TauJets_nCh 
00373                           << ", GCT_TauJets_DeadCh_efficiency: " << 1 - (float)GCT_TauJets_nDeadCh/(float)GCT_TauJets_nCh 
00374                           << " GCT_TauJets_DeadCh QTResult = " << GCT_TauJets_DeadCh_QReport->getQTresult() << std::endl;
00375 
00376       GCT_TauJets_nBadCh+=GCT_TauJets_nDeadCh;
00377     } 
00378 
00379     if (GCT_TauJets_HotCh_QReport) {
00380       int GCT_TauJets_nHotCh = GCT_TauJets_HotCh_QReport->getBadChannels().size();
00381       if( verbose_ ) cout << "  GCT_TauJets_nHotCh: "  << GCT_TauJets_nHotCh 
00382                           << ", GCT_TauJets_nCh: " << GCT_TauJets_nCh 
00383                           << ", GCT_TauJets_HotCh_efficiency: " << 1 - (float)GCT_TauJets_nHotCh/(float)GCT_TauJets_nCh 
00384                           << " GCT_TauJets_HotCh QTResult = " << GCT_TauJets_HotCh_QReport->getQTresult() << std::endl;
00385 
00386       GCT_TauJets_nBadCh+=GCT_TauJets_nHotCh;
00387     }
00388 
00389     if( verbose_ ) std::cout << "    GCT_TauJets total efficiency = " << 1 - (float)GCT_TauJets_nBadCh/(float)GCT_TauJets_nCh << std::endl;
00390 
00391     double GCT_TauJets_nentries = GCT_TauJets_QHist->getEntries();
00392     float taujetsResult = -1;
00393     if( (counterLS_>=thresholdLS_ && GCT_TauJets_nentries==0) ) taujetsResult = 0;
00394     if( (GCT_TauJets_nentries>GCT_TauJets_threshold_) ) taujetsResult = 1 - (float)(GCT_TauJets_nBadCh-nCh_no_inst)/(float)(GCT_TauJets_nCh-nCh_no_inst);
00395     summaryContent[3] = ( taujetsResult < (1.0+1e-10) ) ? taujetsResult : 1.0;
00396   }
00397 
00398 
00399 
00400 
00401   //
00402   // 04  Jets Quality Tests
00403   //
00404   if (GCT_AllJets_QHist){
00405     const QReport *GCT_AllJets_DeadCh_QReport = GCT_AllJets_QHist->getQReport("DeadChannels_GCT_2D_tight");
00406     const QReport *GCT_AllJets_HotCh_QReport = GCT_AllJets_QHist->getQReport("HotChannels_GCT_2D");
00407 
00408     int GCT_AllJets_nBadCh = 0;
00409 
00410     if (GCT_AllJets_DeadCh_QReport) {
00411       int GCT_AllJets_nDeadCh = GCT_AllJets_DeadCh_QReport->getBadChannels().size();
00412       if( verbose_ ) cout << "  GCT_AllJets_nDeadCh: "  << GCT_AllJets_nDeadCh 
00413                           << ", GCT_AllJets_nCh: " << GCT_AllJets_nCh 
00414                           << ", GCT_AllJets_DeadCh_efficiency: " << 1 - (float)GCT_AllJets_nDeadCh/(float)GCT_AllJets_nCh 
00415                           << " GCT_AllJets_DeadCh QTResult = " << GCT_AllJets_DeadCh_QReport->getQTresult() << std::endl;
00416 
00417       GCT_AllJets_nBadCh+=GCT_AllJets_nDeadCh;
00418     } 
00419 
00420     if (GCT_AllJets_HotCh_QReport) {
00421       int GCT_AllJets_nHotCh = GCT_AllJets_HotCh_QReport->getBadChannels().size();
00422       if( verbose_ ) cout << "  GCT_AllJets_nHotCh: "  << GCT_AllJets_nHotCh 
00423                           << ", GCT_AllJets_nCh: " << GCT_AllJets_nCh 
00424                           << ", GCT_AllJets_HotCh_efficiency: " << 1 - (float)GCT_AllJets_nHotCh/(float)GCT_AllJets_nCh 
00425                           << " GCT_AllJets_HotCh QTResult = " << GCT_AllJets_HotCh_QReport->getQTresult() << std::endl;
00426 
00427       GCT_AllJets_nBadCh+=GCT_AllJets_nHotCh;
00428     }
00429 
00430     if( verbose_ ) std::cout << "    GCT_AllJets total efficiency = " << 1 - (float)GCT_AllJets_nBadCh/(float)GCT_AllJets_nCh << std::endl;
00431 
00432     double GCT_AllJets_nentries = GCT_AllJets_QHist->getEntries();
00433     float jetsResult = -1;
00434     if( (counterLS_>=thresholdLS_ && GCT_AllJets_nentries==0) ) jetsResult = 0;
00435     if( (GCT_AllJets_nentries>GCT_AllJets_threshold_) ) jetsResult = 1 - (float)GCT_AllJets_nBadCh/(float)GCT_AllJets_nCh;
00436     summaryContent[4] = ( jetsResult < (1.0+1e-10) ) ? jetsResult : 1.0;
00437   }
00438 
00439 
00440 
00441 
00442   //
00443   // 05  Muon Quality Tests
00444   //
00445 
00446   if (GMT_QHist){
00447     const QReport *GMT_DeadCh_QReport = GMT_QHist->getQReport("DeadChannels_GMT_2D");
00448     const QReport *GMT_HotCh_QReport  = GMT_QHist->getQReport("HotChannels_GMT_2D");
00449 
00450     int GMT_nBadCh = 0;
00451 
00452     if (GMT_DeadCh_QReport) {
00453       int GMT_nDeadCh = GMT_DeadCh_QReport->getBadChannels().size();
00454       if( verbose_ ) cout << "  GMT_nDeadCh: "  << GMT_nDeadCh 
00455                           << ", GMT_nCh: " << GMT_nCh 
00456                           << ", GMT_DeadCh_efficiency: " << 1 - (float)GMT_nDeadCh/(float)GMT_nCh 
00457                           << " GMT_DeadCh QTResult = " << GMT_DeadCh_QReport->getQTresult() << std::endl;
00458 
00459       GMT_nBadCh+=GMT_nDeadCh;
00460     } 
00461 
00462     if (GMT_HotCh_QReport) {
00463       int GMT_nHotCh = GMT_HotCh_QReport->getBadChannels().size();
00464       if( verbose_ ) cout << "  GMT_nHotCh: "  << GMT_nHotCh 
00465                           << ", GMT_nCh: " << GMT_nCh 
00466                           << ", GMT_HotCh_efficiency: " << 1 - (float)GMT_nHotCh/(float)GMT_nCh 
00467                           << " GMT_HotCh QTResult = " << GMT_HotCh_QReport->getQTresult() << std::endl;
00468 
00469       GMT_nBadCh+=GMT_nHotCh;
00470     }
00471 
00472     if( verbose_ ) std::cout << "    GMT total efficiency = " << 1 - (float)GMT_nBadCh/(float)GMT_nCh << std::endl;
00473 
00474     double GMT_nentries = GMT_QHist->getEntries();
00475     float muonResult = -1;
00476     if( (counterLS_>=thresholdLS_ && GMT_nentries==0) ) muonResult = 0;
00477     if( (GMT_nentries>GMT_Muons_threshold_) ) muonResult = 1.5*(1 - (float)GMT_nBadCh/(float)GMT_nCh);
00478     summaryContent[5] = ( muonResult < (1.0+1e-10) ) ? muonResult : 1.0;
00479   }
00480 
00481 
00482 
00483   //
00484   // 06  GT Quality Tests
00485   //
00486   double gt_algobits_prob = 0;
00487   double gt_techbits_prob = 0;
00488 
00489   if (GT_AlgoBits_QHist){
00490     gt_algobits_prob = 1;
00491     const QReport *GT_AlgoBits_QReport = GT_AlgoBits_QHist->getQReport("CompareHist_GT");
00492     if (GT_AlgoBits_QReport) gt_algobits_prob = GT_AlgoBits_QReport->getQTresult();
00493   }
00494   if (GT_TechBits_QHist){
00495     gt_techbits_prob = 1;
00496     const QReport *GT_TechBits_QReport = GT_TechBits_QHist->getQReport("CompareHist_GT");
00497     if (GT_TechBits_QReport) gt_techbits_prob = GT_TechBits_QReport->getQTresult();
00498   }
00499 
00500   if( gt_algobits_prob!=-1 && gt_techbits_prob!=-1 ) summaryContent[6] = 0.5*( gt_algobits_prob + gt_techbits_prob );
00501   else if( GT_AlgoBits_QHist && GT_TechBits_QHist  ) summaryContent[6] = 1;
00502   else summaryContent[6] = 0;
00503 
00504 
00505 
00506 
00507   //
00508   // 07 - 17  L1T EMU Quality Tests
00509   //
00510 
00511 
00512 
00513   //
00514   // Apply masks for data and emulator
00515   //
00516 
00517   //  Data Mask
00518   unsigned int NumDataMask = dataMask.size();
00519   std::vector<string> maskedData;
00520   for( unsigned int i=0; i<NumDataMask; i++ ){
00521     std::string mask_sys_tmp  = dataMask[i];
00522     std::string mask_sys = StringToUpper(mask_sys_tmp);
00523     switch(s_mapDataValues[mask_sys])
00524       {
00525       case data_empty:
00526         break;
00527       case data_all:
00528         for( int m=0; m<7; m++ ) summaryContent[m] = -2;
00529         maskedData.push_back(mask_sys_tmp);
00530         break;
00531       case data_gt:
00532         summaryContent[6]=-2;
00533         maskedData.push_back(mask_sys_tmp);
00534         break;
00535       case data_muons:
00536         summaryContent[5]=-2;
00537         maskedData.push_back(mask_sys_tmp);
00538         break;
00539       case data_jets:
00540         summaryContent[4]=-2;
00541         maskedData.push_back(mask_sys_tmp);
00542         break;
00543       case data_taujets:
00544         summaryContent[3]=-2;
00545         maskedData.push_back(mask_sys_tmp);
00546         break;
00547       case data_isoem:
00548         summaryContent[2]=-2;
00549         maskedData.push_back(mask_sys_tmp);
00550         break;
00551       case data_nonisoem:
00552         summaryContent[1]=-2;
00553         maskedData.push_back(mask_sys_tmp);
00554         break;
00555       case data_met:
00556         summaryContent[0]=-2;
00557         maskedData.push_back(mask_sys_tmp);
00558         break;
00559       default:
00560         if( verbose_ ) cout << "   User input mask '" << mask_sys_tmp << "' is not recognized." << endl;
00561         break;
00562       }
00563   }
00564 
00565   //  Emulator Mask
00566   unsigned int NumEmulMask = emulMask.size();
00567   std::vector<string> maskedEmul;
00568   for( unsigned int i=0; i<NumEmulMask; i++ ){
00569     std::string mask_sys_tmp  = emulMask[i];
00570     std::string mask_sys = StringToUpper(mask_sys_tmp);
00571     switch(s_mapEmulValues[mask_sys])
00572       {
00573       case emul_empty:
00574         break;
00575       case emul_all:
00576         for( int m=7; m<18; m++ ) summaryContent[m] = -2;
00577         maskedEmul.push_back(mask_sys_tmp);
00578         break;
00579       case emul_glt:
00580         summaryContent[7]=-2;
00581         maskedEmul.push_back(mask_sys_tmp);
00582         break;
00583       case emul_gmt:
00584         summaryContent[8]=-2;
00585         maskedEmul.push_back(mask_sys_tmp);
00586         break;
00587       case emul_rpc:
00588         summaryContent[9]=-2;
00589         maskedEmul.push_back(mask_sys_tmp);
00590         break;
00591       case emul_ctp:
00592         summaryContent[10]=-2;
00593         maskedEmul.push_back(mask_sys_tmp);
00594         break;
00595       case emul_ctf:
00596         summaryContent[11]=-2;
00597         maskedEmul.push_back(mask_sys_tmp);
00598         break;
00599       case emul_dtp:
00600         summaryContent[12]=-2;
00601         maskedEmul.push_back(mask_sys_tmp);
00602         break;
00603       case emul_dtf:
00604         summaryContent[13]=-2;
00605         maskedEmul.push_back(mask_sys_tmp);
00606         break;
00607       case emul_htp:
00608         summaryContent[14]=-2;
00609         maskedEmul.push_back(mask_sys_tmp);
00610         break;
00611       case emul_etp:
00612         summaryContent[15]=-2;
00613         maskedEmul.push_back(mask_sys_tmp);
00614         break;
00615       case emul_gct:
00616         summaryContent[16]=-2;
00617         maskedEmul.push_back(mask_sys_tmp);
00618         break;
00619       case emul_rct:
00620         summaryContent[17]=-2;
00621         maskedEmul.push_back(mask_sys_tmp);
00622         break;
00623       default:
00624         if( verbose_ ) cout << "   User input mask '" << mask_sys_tmp << "' is not recognized." << endl;
00625         break;
00626       }
00627   }
00628 
00629 
00630   int numUnMaskedSystems = 0;
00631   for( int m=0; m<nsys_; m++ ){
00632     if( summaryContent[m]>-1e-5){
00633       if( m<7 ){
00634         summarySum += summaryContent[m];
00635         numUnMaskedSystems++;
00636       }
00637 
00638       reportSummaryContent_[m]->Fill( summaryContent[m] );
00639     }
00640   }
00641 
00642 
00643 
00644   // For now, only use L1T for reportSummary value
00645   reportSummary = summarySum/float(numUnMaskedSystems);
00646   if (reportSummary_) reportSummary_->Fill(reportSummary);
00647   
00648 
00649   //L1T summary map
00650   reportSummaryMap_->setBinContent(1,11,summaryContent[6]); // GT
00651   reportSummaryMap_->setBinContent(1,10,summaryContent[5]); // Muons
00652   reportSummaryMap_->setBinContent(1,9, summaryContent[4]); // Jets
00653   reportSummaryMap_->setBinContent(1,8, summaryContent[3]); // TauJets
00654   reportSummaryMap_->setBinContent(1,7, summaryContent[2]); // IsoEM
00655   reportSummaryMap_->setBinContent(1,6, summaryContent[1]); // NonIsoEM
00656   reportSummaryMap_->setBinContent(1,5, summaryContent[0]); // MET
00657 
00658   //L1TEMU summary map
00659   reportSummaryMap_->setBinContent(2,11,summaryContent[7]); // GLT
00660   reportSummaryMap_->setBinContent(2,10,summaryContent[8]); // GMT
00661   reportSummaryMap_->setBinContent(2,9, summaryContent[9]); // RPC
00662   reportSummaryMap_->setBinContent(2,8, summaryContent[10]);// CTP
00663   reportSummaryMap_->setBinContent(2,7, summaryContent[11]);// CTF
00664   reportSummaryMap_->setBinContent(2,6, summaryContent[12]);// DTP
00665   reportSummaryMap_->setBinContent(2,5, summaryContent[13]);// DTF
00666   reportSummaryMap_->setBinContent(2,4, summaryContent[14]);// HTP
00667   reportSummaryMap_->setBinContent(2,3, summaryContent[15]);// ETP
00668   reportSummaryMap_->setBinContent(2,2, summaryContent[16]);// GCT
00669   reportSummaryMap_->setBinContent(2,1, summaryContent[17]);// RCT
00670 
00671 
00672   if( verbose_ ){
00673     if( maskedData.size()>0 ){
00674       std::cout << "  Masked Data Systems = ";
00675       for( unsigned int i=0; i<maskedData.size(); i++ ){
00676         if( i!=maskedData.size()-1 ){
00677           std::cout << maskedData[i] << ", ";
00678         }
00679         else {
00680           std::cout << maskedData[i] << std::endl;
00681         }
00682       }
00683     }
00684     if( maskedEmul.size()>0 ){
00685       std::cout << "  Masked Emul Systems = ";
00686       for( unsigned int i=0; i<maskedEmul.size(); i++ ){
00687         if( i!=maskedEmul.size()-1 ){
00688           std::cout << maskedEmul[i] << ", ";
00689         }
00690         else {
00691           std::cout << maskedEmul[i] << std::endl;
00692         }
00693       }
00694     }
00695 
00696     std::cout << "  L1T " << std::endl;
00697     std::cout << "     summaryContent[0]  = MET      = " << summaryContent[0] << std::endl;
00698     std::cout << "     summaryContent[1]  = NonIsoEM = " << summaryContent[1] << std::endl;
00699     std::cout << "     summaryContent[2]  = IsoEM    = " << summaryContent[2] << std::endl;
00700     std::cout << "     summaryContent[3]  = TauJets  = " << summaryContent[3] << std::endl;
00701     std::cout << "     summaryContent[4]  = Jets     = " << summaryContent[4] << std::endl;
00702     std::cout << "     summaryContent[5]  = Muons    = " << summaryContent[5] << std::endl;
00703     std::cout << "     summaryContent[6]  = GT       = " << summaryContent[6] << std::endl;
00704     std::cout << "  L1T EMU" << std::endl;
00705     std::cout << "     summaryContent[7]  = GLT      = " << summaryContent[7] << std::endl;
00706     std::cout << "     summaryContent[8]  = GMT      = " << summaryContent[8] << std::endl;
00707     std::cout << "     summaryContent[9]  = RPC      = " << summaryContent[9] << std::endl;
00708     std::cout << "     summaryContent[10] = CTP      = " << summaryContent[10] << std::endl;
00709     std::cout << "     summaryContent[11] = CTF      = " << summaryContent[11] << std::endl;
00710     std::cout << "     summaryContent[12] = DTP      = " << summaryContent[12] << std::endl;
00711     std::cout << "     summaryContent[13] = DTF      = " << summaryContent[13] << std::endl;
00712     std::cout << "     summaryContent[14] = HTP      = " << summaryContent[14] << std::endl;
00713     std::cout << "     summaryContent[15] = ETP      = " << summaryContent[15] << std::endl;
00714     std::cout << "     summaryContent[16] = GCT      = " << summaryContent[16] << std::endl;
00715     std::cout << "     summaryContent[17] = RCT      = " << summaryContent[17] << std::endl;
00716   }
00717 
00718 } 
00719 
00720 
00721 
00722 //--------------------------------------------------------
00723 void L1TEventInfoClient::analyze(const Event& e, const EventSetup& context){
00724    
00725   counterEvt_++;
00726   if (prescaleEvt_<1) return;
00727   if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00728   
00729   if(verbose_) cout << "L1TEventInfoClient::analyze" << endl;
00730 
00731   
00732 
00733 
00734   //reportSummary = average of report summaries of each system
00735   
00736  
00737 }
00738 
00739 //--------------------------------------------------------
00740 void L1TEventInfoClient::endRun(const Run& r, const EventSetup& context){
00741 }
00742 
00743 //--------------------------------------------------------
00744 void L1TEventInfoClient::endJob(){
00745 }
00746 
00747 
00748 
00749 TH1F * L1TEventInfoClient::get1DHisto(string meName, DQMStore * dbi)
00750 {
00751 
00752   MonitorElement * me_ = dbi->get(meName);
00753 
00754   if (!me_) { 
00755     if(verbose_) cout << "ME NOT FOUND." << endl;
00756     return NULL;
00757   }
00758 
00759   return me_->getTH1F();
00760 }
00761 
00762 TH2F * L1TEventInfoClient::get2DHisto(string meName, DQMStore * dbi)
00763 {
00764 
00765 
00766   MonitorElement * me_ = dbi->get(meName);
00767 
00768   if (!me_) { 
00769     if(verbose_) cout << "ME NOT FOUND." << endl;
00770     return NULL;
00771   }
00772 
00773   return me_->getTH2F();
00774 }
00775 
00776 
00777 
00778 TProfile2D *  L1TEventInfoClient::get2DProfile(string meName, DQMStore * dbi)
00779 {
00780 
00781 
00782   MonitorElement * me_ = dbi->get(meName);
00783 
00784   if (!me_) { 
00785      if(verbose_) cout << "ME NOT FOUND." << endl;
00786    return NULL;
00787   }
00788 
00789   return me_->getTProfile2D();
00790 }
00791 
00792 
00793 TProfile *  L1TEventInfoClient::get1DProfile(string meName, DQMStore * dbi)
00794 {
00795 
00796 
00797   MonitorElement * me_ = dbi->get(meName);
00798 
00799   if (!me_) { 
00800     if(verbose_) cout << "ME NOT FOUND." << endl;
00801     return NULL;
00802   }
00803 
00804   return me_->getTProfile();
00805 }
00806 
00807 string L1TEventInfoClient::StringToUpper(string strToConvert)
00808 {//change each element of the string to upper case
00809    for(unsigned int i=0;i<strToConvert.length();i++)
00810    {
00811       strToConvert[i] = toupper(strToConvert[i]);
00812    }
00813    return strToConvert;//return the converted string
00814 }
00815 
00816 
00817 
00818 
00819 
00820 
00821