CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/DQM/L1TMonitorClient/src/L1TRPCTFClient.cc

Go to the documentation of this file.
00001 #include "DQM/L1TMonitorClient/interface/L1TRPCTFClient.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 
00013 #include <TF1.h>
00014 #include <stdio.h>
00015 #include <sstream>
00016 #include <math.h>
00017 #include <TProfile.h>
00018 #include <TProfile2D.h>
00019 
00020 using namespace edm;
00021 using namespace std;
00022 
00023 L1TRPCTFClient::L1TRPCTFClient(const edm::ParameterSet& ps)
00024 {
00025   parameters_=ps;
00026   initialize();
00027 }
00028 
00029 L1TRPCTFClient::~L1TRPCTFClient(){
00030  LogInfo("TriggerDQM")<<"[TriggerDQM]: ending... ";
00031 }
00032 
00033 //--------------------------------------------------------
00034 void L1TRPCTFClient::initialize(){ 
00035 
00036   counterLS_=0; 
00037   counterEvt_=0; 
00038   
00039   // get back-end interface
00040   dbe_ = Service<DQMStore>().operator->();
00041   
00042   // base folder for the contents of this job
00043   monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","");
00044 //  cout << "Monitor name = " << monitorName_ << endl;
00045   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00046 //  cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00047   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00048 //  cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00049   output_dir_ = parameters_.getUntrackedParameter<string>("output_dir","");
00050 //  cout << "DQM output dir = " << output_dir_ << endl;
00051   input_dir_ = parameters_.getUntrackedParameter<string>("input_dir","");
00052 //  cout << "DQM input dir = " << input_dir_ << endl;
00053   
00054   verbose_ = parameters_.getUntrackedParameter<bool>("verbose", false);
00055   
00056   m_runInEventLoop = parameters_.getUntrackedParameter<bool>("runInEventLoop", false);
00057   m_runInEndLumi = parameters_.getUntrackedParameter<bool>("runInEndLumi", false);
00058   m_runInEndRun = parameters_.getUntrackedParameter<bool>("runInEndRun", false);
00059   m_runInEndJob = parameters_.getUntrackedParameter<bool>("runInEndJob", false);
00060 
00061 
00062   LogInfo( "TriggerDQM");
00063 
00064       
00065 }
00066 
00067 //--------------------------------------------------------
00068 void L1TRPCTFClient::beginJob(void){
00069 
00070   LogInfo("TriggerDQM")<<"[TriggerDQM]: Begin Job";
00071 
00072   // get backendinterface
00073   dbe_ = Service<DQMStore>().operator->();  
00074 
00075   dbe_->setCurrentFolder(output_dir_);
00076 
00077   m_deadChannels = dbe_->book2D("RPCTF_deadchannels",
00078                                 "RPCTF deadchannels",
00079                                 33, -16.5, 16.5,
00080                                 144,  -0.5, 143.5);
00081   m_noisyChannels =  dbe_->book2D("RPCTF_noisychannels",
00082                                 "RPCTF noisy channels",
00083                                 33, -16.5, 16.5,
00084                                 144,  -0.5, 143.5);
00085 }
00086 //--------------------------------------------------------
00087 void L1TRPCTFClient::beginRun(const Run& r, const EventSetup& context) {
00088 }
00089 
00090 //--------------------------------------------------------
00091 void L1TRPCTFClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00092    // optionally reset histograms here
00093    // clientHisto->Reset();
00094 }
00095 //--------------------------------------------------------
00096 
00097 void L1TRPCTFClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00098                           const edm::EventSetup& c)
00099 {
00100    if (verbose_) std::cout <<  "L1TRPCTFClient::endLuminosityBlock" << std::endl;
00101 
00102    if (m_runInEndLumi) {
00103 
00104        processHistograms();
00105    }
00106 
00107 }                         
00108 
00109 //--------------------------------------------------------
00110 void L1TRPCTFClient::analyze(const Event& e, const EventSetup& context) {
00111     //   cout << "L1TRPCTFClient::analyze" << endl;
00112     counterEvt_++;
00113     if (prescaleEvt_ < 1)
00114         return;
00115     if (prescaleEvt_ > 0 && counterEvt_ % prescaleEvt_ != 0)
00116         return;
00117 
00118     // there is no loop on events in the offline harvesting step
00119     // code here will not be executed offline
00120 
00121     if (m_runInEventLoop) {
00122 
00123         processHistograms();
00124     }
00125 
00126 }
00127 
00128 //--------------------------------------------------------
00129 void L1TRPCTFClient::endRun(const Run& r, const EventSetup& context){
00130 
00131     if (m_runInEndRun) {
00132 
00133         processHistograms();
00134     }
00135 
00136 }
00137 
00138 //--------------------------------------------------------
00139 void L1TRPCTFClient::endJob() {
00140 
00141     if (m_runInEndJob) {
00142 
00143         processHistograms();
00144     }
00145 
00146 }
00147 
00148 
00149 //--------------------------------------------------------
00150 void L1TRPCTFClient::processHistograms() {
00151 
00152     dbe_->setCurrentFolder(input_dir_);
00153 
00154    {
00155 
00156      MonitorElement *me
00157          = dbe_->get( (input_dir_+"/RPCTF_muons_eta_phi_bx0").c_str() );
00158 
00159      if (me){
00160        const QReport *qreport;
00161 
00162        qreport = me->getQReport("DeadChannels_RPCTF_2D");
00163        if (qreport) {
00164          vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
00165          for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
00166               channel != badChannels.end();
00167               ++channel)
00168          {
00169            m_deadChannels->setBinContent((*channel).getBinX(),
00170                                          (*channel).getBinY(),
00171                                          100);
00172          } // for(badchannels)
00173        } //if (qreport)
00174 
00175        qreport = me->getQReport("HotChannels_RPCTF_2D");
00176        if (qreport) {
00177          vector<dqm::me_util::Channel> badChannels = qreport->getBadChannels();
00178          for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin();
00179               channel != badChannels.end();
00180               ++channel)
00181          {
00182            // (*channel).getBinY() == 0 for NoisyChannels QTEST
00183            m_noisyChannels->setBinContent((*channel).getBinX(), 100);
00184          } // for(badchannels)
00185        } //if (qreport)
00186  //      else std::cout << "dupa" << std::endl;
00187      } // if (me)
00188 
00189 
00190    }
00191 
00192 
00193    if (verbose_)
00194    {
00195      std::vector<string> meVec = dbe_->getMEs();
00196      for (vector<string>::const_iterator it = meVec.begin(); it != meVec.end(); it++) {
00197 
00198          std::string full_path = input_dir_ + "/" + (*it);
00199          MonitorElement * me =dbe_->get(full_path);
00200 
00201          // for this MEs, get list of associated QTs
00202          std::vector<QReport *> Qtest_map = me->getQReports();
00203 
00204          if (Qtest_map.size() > 0) {
00205            std::cout << "Test: " << full_path << std::endl;
00206            for (std::vector<QReport *>::const_iterator it = Qtest_map.begin();
00207                  it != Qtest_map.end();
00208                  ++it)
00209            {
00210                std::cout
00211                    << " Name "<< (*it)->getQRName()
00212                    << " Status " <<  (*it)->getStatus()
00213                    <<std::endl;
00214 
00215                std::vector<dqm::me_util::Channel> badChannels=(*it)->getBadChannels();
00216 
00217                vector<dqm::me_util::Channel>::iterator badchsit = badChannels.begin();
00218                while(badchsit != badChannels.end())
00219                {
00220                  int ix = (*badchsit).getBinX();
00221                  int iy = (*badchsit).getBinY();
00222                  std::cout << "(" << ix <<","<< iy << ") ";
00223                  ++badchsit;
00224                }
00225                std::cout << std::endl;
00226 
00227            }
00228          }
00229 
00230      } //
00231    }
00232 
00233 
00234 }
00235 
00236