CMS 3D CMS Logo

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::CachingVariableFactoryArgarg_
 
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 115 of file CachingVariable.h.

Constructor & Destructor Documentation

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

Definition at line 44 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.

45  : arg_(arg) {
46  if (arg_.iConfig.exists("separator"))
48  else
49  separator_ = "_";
50 
51  name_ = arg_.n;
53 }
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 118 of file CachingVariable.h.

References bookConverter::compute(), and iEvent.

118 {}

Member Function Documentation

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

Definition at line 66 of file CachingVariable.cc.

References iCompute_, and contentValuesCheck::ss.

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

66  {
67  std::map<std::string, const ComputedVariable*>::const_iterator it = iCompute_.find(var);
68  if (it == iCompute_.end()) {
69  std::stringstream ss;
70  ss << "cannot assign: " << var << ". List of variable declared:\n";
71  for (std::map<std::string, const ComputedVariable*>::const_iterator it = iCompute_.begin(); it != iCompute_.end();
72  ++it)
73  ss << it->first << std::endl;
74  edm::LogError("VariableComputer") << ss.str();
75  } else
76  it->second->setCache(value);
77 }
std::map< std::string, const ComputedVariable * > iCompute_
Definition: value.py:1
virtual void VariableComputer::compute ( const edm::Event iEvent) const
pure virtual
void VariableComputer::declare ( std::string  var,
edm::ConsumesCollector iC 
)

Definition at line 55 of file CachingVariable.cc.

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

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

55  {
56  std::string aName = name_ + separator_ + var;
57  ComputedVariable* newVar = new ComputedVariable(method_, aName, arg_.iConfig, this, iC);
58  if (iCompute_.find(var) != iCompute_.end()) {
59  edm::LogError("VariableComputer") << "redeclaring: " << var << " skipping.";
60  delete newVar;
61  return;
62  }
63  iCompute_[var] = newVar;
64  arg_.m.insert(std::make_pair(aName, newVar));
65 }
std::string separator_
const CachingVariable::CachingVariableFactoryArg & arg_
std::map< std::string, const ComputedVariable * > iCompute_
std::string method_
void VariableComputer::doesNotCompute ( ) const

Definition at line 79 of file CachingVariable.cc.

References iCompute_.

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

79  {
80  for (std::map<std::string, const ComputedVariable*>::const_iterator it = iCompute_.begin(); it != iCompute_.end();
81  ++it)
82  it->second->setNotCompute();
83 }
std::map< std::string, const ComputedVariable * > iCompute_
void VariableComputer::doesNotCompute ( std::string  var) const

Definition at line 84 of file CachingVariable.cc.

References iCompute_, and contentValuesCheck::ss.

84  {
85  std::map<std::string, const ComputedVariable*>::const_iterator it = iCompute_.find(var);
86  if (it == iCompute_.end()) {
87  std::stringstream ss;
88  ss << "cannot act on: " << var << ". List of variable declared:\n";
89  for (std::map<std::string, const ComputedVariable*>::const_iterator it = iCompute_.begin(); it != iCompute_.end();
90  ++it)
91  ss << it->first << std::endl;
92  edm::LogError("VariableComputer") << ss.str();
93  } else
94  it->second->setNotCompute();
95 }
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 127 of file CachingVariable.h.

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

127  {
129  eventCacheID_ != iEvent.cacheIdentifier());
130  if (retValue) {
131  eventCacheID_ = iEvent.cacheIdentifier();
132  }
133  return retValue;
134  }
CacheIdentifier_t cacheIdentifier() const
Definition: Event.cc:33
edm::Event::CacheIdentifier_t eventCacheID_

Member Data Documentation

const CachingVariable::CachingVariableFactoryArg& VariableComputer::arg_
protected

Definition at line 137 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

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

Definition at line 143 of file CachingVariable.h.

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

Definition at line 140 of file CachingVariable.h.

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

std::string VariableComputer::method_
protected

Definition at line 139 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

std::string VariableComputer::name_
protected

Definition at line 138 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

std::string VariableComputer::separator_
protected

Definition at line 141 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().