1 #ifndef CommonTools_UtilAlgos_AssociationVectorSelector_h
2 #define CommonTools_UtilAlgos_AssociationVectorSelector_h
15 template<
typename KeyRefProd,
typename CVal,
35 template<
typename KeyRefProd,
typename CVal,
typename KeySelector,
typename ValSelector>
38 selectKey_(
reco::modules::
make<KeySelector>(cfg, consumesCollector())),
39 selectVal_(
reco::modules::
make<ValSelector>(cfg, consumesCollector())) {
40 std::string alias(cfg.template getParameter<std::string>(
"@module_label"));
41 produces<collection_t>().setBranchAlias(alias);
42 produces<association_t>().setBranchAlias(alias +
"Association");
45 template<
typename KeyRefProd,
typename CVal,
typename KeySelector,
typename ValSelector>
50 evt.
getByToken(associationToken_, association);
52 vector<typename CVal::value_type> selectedValues;
53 size_t size = association->size();
54 selected->reserve(
size);
55 selectedValues.reserve(
size);
57 i != association->end(); ++
i) {
59 if(selectKey_(obj)&&selectVal_(
i->second)) {
62 selectedValues.push_back(
i->second);
68 auto_ptr<association_t> selectedAssociation(
new association_t(ref, selected.get()));
69 size = selected->size();
71 for(
size_t i = 0;
i !=
size; ++
i)
72 selectedAssociation->setValue(
i, selectedValues[
i]);
73 evt.
put(selectedAssociation);
transient_vector_type::const_iterator const_iterator
bool getByToken(EDGetToken token, Handle< PROD > &result) const
S make(const edm::ParameterSet &cfg)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< association_t > associationToken_
void produce(edm::Event &, const edm::EventSetup &) override
association_t::CKey collection_t
KeyRefProd::product_type CKey
RefProd< PROD > getRefBeforePut()
KeyRef::value_type key_type
edm::AssociationVector< KeyRefProd, CVal > association_t
tuple size
Write out results.
AssociationVectorSelector(const edm::ParameterSet &)