#include <PhysicsTools/UtilAlgos/interface/CachingVariable.h>
Public Member Functions | |
void | assign (std::string var, double &value) const |
virtual void | compute (const edm::Event &iEvent) const =0 |
void | declare (std::string var) |
void | doesNotCompute (std::string var) const |
void | doesNotCompute () const |
const std::string & | name () const |
VariableComputer (CachingVariable::CachingVariableFactoryArg arg) | |
virtual | ~VariableComputer () |
Protected Attributes | |
CachingVariable::CachingVariableFactoryArg & | arg_ |
std::map< std::string,const ComputedVariable * > | iCompute_ |
std::string | method_ |
std::string | name_ |
std::string | separator_ |
Definition at line 106 of file CachingVariable.h.
VariableComputer::VariableComputer | ( | CachingVariable::CachingVariableFactoryArg | arg | ) |
Definition at line 41 of file CachingVariable.cc.
References arg_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), CachingVariable::CachingVariableFactoryArg::iConfig, method_, CachingVariable::CachingVariableFactoryArg::n, name_, and separator_.
00041 : arg_(arg) { 00042 if (arg_.iConfig.exists("separator")) separator_ = arg_.iConfig.getParameter<std::string>("separator"); 00043 else separator_ ="_"; 00044 00045 name_=arg_.n; 00046 method_ = arg_.iConfig.getParameter<std::string>("computer"); 00047 }
virtual VariableComputer::~VariableComputer | ( | ) | [inline, virtual] |
void VariableComputer::assign | ( | std::string | var, | |
double & | value | |||
) | const |
Definition at line 60 of file CachingVariable.cc.
References lat::endl(), iCompute_, it, and ss.
Referenced by VariableComputerTest::compute().
00060 { 00061 std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var); 00062 if (it == iCompute_.end()){ 00063 std::stringstream ss; 00064 ss<<"cannot assign: "<<var<<". List of variable declared:\n"; 00065 for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it) 00066 ss<<it->first<<std::endl; 00067 edm::LogError("VariableComputer")<<ss.str(); 00068 } 00069 else 00070 it->second->setCache(value); 00071 }
virtual void VariableComputer::compute | ( | const edm::Event & | iEvent | ) | const [pure virtual] |
void VariableComputer::declare | ( | std::string | var | ) |
Definition at line 49 of file CachingVariable.cc.
References arg_, iCompute_, CachingVariable::CachingVariableFactoryArg::iConfig, CachingVariable::CachingVariableFactoryArg::m, method_, name_, and separator_.
Referenced by VariableComputerTest::VariableComputerTest().
00049 { 00050 std::string aName = name_+separator_+var; 00051 ComputedVariable * newVar = new ComputedVariable(method_,aName,arg_.iConfig,this); 00052 if (iCompute_.find(var) != iCompute_.end()){ 00053 edm::LogError("VariableComputer")<<"redeclaring: "<<var<<" skipping."; 00054 delete newVar; 00055 return; 00056 } 00057 iCompute_[var] = newVar; 00058 arg_.m.insert(std::make_pair(aName,newVar)); 00059 }
void VariableComputer::doesNotCompute | ( | std::string | var | ) | const |
Definition at line 77 of file CachingVariable.cc.
References lat::endl(), iCompute_, it, and ss.
00077 { 00078 std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var); 00079 if (it == iCompute_.end()){ 00080 std::stringstream ss; 00081 ss<<"cannot act on: "<<var<<". List of variable declared:\n"; 00082 for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it) 00083 ss<<it->first<<std::endl; 00084 edm::LogError("VariableComputer")<<ss.str(); 00085 } 00086 else 00087 it->second->setNotCompute(); 00088 }
void VariableComputer::doesNotCompute | ( | ) | const |
Definition at line 73 of file CachingVariable.cc.
Referenced by VariableComputerTest::compute().
00073 { 00074 for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it) 00075 it->second->setNotCompute(); 00076 }
const std::string& VariableComputer::name | ( | void | ) | const [inline] |
Definition at line 112 of file CachingVariable.h.
References name_.
Referenced by ComputedVariable::eval().
00112 { return name_;}
std::map<std::string ,const ComputedVariable *> VariableComputer::iCompute_ [mutable, protected] |
Definition at line 122 of file CachingVariable.h.
Referenced by assign(), declare(), and doesNotCompute().
std::string VariableComputer::method_ [protected] |
std::string VariableComputer::name_ [protected] |
Definition at line 120 of file CachingVariable.h.
Referenced by declare(), name(), and VariableComputer().
std::string VariableComputer::separator_ [protected] |