1 #ifndef CommonTools_UtilAlgos_FwdPtrCollectionFilter_h
2 #define CommonTools_UtilAlgos_FwdPtrCollectionFilter_h
26 template <
class T,
class S,
class H = ProductFromFwdPtrFactory<T> >
37 if ( params.
exists(
"filter") ) {
40 if ( params.
exists(
"makeClones") ) {
44 produces< std::vector< edm::FwdPtr<T> > > ();
46 produces< std::vector<T> > ();
54 std::auto_ptr< std::vector< edm::FwdPtr<T> > > pOutput (
new std::vector<
edm::FwdPtr<T> > );
56 std::auto_ptr< std::vector<T> > pClones (
new std::vector<T> );
62 if ( !foundAsFwdPtr ) {
67 if ( !foundAsFwdPtr ) {
69 iend = hSrcAsView->end(),
70 i = ibegin;
i!= iend; ++
i ) {
72 pOutput->push_back(
edm::FwdPtr<T>( hSrcAsView->ptrAt(
i - ibegin ), hSrcAsView->ptrAt(
i - ibegin ) ) );
75 T outclone = factory( pOutput->back() );
76 pClones->push_back( outclone );
81 for (
typename std::vector<
edm::FwdPtr<T> >::const_iterator ibegin = hSrcAsFwdPtr->begin(),
82 iend = hSrcAsFwdPtr->end(),
83 i = ibegin;
i!= iend; ++
i ) {
85 pOutput->push_back( *
i );
88 T outclone = factory( pOutput->back() );
89 pClones->push_back( outclone );
96 bool pass = pOutput->size() > 0;
97 iEvent.
put( pOutput );
99 iEvent.
put( pClones );
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
FwdPtrCollectionFilter(edm::ParameterSet const ¶ms)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< edm::View< T > > srcViewToken_
virtual bool filter(edm::Event &iEvent, const edm::EventSetup &iSetup)
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< std::vector< edm::FwdPtr< T > > > srcToken_
double S(const TLorentzVector &, const TLorentzVector &)
volatile std::atomic< bool > shutdown_flag false
~FwdPtrCollectionFilter()
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)