00001 /* 00002 * ===================================================================================== 00003 * Filename: RecoTauPiZeroFlattener.cc 00004 * 00005 * Description: Produce a plain vector<RecoTauPizero> from the the PiZeros in 00006 * a JetPiZeroAssociation associated to the input jets. 00007 * Created: 10/31/2010 12:33:41 00008 * 00009 * Author: Evan K. Friis (UC Davis), evan.klose.friis@cern.ch 00010 * ===================================================================================== 00011 */ 00012 00013 #include <boost/foreach.hpp> 00014 #include <algorithm> 00015 00016 #include "FWCore/Framework/interface/EDProducer.h" 00017 #include "FWCore/Framework/interface/EventSetup.h" 00018 #include "FWCore/Framework/interface/ESHandle.h" 00019 #include "FWCore/Framework/interface/Event.h" 00020 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00021 00022 #include "DataFormats/JetReco/interface/PFJetCollection.h" 00023 #include "DataFormats/TauReco/interface/JetPiZeroAssociation.h" 00024 #include "DataFormats/Candidate/interface/CandidateFwd.h" 00025 00026 #include "RecoTauTag/RecoTau/interface/RecoTauCommonUtilities.h" 00027 00028 class RecoTauPiZeroFlattener : public edm::EDProducer { 00029 public: 00030 explicit RecoTauPiZeroFlattener(const edm::ParameterSet &pset); 00031 ~RecoTauPiZeroFlattener() {} 00032 void produce(edm::Event& evt, const edm::EventSetup& es); 00033 private: 00034 edm::InputTag jetSrc_; 00035 edm::InputTag piZeroSrc_; 00036 }; 00037 00038 RecoTauPiZeroFlattener::RecoTauPiZeroFlattener(const edm::ParameterSet& pset) { 00039 jetSrc_ = pset.getParameter<edm::InputTag>("jetSrc"); 00040 piZeroSrc_ = pset.getParameter<edm::InputTag>("piZeroSrc"); 00041 produces<std::vector<reco::RecoTauPiZero> >(); 00042 } 00043 00044 void 00045 RecoTauPiZeroFlattener::produce(edm::Event& evt, const edm::EventSetup& es) { 00046 // Get the jet input collection via a view of Candidates 00047 edm::Handle<reco::CandidateView> jetView; 00048 evt.getByLabel(jetSrc_, jetView); 00049 00050 // Convert to a vector of PFJetRefs 00051 reco::PFJetRefVector jets = 00052 reco::tau::castView<reco::PFJetRefVector>(jetView); 00053 00054 // Get the pizero input collection 00055 edm::Handle<reco::JetPiZeroAssociation> piZeroAssoc; 00056 evt.getByLabel(piZeroSrc_, piZeroAssoc); 00057 00058 // Create output collection 00059 std::auto_ptr<std::vector<reco::RecoTauPiZero> > output( 00060 new std::vector<reco::RecoTauPiZero>()); 00061 00062 // Loop over the jets and append the pizeros for each jet to our output 00063 // collection. 00064 BOOST_FOREACH(reco::PFJetRef jetRef, jets) { 00065 const std::vector<reco::RecoTauPiZero>& pizeros = (*piZeroAssoc)[jetRef]; 00066 output->reserve(output->size() + pizeros.size()); 00067 output->insert(output->end(), pizeros.begin(), pizeros.end()); 00068 } 00069 00070 evt.put(output); 00071 } 00072 00073 #include "FWCore/Framework/interface/MakerMacros.h" 00074 DEFINE_FWK_MODULE(RecoTauPiZeroFlattener);