CMS 3D CMS Logo

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 
21  const RefCountedVertexTrack tr,
22  unsigned int hint) const {
23  //checking if the track passed really belongs to the vertex
24  std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
25  std::vector<RefCountedVertexTrack>::iterator pos = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<5>(tr));
26  if (pos != tracks.end()) {
27  return estimateFittedTrack(vertex, *pos);
28  } else {
29  return estimateNFittedTrack(vertex, tr);
30  }
31 }
32 
35  unsigned int hint) const {
36  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track, vertex.vertexState());
37  return estimate(vertex, vertexTrack);
38 }
39 
41  const reco::TransientTrack& track) const {
42  // GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
43  GlobalPoint linP(Basic3DVector<float>(vertex.position()));
44 
45  RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, track);
46  GlobalError err(vertex.covariance());
47  VertexState vState(linP, err);
48  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
49 
50  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
51  CachingVertex<5> cachingVertex(linP, err, initialTracks, vertex.chi2());
52  // FIXME: this should work also for tracks without a persistent ref.
53  // const TrackTransientTrack* ttt = dynamic_cast<const TrackTransientTrack*>(track.basicTransientTrack());
54  // if ((ttt!=0) &&
55  if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end()) {
56  return estimateFittedTrack(cachingVertex, vertexTrack);
57  } else {
58  return estimateNFittedTrack(cachingVertex, vertexTrack);
59  }
60 }
61 
62 // methods to calculate track<-->vertex compatibility
63 // with the track belonging to the vertex
64 
66  const CachingVertex<5>& v, const RefCountedVertexTrack track) const {
67  //remove track from the vertex using the vertex updator
68  // Using the update instead of the remove methode, we can specify a weight which
69  // is different than then one which the vertex track has been defined with.
70  if (track->refittedStateAvailable())
71  return BDpair(true, track->smoothedChi2());
72  throw VertexException("GsfVertexTrackCompatibilityEstimator::vertex has to be smoothed.");
73 
74  // CachingVertex rVert = updator.remove(v, track);
75  // RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
76  // return estimateDifference(v,rVert,newSmoothedTrack);
77 }
78 
79 // method calculating track<-->vertex compatibility
80 //with the track not belonging to vertex
82  const CachingVertex<5>& v, const RefCountedVertexTrack track) const {
83  // Using the update instead of the add methode, we can specify a weight which
84  // is different than then one which the vertex track has been defined with.
85  CachingVertex<5> rVert = updator.add(v, track);
86  if (!rVert.isValid())
87  return BDpair(false, -1.);
88  return BDpair(true, rVert.totalChiSquared() - v.totalChiSquared());
89 }
CachingVertex< 5 >::RefCountedVertexTrack RefCountedVertexTrack
Common base class.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
float totalChiSquared() const
BDpair estimateFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const
BDpair estimate(const CachingVertex< 5 > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
bool isValid() const
fixed size matrix
BDpair estimateNFittedTrack(const CachingVertex< 5 > &v, const RefCountedVertexTrack track) const