00001 // \class JetTracksAssociatorAtVertex JetTracksAssociatorAtVertex.cc 00002 // 00003 // Original Author: Andrea Rizzi 00004 // Created: Wed Apr 12 11:12:49 CEST 2006 00005 // Accommodated for Jet Package by: Fedor Ratnikov Jul. 30, 2007 00006 // $Id: JetTracksAssociatorAtVertex.cc,v 1.6 2010/03/18 09:17:25 srappocc Exp $ 00007 // 00008 #include "FWCore/MessageLogger/interface/MessageLogger.h" 00009 00010 // user include files 00011 #include "FWCore/Framework/interface/Event.h" 00012 #include "DataFormats/Common/interface/View.h" 00013 #include "DataFormats/JetReco/interface/Jet.h" 00014 #include "DataFormats/TrackReco/interface/Track.h" 00015 #include "DataFormats/JetReco/interface/JetTracksAssociation.h" 00016 00017 #include "JetTracksAssociatorAtVertex.h" 00018 00019 JetTracksAssociatorAtVertex::JetTracksAssociatorAtVertex(const edm::ParameterSet& fConfig) 00020 : mJets (fConfig.getParameter<edm::InputTag> ("jets")), 00021 mTracks (fConfig.getParameter<edm::InputTag> ("tracks")), 00022 mAssociator (fConfig.getParameter<double> ("coneSize")) 00023 { 00024 produces<reco::JetTracksAssociation::Container> (); 00025 } 00026 00027 JetTracksAssociatorAtVertex::~JetTracksAssociatorAtVertex() {} 00028 00029 void JetTracksAssociatorAtVertex::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) { 00030 edm::Handle <edm::View <reco::Jet> > jets_h; 00031 fEvent.getByLabel (mJets, jets_h); 00032 edm::Handle <reco::TrackCollection> tracks_h; 00033 fEvent.getByLabel (mTracks, tracks_h); 00034 00035 std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h))); 00036 00037 // format inputs 00038 std::vector <edm::RefToBase<reco::Jet> > allJets; 00039 allJets.reserve (jets_h->size()); 00040 for (unsigned i = 0; i < jets_h->size(); ++i) allJets.push_back (jets_h->refAt(i)); 00041 std::vector <reco::TrackRef> allTracks; 00042 allTracks.reserve (tracks_h->size()); 00043 // run algo 00044 for (unsigned i = 0; i < tracks_h->size(); ++i) { 00045 allTracks.push_back (reco::TrackRef (tracks_h, i)); 00046 } 00047 mAssociator.produce (&*jetTracks, allJets, allTracks); 00048 00049 00050 // store output 00051 fEvent.put (jetTracks); 00052 }