CMS 3D CMS Logo

L1TGMTClient.cc

Go to the documentation of this file.
00001 #include "DQM/L1TMonitorClient/interface/L1TGMTClient.h"
00002 
00003 #include "FWCore/ServiceRegistry/interface/Service.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 #include "DQMServices/Core/interface/DQMStore.h"
00007 #include "DQMServices/Core/interface/MonitorElement.h"
00008 
00009 #include <sstream>
00010 
00011 using namespace edm;
00012 using namespace std;
00013 
00014 L1TGMTClient::L1TGMTClient(const edm::ParameterSet& ps)
00015 {
00016   parameters_=ps;
00017   initialize();
00018 }
00019 
00020 L1TGMTClient::~L1TGMTClient(){
00021   LogInfo("TriggerDQM")<<"[TriggerDQM]: ending... ";
00022 }
00023 
00024 //--------------------------------------------------------
00025 void L1TGMTClient::initialize(){ 
00026 
00027   counterLS_=0; 
00028   counterEvt_=0; 
00029   
00030   // get back-end interface
00031   dbe_ = Service<DQMStore>().operator->();
00032   
00033   // base folder for the contents of this job
00034   monitorName_ = parameters_.getUntrackedParameter<string>("monitorName","");
00035   cout << "Monitor name = " << monitorName_ << endl;
00036   prescaleLS_ = parameters_.getUntrackedParameter<int>("prescaleLS", -1);
00037   cout << "DQM lumi section prescale = " << prescaleLS_ << " lumi section(s)"<< endl;
00038   prescaleEvt_ = parameters_.getUntrackedParameter<int>("prescaleEvt", -1);
00039   cout << "DQM event prescale = " << prescaleEvt_ << " events(s)"<< endl;
00040   output_dir_ = parameters_.getUntrackedParameter<string>("output_dir","");
00041   cout << "DQM output dir = " << output_dir_ << endl;
00042   input_dir_ = parameters_.getUntrackedParameter<string>("input_dir","");
00043   cout << "DQM input dir = " << input_dir_ << endl;
00044   
00045   LogInfo( "TriggerDQM");
00046 
00047       
00048 }
00049 
00050 //--------------------------------------------------------
00051 void L1TGMTClient::beginJob(const EventSetup& context){
00052 
00053   LogInfo("TriggerDQM")<<"[TriggerDQM]: Begin Job";
00054 
00055   // get backendinterface
00056   dbe_ = Service<DQMStore>().operator->();  
00057 
00058   dbe_->setCurrentFolder(output_dir_);
00059 
00060   // booking
00061   eff_eta_dtcsc = bookClone1DVB("eff_eta_dtcsc","efficiency DTCSC vs eta","eta_DTCSC_and_RPC");
00062   eff_eta_dtcsc->setAxisTitle("eta",1);
00063   eff_eta_dtcsc->getTH1F()->Sumw2();
00064   
00065   eff_eta_rpc   = bookClone1DVB("eff_eta_rpc","efficiency RPC vs eta","eta_DTCSC_and_RPC");
00066   eff_eta_rpc->setAxisTitle("eta",1);
00067   eff_eta_rpc->getTH1F()->Sumw2();
00068 
00069   
00070   eff_phi_dtcsc = bookClone1D("eff_phi_dtcsc","efficiency DTCSC vs phi","phi_DTCSC_and_RPC");
00071   eff_phi_dtcsc->setAxisTitle("phi (deg)",1);
00072   eff_phi_dtcsc->getTH1F()->Sumw2();
00073   
00074   eff_phi_rpc   = bookClone1D("eff_phi_rpc","efficiency RPC vs phi","phi_DTCSC_and_RPC");
00075   eff_phi_rpc->setAxisTitle("phi (deg)",1);
00076   eff_phi_rpc->getTH1F()->Sumw2();
00077   
00078   
00079   eff_etaphi_dtcsc = bookClone2D("eff_etaphi_dtcsc","efficiency DTCSC vs eta and phi","etaphi_DTCSC_and_RPC");
00080   eff_etaphi_dtcsc->setAxisTitle("eta",1);
00081   eff_etaphi_dtcsc->setAxisTitle("phi (deg)",2);
00082   eff_etaphi_dtcsc->getTH2F()->Sumw2();
00083   
00084   eff_etaphi_rpc   = bookClone2D("eff_etaphi_rpc","efficiency RPC vs eta and phi","etaphi_DTCSC_and_RPC");
00085   eff_etaphi_rpc->setAxisTitle("eta",1);
00086   eff_etaphi_rpc->setAxisTitle("phi (deg)",2);
00087   eff_etaphi_rpc->getTH2F()->Sumw2();
00088   
00089   ratio_dt_rpcb_lumi  = bookClone1D("ratio_dt_rpcb_lumi" ,"ratio candidates DT/RPCb per lumisegment","DTTF_candlumi");
00090   ratio_csc_rpcf_lumi = bookClone1D("ratio_csc_rpcf_lumi","ratio candidates CSC/RPCf per lumisegment","DTTF_candlumi");
00091 }
00092 
00093 //--------------------------------------------------------
00094 void L1TGMTClient::beginRun(const Run& r, const EventSetup& context) {
00095 }
00096 
00097 //--------------------------------------------------------
00098 void L1TGMTClient::beginLuminosityBlock(const LuminosityBlock& lumiSeg, const EventSetup& context) {
00099    // optionally reset histograms here
00100    // clientHisto->Reset();
00101 }
00102 //--------------------------------------------------------
00103 
00104 void L1TGMTClient::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, 
00105                           const edm::EventSetup& c){
00106   counterLS_++;
00107   if (prescaleLS_<1) return;
00108   if (prescaleLS_>0 && counterLS_%prescaleLS_ != 0) return;
00109 //  cout << "L1TGMTClient::endLumi" << endl;
00110 
00111   process();
00112 }             
00113 //--------------------------------------------------------
00114 void L1TGMTClient::analyze(const Event& e, const EventSetup& context){
00115    counterEvt_++;
00116    if (prescaleEvt_<1) return;
00117    if (prescaleEvt_>0 && counterEvt_%prescaleEvt_ != 0) return;
00118    process();
00119 }
00120 
00121 //--------------------------------------------------------
00122 void L1TGMTClient::process() {
00123   
00124 //  cout << "L1TGMTClient: processing..." << endl;
00125   
00126   makeEfficiency1D(eff_eta_dtcsc,"eta_DTCSC_and_RPC","eta_RPC_only");
00127   makeEfficiency1D(eff_eta_rpc  ,"eta_DTCSC_and_RPC","eta_DTCSC_only");
00128   
00129   makeEfficiency1D(eff_phi_dtcsc,"phi_DTCSC_and_RPC","phi_RPC_only");
00130   makeEfficiency1D(eff_phi_rpc  ,"phi_DTCSC_and_RPC","phi_DTCSC_only");
00131   
00132   makeEfficiency2D(eff_etaphi_dtcsc,"etaphi_DTCSC_and_RPC","etaphi_RPC_only");
00133   makeEfficiency2D(eff_etaphi_rpc  ,"etaphi_DTCSC_and_RPC","etaphi_DTCSC_only");
00134   
00135   makeRatio1D(ratio_dt_rpcb_lumi, "DTTF_candlumi", "RPCb_candlumi");
00136   makeRatio1D(ratio_csc_rpcf_lumi,"CSCTF_candlumi","RPCf_candlumi");  
00137   
00138 }
00139 //--------------------------------------------------------
00140 void L1TGMTClient::endRun(const Run& r, const EventSetup& context){
00141   process();
00142 }
00143 
00144 //--------------------------------------------------------
00145 void L1TGMTClient::endJob(){
00146 }
00147 
00149 void L1TGMTClient::makeRatio1D(MonitorElement* mer, string h1Name, string h2Name) {
00150    TH1F* h1 = get1DHisto(input_dir_+"/"+h1Name,dbe_);
00151    TH1F* h2 = get1DHisto(input_dir_+"/"+h2Name,dbe_);
00152    TH1F* hr = mer->getTH1F();
00153    
00154    if(hr && h1 && h2) {
00155      hr->Divide(h1,h2,1.,1.," ");
00156    }
00157 }
00158 
00160 void L1TGMTClient::makeEfficiency1D(MonitorElement* meeff, string heName, string hiName) {
00161    TH1F* he = get1DHisto(input_dir_+"/"+heName,dbe_);
00162    TH1F* hi = get1DHisto(input_dir_+"/"+hiName,dbe_);
00163    TH1F* heff = meeff->getTH1F();
00164    
00165    if(heff && he && hi) {
00166      TH1F* hall = (TH1F*) he->Clone("hall");
00167      hall->Add(hi);
00168      heff->Divide(he,hall,1.,1.,"B");
00169      delete hall;
00170    }
00171 }
00172 
00174 void L1TGMTClient::makeEfficiency2D(MonitorElement* meeff, string heName, string hiName) {
00175    TH2F* he = get2DHisto(input_dir_+"/"+heName,dbe_);
00176    TH2F* hi = get2DHisto(input_dir_+"/"+hiName,dbe_);
00177    TH2F* heff = meeff->getTH2F();
00178   
00179    if(heff && he && hi) {
00180      TH2F* hall = (TH2F*) he->Clone("hall");
00181      hall->Add(hi);
00182      heff->Divide(he,hall,1.,1.,"B");
00183      delete hall;
00184    }
00185 }
00186 
00188 TH1F* L1TGMTClient::get1DHisto(string meName, DQMStore* dbi) {
00189   MonitorElement * me_ = dbi->get(meName);
00190 
00191   if (!me_) { 
00192     LogInfo("TriggerDQM") << "L1TGMT: " << meName << " NOT FOUND.";
00193     return NULL;
00194   }
00195   return me_->getTH1F();
00196 }
00197 
00199 TH2F* L1TGMTClient::get2DHisto(string meName, DQMStore* dbi) {
00200   MonitorElement * me_ = dbi->get(meName);
00201 
00202   if (!me_) { 
00203     LogInfo("TriggerDQM") << "L1TGMT: " << meName << " NOT FOUND.";
00204     return NULL;
00205   }
00206   return me_->getTH2F();
00207 }
00209 MonitorElement* L1TGMTClient::bookClone1D(string name, string title, string hrefName) {
00210   MonitorElement* me;
00211   
00212   TH1F* href = get1DHisto(input_dir_+"/"+hrefName,dbe_);
00213   if(href) {
00214     const unsigned nbx = href->GetNbinsX();
00215     const double xmin = href->GetXaxis()->GetXmin();
00216     const double xmax = href->GetXaxis()->GetXmax();
00217     me = dbe_->book1D(name,title,nbx,xmin,xmax);
00218   } else {
00219     me = NULL;
00220   }
00221   
00222   return me;
00223 }
00225 MonitorElement* L1TGMTClient::bookClone1DVB(string name, string title, string hrefName) {
00226   MonitorElement* me;
00227   
00228   TH1F* href = get1DHisto(input_dir_+"/"+hrefName,dbe_);
00229   if(href) {
00230     int nbx = href->GetNbinsX();
00231     if(nbx>99) nbx=99;
00232     float xbins[100];
00233     for(int i=0; i<nbx; i++) {
00234       xbins[i]=href->GetBinLowEdge(i+1);
00235     }
00236     xbins[nbx]=href->GetXaxis()->GetXmax();
00237     me = dbe_->book1D(name,title,nbx,xbins);
00238   } else {
00239     me = NULL;
00240   }
00241   
00242   return me;
00243 }
00245 MonitorElement* L1TGMTClient::bookClone2D(string name, string title, string hrefName) {
00246   MonitorElement* me;
00247   
00248   TH2F* href = get2DHisto(input_dir_+"/"+hrefName,dbe_);
00249   if(href) {
00250     const unsigned nbx = href->GetNbinsX();
00251     const double xmin = href->GetXaxis()->GetXmin();
00252     const double xmax = href->GetXaxis()->GetXmax();
00253     const unsigned nby = href->GetNbinsY();
00254     const double ymin = href->GetYaxis()->GetXmin();
00255     const double ymax = href->GetYaxis()->GetXmax();
00256     me = dbe_->book2D(name,title,nbx,xmin,xmax,nby,ymin,ymax);
00257   } else {
00258     me = NULL;
00259   }
00260   
00261   return me;
00262 }
00264 
00265 
00266 

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