CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoTauTag/RecoTau/plugins/PFTauViewRefMerger.cc

Go to the documentation of this file.
00001 /* \class PFTauViewRefMerger
00002  *
00003  * Produces a RefVector of PFTaus from a different views of PFTau.
00004  *
00005  * Note that the collections must all come from the same original collection!
00006  *
00007  * Author: Evan K. Friis
00008  *
00009  */
00010 #include <boost/foreach.hpp>
00011 
00012 #include "DataFormats/TauReco/interface/PFTauFwd.h"
00013 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h"
00014 
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "DataFormats/Candidate/interface/Candidate.h"
00017 #include "FWCore/Framework/interface/EDProducer.h"
00018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00019 #include "FWCore/Framework/interface/Event.h"
00020 #include "DataFormats/Common/interface/Handle.h"
00021 
00022 class PFTauViewRefMerger : public edm::EDProducer {
00023   public:
00024     explicit PFTauViewRefMerger(const edm::ParameterSet& cfg) :
00025         src_(cfg.getParameter<std::vector<edm::InputTag> >("src")) {
00026           produces<reco::PFTauRefVector>();
00027         }
00028   private:
00029     void produce(edm::Event & evt, const edm::EventSetup &) {
00030       std::auto_ptr<reco::PFTauRefVector> out(new reco::PFTauRefVector());
00031       BOOST_FOREACH(const edm::InputTag& inputSrc, src_) {
00032         edm::Handle<reco::CandidateView> src;
00033         evt.getByLabel(inputSrc, src);
00034         reco::PFTauRefVector inputRefs =
00035             reco::tau::castView<reco::PFTauRefVector>(src);
00036         // Merge all the collections
00037         BOOST_FOREACH(const reco::PFTauRef tau, inputRefs) {
00038           out->push_back(tau);
00039         }
00040       }
00041       evt.put(out);
00042     }
00043     std::vector<edm::InputTag> src_;
00044 };
00045 
00046 DEFINE_FWK_MODULE(PFTauViewRefMerger);