00001 #include "PhysicsTools/PatUtils/interface/SimpleJetTrackAssociator.h" 00002 #include "DataFormats/TrackReco/interface/Track.h" 00003 #include "DataFormats/Math/interface/deltaR.h" 00004 00005 void 00006 helper::SimpleJetTrackAssociator::associateTransient(const math::XYZVector &dir, 00007 const reco::TrackCollection &in, reco::TrackRefVector &out) { 00008 for (size_t i = 0, n = in.size(); i < n; i++) { 00009 const reco::Track & t = in[i]; 00010 if ((t.numberOfValidHits() < nHits_) || (t.normalizedChi2() > chi2nMax_)) continue; 00011 if (deltaR2(dir, t) < deltaR2_) { 00012 reco::TrackRef tr(&in, i); // note: transient ref 00013 out.push_back(tr); 00014 } 00015 } 00016 } 00017 00018 void 00019 helper::SimpleJetTrackAssociator::associate(const math::XYZVector &dir, 00020 const edm::View<reco::Track> &in, reco::TrackRefVector &out) { 00021 for (size_t i = 0, n = in.size(); i < n; i++) { 00022 const reco::Track & t = in[i]; 00023 if ((t.numberOfValidHits() < nHits_) || (t.normalizedChi2() > chi2nMax_)) continue; 00024 if (deltaR2(dir, t) < deltaR2_) { 00025 reco::TrackRef tr = in.refAt(i).castTo<reco::TrackRef>(); 00026 out.push_back(tr); 00027 } 00028 } 00029 }