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::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 }
std::string separator_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool exists(std::string const &parameterName) const
checks if a parameter exists
A arg
Definition: Factorize.h:31
const CachingVariable::CachingVariableFactoryArg & arg_
std::string method_

◆ ~VariableComputer()

virtual VariableComputer::~VariableComputer ( )
inlinevirtual

Definition at line 118 of file CachingVariable.h.

118 {}

Member Function Documentation

◆ assign()

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

Definition at line 65 of file CachingVariable.cc.

References iCompute_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, contentValuesCheck::ss, and ALCARECOEcalPhiSym_cff::var.

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

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

◆ compute()

virtual void VariableComputer::compute ( const edm::Event iEvent) const
pure virtual

◆ declare()

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 ALCARECOEcalPhiSym_cff::var.

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

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

◆ doesNotCompute() [1/2]

void VariableComputer::doesNotCompute ( ) const

Definition at line 78 of file CachingVariable.cc.

References iCompute_, and ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it.

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

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

◆ doesNotCompute() [2/2]

void VariableComputer::doesNotCompute ( std::string  var) const

Definition at line 83 of file CachingVariable.cc.

References iCompute_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, contentValuesCheck::ss, and ALCARECOEcalPhiSym_cff::var.

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

◆ name()

const std::string& VariableComputer::name ( void  ) const
inline

Definition at line 121 of file CachingVariable.h.

References name_.

Referenced by config.CFG::__str__(), and validation.Sample::digest().

121 { return name_; }

◆ notSeenThisEventAlready()

bool VariableComputer::notSeenThisEventAlready ( const edm::Event iEvent) const
inline

Definition at line 127 of file CachingVariable.h.

References eventCacheID_, iEvent, and WZElectronSkims53X_cff::max.

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

Member Data Documentation

◆ arg_

const CachingVariable::CachingVariableFactoryArg& VariableComputer::arg_
protected

Definition at line 137 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

◆ eventCacheID_

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

Definition at line 143 of file CachingVariable.h.

Referenced by notSeenThisEventAlready().

◆ iCompute_

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

Definition at line 140 of file CachingVariable.h.

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

◆ method_

std::string VariableComputer::method_
protected

Definition at line 139 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().

◆ name_

std::string VariableComputer::name_
protected

Definition at line 138 of file CachingVariable.h.

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

◆ separator_

std::string VariableComputer::separator_
protected

Definition at line 141 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().