#include <CachingVariable.h>
Public Member Functions | |
CachingVariable::evalType | eval (const edm::Event &iEvent) const |
unsigned int | maxSlots () const |
VarSplitter (CachingVariableFactoryArg arg) | |
Protected Attributes | |
std::vector< double > | slots_ |
bool | useOverFlow_ |
bool | useUnderFlow_ |
std::string | var_ |
Definition at line 188 of file CachingVariable.h.
VarSplitter::VarSplitter | ( | CachingVariableFactoryArg | arg | ) | [inline] |
Definition at line 190 of file CachingVariable.h.
References CachingVariable::conf_, edm::ParameterSet::dump(), edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), i, CachingVariable::CachingVariableFactoryArg::iConfig, prof2calltree::l, Splitter::labels_, CachingVariable::CachingVariableFactoryArg::m, maxSlots(), CachingVariable::CachingVariableFactoryArg::n, CachingVariable::name(), Splitter::short_labels_, slots_, useOverFlow_, useUnderFlow_, and var_.
: Splitter("VarSplitter",arg.n,arg.iConfig) { var_=arg.iConfig.getParameter<std::string>("var"); useUnderFlow_=arg.iConfig.getParameter<bool>("useUnderFlow"); useOverFlow_=arg.iConfig.getParameter<bool>("useOverFlow"); slots_=arg.iConfig.getParameter<std::vector<double> >("slots"); if (useUnderFlow_){ labels_.push_back("underflow"); short_labels_.push_back("_"+arg.n+"_underflow");} std::vector<std::string> confLabels; if (arg.iConfig.exists("labels")){ confLabels=arg.iConfig.getParameter<std::vector<std::string> >("labels"); } else{ std::string labelFormat = arg.iConfig.getParameter<std::string>("labelsFormat"); for (unsigned int is=0;is!=slots_.size()-1;++is){ std::string l(Form(labelFormat.c_str(),slots_[is],slots_[is+1])); confLabels.push_back(l); } } for (unsigned int i=0;i!=confLabels.size();++i){ labels_.push_back(confLabels[i]); std::stringstream ss; ss<<"_"<<arg.n<<"_"<<i; short_labels_.push_back(ss.str()); } if (useOverFlow_) { labels_.push_back("overFlow"); short_labels_.push_back("_"+arg.n+"_overFlow");} //check consistency if (labels_.size()!=maxSlots()) edm::LogError("Splitter")<<"splitter with name: "<<name()<<" has inconsistent configuration\n"<<conf_.dump(); arg.m[arg.n]=this; }
CachingVariable::evalType VarSplitter::eval | ( | const edm::Event & | iEvent | ) | const [virtual] |
Implements Splitter.
Definition at line 4 of file CachingVariable.cc.
References CachingVariable::compute(), i, iEvent, Splitter::maxIndex(), slots_, useOverFlow_, useUnderFlow_, v, and var_.
{ const CachingVariable * var=edm::Service<VariableHelperService>()->get().variable(var_); if (!var->compute(iEvent)) return std::make_pair(false,0); double v=(*var)(iEvent); if (v<slots_.front()){ if (useUnderFlow_) return std::make_pair(true,0); else return std::make_pair(false,0); } if (v>=slots_.back()){ if (useOverFlow_) return std::make_pair(true,(double)maxIndex()); else return std::make_pair(false,0); } unsigned int i=1; for (;i<slots_.size();++i) if (v<slots_[i]) break; if (useUnderFlow_) return std::make_pair(true,(double) i); //need to substract 1 because checking on upper edges else return std::make_pair(true,(double)i-1); }
unsigned int VarSplitter::maxSlots | ( | ) | const [inline, virtual] |
Reimplemented from Splitter.
Definition at line 230 of file CachingVariable.h.
References asciidump::s, slots_, useOverFlow_, and useUnderFlow_.
Referenced by VarSplitter().
{ unsigned int s=slots_.size()-1; if (useUnderFlow_) s++; if (useOverFlow_) s++; return s;}
std::vector<double> VarSplitter::slots_ [protected] |
Definition at line 240 of file CachingVariable.h.
Referenced by eval(), maxSlots(), and VarSplitter().
bool VarSplitter::useOverFlow_ [protected] |
Definition at line 239 of file CachingVariable.h.
Referenced by eval(), maxSlots(), and VarSplitter().
bool VarSplitter::useUnderFlow_ [protected] |
Definition at line 238 of file CachingVariable.h.
Referenced by eval(), maxSlots(), and VarSplitter().
std::string VarSplitter::var_ [protected] |
Definition at line 237 of file CachingVariable.h.
Referenced by eval(), and VarSplitter().