CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
ValueMapVariableBase< ObjType, TIn, ValType > Class Template Referenceabstract

#include <SimpleFlatTableProducer.h>

Inheritance diagram for ValueMapVariableBase< ObjType, TIn, ValType >:
ExtVariable< ObjType > VariableBase TypedValueMapVariable< ObjType, TIn, StringFunctor, ValType > ValueMapVariable< ObjType, TIn, ValType >

Public Member Functions

virtual ValType eval (const edm::Handle< edm::ValueMap< TIn >> &vmap, const edm::Ptr< ObjType > &op) const =0
 
void fill (const edm::Event &iEvent, std::vector< edm::Ptr< ObjType >> selptrs, nanoaod::FlatTable &out) const override
 
 ValueMapVariableBase (const std::string &aname, const edm::ParameterSet &cfg, edm::ConsumesCollector &&cc, bool skipNonExistingSrc=false)
 
- Public Member Functions inherited from ExtVariable< ObjType >
 ExtVariable (const std::string &aname, const edm::ParameterSet &cfg)
 
- Public Member Functions inherited from VariableBase
const std::string & name () const
 
 VariableBase (const std::string &aname, const edm::ParameterSet &cfg)
 
virtual ~VariableBase ()
 

Protected Attributes

const bool skipNonExistingSrc_
 
edm::EDGetTokenT< edm::ValueMap< TIn > > token_
 
- Protected Attributes inherited from VariableBase
std::string doc_
 
std::string name_
 
int precision_
 

Detailed Description

template<typename ObjType, typename TIn, typename ValType = TIn>
class ValueMapVariableBase< ObjType, TIn, ValType >

Definition at line 87 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ ValueMapVariableBase()

template<typename ObjType, typename TIn, typename ValType = TIn>
ValueMapVariableBase< ObjType, TIn, ValType >::ValueMapVariableBase ( const std::string &  aname,
const edm::ParameterSet cfg,
edm::ConsumesCollector &&  cc,
bool  skipNonExistingSrc = false 
)
inline

Definition at line 89 of file SimpleFlatTableProducer.h.

93  : ExtVariable<ObjType>(aname, cfg),
95  token_(cc.consumes<edm::ValueMap<TIn>>(cfg.getParameter<edm::InputTag>("src"))) {}
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
edm::EDGetTokenT< edm::ValueMap< TIn > > token_

Member Function Documentation

◆ eval()

template<typename ObjType, typename TIn, typename ValType = TIn>
virtual ValType ValueMapVariableBase< ObjType, TIn, ValType >::eval ( const edm::Handle< edm::ValueMap< TIn >> &  vmap,
const edm::Ptr< ObjType > &  op 
) const
pure virtual

◆ fill()

template<typename ObjType, typename TIn, typename ValType = TIn>
void ValueMapVariableBase< ObjType, TIn, ValType >::fill ( const edm::Event iEvent,
std::vector< edm::Ptr< ObjType >>  selptrs,
nanoaod::FlatTable out 
) const
inlineoverridevirtual

Implements ExtVariable< ObjType >.

Definition at line 97 of file SimpleFlatTableProducer.h.

References VariableBase::doc_, ValueMapVariableBase< ObjType, TIn, ValType >::eval(), mps_fire::i, iEvent, edm::HandleBase::isValid(), dqmiodumpmetadata::n, VariableBase::name_, MillePedeFileConverter_cfg::out, VariableBase::precision_, ValueMapVariableBase< ObjType, TIn, ValType >::skipNonExistingSrc_, and ValueMapVariableBase< ObjType, TIn, ValType >::token_.

97  {
99  iEvent.getByToken(token_, vmap);
100  std::vector<ValType> vals;
101  if (vmap.isValid() || !skipNonExistingSrc_) {
102  vals.resize(selptrs.size());
103  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
104  // calls the overloaded method to either get the valuemap value directly, or a function of the object value.
105  vals[i] = this->eval(vmap, selptrs[i]);
106  }
107  }
108  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
109  }
int iEvent
Definition: GenABIO.cc:224
virtual ValType eval(const edm::Handle< edm::ValueMap< TIn >> &vmap, const edm::Ptr< ObjType > &op) const =0
edm::EDGetTokenT< edm::ValueMap< TIn > > token_
bool isValid() const
Definition: HandleBase.h:70

Member Data Documentation

◆ skipNonExistingSrc_

template<typename ObjType, typename TIn, typename ValType = TIn>
const bool ValueMapVariableBase< ObjType, TIn, ValType >::skipNonExistingSrc_
protected

◆ token_

template<typename ObjType, typename TIn, typename ValType = TIn>
edm::EDGetTokenT<edm::ValueMap<TIn> > ValueMapVariableBase< ObjType, TIn, ValType >::token_
protected