CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/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.3 2009/03/30 15:06:33 bainbrid Exp $
00004 
00005 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRVertex.h"
00006 #include "DataFormats/Math/interface/deltaR.h"
00007 
00008 // -----------------------------------------------------------------------------
00009 //
00010 JetTracksAssociationDRVertex::JetTracksAssociationDRVertex( double fDr ) 
00011   : JetTracksAssociationDR(fDr),
00012     propagatedTracks_()
00013 {;}
00014 
00015 // -----------------------------------------------------------------------------
00016 //
00017 JetTracksAssociationDRVertex::~JetTracksAssociationDRVertex() 
00018 {;}
00019 
00020 // -----------------------------------------------------------------------------
00021 //
00022 void JetTracksAssociationDRVertex::produce( Association* fAssociation, 
00023                                             const Jets& fJets,
00024                                             const Tracks& fTracks,
00025                                             const TrackQuality& fQuality ) 
00026 {
00027   JetRefs jets;
00028   createJetRefs( jets, fJets );
00029   TrackRefs tracks;
00030   createTrackRefs( tracks, fTracks, fQuality );
00031   produce( fAssociation, jets, tracks );
00032 }
00033 
00034 // -----------------------------------------------------------------------------
00035 //
00036 void JetTracksAssociationDRVertex::produce( Association* fAssociation, 
00037                                             const JetRefs& fJets,
00038                                             const TrackRefs& fTracks ) 
00039 {
00040   //clear();
00041   propagateTracks( fTracks ); 
00042   associateTracksToJets( fAssociation, fJets, fTracks ); 
00043 }
00044 
00045 // -----------------------------------------------------------------------------
00046 //
00047 void JetTracksAssociationDRVertex::associateTracksToJet( reco::TrackRefVector& associated,
00048                                                          const reco::Jet& fJet,
00049                                                          const TrackRefs& fTracks ) 
00050 {
00051   associated.clear();
00052   std::vector<math::RhoEtaPhiVector>::const_iterator ii = propagatedTracks_.begin();
00053   std::vector<math::RhoEtaPhiVector>::const_iterator jj = propagatedTracks_.end();
00054   for ( ; ii != jj; ++ii ) {
00055     uint32_t index = ii - propagatedTracks_.begin();
00056     double dR2 = deltaR2( fJet.eta(), fJet.phi(), ii->eta(), ii->phi() );
00057     if ( dR2 < mDeltaR2Threshold ) { associated.push_back( fTracks[index] ); }
00058   }
00059 }
00060 
00061 // -----------------------------------------------------------------------------
00062 //
00063 void JetTracksAssociationDRVertex::propagateTracks( const TrackRefs& fTracks ) 
00064 {
00065   propagatedTracks_.clear();
00066   propagatedTracks_.reserve( fTracks.size() );
00067   TrackRefs::const_iterator ii = fTracks.begin();
00068   TrackRefs::const_iterator jj = fTracks.end();
00069   for ( ; ii != jj; ++ii ) {
00070     propagatedTracks_.push_back( math::RhoEtaPhiVector( (**ii).p(), (**ii).eta(), (**ii).phi() ) ); 
00071   }
00072 }  
00073 
00074