CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SharedTracks.cc
Go to the documentation of this file.
2 namespace vertexTools {
3  using namespace reco;
4  double computeSharedTracks(const Vertex &pv, const std::vector<TrackRef> &svTracks,
5  double minTrackWeight, float )
6  {
7  std::set<TrackRef> pvTracks;
8  for(std::vector<TrackBaseRef>::const_iterator iter = pv.tracks_begin();
9  iter != pv.tracks_end(); iter++)
10  if (pv.trackWeight(*iter) >= minTrackWeight)
11  pvTracks.insert(iter->castTo<TrackRef>());
12 
13  unsigned int count = 0;
14  for(std::vector<TrackRef>::const_iterator iter = svTracks.begin();
15  iter != svTracks.end(); iter++)
16  count += pvTracks.count(*iter);
17 
18  return (double)count/(double)svTracks.size();
19  }
20  double computeSharedTracks(const Vertex &pv, const std::vector<CandidatePtr> &svTracks,
21  double minTrackWeight, float maxsigma)
22  {
23  unsigned int count = 0;
24  for(std::vector<CandidatePtr>::const_iterator iter = svTracks.begin();
25  iter != svTracks.end(); iter++)
26  {
27  if( std::abs((*iter)->bestTrack()->dz()-pv.z())/(*iter)->bestTrack()->dzError() < maxsigma &&
28  std::abs((*iter)->bestTrack()->dxy(pv.position())/(*iter)->bestTrack()->dxyError()) < maxsigma
29  )
30  count++;
31  }
32  return (double)count/(double)svTracks.size();
33  }
34  double computeSharedTracks(const VertexCompositePtrCandidate &sv2, const std::vector<CandidatePtr> &svTracks, double , float )
35  {
36  unsigned int count = 0;
37  for(std::vector<CandidatePtr>::const_iterator iter = svTracks.begin();
38  iter != svTracks.end(); iter++)
39  {
40  if(std::find(sv2.daughterPtrVector().begin(),sv2.daughterPtrVector().end(),*iter)!= sv2.daughterPtrVector().end())
41  count++;
42  }
43  return (double)count/(double)svTracks.size();
44  }
45 
46 
47  double computeSharedTracks(const reco::Vertex &pv, const reco::VertexCompositePtrCandidate &sv, double minTrackWeight,float mindist)
48  {
49  return computeSharedTracks(pv,sv.daughterPtrVector(),minTrackWeight,mindist);
50  }
51  double computeSharedTracks(const reco::Vertex &pv, const reco::Vertex &sv, double minTrackWeight,float )
52  {
53  std::vector<TrackRef> svTracks;
54  for(std::vector<TrackBaseRef>::const_iterator iter = sv.tracks_begin();
55  iter != sv.tracks_end(); iter++)
56  if (sv.trackWeight(*iter) >= minTrackWeight)
57  svTracks.push_back(iter->castTo<TrackRef>());
58  return computeSharedTracks(pv,svTracks,minTrackWeight);
59 
60  }
62  {
63  return computeSharedTracks(sv,sv2.daughterPtrVector());
64  }
65 
66 
67 }
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:44
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
const Point & position() const
position
Definition: Vertex.h:99
double computeSharedTracks(const reco::Vertex &pv, const std::vector< reco::TrackRef > &svTracks, double minTrackWeight=0.5, float unused=0)
Definition: SharedTracks.cc:4
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double z() const
y coordinate
Definition: Vertex.h:105
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:73
const daughters & daughterPtrVector() const
references to daughtes
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:39