CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
edm::FwdPtrCollectionFilter< T, S, H > Class Template Reference

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. More...

#include "CommonTools/UtilAlgos/interface/FwdPtrCollectionFilter.h"

Inheritance diagram for edm::FwdPtrCollectionFilter< T, S, H >:
edm::stream::EDFilter<> edm::stream::EDFilterBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

bool filter (edm::Event &iEvent, edm::EventSetup const &iSetup) override
 
 FwdPtrCollectionFilter (edm::ParameterSet const &ps)
 
- Public Member Functions inherited from edm::stream::EDFilter<>
 EDFilter ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
- Public Member Functions inherited from edm::stream::EDFilterBase
 EDFilterBase ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilterBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Attributes

bool const filter_
 
bool const makeClones_
 
S selector_
 
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > const srcToken_
 
edm::EDGetTokenT< edm::View< T > > const srcViewToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDFilter<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDFilterBase
typedef EDFilterAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::stream::EDFilterBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<class T, class S, class H = ProductFromFwdPtrFactory<T>>
class edm::FwdPtrCollectionFilter< T, S, H >

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.

Author
Salvatore Rappoccio

Definition at line 26 of file FwdPtrCollectionFilter.h.

Constructor & Destructor Documentation

template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::FwdPtrCollectionFilter< T, S, H >::FwdPtrCollectionFilter ( edm::ParameterSet const &  ps)
inlineexplicit

Definition at line 29 of file FwdPtrCollectionFilter.h.

References edm::FwdPtrCollectionFilter< T, S, H >::filter_, edm::ParameterSet::getParameter(), edm::FwdPtrCollectionFilter< T, S, H >::makeClones_, edm::FwdPtrCollectionFilter< T, S, H >::selector_, and edm::FwdPtrCollectionFilter< T, S, H >::srcViewToken_.

29  :
30  srcToken_{consumes<std::vector<edm::FwdPtr<T>>>(ps.getParameter<edm::InputTag>("src"))},
31  srcViewToken_{mayConsume<edm::View<T>>(ps.getParameter<edm::InputTag>("src"))},
32  filter_{ps.exists("filter") ? ps.getParameter<bool>("filter") : false},
33  makeClones_{ps.exists("makeClones") ? ps.getParameter<bool>("makeClones") : false},
34  selector_{ps}
35  {
36  produces<std::vector<edm::FwdPtr<T>>>();
37  if (makeClones_) {
38  produces<std::vector<T>>();
39  }
40  }
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > const srcToken_
edm::EDGetTokenT< edm::View< T > > const srcViewToken_

Member Function Documentation

template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
bool edm::FwdPtrCollectionFilter< T, S, H >::filter ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
inlineoverridevirtual

Implements edm::stream::EDFilterBase.

Definition at line 42 of file FwdPtrCollectionFilter.h.

References edm::FwdPtrCollectionFilter< T, S, H >::filter_, edm::Event::getByToken(), class-composition::H, mps_fire::i, edm::FwdPtrCollectionFilter< T, S, H >::makeClones_, eostools::move(), AlCaHLTBitMon_ParallelJobs::p, edm::Event::put(), edm::FwdPtrCollectionFilter< T, S, H >::selector_, edm::FwdPtrCollectionFilter< T, S, H >::srcToken_, edm::FwdPtrCollectionFilter< T, S, H >::srcViewToken_, and create_public_lumi_plots::transform.

Referenced by Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::filter(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::find(), Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::setDataAccessor(), and Vispa.Plugins.Browser.BrowserTabController.BrowserTabController::switchCenterView().

43  {
44  auto pOutput = std::make_unique<std::vector<edm::FwdPtr<T>>>();
45 
46  // First try to access as a vector<FwdPtr<T>>; otherwise try as a View<T>.
48  if (iEvent.getByToken(srcToken_, hSrcAsFwdPtr)) {
49  std::copy_if(std::cbegin(*hSrcAsFwdPtr), std::cend(*hSrcAsFwdPtr), std::back_inserter(*pOutput),
50  [this](auto const ptr) { return selector_(*ptr); });
51  }
52  else {
53  edm::Handle<edm::View<T>> hSrcAsView;
54  iEvent.getByToken(srcViewToken_, hSrcAsView);
55  for (auto ibegin = std::cbegin(*hSrcAsView), iend = std::cend(*hSrcAsView), i = ibegin; i!= iend; ++i) {
56  if (selector_(*i)) {
57  auto const p = hSrcAsView->ptrAt(i-ibegin);
58  pOutput->emplace_back(p,p);
59  }
60  }
61  }
62 
63  // Must form pClones *before* std::move(pOutput) has been called.
64  if (makeClones_) {
65  H factory;
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); });
69  iEvent.put(std::move(pClones));
70  }
71 
72  bool const pass {!pOutput->empty()};
73  iEvent.put(std::move(pOutput));
74 
75  return filter_ ? pass : true;
76  }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > const srcToken_
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< edm::View< T > > const srcViewToken_

Member Data Documentation

template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
bool const edm::FwdPtrCollectionFilter< T, S, H >::filter_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
bool const edm::FwdPtrCollectionFilter< T, S, H >::makeClones_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
S edm::FwdPtrCollectionFilter< T, S, H >::selector_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::EDGetTokenT<std::vector<edm::FwdPtr<T> > > const edm::FwdPtrCollectionFilter< T, S, H >::srcToken_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::EDGetTokenT<edm::View<T> > const edm::FwdPtrCollectionFilter< T, S, H >::srcViewToken_
protected