CMS 3D CMS Logo

CollectionAdder.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_UtilAlgos_CollectionAdder_h
2 #define PhysicsTools_UtilAlgos_CollectionAdder_h
3 /* \class CollectionAdder<C>
4  *
5  * \author Luca Lista, INFN
6  *
7  * \version $Id: CollectionAdder.h,v 1.3 2010/02/20 20:55:17 wmtan Exp $
8  */
15 
16 template <typename C>
18 public:
19  typedef C collection;
21  : srcTokens_(edm::vector_transform(cfg.template getParameter<std::vector<edm::InputTag>>("src"),
22  [this](edm::InputTag const& tag) { return consumes<collection>(tag); })) {
23  produces<collection>();
24  }
25 
26 private:
27  std::vector<edm::EDGetTokenT<collection>> srcTokens_;
28  void produce(edm::StreamID, edm::Event& evt, const edm::EventSetup&) const override {
29  std::unique_ptr<collection> coll(new collection);
30  typename collection::Filler filler(*coll);
31  for (size_t i = 0; i < srcTokens_.size(); ++i) {
33  evt.getByToken(srcTokens_[i], src);
34  *coll += *src;
35  }
36  evt.put(std::move(coll));
37  }
38 };
39 
40 #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:528
void produce(edm::StreamID, edm::Event &evt, const edm::EventSetup &) const override
auto vector_transform(std::vector< InputType > const &input, Function predicate) -> std::vector< typename std::remove_cv< typename std::remove_reference< decltype(predicate(input.front()))>::type >::type >
Definition: transform.h:11
std::vector< edm::EDGetTokenT< collection > > srcTokens_
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
CollectionAdder(const edm::ParameterSet &cfg)
HLT enums.
def move(src, dest)
Definition: eostools.py:511