CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CollectionCombiner.h
Go to the documentation of this file.
1 #ifndef CollectionCombiner_H
2 #define CollectionCombiner_H
3 
4 
16 // system include files
17 #include <memory>
18 
19 // user include files
22 
25 
27 
28 template <typename Collection>
30 public:
31  explicit CollectionCombiner(const edm::ParameterSet&);
33 
34 private:
35  virtual void produce(edm::Event&, const edm::EventSetup&);
36 
37  // ----------member data ---------------------------
38  std::vector<edm::InputTag> labels;
39 };
40 
41 template <typename Collection>
43  labels = iConfig.getParameter<std::vector<edm::InputTag> >("labels");
44  produces<Collection>();
45 }
46 template <typename Collection>
48 
49 template <typename Collection>
51 {
52  unsigned int i=0,i_max=labels.size();
54  std::auto_ptr<Collection> merged(new Collection());
55  for (;i!=i_max;++i){
56  iEvent.getByLabel(labels[i], handle);
57  merged->insert(merged->end(), handle->begin(), handle->end());
58  }
59  iEvent.put(merged);
60 }
61 
62 
63 #endif
T getParameter(std::string const &) const
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:85
virtual void produce(edm::Event &, const edm::EventSetup &)
tuple handle
Definition: patZpeak.py:22
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
CollectionCombiner(const edm::ParameterSet &)
std::vector< edm::InputTag > labels