CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoVertex/VertexTools/src/NbSharedTracks.cc

Go to the documentation of this file.
00001 #include "DataFormats/VertexReco/interface/Vertex.h"
00002 #include "DataFormats/TrackReco/interface/Track.h"
00003 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00004 
00005 // this class' header
00006 #include "RecoVertex/VertexTools/interface/NbSharedTracks.h"
00007 
00008 
00009 int reco::NbSharedTracks::sharedTracks(const reco::Vertex &v1,
00010                                        const reco::Vertex &v2) const {
00011 
00012   int nSharedTracks = 0;
00013 
00014   // for first vertex
00015   Vertex::trackRef_iterator v1TrackIter;
00016   Vertex::trackRef_iterator v1TrackBegin = v1.tracks_begin();
00017   Vertex::trackRef_iterator v1TrackEnd   = v1.tracks_end();
00018   
00019 
00020   // for second vertex
00021   Vertex::trackRef_iterator v2TrackIter;
00022   Vertex::trackRef_iterator v2TrackBegin = v2.tracks_begin();
00023   Vertex::trackRef_iterator v2TrackEnd   = v2.tracks_end();
00024   
00025   for (v1TrackIter = v1TrackBegin; v1TrackIter != v1TrackEnd; v1TrackIter++) {
00026     for (v2TrackIter = v2TrackBegin; v2TrackIter != v2TrackEnd; v2TrackIter++) {
00027       if ( (*v1TrackIter) == (*v2TrackIter) ) {
00028         nSharedTracks++;
00029       } // if 
00030     } // for v2TrackIter
00031   } //for v1TrackIter
00032 
00033 
00034   return nSharedTracks;
00035 } // int sharedTracks