CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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.4 2013/02/28 00:34:12 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&) override {
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
00038