CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

virtual bool filter (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
 FwdPtrCollectionFilter ()
 
 FwdPtrCollectionFilter (edm::ParameterSet const &params)
 
 ~FwdPtrCollectionFilter ()
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDFilter ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Attributes

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

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- 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 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 27 of file FwdPtrCollectionFilter.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file FwdPtrCollectionFilter.h.

29 {}
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::FwdPtrCollectionFilter< T, S, H >::FwdPtrCollectionFilter ( edm::ParameterSet const &  params)
inlineexplicit

Definition at line 31 of file FwdPtrCollectionFilter.h.

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

31  :
32  srcToken_( consumes< std::vector< edm::FwdPtr<T> > >( params.getParameter<edm::InputTag>("src") ) ),
33  srcViewToken_( mayConsume< edm::View<T> >( params.getParameter<edm::InputTag>("src") ) ),
34  filter_(false), makeClones_(false),
35  selector_( params )
36  {
37  if ( params.exists("filter") ) {
38  filter_ = params.getParameter<bool>("filter");
39  }
40  if ( params.exists("makeClones") ) {
41  makeClones_ = params.getParameter<bool>("makeClones");
42  }
43 
44  produces< std::vector< edm::FwdPtr<T> > > ();
45  if ( makeClones_ ) {
46  produces< std::vector<T> > ();
47  }
48  }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< edm::View< T > > srcViewToken_
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > srcToken_
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::FwdPtrCollectionFilter< T, S, H >::~FwdPtrCollectionFilter ( )
inline

Definition at line 50 of file FwdPtrCollectionFilter.h.

50 {}

Member Function Documentation

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

Implements edm::EDFilter.

Definition at line 52 of file FwdPtrCollectionFilter.h.

References edm::FwdPtrCollectionFilter< T, S, H >::filter_, edm::Event::getByToken(), class-composition::H, i, edm::FwdPtrCollectionFilter< T, S, H >::makeClones_, edm::Event::put(), edm::FwdPtrCollectionFilter< T, S, H >::selector_, edm::FwdPtrCollectionFilter< T, S, H >::srcToken_, and edm::FwdPtrCollectionFilter< T, S, H >::srcViewToken_.

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().

52  {
53 
54  std::auto_ptr< std::vector< edm::FwdPtr<T> > > pOutput ( new std::vector<edm::FwdPtr<T> > );
55 
56  std::auto_ptr< std::vector<T> > pClones ( new std::vector<T> );
57 
58 
60  edm::Handle< edm::View<T> > hSrcAsView;
61  bool foundAsFwdPtr = iEvent.getByToken( srcToken_, hSrcAsFwdPtr );
62  if ( !foundAsFwdPtr ) {
63  iEvent.getByToken( srcViewToken_, hSrcAsView );
64  }
65 
66  // First try to access as a View<T>. If not a View<T>, look as a vector<FwdPtr<T> >
67  if ( !foundAsFwdPtr ) {
68  for ( typename edm::View<T>::const_iterator ibegin = hSrcAsView->begin(),
69  iend = hSrcAsView->end(),
70  i = ibegin; i!= iend; ++i ) {
71  if ( selector_( *i ) ) {
72  pOutput->push_back( edm::FwdPtr<T>( hSrcAsView->ptrAt( i - ibegin ), hSrcAsView->ptrAt( i - ibegin ) ) );
73  if ( makeClones_ ) {
74  H factory;
75  T outclone = factory( pOutput->back() );
76  pClones->push_back( outclone );
77  }
78  }
79  }
80  } else {
81  for ( typename std::vector<edm::FwdPtr<T> >::const_iterator ibegin = hSrcAsFwdPtr->begin(),
82  iend = hSrcAsFwdPtr->end(),
83  i = ibegin; i!= iend; ++i ) {
84  if ( selector_( **i ) ) {
85  pOutput->push_back( *i );
86  if ( makeClones_ ) {
87  H factory;
88  T outclone = factory( pOutput->back() );
89  pClones->push_back( outclone );
90  }
91  }
92  }
93 
94  }
95 
96  bool pass = pOutput->size() > 0;
97  iEvent.put( pOutput );
98  if ( makeClones_ )
99  iEvent.put( pClones );
100  if ( filter_ )
101  return pass;
102  else
103  return true;
104 
105  }
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
edm::EDGetTokenT< edm::View< T > > srcViewToken_
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > srcToken_
long double T

Member Data Documentation

template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
bool edm::FwdPtrCollectionFilter< T, S, H >::filter_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
bool 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> > > edm::FwdPtrCollectionFilter< T, S, H >::srcToken_
protected
template<class T , class S , class H = ProductFromFwdPtrFactory<T>>
edm::EDGetTokenT< edm::View<T> > edm::FwdPtrCollectionFilter< T, S, H >::srcViewToken_
protected