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 66 of file CachingVariable.cc.

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

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

◆ 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 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_
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 79 of file CachingVariable.cc.

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

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_

◆ doesNotCompute() [2/2]

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

Definition at line 84 of file CachingVariable.cc.

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

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_

◆ 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 SiStripPI::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().