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>
37 association_(cfg.
template getParameter<edm::InputTag>(
"association")),
38 selectKey_(
reco::modules::
make<KeySelector>(cfg)),
39 selectVal_(
reco::modules::
make<ValSelector>(cfg)) {
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>
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
S make(const edm::ParameterSet &cfg)
edm::InputTag association_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
void produce(edm::Event &, const edm::EventSetup &) override
association_t::CKey collection_t
KeyRefProd::product_type CKey
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
KeyRef::value_type key_type
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
edm::AssociationVector< KeyRefProd, CVal > association_t
tuple size
Write out results.
AssociationVectorSelector(const edm::ParameterSet &)