CMS 3D CMS Logo

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  srcToken_( consumes<edm::View<T> >( 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.getByToken( srcToken_, hSrc );
41 
42  std::unique_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(std::move(pOutputFwdPtr));
54  }
55 
56  protected :
58  };
59 }
60 
61 #endif
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
int iEvent
Definition: GenABIO.cc:230
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
FwdPtrProducer(edm::ParameterSet const &params)
Produces a list of FwdPtr&#39;s to an input collection.
HLT enums.
edm::EDGetTokenT< edm::View< T > > srcToken_
long double T
def move(src, dest)
Definition: eostools.py:510