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  src_ ( 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.getByLabel( src_, 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
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:94
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
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