CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
pat::helper::NamedUserDataLoader< A > Class Template Reference

Public Member Functions

template<typename T , typename TParent = T>
void addData (const edm::Event &iEvent, const std::vector< edm::Ptr< T >> &ptrs, std::vector< edm::Handle< edm::View< TParent >>> parents, std::vector< T > &out) const
 
 NamedUserDataLoader (const edm::ParameterSet &iConfig, const std::string &main, edm::ConsumesCollector &&cc)
 

Private Attributes

std::vector< std::pair< std::string, edm::EDGetTokenT< typename A::product_type > > > labelsAndTokens_
 

Detailed Description

template<typename A>
class pat::helper::NamedUserDataLoader< A >

Definition at line 73 of file PATObjectUserDataEmbedder.cc.

Constructor & Destructor Documentation

◆ NamedUserDataLoader()

template<typename A>
pat::helper::NamedUserDataLoader< A >::NamedUserDataLoader ( const edm::ParameterSet iConfig,
const std::string &  main,
edm::ConsumesCollector &&  cc 
)
inline

Definition at line 75 of file PATObjectUserDataEmbedder.cc.

75  {
76  if (iConfig.existsAs<edm::ParameterSet>(main)) {
77  edm::ParameterSet const &srcPSet = iConfig.getParameter<edm::ParameterSet>(main);
78  for (const std::string &label : srcPSet.getParameterNamesForType<edm::InputTag>()) {
79  labelsAndTokens_.emplace_back(
80  label, cc.consumes<typename A::product_type>(srcPSet.getParameter<edm::InputTag>(label)));
81  }
82  }
83  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
char const * label
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:179
std::vector< std::pair< std::string, edm::EDGetTokenT< typename A::product_type > > > labelsAndTokens_
Definition: main.py:1

Member Function Documentation

◆ addData()

template<typename A>
template<typename T , typename TParent = T>
void pat::helper::NamedUserDataLoader< A >::addData ( const edm::Event iEvent,
const std::vector< edm::Ptr< T >> &  ptrs,
std::vector< edm::Handle< edm::View< TParent >>>  parents,
std::vector< T > &  out 
) const
inline

Definition at line 85 of file PATObjectUserDataEmbedder.cc.

88  {
89  A adder;
90  unsigned int n = ptrs.size();
92  for (const auto &pair : labelsAndTokens_) {
93  iEvent.getByToken(pair.second, handle);
94  for (unsigned int i = 0; i < n; ++i) {
95  auto ptr = getPtrForProd(ptrs[i], parents, *handle);
96  adder.addData(out[i], pair.first, (*handle)[ptr]);
97  }
98  }
99  }
TPRegexp parents
Definition: eve_filter.cc:21
int iEvent
Definition: GenABIO.cc:224
std::vector< std::pair< std::string, edm::EDGetTokenT< typename A::product_type > > > labelsAndTokens_
edm::Ptr< TParent > getPtrForProd(edm::Ptr< T > ptr, const std::vector< edm::Handle< edm::View< TParent >>> &parentColls, const TProd &prod)
Definition: APVGainStruct.h:7

Member Data Documentation

◆ labelsAndTokens_

template<typename A>
std::vector<std::pair<std::string, edm::EDGetTokenT<typename A::product_type> > > pat::helper::NamedUserDataLoader< A >::labelsAndTokens_
private