CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
tnp::ProbeVariable Class Reference

A variable for the probe: can be a string expression or an external ValueMap<float> More...

#include <BaseTreeFiller.h>

Public Member Functions

float * address () const
 Addess for ROOT Branch. More...
 
void fill (const reco::CandidateBaseRef &probe) const
 To be called for each item. More...
 
void init (const edm::Event &iEvent) const
 To be called at the beginning of the event (will fetch ValueMap if needed) More...
 
const std::string & name () const
 name More...
 
 ProbeVariable (const std::string &name, const edm::EDGetTokenT< edm::ValueMap< float > > &srcToken)
 Create a ProbeVariable to be read from a ValueMap. More...
 
 ProbeVariable (const std::string &name, const std::string &expression)
 Create a ProbeVariable to be evaluated on the fly from a string expression. More...
 
 ~ProbeVariable ()
 Destructor (does nothing) More...
 

Private Attributes

bool external_
 true if it's an external ValueMap, false if it's a StringParser function More...
 
StringObjectFunction< reco::Candidate, true > function_
 a lazy-parsed StringObjectFunction<reco::Candidate> that gets all the methods of daughter classes too More...
 
edm::Handle< edm::ValueMap< float > > handle_
 the handle to keep the ValueMap More...
 
std::string name_
 the name of the variable, which becomes the ROOT branch name More...
 
edm::EDGetTokenT< edm::ValueMap< float > > srcToken_
 the external valuemap More...
 
float value_
 the place where we store the value, and that ROOT uses to fill the tree More...
 

Detailed Description

A variable for the probe: can be a string expression or an external ValueMap<float>

Definition at line 44 of file BaseTreeFiller.h.

Constructor & Destructor Documentation

◆ ProbeVariable() [1/2]

tnp::ProbeVariable::ProbeVariable ( const std::string &  name,
const std::string &  expression 
)
inline

Create a ProbeVariable to be evaluated on the fly from a string expression.

Definition at line 47 of file BaseTreeFiller.h.

48  : name_(name), external_(false), function_(expression) {}

◆ ProbeVariable() [2/2]

tnp::ProbeVariable::ProbeVariable ( const std::string &  name,
const edm::EDGetTokenT< edm::ValueMap< float > > &  srcToken 
)
inline

Create a ProbeVariable to be read from a ValueMap.

Definition at line 51 of file BaseTreeFiller.h.

52  : name_(name), external_(true), function_("-1"), srcToken_(srcToken) {}

◆ ~ProbeVariable()

tnp::ProbeVariable::~ProbeVariable ( )

Destructor (does nothing)

Definition at line 13 of file BaseTreeFiller.cc.

13 {}

Member Function Documentation

◆ address()

float* tnp::ProbeVariable::address ( ) const
inline

Addess for ROOT Branch.

Definition at line 58 of file BaseTreeFiller.h.

58 { return &value_; }

References value_.

◆ fill()

void tnp::ProbeVariable::fill ( const reco::CandidateBaseRef probe) const
inline

To be called for each item.

Definition at line 70 of file BaseTreeFiller.h.

70 { value_ = external_ ? (*handle_)[probe] : function_(*probe); }

References external_, function_, and value_.

◆ init()

void tnp::ProbeVariable::init ( const edm::Event iEvent) const
inline

To be called at the beginning of the event (will fetch ValueMap if needed)

Definition at line 64 of file BaseTreeFiller.h.

64  {
65  if (external_)
66  iEvent.getByToken(srcToken_, handle_);
67  }

References external_, handle_, iEvent, and srcToken_.

◆ name()

const std::string& tnp::ProbeVariable::name ( void  ) const
inline

name

Definition at line 61 of file BaseTreeFiller.h.

61 { return name_; }

References name_.

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

Member Data Documentation

◆ external_

bool tnp::ProbeVariable::external_
private

true if it's an external ValueMap, false if it's a StringParser function

Definition at line 79 of file BaseTreeFiller.h.

Referenced by fill(), and init().

◆ function_

StringObjectFunction<reco::Candidate, true> tnp::ProbeVariable::function_
private

a lazy-parsed StringObjectFunction<reco::Candidate> that gets all the methods of daughter classes too

Definition at line 82 of file BaseTreeFiller.h.

Referenced by fill().

◆ handle_

edm::Handle<edm::ValueMap<float> > tnp::ProbeVariable::handle_
mutableprivate

the handle to keep the ValueMap

Definition at line 90 of file BaseTreeFiller.h.

Referenced by init().

◆ name_

std::string tnp::ProbeVariable::name_
private

the name of the variable, which becomes the ROOT branch name

Definition at line 74 of file BaseTreeFiller.h.

Referenced by name().

◆ srcToken_

edm::EDGetTokenT<edm::ValueMap<float> > tnp::ProbeVariable::srcToken_
private

the external valuemap

Definition at line 88 of file BaseTreeFiller.h.

Referenced by init().

◆ value_

float tnp::ProbeVariable::value_
mutableprivate

the place where we store the value, and that ROOT uses to fill the tree

Definition at line 76 of file BaseTreeFiller.h.

Referenced by address(), and fill().

tnp::ProbeVariable::srcToken_
edm::EDGetTokenT< edm::ValueMap< float > > srcToken_
the external valuemap
Definition: BaseTreeFiller.h:88
tnp::ProbeVariable::name
const std::string & name() const
name
Definition: BaseTreeFiller.h:61
tnp::ProbeVariable::function_
StringObjectFunction< reco::Candidate, true > function_
a lazy-parsed StringObjectFunction<reco::Candidate> that gets all the methods of daughter classes too
Definition: BaseTreeFiller.h:82
tnp::ProbeVariable::value_
float value_
the place where we store the value, and that ROOT uses to fill the tree
Definition: BaseTreeFiller.h:76
L1Validator_cfi.srcToken
srcToken
Definition: L1Validator_cfi.py:8
iEvent
int iEvent
Definition: GenABIO.cc:224
tnp::ProbeVariable::external_
bool external_
true if it's an external ValueMap, false if it's a StringParser function
Definition: BaseTreeFiller.h:79
tnp::ProbeVariable::handle_
edm::Handle< edm::ValueMap< float > > handle_
the handle to keep the ValueMap
Definition: BaseTreeFiller.h:90
tnp::ProbeVariable::name_
std::string name_
the name of the variable, which becomes the ROOT branch name
Definition: BaseTreeFiller.h:74