CMS 3D CMS Logo

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

#include <SimpleFlatTableProducer.h>

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

Public Member Functions

void fill (const edm::Event &iEvent, std::vector< edm::Ptr< ObjType >> selptrs, nanoaod::FlatTable &out) const override
 
 ValueMapVariable (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 ValueMapVariable< ObjType, TIn, ValType >

Definition at line 79 of file SimpleFlatTableProducer.h.

Constructor & Destructor Documentation

◆ ValueMapVariable()

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

Definition at line 81 of file SimpleFlatTableProducer.h.

85  : ExtVariable<ObjType>(aname, cfg),
87  token_(cc.consumes<edm::ValueMap<TIn>>(cfg.getParameter<edm::InputTag>("src"))) {}
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::ValueMap< TIn > > token_

Member Function Documentation

◆ fill()

template<typename ObjType , typename TIn , typename ValType = TIn>
void ValueMapVariable< 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 88 of file SimpleFlatTableProducer.h.

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

88  {
90  iEvent.getByToken(token_, vmap);
91  std::vector<ValType> vals;
92  if (vmap.isValid() || !skipNonExistingSrc_) {
93  vals.resize(selptrs.size());
94  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
95  vals[i] = (*vmap)[selptrs[i]];
96  }
97  }
98  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
99  }
int iEvent
Definition: GenABIO.cc:224
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 ValueMapVariable< ObjType, TIn, ValType >::skipNonExistingSrc_
protected

◆ token_

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