Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:13

0001 #include "PhysicsTools/PatUtils/interface/SimpleJetTrackAssociator.h"
0002 #include "DataFormats/TrackReco/interface/Track.h"
0003 #include "DataFormats/Math/interface/deltaR.h"
0004 
0005 void helper::SimpleJetTrackAssociator::associateTransient(const math::XYZVector &dir,
0006                                                           const reco::TrackCollection &in,
0007                                                           reco::TrackRefVector &out) {
0008   for (size_t i = 0, n = in.size(); i < n; i++) {
0009     const reco::Track &t = in[i];
0010     if ((t.numberOfValidHits() < nHits_) || (t.normalizedChi2() > chi2nMax_))
0011       continue;
0012     if (deltaR2(dir, t) < deltaR2_) {
0013       reco::TrackRef tr(&in, i);  // note: transient ref
0014       out.push_back(tr);
0015     }
0016   }
0017 }
0018 
0019 void helper::SimpleJetTrackAssociator::associate(const math::XYZVector &dir,
0020                                                  const edm::View<reco::Track> &in,
0021                                                  reco::TrackRefVector &out) {
0022   for (size_t i = 0, n = in.size(); i < n; i++) {
0023     const reco::Track &t = in[i];
0024     if ((t.numberOfValidHits() < nHits_) || (t.normalizedChi2() > chi2nMax_))
0025       continue;
0026     if (deltaR2(dir, t) < deltaR2_) {
0027       reco::TrackRef tr = in.refAt(i).castTo<reco::TrackRef>();
0028       out.push_back(tr);
0029     }
0030   }
0031 }