Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00009
00010
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 mAssociatorAssigned (fConfig.getParameter<double> ("coneSize")),
00024 useAssigned(false), pvSrc()
00025 {
00026
00027 if ( fConfig.exists("useAssigned") ) {
00028 useAssigned = fConfig.getParameter<bool> ("useAssigned");
00029 pvSrc = fConfig.getParameter<edm::InputTag> ("pvSrc");
00030 }
00031
00032 produces<reco::JetTracksAssociation::Container> ();
00033 }
00034
00035 JetTracksAssociatorAtVertex::~JetTracksAssociatorAtVertex() {}
00036
00037 void JetTracksAssociatorAtVertex::produce(edm::Event& fEvent, const edm::EventSetup& fSetup) {
00038 edm::Handle <edm::View <reco::Jet> > jets_h;
00039 fEvent.getByLabel (mJets, jets_h);
00040 edm::Handle <reco::TrackCollection> tracks_h;
00041 fEvent.getByLabel (mTracks, tracks_h);
00042
00043 std::auto_ptr<reco::JetTracksAssociation::Container> jetTracks (new reco::JetTracksAssociation::Container (reco::JetRefBaseProd(jets_h)));
00044
00045
00046 std::vector <edm::RefToBase<reco::Jet> > allJets;
00047 allJets.reserve (jets_h->size());
00048 for (unsigned i = 0; i < jets_h->size(); ++i) allJets.push_back (jets_h->refAt(i));
00049 std::vector <reco::TrackRef> allTracks;
00050 allTracks.reserve (tracks_h->size());
00051
00052 for (unsigned i = 0; i < tracks_h->size(); ++i) {
00053 allTracks.push_back (reco::TrackRef (tracks_h, i));
00054 }
00055 if ( !useAssigned ) {
00056 mAssociator.produce (&*jetTracks, allJets, allTracks);
00057 } else {
00058 edm::Handle<reco::VertexCollection> pvHandle;
00059 fEvent.getByLabel(pvSrc,pvHandle);
00060 const reco::VertexCollection & vertices = *pvHandle.product();
00061 mAssociatorAssigned.produce (&*jetTracks, allJets, allTracks,vertices);
00062 }
00063
00064
00065
00066 fEvent.put (jetTracks);
00067 }