Go to the documentation of this file.00001
00002
00003
00004
00005 #include "RecoJets/JetAssociationAlgorithms/interface/JetTracksAssociationDRVertexAssigned.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 #include "DataFormats/Math/interface/Point3D.h"
00013 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00014
00015 JetTracksAssociationDRVertexAssigned::JetTracksAssociationDRVertexAssigned (double fDr)
00016 : mDeltaR2Threshold (fDr*fDr)
00017 {}
00018
00019 void JetTracksAssociationDRVertexAssigned::produce (reco::JetTracksAssociation::Container* fAssociation,
00020 const std::vector <edm::RefToBase<reco::Jet> >& fJets,
00021 const std::vector <reco::TrackRef>& fTracks,
00022 const reco::VertexCollection& vertices) const
00023 {
00024
00025 std::vector <math::RhoEtaPhiVector> trackP3s;
00026 std::map <int,double> trackvert;
00027
00028
00029
00030 trackP3s.reserve (fTracks.size());
00031 for (unsigned i = 0; i < fTracks.size(); ++i) {
00032 const reco::Track* track = &*(fTracks[i]);
00033 trackP3s.push_back (math::RhoEtaPhiVector (track->p(),track->eta(), track->phi()));
00034
00035
00036
00037 const reco::TrackBaseRef ttr1(fTracks[i]);
00038
00039
00040 int trackhasvert = -1;
00041 for( reco::VertexCollection::const_iterator iv = vertices.begin(); iv != vertices.end(); iv++) {
00042 std::vector<reco::TrackBaseRef>::const_iterator rr =
00043 find((*iv).tracks_begin(),
00044 (*iv).tracks_end(),
00045 ttr1);
00046 if( rr != (*iv).tracks_end() ) {
00047 trackhasvert = 1;
00048 trackvert[i] = (*iv).position().z();
00049
00050 break;
00051 }
00052 }
00053 if(trackhasvert < 0) {
00054
00055 math::XYZPoint ppt(0.,0.,0.);
00056 trackvert[i] = track->dz(ppt);
00057
00058
00059 }
00060
00061 }
00062
00063 for (unsigned j = 0; j < fJets.size(); ++j) {
00064
00065 reco::TrackRefVector assoTracks;
00066 const reco::Jet* jet = &*(fJets[j]);
00067 double jetEta = jet->eta();
00068 double jetPhi = jet->phi();
00069 double neweta = 0;
00070 for (unsigned t = 0; t < fTracks.size(); ++t) {
00071
00072 std::map<int, double>::iterator cur = trackvert.find(t);
00073 if(cur != trackvert.end()) {
00074 neweta = jet->physicsEta((*cur).second,jetEta);
00075 } else {
00076 neweta = jetEta;
00077
00078 }
00079
00080
00081
00082 double dR2 = deltaR2 (neweta, jetPhi, trackP3s[t].eta(), trackP3s[t].phi());
00083 if (dR2 < mDeltaR2Threshold) assoTracks.push_back (fTracks[t]);
00084 }
00085
00086 reco::JetTracksAssociation::setValue (fAssociation, fJets[j], assoTracks);
00087 }
00088
00089 }