CMS 3D CMS Logo

ProductFromFwdPtrProducer.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_ProductFromFwdPtrProducer_h
2 #define CommonTools_UtilAlgos_ProductFromFwdPtrProducer_h
3 
4 
21 #include <vector>
22 
23 namespace edm {
24 
25 
26 
27  template < class T, class H = ProductFromFwdPtrFactory<T> >
29  public :
30  explicit ProductFromFwdPtrProducer( edm::ParameterSet const & params ) :
31  srcToken_ ( consumes< std::vector<edm::FwdPtr<T> > >( params.getParameter<edm::InputTag>("src") ) )
32  {
33  produces< std::vector<T> > ();
34  }
35 
37 
38  void produce(edm::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const override {
39 
41  iEvent.getByToken( srcToken_, hSrc );
42 
43  std::unique_ptr< std::vector<T> > pOutput ( new std::vector<T> );
44 
45  for ( typename std::vector< edm::FwdPtr<T> >::const_iterator ibegin = hSrc->begin(),
46  iend = hSrc->end(),
47  i = ibegin; i!= iend; ++i ) {
48  H factory;
49  T t = factory(*i);
50  pOutput->push_back( t );
51  }
52 
53 
54  iEvent.put(std::move(pOutput));
55  }
56 
57  protected :
59  };
60 }
61 
62 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:136
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
ProductFromFwdPtrProducer(edm::ParameterSet const &params)
const edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > srcToken_
HLT enums.
Produces a list of objects "by value" that correspond to the FwdPtr&#39;s from an input collection...
long double T
def move(src, dest)
Definition: eostools.py:510