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::StreamID, edm::Event & iEvent, const edm::EventSetup& iSetup) const 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
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
virtual void produce(edm::StreamID, edm::Event &iEvent, const edm::EventSetup &iSetup) const override
ProductFromFwdPtrProducer(edm::ParameterSet const &params)
const edm::EDGetTokenT< std::vector< edm::FwdPtr< T > > > srcToken_
Produces a list of objects &quot;by value&quot; that correspond to the FwdPtr&#39;s from an input collection...
long double T