CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_4/src/DQM/DataScouting/src/ScoutingAnalyzerBase.cc

Go to the documentation of this file.
00001 #include "DQM/DataScouting/interface/ScoutingAnalyzerBase.h"
00002 #include "DQMServices/Core/interface/DQMStore.h"
00003 #include "DQMServices/Core/interface/MonitorElement.h"
00004 #include "FWCore/ServiceRegistry/interface/Service.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 #include <iostream>
00008 #include <sstream>
00009 
00010 //------------------------------------------------------------------------------
00011 
00012 ScoutingAnalyzerBase::ScoutingAnalyzerBase( const edm::ParameterSet& conf ){
00013   m_MEsPath = conf.getUntrackedParameter<std::string>("rootPath","DataScouting") ;
00014   m_modulePath = conf.getUntrackedParameter<std::string>("modulePath","DataScouting") ;
00015   m_verbosityLevel = conf.getUntrackedParameter<unsigned int>("verbosityLevel", 0) ;
00016   if (m_modulePath.size() != 0)
00017     m_MEsPath+="/"+m_modulePath; 
00018  }
00019  
00020 //--------------------------------------------------------------------------
00021 
00022 ScoutingAnalyzerBase::~ScoutingAnalyzerBase(){}
00023 
00024 //------------------------------------------------------------------------------
00025 
00026 void ScoutingAnalyzerBase::beginJob(){
00027   m_store = edm::Service<DQMStore>().operator->() ;
00028   if (!m_store)
00029    { edm::LogError("ScoutingAnalyzerBase::prepareStore")<<"No DQMStore found !" ; }
00030   m_store->setVerbose(m_verbosityLevel) ;
00031   m_store->setCurrentFolder(m_MEsPath) ;
00032   bookMEs() ;
00033   }
00034 
00035 //------------------------------------------------------------------------------
00036 
00037 inline std::string ScoutingAnalyzerBase::newName(const std::string & name) {  
00038   // let's keep it in case we need massage
00039   return name;  
00040 }
00041 
00042 //------------------------------------------------------------------------------
00043 
00044 MonitorElement * ScoutingAnalyzerBase::bookH1
00045  ( const std::string & name, const std::string & title,
00046    int nchX, double lowX, double highX,
00047    const std::string & titleX, const std::string & titleY,
00048    Option_t * option )
00049  {
00050   MonitorElement * me = m_store->book1DD(newName(name),title,nchX,lowX,highX) ;
00051   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00052   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00053   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00054   return me ;
00055  }
00056 
00057 //------------------------------------------------------------------------------
00058 
00059 MonitorElement * ScoutingAnalyzerBase::bookH1withSumw2
00060  ( const std::string & name, const std::string & title,
00061    int nchX, double lowX, double highX,
00062    const std::string & titleX, const std::string & titleY,
00063    Option_t * option )
00064  {
00065    
00066   std::cout << newName(name) << std::endl;
00067   MonitorElement * me = m_store->book1DD(newName(name),title,nchX,lowX,highX) ;
00068   me->getTH1()->Sumw2() ;
00069   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00070   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00071   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00072   return me ;
00073  }
00074 
00075 //------------------------------------------------------------------------------
00076 
00077 MonitorElement * ScoutingAnalyzerBase::bookH1BinArray
00078  ( const std::string & name, const std::string & title,
00079    int nchX, float *xbinsize,
00080    const std::string & titleX, const std::string & titleY,
00081    Option_t * option )
00082  {
00083   MonitorElement * me = m_store->book1D(newName(name),title,nchX,xbinsize) ;
00084   //book1DD not implemented in DQMServices/Core/src/DQMStore.cc
00085   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00086   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00087   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00088   return me ;
00089  }
00090 
00091 //------------------------------------------------------------------------------
00092 
00093 MonitorElement * ScoutingAnalyzerBase::bookH1withSumw2BinArray
00094  ( const std::string & name, const std::string & title,
00095    int nchX, float *xbinsize,
00096    const std::string & titleX, const std::string & titleY,
00097    Option_t * option )
00098  {
00099    
00100   std::cout << newName(name) << std::endl;
00101   MonitorElement * me = m_store->book1D(newName(name),title,nchX,xbinsize) ;
00102   //book1DD not implemented in DQMServices/Core/src/DQMStore.cc
00103   me->getTH1()->Sumw2() ;
00104   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00105   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00106   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00107   return me ;
00108  }
00109 
00110 //------------------------------------------------------------------------------
00111 
00112 MonitorElement * ScoutingAnalyzerBase::bookH2
00113  ( const std::string & name, const std::string & title,
00114    int nchX, double lowX, double highX,
00115    int nchY, double lowY, double highY,
00116    const std::string & titleX, const std::string & titleY,
00117    Option_t * option )
00118  {
00119   MonitorElement * me = m_store->book2DD(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
00120   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00121   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00122   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00123   return me ;
00124  }
00125 
00126 //------------------------------------------------------------------------------
00127 
00128 MonitorElement * ScoutingAnalyzerBase::bookH2withSumw2
00129  ( const std::string & name, const std::string & title,
00130    int nchX, double lowX, double highX,
00131    int nchY, double lowY, double highY,
00132    const std::string & titleX, const std::string & titleY,
00133    Option_t * option )
00134  {
00135   MonitorElement * me = m_store->book2DD(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
00136   me->getTH1()->Sumw2() ;
00137   if (titleX!="") { me->getTH1()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00138   if (titleY!="") { me->getTH1()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00139   if (TString(option)!="") { me->getTH1()->SetOption(option) ; }
00140   return me ;
00141  }
00142 
00143 //------------------------------------------------------------------------------
00144 
00145 MonitorElement * ScoutingAnalyzerBase::bookP1
00146  ( const std::string & name, const std::string & title,
00147    int nchX, double lowX, double highX,
00148              double lowY, double highY,
00149    const std::string & titleX, const std::string & titleY,
00150    Option_t * option )
00151  {
00152   MonitorElement * me = m_store->bookProfile(newName(name),title,nchX,lowX,highX,lowY,highY," ") ;
00153   if (titleX!="") { me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str()) ; }
00154   if (titleY!="") { me->getTProfile()->GetYaxis()->SetTitle(titleY.c_str()) ; }
00155   if (TString(option)!="") { me->getTProfile()->SetOption(option) ; }
00156   return me ;
00157  }
00158 
00159 //------------------------------------------------------------------------------
00160 
00161 MonitorElement * ScoutingAnalyzerBase::bookH1andDivide
00162  ( const std::string & name, MonitorElement * num, MonitorElement * denom,
00163    const std::string & titleX, const std::string & titleY,
00164    const std::string & title )
00165  {
00166   std::string name2 = newName(name) ;
00167   TH1D * h_temp = dynamic_cast<TH1D*>( num->getTH1()->Clone(name2.c_str()) );
00168   h_temp->Reset() ;
00169   h_temp->Divide(num->getTH1(),denom->getTH1(),1,1,"b") ;
00170   h_temp->GetXaxis()->SetTitle(titleX.c_str()) ;
00171   h_temp->GetYaxis()->SetTitle(titleY.c_str()) ;
00172   if (title!="") { h_temp->SetTitle(title.c_str()) ; }
00173   if (m_verbosityLevel>0) { h_temp->Print() ; }
00174   MonitorElement * me = m_store->book1DD(name2,h_temp) ;
00175   delete h_temp ;
00176   return me ;
00177  }
00178 
00179 //------------------------------------------------------------------------------
00180 
00181 MonitorElement * ScoutingAnalyzerBase::bookH2andDivide
00182  ( const std::string & name, MonitorElement * num, MonitorElement * denom,
00183    const std::string & titleX, const std::string & titleY,
00184    const std::string & title )
00185  {
00186   std::string name2 = newName(name) ;
00187   TH2D * h_temp = dynamic_cast<TH2D*>( num->getTH1()->Clone(name2.c_str()) );
00188   h_temp->Reset() ;
00189   h_temp->Divide(num->getTH1(),denom->getTH1(),1,1,"b") ;
00190   h_temp->GetXaxis()->SetTitle(titleX.c_str()) ;
00191   h_temp->GetYaxis()->SetTitle(titleY.c_str()) ;
00192   if (title!="") { h_temp->SetTitle(title.c_str()) ; }
00193   if (m_verbosityLevel>0) { h_temp->Print() ; }
00194   MonitorElement * me = m_store->book2DD(name2,h_temp) ;
00195   delete h_temp ;
00196   return me ;
00197  }
00198 
00199 //------------------------------------------------------------------------------
00200 
00201 MonitorElement * ScoutingAnalyzerBase::profileX
00202  ( MonitorElement * me2d,
00203    const std::string & title, const std::string & titleX, const std::string & titleY,
00204    Double_t minimum, Double_t maximum )
00205  {
00206   std::string name2 = me2d->getName()+"_pfx" ;
00207   TProfile * p1_temp = me2d->getTH2D()->ProfileX() ;
00208   if (title!="") { p1_temp->SetTitle(title.c_str()) ; }
00209   if (titleX!="") { p1_temp->GetXaxis()->SetTitle(titleX.c_str()) ; }
00210   if (titleY!="") { p1_temp->GetYaxis()->SetTitle(titleY.c_str()) ; }
00211   if (minimum!=-1111) { p1_temp->SetMinimum(minimum) ; }
00212   if (maximum!=-1111) { p1_temp->SetMaximum(maximum) ; }
00213   MonitorElement * me = m_store->bookProfile(name2,p1_temp) ;
00214   delete p1_temp ;
00215   return me ;
00216  }
00217 
00218 //------------------------------------------------------------------------------
00219 
00220 MonitorElement * ScoutingAnalyzerBase::profileY
00221  ( MonitorElement * me2d,
00222    const std::string & title, const std::string & titleX, const std::string & titleY,
00223    Double_t minimum, Double_t maximum )
00224  {
00225   std::string name2 = me2d->getName()+"_pfy" ;
00226   TProfile * p1_temp = me2d->getTH2D()->ProfileY() ;
00227   if (title!="") { p1_temp->SetTitle(title.c_str()) ; }
00228   if (titleX!="") { p1_temp->GetXaxis()->SetTitle(titleX.c_str()) ; }
00229   if (titleY!="") { p1_temp->GetYaxis()->SetTitle(titleY.c_str()) ; }
00230   if (minimum!=-1111) { p1_temp->SetMinimum(minimum) ; }
00231   if (maximum!=-1111) { p1_temp->SetMaximum(maximum) ; }
00232   MonitorElement * me = m_store->bookProfile(name2,p1_temp) ;
00233   delete p1_temp ;
00234   return me ;
00235  }
00236 
00237 //------------------------------------------------------------------------------
00238