CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
VariableComputer Class Referenceabstract

#include <CachingVariable.h>

Inheritance diagram for VariableComputer:
HLTBitComputer L1BitComputer VariableComputerTest

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 () const
 
void doesNotCompute (std::string var) const
 
const std::string & name () const
 
 VariableComputer (CachingVariable::CachingVariableFactoryArg arg)
 
virtual ~VariableComputer ()
 

Protected Attributes

CachingVariable::CachingVariableFactoryArgarg_
 
std::map< std::string,const
ComputedVariable * > 
iCompute_
 
std::string method_
 
std::string name_
 
std::string separator_
 

Detailed Description

Definition at line 106 of file CachingVariable.h.

Constructor & Destructor Documentation

VariableComputer::VariableComputer ( CachingVariable::CachingVariableFactoryArg  arg)

Definition at line 35 of file CachingVariable.cc.

References arg_, edm::ParameterSet::exists(), edm::ParameterSet::getParameter(), CachingVariable::CachingVariableFactoryArg::iConfig, method_, CachingVariable::CachingVariableFactoryArg::n, name_, and separator_.

35  : arg_(arg) {
36  if (arg_.iConfig.exists("separator")) separator_ = arg_.iConfig.getParameter<std::string>("separator");
37  else separator_ ="_";
38 
39  name_=arg_.n;
40  method_ = arg_.iConfig.getParameter<std::string>("computer");
41 }
T getParameter(std::string const &) const
std::string separator_
bool exists(std::string const &parameterName) const
checks if a parameter exists
CachingVariable::CachingVariableFactoryArg & arg_
std::string method_
virtual VariableComputer::~VariableComputer ( )
inlinevirtual

Definition at line 109 of file CachingVariable.h.

109 {}

Member Function Documentation

void VariableComputer::assign ( std::string  var,
double &  value 
) const

Definition at line 54 of file CachingVariable.cc.

References iCompute_.

Referenced by L1BitComputer::compute(), HLTBitComputer::compute(), and VariableComputerTest::compute().

54  {
55  std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var);
56  if (it == iCompute_.end()){
57  std::stringstream ss;
58  ss<<"cannot assign: "<<var<<". List of variable declared:\n";
59  for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
60  ss<<it->first<<std::endl;
61  edm::LogError("VariableComputer")<<ss.str();
62  }
63  else
64  it->second->setCache(value);
65 }
std::map< std::string,const ComputedVariable * > iCompute_
virtual void VariableComputer::compute ( const edm::Event iEvent) const
pure virtual
void VariableComputer::declare ( std::string  var)

Definition at line 43 of file CachingVariable.cc.

References arg_, iCompute_, CachingVariable::CachingVariableFactoryArg::iConfig, CachingVariable::CachingVariableFactoryArg::m, method_, name_, and separator_.

Referenced by HLTBitComputer::HLTBitComputer(), L1BitComputer::L1BitComputer(), and VariableComputerTest::VariableComputerTest().

43  {
44  std::string aName = name_+separator_+var;
45  ComputedVariable * newVar = new ComputedVariable(method_,aName,arg_.iConfig,this);
46  if (iCompute_.find(var) != iCompute_.end()){
47  edm::LogError("VariableComputer")<<"redeclaring: "<<var<<" skipping.";
48  delete newVar;
49  return;
50  }
51  iCompute_[var] = newVar;
52  arg_.m.insert(std::make_pair(aName,newVar));
53 }
std::string separator_
CachingVariable::CachingVariableFactoryArg & arg_
std::map< std::string,const ComputedVariable * > iCompute_
std::string method_
void VariableComputer::doesNotCompute ( ) const

Definition at line 67 of file CachingVariable.cc.

References iCompute_.

Referenced by L1BitComputer::compute(), HLTBitComputer::compute(), and VariableComputerTest::compute().

67  {
68  for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
69  it->second->setNotCompute();
70 }
std::map< std::string,const ComputedVariable * > iCompute_
void VariableComputer::doesNotCompute ( std::string  var) const

Definition at line 71 of file CachingVariable.cc.

References iCompute_.

71  {
72  std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var);
73  if (it == iCompute_.end()){
74  std::stringstream ss;
75  ss<<"cannot act on: "<<var<<". List of variable declared:\n";
76  for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
77  ss<<it->first<<std::endl;
78  edm::LogError("VariableComputer")<<ss.str();
79  }
80  else
81  it->second->setNotCompute();
82 }
std::map< std::string,const ComputedVariable * > iCompute_
const std::string& VariableComputer::name ( ) const
inline

Definition at line 112 of file CachingVariable.h.

References name_.

Referenced by BeautifulSoup.Tag::_invert(), and ComputedVariable::eval().

112 { return name_;}

Member Data Documentation

CachingVariable::CachingVariableFactoryArg& VariableComputer::arg_
protected

Definition at line 119 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

std::map<std::string ,const ComputedVariable *> VariableComputer::iCompute_
mutableprotected

Definition at line 122 of file CachingVariable.h.

Referenced by assign(), declare(), and doesNotCompute().

std::string VariableComputer::method_
protected

Definition at line 121 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

std::string VariableComputer::name_
protected
std::string VariableComputer::separator_
protected

Definition at line 123 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().