CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
GsfVertexTrackCompatibilityEstimator.cc
Go to the documentation of this file.
3 #include <algorithm>
4 using namespace reco;
5 
6 // template <unsigned int N>
7 // struct vT_find
8 // {
9 // typedef typename CachingVertex<N>::RefCountedVertexTrack RefCountedVertexTrack;
10 // bool operator()(const CachingVertex<5> & v, const RefCountedVertexTrack t)
11 // {
12 // //initial tracks
13 // vector<RefCountedVertexTrack> tracks = v.tracks();
14 // vector<RefCountedVertexTrack>::iterator pos
15 // = find_if(tracks.begin(), tracks.end(), VertexTrackEqual(t));
16 // return (pos != tracks.end());
17 // }
18 // };
19 
20 
21 std::pair<bool, double>
23  const RefCountedVertexTrack tr) const
24 {
25 //checking if the track passed really belongs to the vertex
26  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
27  std::vector<RefCountedVertexTrack>::iterator pos
28  = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<5>(tr));
29  if (pos != tracks.end()) {
30  return estimateFittedTrack(vertex,*pos);
31  } else {
32  return estimateNFittedTrack(vertex,tr);
33  }
34 }
35 
36 
37 std::pair<bool, double>
40 {
41  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
42  vertex.vertexState());
43  return estimate(vertex, vertexTrack);
44 }
45 
46 
47 std::pair<bool, double>
49  const reco::TransientTrack & track) const
50 {
51 // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
52  GlobalPoint linP(Basic3DVector<float> (vertex.position()));
53 
55  lTrackFactory.linearizedTrackState(linP, track);
56  GlobalError err(vertex.covariance());
57  VertexState vState(linP, err);
58  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
59 
60  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
61  CachingVertex<5> cachingVertex(linP, err, initialTracks,
62  vertex.chi2());
63  // FIXME: this should work also for tracks without a persistent ref.
64 // const TrackTransientTrack* ttt = dynamic_cast<const TrackTransientTrack*>(track.basicTransientTrack());
65 // if ((ttt!=0) &&
66  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
67  {
68  return estimateFittedTrack(cachingVertex, vertexTrack);
69  } else {
70  return estimateNFittedTrack(cachingVertex, vertexTrack);
71  }
72 }
73 
74 
75 
76 // methods to calculate track<-->vertex compatibility
77 // with the track belonging to the vertex
78 
79 std::pair<bool, double>
82 {
83  //remove track from the vertex using the vertex updator
84  // Using the update instead of the remove methode, we can specify a weight which
85  // is different than then one which the vertex track has been defined with.
86  if (track->refittedStateAvailable()) return BDpair(true, track->smoothedChi2());
87  throw VertexException
88  ("GsfVertexTrackCompatibilityEstimator::vertex has to be smoothed.");
89 
90 // CachingVertex rVert = updator.remove(v, track);
91 // RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
92 // return estimateDifference(v,rVert,newSmoothedTrack);
93 }
94 
95 // method calculating track<-->vertex compatibility
96 //with the track not belonging to vertex
97 std::pair<bool, double>
99  (const CachingVertex<5> & v, const RefCountedVertexTrack track) const
100 {
101  // Using the update instead of the add methode, we can specify a weight which
102  // is different than then one which the vertex track has been defined with.
103  CachingVertex<5> rVert = updator.add(v, track);
104  if (!rVert.isValid()) return BDpair(false,-1.);
105  return BDpair(true, rVert.totalChiSquared()-v.totalChiSquared());
106 }
107 
std::vector< RefCountedVertexTrack > tracks() const
Definition: CachingVertex.h:92
VertexState vertexState() const
Definition: CachingVertex.h:86
CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:45
TrackBaseRef trackBaseRef() const
Common base class.
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
Definition: Vertex.h:110
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:93
float totalChiSquared() const
double chi2() const
chi-squares
Definition: Vertex.h:82
BDpair estimateNFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const
virtual BDpair estimate(const CachingVertex< 5 > &vrt, const RefCountedVertexTrack track) const
tuple tracks
Definition: testEve_cfg.py:39
bool isValid() const
Definition: CachingVertex.h:96
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:40
mathSSE::Vec4< T > v
BDpair estimateFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const