CMS 3D CMS Logo

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 
00062       
00063 }
00064 
00065 //--------------------------------------------------------
00066 void L1TEventInfoClient::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("L1T/EventInfo");
00073 
00074 //  sprintf(histo, "reportSummary");
00075   if ( reportSummary_ = dbe_->get("L1T/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("L1T/EventInfo/reportSummaryContents");
00087 
00088   
00089   char histo[100];
00090   
00091   for (int n = 0; n < nSubsystems; n++) {    
00092 
00093     
00094     switch(n){
00095     case 0 :   sprintf(histo,"L1T_ECAL");    break;
00096     case 1 :   sprintf(histo,"L1T_HCAL");    break;
00097     case 2 :   sprintf(histo,"L1T_RCT");     break;
00098     case 3 :   sprintf(histo,"L1T_GCT");     break;
00099     case 4 :   sprintf(histo,"L1T_DTTPG");   break;
00100     case 5 :   sprintf(histo,"L1T_DTTF");    break;
00101     case 6 :   sprintf(histo,"L1T_CSCTPG");  break;
00102     case 7 :   sprintf(histo,"L1T_CSCTF");   break;
00103     case 8 :   sprintf(histo,"L1T_RPC");     break;
00104     case 9 :   sprintf(histo,"L1T_GMT");     break;
00105     case 10 :  sprintf(histo,"L1T_GT");      break;
00106     case 11 :  sprintf(histo,"L1T_RPCTG");   break;
00107     case 12 :  sprintf(histo,"L1T_EMUL");    break;
00108     case 13 :  sprintf(histo,"L1T_Timing");  break;
00109     case 14 :  sprintf(histo,"L1T_Test1");   break;
00110     case 15 :  sprintf(histo,"L1T_Test2");   break;
00111     case 16 :  sprintf(histo,"L1T_Test3");   break;
00112     case 17 :  sprintf(histo,"L1T_Test4");   break;
00113     case 18 :  sprintf(histo,"L1T_Test5");   break;
00114     case 19 :  sprintf(histo,"L1T_Test6");   break;
00115     }  
00116     
00117   
00118     //    if( reportSummaryContent_[i] = dbe_->get("L1T/EventInfo/reportSummaryContents/" + histo) ) 
00119     //  {
00120     //  dbe_->removeElement(reportSummaryContent_[i]->getName());
00121     //  }
00122     
00123     reportSummaryContent_[n] = dbe_->bookFloat(histo);
00124   }
00125 
00126   //initialize reportSummaryContents to 1
00127   for (int k = 0; k < nSubsystems; k++) {
00128     summaryContent[k] = 1;
00129     reportSummaryContent_[k]->Fill(1.);
00130   }  
00131 
00132 
00133   dbe_->setCurrentFolder("L1T/EventInfo");
00134 
00135   if ( reportSummaryMap_ = dbe_->get("L1T/EventInfo/reportSummaryMap") ) {
00136   dbe_->removeElement(reportSummaryMap_->getName());
00137   }
00138 
00139   //reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 5, 1, 6, 4, 1, 5);
00140   reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 1, 1, 2, 8, 1, 9);
00141   reportSummaryMap_->setAxisTitle("", 1);
00142   reportSummaryMap_->setAxisTitle("", 2);
00143   reportSummaryMap_->setBinLabel(1,"DTTF",2);
00144   reportSummaryMap_->setBinLabel(2,"CSCTF",2);
00145   reportSummaryMap_->setBinLabel(3,"RPC",2);
00146   reportSummaryMap_->setBinLabel(4,"GMT",2);
00147   reportSummaryMap_->setBinLabel(5,"RCT",2);
00148   reportSummaryMap_->setBinLabel(6,"GCT",2);
00149   reportSummaryMap_->setBinLabel(7,"GT",2);
00150   reportSummaryMap_->setBinLabel(8,"Timing",2);
00151   reportSummaryMap_->setBinLabel(1," ",1);
00152 
00153 }
00154 
00155 //--------------------------------------------------------
00156 void L1TEventInfoClient::beginRun(const Run& r, const EventSetup& context) {
00157 }
00158 
00159 //--------------------------------------------------------
00160 void L1TEventInfoClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00161    // optionally reset histograms here
00162 }
00163 
00164 void L1TEventInfoClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00165                           const edm::EventSetup& c){   
00166 
00167 
00168   MonitorElement *GCT_QHist = dbe_->get("L1T/L1TGCT/NonIsoEmOccEtaPhi");
00169   MonitorElement *RCT_QHist = dbe_->get("L1T/L1TRCT/RctNonIsoEmOccEtaPhi");
00170   MonitorElement *GMT_QHist = dbe_->get("L1T/L1TGMT/GMT_etaphi");
00171   //MonitorElement *CSCTF_QHist = dbe_->get("L1T/L1TCSCTF/CSCTF_occupancies");
00172   MonitorElement *CSCTF_QHist = dbe_->get("L1T/L1TCSCTF/CSCTF_Chamber_Occupancies");
00173   MonitorElement *DTTF_QHist = dbe_->get("L1T/L1TDTTF/DTTF_TRACKS/INTEG/Occupancy Summary");
00174   
00175   //MonitorElement *DTTF_QHist_phi = dbe_->get("L1T/L1TDTTF/DTTF_TRACKS/INTEG/Integrated Packed Phi");
00176   //MonitorElement *DTTF_QHist_pt = dbe_->get("L1T/L1TDTTF/DTTF_TRACKS/INTEG/Integrated Packed Pt");
00177   //MonitorElement *DTTF_QHist_qual = dbe_->get("L1T/L1TDTTF/DTTF_TRACKS/INTEG/Integrated Packed Quality");
00178 
00179 
00180   int nSubsystems = 20;
00181   for (int k = 0; k < nSubsystems; k++) {
00182     summaryContent[k] = 1;
00183     reportSummaryContent_[k]->Fill(1.);
00184   }
00185   summarySum = 0;
00186 
00187   
00188   int GCT_nXCh = 0,GCT_nYCh=0,RCT_nXCh=0,RCT_nYCh=0,GMT_nXCh=0,GMT_nYCh=0,CSCTF_nXCh=0,CSCTF_nYCh=0,DTTF_nXCh=0,DTTF_nYCh=0;
00189 
00190   if(GCT_QHist){
00191     GCT_nXCh = GCT_QHist->getNbinsX(); 
00192     GCT_nYCh = GCT_QHist->getNbinsY();
00193   }
00194   if(RCT_QHist){
00195     RCT_nXCh = RCT_QHist->getNbinsX(); 
00196     RCT_nYCh = RCT_QHist->getNbinsY();
00197   }
00198   if(GMT_QHist){
00199     GMT_nXCh = GMT_QHist->getNbinsX(); 
00200     GMT_nYCh = GMT_QHist->getNbinsY();
00201   }
00202   if(CSCTF_QHist){
00203     CSCTF_nXCh = CSCTF_QHist->getNbinsX(); 
00204     CSCTF_nYCh = CSCTF_QHist->getNbinsY();
00205   }
00206   if(DTTF_QHist){
00207     DTTF_nXCh = DTTF_QHist->getNbinsX();  
00208     DTTF_nYCh = DTTF_QHist->getNbinsY();
00209   } 
00210 
00211 
00212   int GCT_nCh=0,RCT_nCh=0,GMT_nCh=0,CSCTF_nCh=0,DTTF_nCh=0;
00213   
00214   if(GCT_nYCh) 
00215     GCT_nCh = GCT_nXCh*GCT_nYCh;
00216   if(RCT_nYCh) 
00217     RCT_nCh = RCT_nXCh*RCT_nYCh;
00218   if(GMT_nYCh) 
00219     GMT_nCh = GMT_nXCh*GMT_nYCh;
00220   if(CSCTF_nYCh) 
00221     CSCTF_nCh = CSCTF_nXCh*CSCTF_nYCh;
00222   if(DTTF_nYCh)
00223     DTTF_nCh = DTTF_nXCh*DTTF_nYCh;
00224   
00225 
00226   if (GCT_QHist){
00227     const QReport *GCT_QReport = GCT_QHist->getQReport("HotChannels_GCT");
00228     if (GCT_QReport) {
00229       int GCT_nBadCh = GCT_QReport->getBadChannels().size();
00230       //cout << "nBadCh(GCT): "  << GCT_nBadCh << endl;
00231       summaryContent[3] =  1 - GCT_nBadCh/GCT_nCh;
00232       //cout << "summaryContent[0]-GCT=" << summaryContent[0] << endl;
00233       reportSummaryContent_[3]->Fill( summaryContent[3] );
00234     } 
00235    
00236     // //get list of quality tests
00237    //     std::vector<QReport *> Qtest_map = NonIsoEmDeadEtaPhiChannels->getQReports();
00238    //     cout << "Qtest_map.size() = " << Qtest_map.size() << endl;
00239    //     if(Qtest_map.size() > 0) {
00240    //       for (std::vector<QReport *>::const_iterator it=Qtest_map.begin(); it!=Qtest_map.end(); it++)
00241    //   {
00242    //     //cout << endl;
00243    //     string qt_name = (*it)->getQRName();
00244    //     int qt_status = (*it)->getStatus();
00245    
00246    //     cout << "qt_name = " << qt_name << endl;
00247    //     cout << "qt_status = " << qt_status << endl;
00248    //     
00249    //   }
00250  }
00251 
00252   
00253   if (RCT_QHist){
00254     const QReport *RCT_QReport = RCT_QHist->getQReport("HotChannels_RCT");
00255     if (RCT_QReport) {
00256       int RCT_nBadCh = RCT_QReport->getBadChannels().size();
00257       summaryContent[2]=1-RCT_nBadCh/RCT_nCh;
00258       reportSummaryContent_[2]->Fill( summaryContent[2] );
00259     } 
00260   }
00261 
00262   if (GMT_QHist){
00263     const QReport *GMT_QReport = GMT_QHist->getQReport("HotChannels_GMT");
00264     if (GMT_QReport) {
00265       int GMT_nBadCh = GMT_QReport->getBadChannels().size();
00266       summaryContent[9] = 1 - GMT_nBadCh/GMT_nCh;
00267       reportSummaryContent_[9]->Fill( summaryContent[9] );
00268     } 
00269   }
00270 
00271   if (CSCTF_QHist){
00272 //     const QReport *CSCTF_QReport = CSCTF_QHist->getQReport("HotChannels_CSCTF");
00273 //     if (CSCTF_QReport) {
00274 //       int CSCTF_nBadCh = CSCTF_QReport->getBadChannels().size();
00275 //       summaryContent[7] = 1 - CSCTF_nBadCh/CSCTF_nCh;
00276 //       reportSummaryContent_[7]->Fill( summaryContent[7]);
00277 //     } 
00278 
00279     int nFilledBins_CSCTF = 0;
00280     int nTotalBins_CSCTF  = 0;
00281 
00282     for(int i=1; i<55; i++)// 54
00283       for(int j=1; j<11;j++){ // 10
00284         if( (j==1 || j==10) && ((i%9)>3 || (i%9)==0) ) continue;  // Skip uninstrumented regions
00285         nTotalBins_CSCTF++;
00286         if(CSCTF_QHist->getBinContent(i,j)) nFilledBins_CSCTF++;
00287       }
00288 
00289     summaryContent[7] = (float)nFilledBins_CSCTF / (float)nTotalBins_CSCTF;
00290     reportSummaryContent_[7]->Fill( summaryContent[7] );
00291   }
00292 
00293   if (DTTF_QHist){
00294 //      const QReport *DTTF_QReport = DTTF_QHist->getQReport("HotChannels_DTTF_2D");
00295 //      cout << "DTTF_QReport: " << DTTF_QReport << endl;
00296 
00297 //      if (DTTF_QReport) {
00298 //        int DTTF_nBadCh = DTTF_QReport->getBadChannels().size();
00299 //        cout << "nBadCh(DTTF): "  << DTTF_nBadCh << endl;
00300 //        cout << "hotchannel: " << DTTF_QReport->getQRName() << endl;
00301 //        cout << "hotchannel: " << DTTF_QReport->getMessage() << endl;
00302 //        cout << "getStatus: " << DTTF_QReport->getStatus() << endl;
00303 //      } 
00304 
00305 //     if (DTTF_QReport) {
00306 //       int DTTF_nBadCh = DTTF_QReport->getBadChannels().size();
00307 //       //cout << "nBadCh(DTTF): "  << DTTF_nBadCh << endl;
00308 //       summaryContent[5] = 1 - DTTF_nBadCh/DTTF_nCh;
00309 //       //cout << "summaryContent[4]-DTTF=" << summaryContent[4] << endl;
00310 //       reportSummaryContent_[5]->Fill( summaryContent[5] );
00311 //    } 
00312 
00313     //summaryContent = fraction of filled bins
00314     int nFilledBins = 0;
00315     int nTotalBins  = 72;
00316     for(int i=1; i<7; i++)//6 logical wheels
00317       for(int j=1; j<13;j++){ //12 sectors
00318         if(DTTF_QHist->getBinContent(i,j)) nFilledBins++;
00319       }
00320     summaryContent[5] = (float)nFilledBins / (float)nTotalBins;
00321     reportSummaryContent_[5]->Fill( summaryContent[5] );
00322   }
00323 
00324   //obtain results from Comp2RefChi2 test
00325 //   if(DTTF_QHist_phi){
00326 //     const QReport *DTTF_QReport_phi = DTTF_QHist_phi->getQReport("CompareHist");
00327 //     if (DTTF_QReport_phi){
00328 //       cout << "phi: " << DTTF_QReport_phi->getQRName() << endl;
00329 //       cout << "phi: " << DTTF_QReport_phi->getMessage() << endl;
00330 //       cout << "getStatus: " << DTTF_QReport_phi->getStatus() << endl;
00331 //     }
00332     
00333 //    const QReport *DTTF_QReport_phi2 = DTTF_QHist_phi->getQReport("HotChannels_DTTF_phi");
00334 //     cout << "DTTF_QReport_phi2: " << DTTF_QReport_phi2 << endl;
00335 //     if (DTTF_QReport_phi2) {
00336 //       int DTTF_nBadCh = DTTF_QReport_phi2->getBadChannels().size();
00337 //       cout << "nBadCh(DTTF): "  << DTTF_nBadCh << endl;
00338 //       cout << "hotchannel: " << DTTF_QReport_phi2->getQRName() << endl;
00339 //       cout << "hotchannel: " << DTTF_QReport_phi2->getMessage() << endl;
00340 //       cout << "getStatus: " << DTTF_QReport_phi2->getStatus() << endl;
00341 //     } 
00342 
00343 // }
00344   
00345 //   if(DTTF_QHist_pt){
00346 //     const QReport *DTTF_QReport_pt = DTTF_QHist_pt->getQReport("CompareHist");
00347 //     if (DTTF_QReport_pt){
00348 //       cout << "pt: " << DTTF_QReport_pt->getQRName() << endl;
00349 //       cout << "pt: " << DTTF_QReport_pt->getMessage() << endl;
00350 //       cout << "getStatus: " << DTTF_QReport_pt->getStatus() << endl;
00351 //     }
00352   
00353 //     const QReport *DTTF_QReport_pt2 = DTTF_QHist_pt->getQReport("HotChannels_DTTF_pt");
00354 //     cout << "DTTF_QReport_pt2: " << DTTF_QReport_pt2 << endl;
00355 //     if (DTTF_QReport_pt2) {
00356 //       int DTTF_nBadCh = DTTF_QReport_pt2->getBadChannels().size();
00357 //       cout << "nBadCh(DTTF): "  << DTTF_nBadCh << endl;
00358 //       cout << "hotchannel: " << DTTF_QReport_pt2->getQRName() << endl;
00359 //       cout << "hotchannel: " << DTTF_QReport_pt2->getMessage() << endl;
00360 //       cout << "getStatus: " << DTTF_QReport_pt2->getStatus() << endl;
00361 //     }
00362 
00363 //  }
00364   
00365 //   if(DTTF_QHist_qual){
00366 //     const QReport *DTTF_QReport_qual = DTTF_QHist_qual->getQReport("CompareHist");
00367 //     if (DTTF_QReport_qual){
00368 //       cout << "qual: " << DTTF_QReport_qual->getQRName() << endl;
00369 //       cout << "qual: " << DTTF_QReport_qual->getMessage() << endl;
00370 //       cout << "getStatus: " << DTTF_QReport_qual->getStatus() << endl;
00371 //     }
00372 //   }
00373   
00374   
00375   for (int m = 0; m < nSubsystems; m++) {    
00376     summarySum += summaryContent[m];
00377   }
00378   
00379   reportSummary = summarySum / nSubsystems;
00380   //cout << "reportSummary " << reportSummary << endl;
00381   if (reportSummary_) reportSummary_->Fill(reportSummary);
00382   
00383 
00384     //5x4 summary map", " << 
00385 //  int jcount=0;
00386 //    //fill the known systems
00387 //   for (int i = 0; i < nSubsystems; i++) {
00388 //     cout << "summaryContent[" << i << "]" << summaryContent[i] << endl;
00389 //     if(!(i%5))jcount++;
00390 //     reportSummaryMap_->setBinContent(i%5+1,jcount, summaryContent[i]);
00391 //   }
00392 
00393    //8x1 summary map
00394   reportSummaryMap_->setBinContent(1,1,summaryContent[5]);//DTTF
00395   reportSummaryMap_->setBinContent(1,2,summaryContent[7]);//CSCTF
00396   reportSummaryMap_->setBinContent(1,3,summaryContent[8]);//RPC
00397   reportSummaryMap_->setBinContent(1,4,summaryContent[1]);//GMT
00398   reportSummaryMap_->setBinContent(1,5,summaryContent[9]);//RCT
00399   reportSummaryMap_->setBinContent(1,6,summaryContent[3]);//GCT
00400   reportSummaryMap_->setBinContent(1,7,summaryContent[10]);//GT
00401   reportSummaryMap_->setBinContent(1,8,summaryContent[13]);//Timing
00402 
00403 //   //fill for known systems
00404 //   for(int i = 1; i < 6; i++){
00405     
00406 //     cout << "summaryContent[" << i-1 << "] = " << summaryContent[i-1] << endl;
00407 //     reportSummaryMap_->setBinContent( i, 1, summaryContent[i-1] );
00408 //   }
00409 
00410 //   //fill the rest
00411 //   for (int i = 1; i < 6; i++) {    
00412 //     for (int j = 2; j < 5; j++) {    
00413       
00414 //       reportSummaryMap_->setBinContent( i, j, 1. );
00415 //     }
00416 //   }
00417 
00418 
00419 } 
00420 
00421 
00422 
00423 //--------------------------------------------------------
00424 void L1TEventInfoClient::analyze(const Event& e, const EventSetup& context){
00425    
00426   counterEvt_++;
00427   if (prescaleEvt_<1) return;
00428   if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00429   
00430   if(verbose_) cout << "L1TEventInfoClient::analyze" << endl;
00431 
00432   
00433 
00434 
00435   //reportSummary = average of report summaries of each system
00436   
00437  
00438 }
00439 
00440 //--------------------------------------------------------
00441 void L1TEventInfoClient::endRun(const Run& r, const EventSetup& context){
00442 }
00443 
00444 //--------------------------------------------------------
00445 void L1TEventInfoClient::endJob(){
00446 }
00447 
00448 
00449 
00450 TH1F * L1TEventInfoClient::get1DHisto(string meName, DQMStore * dbi)
00451 {
00452 
00453   MonitorElement * me_ = dbi->get(meName);
00454 
00455   if (!me_) { 
00456     if(verbose_) cout << "ME NOT FOUND." << endl;
00457     return NULL;
00458   }
00459 
00460   return me_->getTH1F();
00461 }
00462 
00463 TH2F * L1TEventInfoClient::get2DHisto(string meName, DQMStore * dbi)
00464 {
00465 
00466 
00467   MonitorElement * me_ = dbi->get(meName);
00468 
00469   if (!me_) { 
00470     if(verbose_) cout << "ME NOT FOUND." << endl;
00471     return NULL;
00472   }
00473 
00474   return me_->getTH2F();
00475 }
00476 
00477 
00478 
00479 TProfile2D *  L1TEventInfoClient::get2DProfile(string meName, DQMStore * dbi)
00480 {
00481 
00482 
00483   MonitorElement * me_ = dbi->get(meName);
00484 
00485   if (!me_) { 
00486      if(verbose_) cout << "ME NOT FOUND." << endl;
00487    return NULL;
00488   }
00489 
00490   return me_->getTProfile2D();
00491 }
00492 
00493 
00494 TProfile *  L1TEventInfoClient::get1DProfile(string meName, DQMStore * dbi)
00495 {
00496 
00497 
00498   MonitorElement * me_ = dbi->get(meName);
00499 
00500   if (!me_) { 
00501     if(verbose_) cout << "ME NOT FOUND." << endl;
00502     return NULL;
00503   }
00504 
00505   return me_->getTProfile();
00506 }
00507 
00508 
00509 
00510 
00511 
00512 
00513 
00514 

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