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 86 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 88 of file SimpleFlatTableProducer.h.

92  : ExtVariable<ObjType>(aname, cfg),
94  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

◆ 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 95 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_.

95  {
97  iEvent.getByToken(token_, vmap);
98  std::vector<ValType> vals;
99  if (vmap.isValid() || !skipNonExistingSrc_) {
100  vals.resize(selptrs.size());
101  for (unsigned int i = 0, n = vals.size(); i < n; ++i) {
102  vals[i] = (*vmap)[selptrs[i]];
103  }
104  }
105  out.template addColumn<ValType>(this->name_, vals, this->doc_, this->precision_);
106  }
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