CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator > Class Template Reference

#include <CachingVariable.h>

Inheritance diagram for TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >:
CachingVariable

Classes

class  getObject
 

Public Member Functions

virtual CachingVariable::valueType calculate (getObject &o) const
 
CachingVariable::evalType eval (const edm::Event &iEvent) const override
 
getObject objects (const edm::Event &iEvent) const
 
 TwoObjectVariable (const CachingVariableFactoryArg &arg, edm::ConsumesCollector &iC)
 
- Public Member Functions inherited from CachingVariable
void addDescriptionLine (const std::string &s)
 
 CachingVariable (std::string m, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
 
bool compute (const edm::Event &iEvent) const
 
const Descriptiondescription () const
 
const std::string & holderName () const
 
const std::string & method () const
 
const std::string & name () const
 
valueType operator() (const edm::Event &iEvent) const
 
void print () const
 
void setHolder (std::string hn) const
 
virtual ~CachingVariable ()
 

Private Attributes

unsigned int indexLhs_
 
unsigned int indexRhs_
 
edm::EDGetTokenT< std::vector< LHS > > srcLhs_
 
edm::InputTag srcLhsTag_
 
edm::EDGetTokenT< std::vector< RHS > > srcRhs_
 
edm::InputTag srcRhsTag_
 

Additional Inherited Members

- Public Types inherited from CachingVariable
typedef std::pair< bool, valueTypeevalType
 
typedef double valueType
 
typedef std::map< std::string, const CachingVariable * > vMap
 
- Protected Member Functions inherited from CachingVariable
evalTypebaseEval (const edm::Event &iEvent) const
 
bool notSeenThisEventAlready (const edm::Event &iEvent) const
 
void setCache (valueType &v) const
 
void setNotCompute () const
 
- Protected Attributes inherited from CachingVariable
evalType cache_
 
edm::ParameterSet conf_
 
Description d_
 
edm::Event::CacheIdentifier_t eventCacheID_ =0
 
std::string holderName_
 
std::string method_
 
std::string name_
 

Detailed Description

template<typename LHS, const char * lLHS, typename RHS, const char * lRHS, typename Calculator>
class TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >

Definition at line 420 of file CachingVariable.h.

Constructor & Destructor Documentation

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::TwoObjectVariable ( const CachingVariableFactoryArg arg,
edm::ConsumesCollector iC 
)
inline

Definition at line 422 of file CachingVariable.h.

References heppy_report::description, CachingVariable::CachingVariableFactoryArg::m, and CachingVariable::CachingVariableFactoryArg::n.

422  :
423  CachingVariable(Calculator::calculationType()+std::string(lLHS)+std::string(lRHS),arg.n,arg.iConfig,iC),
424  srcLhsTag_(edm::Service<InputTagDistributorService>()->retrieve("srcLhs",arg.iConfig)),
425  srcLhs_(iC.consumes<std::vector<LHS> >(srcLhsTag_)),
426  indexLhs_(arg.iConfig.getParameter<unsigned int>("indexLhs")),
427  srcRhsTag_(edm::Service<InputTagDistributorService>()->retrieve("srcRhs",arg.iConfig)),
428  srcRhs_(iC.consumes<std::vector<RHS> >(srcRhsTag_)),
429  indexRhs_(arg.iConfig.getParameter<unsigned int>("indexRhs"))
430  {
431  std::stringstream ss;
433  ss<<"with Obj1 at index: "<<indexLhs_<<" of: "<<srcLhs_;
434  addDescriptionLine(ss.str()); ss.str("");
435  ss<<"with Obj2 at index: "<<indexRhs_<<" of: "<<srcRhs_;
436  addDescriptionLine(ss.str()); ss.str("");
437  arg.m[arg.n]=this;
438  }
CachingVariable(std::string m, std::string n, const edm::ParameterSet &iConfig, edm::ConsumesCollector &iC)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< LHS > > srcLhs_
A arg
Definition: Factorize.h:37
edm::InputTag srcLhsTag_
unsigned int indexLhs_
void addDescriptionLine(const std::string &s)
edm::InputTag srcRhsTag_
unsigned int indexRhs_
edm::EDGetTokenT< std::vector< RHS > > srcRhs_

Member Function Documentation

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
virtual CachingVariable::valueType TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::calculate ( getObject o) const
inlinevirtual

Definition at line 477 of file CachingVariable.h.

References TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::lhs, and TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::rhs.

477  {
478  Calculator calc;
479  return calc(*o.lhs,*o.rhs);
480  }
template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
CachingVariable::evalType TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::eval ( const edm::Event iEvent) const
inlineoverridevirtual

Reimplemented from CachingVariable.

Definition at line 481 of file CachingVariable.h.

References connectstrParser::o, and TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::test.

481  {
482  getObject o=objects(iEvent);
483  if (!o.test) return std::make_pair(false,0);
484  return std::make_pair(true,calculate(o));
485  }
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
Definition: compareHists.cc:44
getObject objects(const edm::Event &iEvent) const
virtual CachingVariable::valueType calculate(getObject &o) const
template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
getObject TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::objects ( const edm::Event iEvent) const
inline

Definition at line 447 of file CachingVariable.h.

References runEdmFileComparison::failed, edm::HandleBase::failedToGet(), edm::Event::getByToken(), TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::lhs, LogDebug, dataset::name, TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::rhs, and TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::getObject::test.

447  {
450  iEvent.getByToken(srcLhs_, lhsH);
451  if (lhsH.failedToGet()){
452  LogDebug("TwoObjectVariable")<<name()<<" could not get a collection with label: "<<srcLhsTag_;
453  return failed;}
454  if (indexLhs_>=lhsH->size()){
455  LogDebug("TwoObjectVariable")<<name()<<" tries to access index: "<<indexLhs_<<" of: "<<srcLhsTag_<<" with: "<<lhsH->size()<<" entries.";
456  return failed;}
457  const LHS & lhs = (*lhsH)[indexLhs_];
458 
460  iEvent.getByToken(srcRhs_, rhsH);
461  if (rhsH.failedToGet()){
462  LogDebug("TwoObjectVariable")<<name()<<" could not get a collection with label: "<<srcLhsTag_;
463  return failed;}
464 
465  if (indexRhs_>=rhsH->size()){
466  LogDebug("TwoObjectVariable")<<name()<<" tries to access index: "<<indexRhs_<<" of: "<<srcRhsTag_<<" with: "<<rhsH->size()<<" entries.";
467  return failed;}
468  const RHS & rhs = (*rhsH)[indexRhs_];
469 
470  failed.test=true;
471  failed.lhs=&lhs;
472  failed.rhs=&rhs;
473  return failed;
474  }
#define LogDebug(id)
TObject * getObject(TDirectory *fDir, const std::vector< std::string > &fObjectName)
Definition: compareHists.cc:44
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
edm::EDGetTokenT< std::vector< LHS > > srcLhs_
edm::InputTag srcLhsTag_
unsigned int indexLhs_
edm::InputTag srcRhsTag_
bool failedToGet() const
Definition: HandleBase.h:78
unsigned int indexRhs_
const std::string & name() const
edm::EDGetTokenT< std::vector< RHS > > srcRhs_

Member Data Documentation

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
unsigned int TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::indexLhs_
private

Definition at line 489 of file CachingVariable.h.

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
unsigned int TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::indexRhs_
private

Definition at line 492 of file CachingVariable.h.

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
edm::EDGetTokenT<std::vector<LHS> > TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::srcLhs_
private

Definition at line 488 of file CachingVariable.h.

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
edm::InputTag TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::srcLhsTag_
private

Definition at line 487 of file CachingVariable.h.

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
edm::EDGetTokenT<std::vector<RHS> > TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::srcRhs_
private

Definition at line 491 of file CachingVariable.h.

template<typename LHS , const char * lLHS, typename RHS , const char * lRHS, typename Calculator >
edm::InputTag TwoObjectVariable< LHS, lLHS, RHS, lRHS, Calculator >::srcRhsTag_
private

Definition at line 490 of file CachingVariable.h.