CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/CommonTools/CandAlgos/plugins/CandViewRefMerger.cc

Go to the documentation of this file.
00001 /* \class CandViewRefMerger
00002  * 
00003  * Producer of merged references to Candidates
00004  *
00005  * \author: Luca Lista, INFN
00006  *
00007  */
00008 
00009 #include "FWCore/Framework/interface/MakerMacros.h"
00010 #include "DataFormats/Candidate/interface/Candidate.h"
00011 #include "FWCore/Framework/interface/EDProducer.h"
00012 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00013 #include "FWCore/Framework/interface/Event.h"
00014 #include "DataFormats/Common/interface/Handle.h"
00015 
00016 class CandViewRefMerger : public edm::EDProducer {
00017 public:
00018   explicit CandViewRefMerger(const edm::ParameterSet& cfg) :
00019     src_(cfg.getParameter<std::vector<edm::InputTag> >("src")) {
00020     produces<std::vector<reco::CandidateBaseRef> >();
00021   }
00022 private:
00023   void produce(edm::Event & evt, const edm::EventSetup &) {
00024     std::auto_ptr<std::vector<reco::CandidateBaseRef> > out(new std::vector<reco::CandidateBaseRef>);
00025     for(std::vector<edm::InputTag>::const_iterator i = src_.begin(); i != src_.end(); ++i) {
00026       edm::Handle<reco::CandidateView> src;
00027       evt.getByLabel(*i, src);
00028       reco::CandidateBaseRefVector refs = src->refVector();
00029       for(reco::CandidateBaseRefVector::const_iterator j = refs.begin(); j != refs.end(); ++j)
00030         out->push_back(*j);
00031     }
00032     evt.put(out);
00033   }
00034   std::vector<edm::InputTag> src_;
00035 };
00036 
00037 DEFINE_FWK_MODULE(CandViewRefMerger);