CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/RecoJets/JetAssociationAlgorithms/src/JetTracksAssociationDRVertex.cc

Go to the documentation of this file.
00001 // Associate jets with tracks by simple "dR" criteria
00002 // Fedor Ratnikov (UMd), Aug. 28, 2007
00003 // $Id: JetTracksAssociationDRVertex.cc,v 1.4 2010/03/18 12:17:58 bainbrid Exp $
00004 
00005 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRVertex.h"
00006 
00007 #include "DataFormats/JetReco/interface/Jet.h"
00008 #include "DataFormats/TrackReco/interface/Track.h"
00009 
00010 #include "DataFormats/Math/interface/deltaR.h"
00011 #include "DataFormats/Math/interface/Vector3D.h"
00012 
00013 
00014 JetTracksAssociationDRVertex::JetTracksAssociationDRVertex (double fDr) 
00015 : mDeltaR2Threshold (fDr*fDr)
00016 {}
00017 
00018 void JetTracksAssociationDRVertex::produce (reco::JetTracksAssociation::Container* fAssociation, 
00019                                          const std::vector <edm::RefToBase<reco::Jet> >& fJets,
00020                                          const std::vector <reco::TrackRef>& fTracks) const 
00021 {
00022   // cache tracks kinematics
00023   std::vector <math::RhoEtaPhiVector> trackP3s;
00024   trackP3s.reserve (fTracks.size());
00025   for (unsigned i = 0; i < fTracks.size(); ++i) {
00026     const reco::Track* track = &*(fTracks[i]);
00027     trackP3s.push_back (math::RhoEtaPhiVector (track->p(),track->eta(), track->phi())); 
00028   }
00029   //loop on jets and associate
00030   for (unsigned j = 0; j < fJets.size(); ++j) {
00031     reco::TrackRefVector assoTracks;
00032     const reco::Jet* jet = &*(fJets[j]); 
00033     double jetEta = jet->eta();
00034     double jetPhi = jet->phi();
00035     for (unsigned t = 0; t < fTracks.size(); ++t) {
00036       double dR2 = deltaR2 (jetEta, jetPhi, trackP3s[t].eta(), trackP3s[t].phi());
00037       if (dR2 < mDeltaR2Threshold)  assoTracks.push_back (fTracks[t]);
00038     }
00039     reco::JetTracksAssociation::setValue (fAssociation, fJets[j], assoTracks);
00040   }
00041 }