1 #ifndef CommonTools_UtilAlgos_FwdPtrCollectionFilter_h 2 #define CommonTools_UtilAlgos_FwdPtrCollectionFilter_h 25 template <
class T,
class S,
class H = ProductFromFwdPtrFactory<T>>
32 filter_{ps.exists(
"filter") ? ps.getParameter<
bool>(
"filter") :
false},
33 makeClones_{ps.exists(
"makeClones") ? ps.getParameter<
bool>(
"makeClones") :
false},
36 produces<std::vector<edm::FwdPtr<T>>>();
38 produces<std::vector<T>>();
44 auto pOutput = std::make_unique<std::vector<edm::FwdPtr<T>>>();
49 std::copy_if(std::cbegin(*hSrcAsFwdPtr), std::cend(*hSrcAsFwdPtr), std::back_inserter(*pOutput),
50 [
this](
auto const ptr) {
return selector_(*ptr); });
55 for (
auto ibegin = std::cbegin(*hSrcAsView), iend = std::cend(*hSrcAsView),
i = ibegin;
i!= iend; ++
i) {
57 auto const p = hSrcAsView->ptrAt(
i-ibegin);
58 pOutput->emplace_back(
p,
p);
66 auto pClones = std::make_unique<std::vector<T>>();
67 std::transform(std::cbegin(*pOutput), std::cend(*pOutput), std::back_inserter(*pClones),
68 [&factory](
auto ptr){
return factory(ptr); });
72 bool const pass {!pOutput->empty()};
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > const srcToken_
FwdPtrCollectionFilter(edm::ParameterSet const &ps)
bool filter(edm::Event &iEvent, edm::EventSetup const &iSetup) override
Selects a list of FwdPtr's to a product T (templated) that satisfy a method S(T) (templated). Can also handle input as View<T>. Can also have a factory class to create new instances of clones if desired.
edm::EDGetTokenT< edm::View< T > > const srcViewToken_