Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:25

0001 #include "RecoVertex/VertexTools/interface/SharedTracks.h"
0002 namespace vertexTools {
0003   using namespace reco;
0004   double computeSharedTracks(const Vertex &pv, const std::vector<TrackRef> &svTracks, double minTrackWeight, float) {
0005     std::set<TrackRef> pvTracks;
0006     for (std::vector<TrackBaseRef>::const_iterator iter = pv.tracks_begin(); iter != pv.tracks_end(); iter++)
0007       if (pv.trackWeight(*iter) >= minTrackWeight)
0008         pvTracks.insert(iter->castTo<TrackRef>());
0009 
0010     unsigned int count = 0;
0011     for (std::vector<TrackRef>::const_iterator iter = svTracks.begin(); iter != svTracks.end(); iter++)
0012       count += pvTracks.count(*iter);
0013 
0014     return (double)count / (double)svTracks.size();
0015   }
0016   double computeSharedTracks(const Vertex &pv,
0017                              const std::vector<CandidatePtr> &svTracks,
0018                              double minTrackWeight,
0019                              float maxsigma) {
0020     unsigned int count = 0;
0021     for (std::vector<CandidatePtr>::const_iterator iter = svTracks.begin(); iter != svTracks.end(); iter++) {
0022       if (std::abs((*iter)->bestTrack()->dz() - pv.z()) / (*iter)->bestTrack()->dzError() < maxsigma &&
0023           std::abs((*iter)->bestTrack()->dxy(pv.position()) / (*iter)->bestTrack()->dxyError()) < maxsigma)
0024         count++;
0025     }
0026     return (double)count / (double)svTracks.size();
0027   }
0028   double computeSharedTracks(const VertexCompositePtrCandidate &sv2,
0029                              const std::vector<CandidatePtr> &svTracks,
0030                              double,
0031                              float) {
0032     unsigned int count = 0;
0033     for (std::vector<CandidatePtr>::const_iterator iter = svTracks.begin(); iter != svTracks.end(); iter++) {
0034       if (std::find(sv2.daughterPtrVector().begin(), sv2.daughterPtrVector().end(), *iter) !=
0035           sv2.daughterPtrVector().end())
0036         count++;
0037     }
0038     return (double)count / (double)svTracks.size();
0039   }
0040 
0041   double computeSharedTracks(const reco::Vertex &pv,
0042                              const reco::VertexCompositePtrCandidate &sv,
0043                              double minTrackWeight,
0044                              float mindist) {
0045     return computeSharedTracks(pv, sv.daughterPtrVector(), minTrackWeight, mindist);
0046   }
0047   double computeSharedTracks(const reco::Vertex &pv, const reco::Vertex &sv, double minTrackWeight, float) {
0048     std::vector<TrackRef> svTracks;
0049     for (std::vector<TrackBaseRef>::const_iterator iter = sv.tracks_begin(); iter != sv.tracks_end(); iter++)
0050       if (sv.trackWeight(*iter) >= minTrackWeight)
0051         svTracks.push_back(iter->castTo<TrackRef>());
0052     return computeSharedTracks(pv, svTracks, minTrackWeight);
0053   }
0054   double computeSharedTracks(const reco::VertexCompositePtrCandidate &sv,
0055                              const reco::VertexCompositePtrCandidate &sv2,
0056                              double,
0057                              float) {
0058     return computeSharedTracks(sv, sv2.daughterPtrVector());
0059   }
0060 
0061 }  // namespace vertexTools