CMS 3D CMS Logo

VariableComputer Class Reference

#include <PhysicsTools/UtilAlgos/interface/CachingVariable.h>

Inheritance diagram for VariableComputer:

VariableComputerTest

List of all members.

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 (std::string var) const
void doesNotCompute () 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 41 of file CachingVariable.cc.

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

00041                                                                                : arg_(arg) {
00042   if (arg_.iConfig.exists("separator")) separator_ = arg_.iConfig.getParameter<std::string>("separator");
00043   else separator_ ="_";
00044   
00045   name_=arg_.n;
00046   method_ = arg_.iConfig.getParameter<std::string>("computer");
00047 }

virtual VariableComputer::~VariableComputer (  )  [inline, virtual]

Definition at line 109 of file CachingVariable.h.

00109 {}


Member Function Documentation

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

Definition at line 60 of file CachingVariable.cc.

References lat::endl(), iCompute_, it, and ss.

Referenced by VariableComputerTest::compute().

00060                                                                 {
00061   std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var);
00062   if (it == iCompute_.end()){
00063     std::stringstream ss;
00064     ss<<"cannot assign: "<<var<<". List of variable declared:\n";
00065     for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
00066       ss<<it->first<<std::endl;
00067     edm::LogError("VariableComputer")<<ss.str();
00068   }
00069   else
00070     it->second->setCache(value);
00071 }

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

Implemented in VariableComputerTest.

Referenced by ComputedVariable::eval().

void VariableComputer::declare ( std::string  var  ) 

Definition at line 49 of file CachingVariable.cc.

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

Referenced by VariableComputerTest::VariableComputerTest().

00049                                            {
00050   std::string aName = name_+separator_+var;
00051   ComputedVariable * newVar = new ComputedVariable(method_,aName,arg_.iConfig,this);
00052   if (iCompute_.find(var) != iCompute_.end()){
00053     edm::LogError("VariableComputer")<<"redeclaring: "<<var<<" skipping.";
00054     delete newVar;
00055     return;
00056   }
00057   iCompute_[var] = newVar;
00058   arg_.m.insert(std::make_pair(aName,newVar));
00059 }

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

Definition at line 77 of file CachingVariable.cc.

References lat::endl(), iCompute_, it, and ss.

00077                                                         {
00078   std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.find(var);
00079   if (it == iCompute_.end()){
00080     std::stringstream ss;
00081     ss<<"cannot act on: "<<var<<". List of variable declared:\n";
00082     for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
00083       ss<<it->first<<std::endl;
00084     edm::LogError("VariableComputer")<<ss.str();
00085   }
00086   else
00087     it->second->setNotCompute();
00088 }

void VariableComputer::doesNotCompute (  )  const

Definition at line 73 of file CachingVariable.cc.

References iCompute_, and it.

Referenced by VariableComputerTest::compute().

00073                                            {
00074   for ( std::map<std::string ,const ComputedVariable *>::const_iterator it=iCompute_.begin(); it!=iCompute_.end();++it)
00075     it->second->setNotCompute();
00076 }

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

Definition at line 112 of file CachingVariable.h.

References name_.

Referenced by ComputedVariable::eval().

00112 { 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_ [mutable, protected]

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]

Definition at line 120 of file CachingVariable.h.

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

std::string VariableComputer::separator_ [protected]

Definition at line 123 of file CachingVariable.h.

Referenced by declare(), and VariableComputer().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:34:54 2009 for CMSSW by  doxygen 1.5.4