CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FwdPtrProducer.h
Go to the documentation of this file.
1 #ifndef CommonTools_UtilAlgos_FwdPtrProducer_h
2 #define CommonTools_UtilAlgos_FwdPtrProducer_h
3 
19 #include <vector>
20 
21 namespace edm {
22 
23  template <class T, class H = FwdPtrFromProductFactory<T> >
25  public:
27  : srcToken_(consumes<edm::View<T> >(params.getParameter<edm::InputTag>("src"))) {
28  produces<std::vector<edm::FwdPtr<T> > >();
29  }
30 
31  ~FwdPtrProducer() override {}
32 
33  void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override {
35  iEvent.getByToken(srcToken_, hSrc);
36 
37  std::unique_ptr<std::vector<edm::FwdPtr<T> > > pOutputFwdPtr(new std::vector<edm::FwdPtr<T> >);
38 
39  for (typename edm::View<T>::const_iterator ibegin = hSrc->begin(), iend = hSrc->end(), i = ibegin; i != iend;
40  ++i) {
41  H factory;
42  FwdPtr<T> ptr = factory(*hSrc, i - ibegin);
43  pOutputFwdPtr->push_back(ptr);
44  }
45 
46  iEvent.put(std::move(pOutputFwdPtr));
47  }
48 
49  protected:
51  };
52 } // namespace edm
53 
54 #endif
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
~FwdPtrProducer() override
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &iEvent, const edm::EventSetup &iSetup) override
def move
Definition: eostools.py:511
FwdPtrProducer(edm::ParameterSet const &params)
Produces a list of FwdPtr&#39;s to an input collection.
edm::EDGetTokenT< edm::View< T > > srcToken_
long double T