CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FwdPtrProducer.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_FwdPtrProducer_h
2 #define CommonTools_UtilAlgos_FwdPtrProducer_h
3 
4 
21 #include <vector>
22 
23 namespace edm {
24 
25 
26  template < class T, class H = FwdPtrFromProductFactory<T> >
28  public :
29  explicit FwdPtrProducer( edm::ParameterSet const & params ) :
30  src_( params.getParameter<edm::InputTag>("src") )
31  {
32  produces< std::vector< edm::FwdPtr<T> > > ();
33  }
34 
36 
37  virtual void produce(edm::Event & iEvent, const edm::EventSetup& iSetup) override {
38 
40  iEvent.getByLabel( src_, hSrc );
41 
42  std::auto_ptr< std::vector< edm::FwdPtr<T> > > pOutputFwdPtr ( new std::vector<edm::FwdPtr<T> > );
43 
44  for ( typename edm::View<T>::const_iterator ibegin = hSrc->begin(),
45  iend = hSrc->end(),
46  i = ibegin; i!= iend; ++i ) {
47  H factory;
48  FwdPtr<T> ptr = factory( *hSrc, i - ibegin );
49  pOutputFwdPtr->push_back( ptr );
50  }
51 
52 
53  iEvent.put( pOutputFwdPtr );
54  }
55 
56  protected :
58  };
59 }
60 
61 #endif
int i
Definition: DBlmapReader.cc:9
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
FwdPtrProducer(edm::ParameterSet const &params)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Produces a list of FwdPtr&#39;s to an input collection.
edm::InputTag src_