Go to the documentation of this file.00001 #ifndef RecoTauTag_TauTagTools_CopyProducer_h
00002 #define RecoTauTag_TauTagTools_CopyProducer_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #include "FWCore/Framework/interface/EDProducer.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00015 #include "FWCore/Utilities/interface/InputTag.h"
00016 #include "DataFormats/Common/interface/View.h"
00017 #include "DataFormats/Common/interface/Ref.h"
00018 #include "DataFormats/Common/interface/RefToBaseVector.h"
00019
00020 #include <algorithm>
00021
00022 namespace reco { namespace tautools {
00023
00024 template<typename Collection>
00025 class CopyProducer : public edm::EDProducer {
00026 public:
00028 explicit CopyProducer( const edm::ParameterSet& pset)
00029 :src_(pset.template getParameter<edm::InputTag>("src")) {
00030 produces<Collection>();
00031 }
00033 ~CopyProducer(){};
00035 virtual void produce(edm::Event& evt, const edm::EventSetup& es) {
00036
00037 std::auto_ptr<Collection> coll(new Collection());
00038 typedef edm::View<typename Collection::value_type> CView;
00039
00040 edm::Handle<CView> input;
00041 evt.getByLabel(src_, input);
00042
00043 coll->reserve(input->size());
00044
00045 std::copy(input->begin(), input->end(), std::back_inserter(*coll));
00046 evt.put( coll );
00047 }
00048 private:
00050 edm::InputTag src_;
00051 };
00052
00053 }}
00054
00055 #endif