CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Validation/RecoEgamma/src/ElectronValidator.cc

Go to the documentation of this file.
00001 
00002 #include "Validation/RecoEgamma/interface/ElectronValidator.h"
00003 #include "DQMServices/Core/interface/DQMStore.h"
00004 #include "DQMServices/Core/interface/MonitorElement.h"
00005 #include "FWCore/ServiceRegistry/interface/Service.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008 #include "TMath.h"
00009 #include "TFile.h"
00010 #include "TH1F.h"
00011 #include "TH1I.h"
00012 #include "TH2F.h"
00013 #include "TProfile.h"
00014 #include "TTree.h"
00015 #include <iostream>
00016 
00017 ElectronValidator::ElectronValidator( const edm::ParameterSet& conf )
00018  {}
00019 
00020 ElectronValidator::~ElectronValidator()
00021  {}
00022 
00023 void ElectronValidator::prepareStore()
00024  {
00025   store_ = edm::Service<DQMStore>().operator->() ;
00026   if (!store_)
00027    { edm::LogError("ElectronValidator::prepareStore")<<"No DQMStore found !" ; }
00028  }
00029 
00030 void ElectronValidator::setStoreFolder( const std::string & path )
00031  { store_->setCurrentFolder(path) ; }
00032 
00033 void ElectronValidator::saveStore( const std::string & filename )
00034  { store_->save(filename) ; }
00035 
00036 MonitorElement * ElectronValidator::bookH1
00037  ( const std::string & name, const std::string & title,
00038    int nchX, double lowX, double highX,
00039    const std::string & titleX, const std::string & titleY )
00040  {
00041   MonitorElement * me = store_->book1D(name,title,nchX,lowX,highX) ;
00042   if (titleX!="") { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00043   if (titleY!="") { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00044   return me ;
00045  }
00046 
00047 MonitorElement * ElectronValidator::bookH1withSumw2
00048  ( const std::string & name, const std::string & title,
00049    int nchX, double lowX, double highX,
00050    const std::string & titleX, const std::string & titleY )
00051  {
00052   MonitorElement * me = store_->book1D(name,title,nchX,lowX,highX) ;
00053   me->getTH1F()->Sumw2() ;
00054   if (titleX!="") { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00055   if (titleY!="") { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00056   return me ;
00057  }
00058 
00059 MonitorElement * ElectronValidator::bookH2
00060  ( const std::string & name, const std::string & title,
00061    int nchX, double lowX, double highX,
00062    int nchY, double lowY, double highY,
00063    const std::string & titleX, const std::string & titleY )
00064  {
00065   MonitorElement * me = store_->book2D(name,title,nchX,lowX,highX,nchY,lowY,highY) ;
00066   if (titleX!="") { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00067   if (titleY!="") { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00068   return me ;
00069  }
00070 
00071 MonitorElement * ElectronValidator::bookH2withSumw2
00072  ( const std::string & name, const std::string & title,
00073    int nchX, double lowX, double highX,
00074    int nchY, double lowY, double highY,
00075    const std::string & titleX, const std::string & titleY )
00076  {
00077   MonitorElement * me = store_->book2D(name,title,nchX,lowX,highX,nchY,lowY,highY) ;
00078   me->getTH2F()->Sumw2() ;
00079   if (titleX!="") { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00080   if (titleY!="") { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00081   return me ;
00082  }
00083 
00084 MonitorElement * ElectronValidator::bookP1
00085  ( const std::string & name, const std::string & title,
00086    int nchX, double lowX, double highX,
00087              double lowY, double highY,
00088    const std::string & titleX, const std::string & titleY )
00089  {
00090   MonitorElement * me = store_->bookProfile(name,title,nchX,lowX,highX,lowY,highY) ;
00091   if (titleX!="") { me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00092   if (titleY!="") { me->getTProfile()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00093   return me ;
00094  }
00095 
00096 MonitorElement * ElectronValidator::bookH1andDivide
00097  ( const std::string & name, MonitorElement * num, MonitorElement * denom,
00098    const std::string & titleX, const std::string & titleY,
00099    const std::string & title, bool print )
00100  {
00101   TH1F * h_temp = (TH1F *)num->getTH1F()->Clone(name.c_str()) ;
00102   h_temp->Reset() ;
00103   h_temp->Divide(num->getTH1(),denom->getTH1(),1,1,"b") ;
00104   h_temp->GetXaxis()->SetTitle(titleX.c_str()) ;
00105   h_temp->GetYaxis()->SetTitle(titleY.c_str()) ;
00106   if (title!="") { h_temp->SetTitle(title.c_str()) ; }
00107   if (print) { h_temp->Print() ; }
00108   MonitorElement * me = store_->book1D(name,h_temp) ;
00109   delete h_temp ;
00110   return me ;
00111  }
00112 
00113 MonitorElement * ElectronValidator::bookH2andDivide
00114  ( const std::string & name, MonitorElement * num, MonitorElement * denom,
00115    const std::string & titleX, const std::string & titleY,
00116    const std::string & title, bool print )
00117  {
00118   TH2F * h_temp = (TH2F *)num->getTH2F()->Clone(name.c_str()) ;
00119   h_temp->Reset() ;
00120   h_temp->Divide(num->getTH1(),denom->getTH1(),1,1,"b") ;
00121   h_temp->GetXaxis()->SetTitle(titleX.c_str()) ;
00122   h_temp->GetYaxis()->SetTitle(titleY.c_str()) ;
00123   if (title!="") { h_temp->SetTitle(title.c_str()) ; }
00124   if (print) { h_temp->Print() ; }
00125   MonitorElement * me = store_->book2D(name,h_temp) ;
00126   delete h_temp ;
00127   return me ;
00128  }
00129 
00130 MonitorElement * ElectronValidator::profileX
00131  ( const std::string & name, MonitorElement * me2d,
00132    const std::string & title, const std::string & titleX, const std::string & titleY,
00133    Double_t minimum, Double_t maximum )
00134  {
00135   if (me2d->getTH2F()->GetSumw2N()==0) me2d->getTH2F()->Sumw2() ; // workaround for https://savannah.cern.ch/bugs/?77751
00136   TProfile * p1_temp = me2d->getTH2F()->ProfileX() ;
00137   if (title!="") { p1_temp->SetTitle(title.c_str()) ; }
00138   if (titleX!="") { p1_temp->GetXaxis()->SetTitle(titleX.c_str()) ; }
00139   if (titleY!="") { p1_temp->GetYaxis()->SetTitle(titleY.c_str()) ; }
00140   if (minimum!=-1111) { p1_temp->SetMinimum(minimum) ; }
00141   if (maximum!=-1111) { p1_temp->SetMaximum(maximum) ; }
00142   MonitorElement * me = store_->bookProfile(name,p1_temp) ;
00143   delete p1_temp ;
00144   return me ;
00145  }
00146 
00147 MonitorElement * ElectronValidator::profileY
00148  ( const std::string & name, MonitorElement * me2d,
00149    const std::string & title, const std::string & titleX, const std::string & titleY,
00150    Double_t minimum, Double_t maximum )
00151  {
00152   if (me2d->getTH2F()->GetSumw2N()==0) me2d->getTH2F()->Sumw2() ; // workaround for https://savannah.cern.ch/bugs/?77751
00153   TProfile * p1_temp = me2d->getTH2F()->ProfileY() ;
00154   if (title!="") { p1_temp->SetTitle(title.c_str()) ; }
00155   if (titleX!="") { p1_temp->GetXaxis()->SetTitle(titleX.c_str()) ; }
00156   if (titleY!="") { p1_temp->GetYaxis()->SetTitle(titleY.c_str()) ; }
00157   if (minimum!=-1111) { p1_temp->SetMinimum(minimum) ; }
00158   if (maximum!=-1111) { p1_temp->SetMaximum(maximum) ; }
00159   MonitorElement * me = store_->bookProfile(name,p1_temp) ;
00160   delete p1_temp ;
00161   return me ;
00162  }
00163 
00164