CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override {
39 
41  iEvent.getByToken( srcToken_, hSrc );
42 
43  std::auto_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( pOutput );
55  }
56 
57  protected :
59  };
60 }
61 
62 #endif
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:243
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ProductFromFwdPtrProducer(edm::ParameterSet const &params)
Produces a list of objects &quot;by value&quot; that correspond to the FwdPtr&#39;s from an input collection...
long double T
edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > srcToken_