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 RazorComputer 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, edm::ConsumesCollector &iC)
 
void doesNotCompute () const
 
void doesNotCompute (std::string var) const
 
const std::string & name () const
 
bool notSeenThisEventAlready (const edm::Event &iEvent) const
 
 VariableComputer (const CachingVariable::CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
 
virtual ~VariableComputer ()
 

Protected Attributes

const
CachingVariable::CachingVariableFactoryArg
arg_
 
edm::Event::CacheIdentifier_t eventCacheID_ =0
 
std::map< std::string,const
ComputedVariable * > 
iCompute_
 
std::string method_
 
std::string name_
 
std::string separator_
 

Detailed Description

Definition at line 114 of file CachingVariable.h.

Constructor & Destructor Documentation

VariableComputer::VariableComputer ( const CachingVariable::CachingVariableFactoryArg arg,
edm::ConsumesCollector iC 
)

Definition at line 35 of file CachingVariable.cc.

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

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

Definition at line 117 of file CachingVariable.h.

117 {}

Member Function Documentation

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

Definition at line 54 of file CachingVariable.cc.

References iCompute_, and contentValuesCheck::ss.

Referenced by RazorComputer::compute(), 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,
edm::ConsumesCollector iC 
)

Definition at line 43 of file CachingVariable.cc.

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

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

43  {
44  std::string aName = name_+separator_+var;
45  ComputedVariable * newVar = new ComputedVariable(method_,aName,arg_.iConfig,this,iC);
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_
const 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_, and contentValuesCheck::ss.

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 ( void  ) const
inline
bool VariableComputer::notSeenThisEventAlready ( const edm::Event iEvent) const
inline

Definition at line 126 of file CachingVariable.h.

References edm::Event::cacheIdentifier(), eventCacheID_, and max().

Referenced by ComputedVariable::eval().

126  {
128  eventCacheID_ != iEvent.cacheIdentifier());
129  if(retValue) {
131  }
132  return retValue;
133  }
const T & max(const T &a, const T &b)
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:32
edm::Event::CacheIdentifier_t eventCacheID_

Member Data Documentation

const CachingVariable::CachingVariableFactoryArg& VariableComputer::arg_
protected

Definition at line 136 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

edm::Event::CacheIdentifier_t VariableComputer::eventCacheID_ =0
mutableprotected

Definition at line 142 of file CachingVariable.h.

Referenced by notSeenThisEventAlready().

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

Definition at line 139 of file CachingVariable.h.

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

std::string VariableComputer::method_
protected

Definition at line 138 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

std::string VariableComputer::name_
protected

Definition at line 137 of file CachingVariable.h.

Referenced by declare(), name(), and VariableComputer().

std::string VariableComputer::separator_
protected

Definition at line 140 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().