CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/RecoMuon/TrackerSeedGenerator/plugins/CollectionCombiner.h

Go to the documentation of this file.
00001 #ifndef CollectionCombiner_H
00002 #define CollectionCombiner_H
00003 
00004 
00016 // system include files
00017 #include <memory>
00018 
00019 // user include files
00020 #include "FWCore/Framework/interface/Frameworkfwd.h"
00021 #include "FWCore/Framework/interface/EDProducer.h"
00022 
00023 #include "FWCore/Framework/interface/Event.h"
00024 #include "FWCore/Framework/interface/MakerMacros.h"
00025 
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 
00028 template <typename Collection>
00029 class CollectionCombiner : public edm::EDProducer{
00030 public:
00031   explicit CollectionCombiner(const edm::ParameterSet&);
00032   ~CollectionCombiner();
00033   
00034 private:
00035   virtual void produce(edm::Event&, const edm::EventSetup&);
00036   
00037   // ----------member data ---------------------------
00038   std::vector<edm::InputTag> labels;
00039 };
00040 
00041 template <typename Collection>
00042 CollectionCombiner<Collection>::CollectionCombiner(const edm::ParameterSet& iConfig){
00043   labels = iConfig.getParameter<std::vector<edm::InputTag> >("labels");
00044   produces<Collection>();
00045 }
00046 template <typename Collection>
00047 CollectionCombiner<Collection>::~CollectionCombiner(){}
00048 
00049 template <typename Collection>
00050 void CollectionCombiner<Collection>::produce(edm::Event& iEvent, const edm::EventSetup& es)
00051 {
00052   unsigned int i=0,i_max=labels.size();
00053   edm::Handle<Collection> handle;
00054   std::auto_ptr<Collection> merged(new Collection());
00055   for (;i!=i_max;++i){
00056     iEvent.getByLabel(labels[i], handle);
00057     merged->insert(merged->end(), handle->begin(), handle->end());
00058   }
00059   iEvent.put(merged);
00060 }
00061 
00062 
00063 #endif