Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:28

0001 // Associate jets with tracks by simple "dR" criteria
0002 // Fedor Ratnikov (UMd), Aug. 28, 2007
0003 
0004 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRVertex.h"
0005 
0006 #include "DataFormats/JetReco/interface/Jet.h"
0007 #include "DataFormats/TrackReco/interface/Track.h"
0008 
0009 #include "DataFormats/Math/interface/deltaR.h"
0010 #include "DataFormats/Math/interface/Vector3D.h"
0011 
0012 JetTracksAssociationDRVertex::JetTracksAssociationDRVertex(double fDr) : mDeltaR2Threshold(fDr * fDr) {}
0013 
0014 void JetTracksAssociationDRVertex::produce(reco::JetTracksAssociation::Container* fAssociation,
0015                                            const std::vector<edm::RefToBase<reco::Jet> >& fJets,
0016                                            const std::vector<reco::TrackRef>& fTracks) const {
0017   // cache tracks kinematics
0018   std::vector<math::RhoEtaPhiVector> trackP3s;
0019   trackP3s.reserve(fTracks.size());
0020   for (unsigned i = 0; i < fTracks.size(); ++i) {
0021     const reco::Track* track = &*(fTracks[i]);
0022     trackP3s.push_back(math::RhoEtaPhiVector(track->p(), track->eta(), track->phi()));
0023   }
0024   //loop on jets and associate
0025   for (unsigned j = 0; j < fJets.size(); ++j) {
0026     reco::TrackRefVector assoTracks;
0027     const reco::Jet* jet = &*(fJets[j]);
0028     double jetEta = jet->eta();
0029     double jetPhi = jet->phi();
0030     for (unsigned t = 0; t < fTracks.size(); ++t) {
0031       double dR2 = deltaR2(jetEta, jetPhi, trackP3s[t].eta(), trackP3s[t].phi());
0032       if (dR2 < mDeltaR2Threshold)
0033         assoTracks.push_back(fTracks[t]);
0034     }
0035     reco::JetTracksAssociation::setValue(fAssociation, fJets[j], assoTracks);
0036   }
0037 }