CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/CommonTools/UtilAlgos/interface/CollectionAdder.h

Go to the documentation of this file.
00001 #ifndef PhysicsTools_UtilAlgos_CollectionAdder_h
00002 #define PhysicsTools_UtilAlgos_CollectionAdder_h
00003 /* \class CollectionAdder<C>
00004  * 
00005  * \author Luca Lista, INFN
00006  * 
00007  * \version $Id: CollectionAdder.h,v 1.3 2010/02/20 20:55:17 wmtan Exp $
00008  */
00009 #include "FWCore/Framework/interface/EDProducer.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011 #include "FWCore/Utilities/interface/InputTag.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "DataFormats/Common/interface/Handle.h"
00014 
00015 template<typename C>
00016 class CollectionAdder : public edm::EDProducer {
00017 public:
00018   typedef C collection;
00019   CollectionAdder(const edm::ParameterSet & cfg ) :
00020     src_(cfg.template getParameter<std::vector<edm::InputTag> >("src")) {
00021     produces<collection>();
00022   }
00023 private:
00024   std::vector<edm::InputTag> src_;
00025   void produce(edm::Event & evt, const edm::EventSetup&) {
00026     std::auto_ptr<collection> coll(new collection);
00027     typename collection::Filler filler(*coll);
00028     for(size_t i = 0; i < src_.size(); ++i ) {
00029       edm::Handle<collection> src;
00030       evt.getByLabel(src_[i], src);
00031       *coll += *src;
00032     }
00033     evt.put(coll);
00034   }
00035 };
00036 
00037 #endif