#include <ConfigurableHisto.h>
Public Types | |
enum | HType { h1, h2, prof } |
Public Member Functions | |
virtual void | book (TFileDirectory *dir) |
virtual ConfigurableHisto * | clone () const |
void | complete () |
ConfigurableHisto (HType t, std::string name, edm::ParameterSet &iConfig) | |
virtual void | fill (const edm::Event &iEvent) |
TH1 * | h () |
const HType & | type () |
virtual | ~ConfigurableHisto () |
Protected Member Functions | |
ConfigurableHisto (const ConfigurableHisto &master) | |
Protected Attributes | |
edm::ParameterSet | conf_ |
TH1 * | h_ |
std::string | name_ |
HType | type_ |
const CachingVariable * | w_ |
const CachingVariable * | x_ |
const CachingVariable * | y_ |
const CachingVariable * | z_ |
Definition at line 53 of file ConfigurableHisto.h.
ConfigurableHisto::ConfigurableHisto | ( | HType | t, |
std::string | name, | ||
edm::ParameterSet & | iConfig | ||
) | [inline] |
virtual ConfigurableHisto::~ConfigurableHisto | ( | ) | [inline, virtual] |
Definition at line 59 of file ConfigurableHisto.h.
{}
ConfigurableHisto::ConfigurableHisto | ( | const ConfigurableHisto & | master | ) | [inline, protected] |
virtual void ConfigurableHisto::book | ( | TFileDirectory * | dir | ) | [inline, virtual] |
Reimplemented in SplittingConfigurableHisto.
Definition at line 63 of file ConfigurableHisto.h.
References conf_, edm::ParameterSet::dump(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), h1, h2, h_, TFileDirectory::make(), ConfigurableAxis::Max(), ConfigurableAxis::Min(), name_, ConfigurableAxis::nBin(), prof, indexGen::title, type(), w_, x_, ConfigurableAxis::xBins(), and y_.
{ std::string title=conf_.getParameter<std::string>("title"); edm::ParameterSet xAxisPSet=conf_.getParameter<edm::ParameterSet>("xAxis"); ConfigurableAxis xAxis(xAxisPSet); x_=edm::Service<VariableHelperService>()->get().variable(xAxisPSet.getParameter<std::string>("var")); std::string yLabel=""; bool yVBin=false; ConfigurableAxis yAxis; if (conf_.exists("yAxis")){ edm::ParameterSet yAxisPSet=conf_.getParameter<edm::ParameterSet>("yAxis"); yAxis=ConfigurableAxis(yAxisPSet); yLabel=yAxis.Label(); //at least TH2 or TProfile if (yAxisPSet.exists("var")) y_=edm::Service<VariableHelperService>()->get().variable(yAxisPSet.getParameter<std::string>("var")); yVBin=yAxis.variableSize(); } if (conf_.exists("zAxis")){ throw; } bool xVBin=xAxis.variableSize(); if (type()==h1){ //make TH1F if (xVBin) h_=dir->make<TH1F>(name_.c_str(),title.c_str(), xAxis.nBin(), xAxis.xBins()); else h_=dir->make<TH1F>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.Min(),xAxis.Max()); } else if (type()==h2){ //make TH2F if (xVBin){ if (yVBin) h_=dir->make<TH2F>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.xBins(), yAxis.nBin(),yAxis.xBins()); else h_=dir->make<TH2F>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.xBins(), yAxis.nBin(),yAxis.Min(),yAxis.Max()); }else{ if (yVBin) h_=dir->make<TH2F>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.Min(),xAxis.Max(), yAxis.nBin(),yAxis.xBins()); else h_=dir->make<TH2F>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.Min(),xAxis.Max(), yAxis.nBin(),yAxis.Min(),yAxis.Max()); } } else if (type()==prof){ //make TProfile std::string pFopt=""; if (conf_.exists("Option")) pFopt=conf_.getParameter<std::string>("Option"); if (xVBin) h_=dir->make<TProfile>(name_.c_str(),title.c_str(), xAxis.nBin(), xAxis.xBins(), yAxis.Min(),yAxis.Max(), pFopt.c_str()); else h_=dir->make<TProfile>(name_.c_str(),title.c_str(), xAxis.nBin(),xAxis.Min(),xAxis.Max(), yAxis.Min(),yAxis.Max(), pFopt.c_str()); } else { edm::LogError("ConfigurableHisto")<<"cannot book: "<<name_<<"\n"<<conf_.dump(); throw; } //cosmetics h_->GetXaxis()->SetTitle(xAxis.Label().c_str()); h_->SetYTitle(yLabel.c_str()); if (conf_.exists("weight")) { w_=edm::Service<VariableHelperService>()->get().variable(conf_.getParameter<std::string>("weight")); } }
virtual ConfigurableHisto* ConfigurableHisto::clone | ( | void | ) | const [inline, virtual] |
Reimplemented in SplittingConfigurableHisto.
Definition at line 61 of file ConfigurableHisto.h.
References ConfigurableHisto().
{ return new ConfigurableHisto(*this);}
void ConfigurableHisto::complete | ( | ) | [inline] |
virtual void ConfigurableHisto::fill | ( | const edm::Event & | iEvent | ) | [inline, virtual] |
Reimplemented in SplittingConfigurableHisto.
Definition at line 153 of file ConfigurableHisto.h.
References CachingVariable::compute(), conf_, edm::ParameterSet::dump(), h1, h2, h_, iEvent, name_, prof, type_, w_, CommonMethods::weight(), x_, and y_.
{ if (!h_) return; double weight=1.0; if (w_){ if (w_->compute(iEvent)) weight=(*w_)(iEvent); else{ edm::LogInfo("ConfigurableHisto")<<"could not compute the weight for: "<<name_ <<" with config:\n"<<conf_.dump() <<" default to 1.0"; } } TProfile * pcast(0); TH2 * h2cast(0); switch(type_){ case h1: if (!h_) throw; if (x_->compute(iEvent)) h_->Fill((*x_)(iEvent),weight); else{ edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_ <<" with config:\n"<<conf_.dump(); } break; case prof: pcast=dynamic_cast<TProfile*>(h_); if (!pcast) throw; if (x_->compute(iEvent) && y_->compute(iEvent)) pcast->Fill((*x_)(iEvent),(*y_)(iEvent),weight); else{ edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_ <<" with config:\n"<<conf_.dump(); } break; case h2: h2cast=dynamic_cast<TH2*>(h_); if (!h2cast) throw; if (x_->compute(iEvent) && y_->compute(iEvent)) h2cast->Fill((*x_)(iEvent),(*y_)(iEvent),weight); else{ edm::LogInfo("ConfigurableHisto")<<"could not fill: "<<name_ <<" with config:\n"<<conf_.dump(); } break; } }
TH1* ConfigurableHisto::h | ( | ) | [inline] |
Definition at line 201 of file ConfigurableHisto.h.
References h_.
Referenced by SplittingConfigurableHisto::book(), and SplittingConfigurableHisto::complete().
{return h_;}
const HType& ConfigurableHisto::type | ( | ) | [inline] |
Definition at line 198 of file ConfigurableHisto.h.
References type_.
Referenced by book().
{ return type_;}
edm::ParameterSet ConfigurableHisto::conf_ [protected] |
Definition at line 217 of file ConfigurableHisto.h.
Referenced by book(), ConfigurableHisto(), and fill().
TH1* ConfigurableHisto::h_ [protected] |
Definition at line 215 of file ConfigurableHisto.h.
Referenced by book(), ConfigurableHisto(), fill(), and h().
std::string ConfigurableHisto::name_ [protected] |
Definition at line 216 of file ConfigurableHisto.h.
Referenced by book(), SplittingConfigurableHisto::book(), ConfigurableHisto(), fill(), and SplittingConfigurableHisto::SplittingConfigurableHisto().
HType ConfigurableHisto::type_ [protected] |
Definition at line 214 of file ConfigurableHisto.h.
Referenced by ConfigurableHisto(), fill(), and type().
const CachingVariable* ConfigurableHisto::w_ [protected] |
Definition at line 222 of file ConfigurableHisto.h.
Referenced by book(), ConfigurableHisto(), and fill().
const CachingVariable* ConfigurableHisto::x_ [protected] |
Definition at line 219 of file ConfigurableHisto.h.
Referenced by book(), ConfigurableHisto(), and fill().
const CachingVariable* ConfigurableHisto::y_ [protected] |
Definition at line 220 of file ConfigurableHisto.h.
Referenced by book(), ConfigurableHisto(), and fill().
const CachingVariable* ConfigurableHisto::z_ [protected] |
Definition at line 221 of file ConfigurableHisto.h.
Referenced by ConfigurableHisto().