Go to the documentation of this file.00001 #include "RecoVertex/GaussianSumVertexFit/interface/GsfVertexTrackCompatibilityEstimator.h"
00002 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
00003 #include <algorithm>
00004 using namespace reco;
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 std::pair<bool, double>
00022 GsfVertexTrackCompatibilityEstimator::estimate(const CachingVertex<5> & vertex,
00023 const RefCountedVertexTrack tr) const
00024 {
00025
00026 std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
00027 std::vector<RefCountedVertexTrack>::iterator pos
00028 = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<5>(tr));
00029 if (pos != tracks.end()) {
00030 return estimateFittedTrack(vertex,*pos);
00031 } else {
00032 return estimateNFittedTrack(vertex,tr);
00033 }
00034 }
00035
00036
00037 std::pair<bool, double>
00038 GsfVertexTrackCompatibilityEstimator::estimate(const CachingVertex<5> & vertex,
00039 const RefCountedLinearizedTrackState track) const
00040 {
00041 RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
00042 vertex.vertexState());
00043 return estimate(vertex, vertexTrack);
00044 }
00045
00046
00047 std::pair<bool, double>
00048 GsfVertexTrackCompatibilityEstimator::estimate(const reco::Vertex & vertex,
00049 const reco::TransientTrack & track) const
00050 {
00051
00052 GlobalPoint linP(Basic3DVector<float> (vertex.position()));
00053
00054 RefCountedLinearizedTrackState linTrack =
00055 lTrackFactory.linearizedTrackState(linP, track);
00056 GlobalError err(vertex.covariance());
00057 VertexState vState(linP, err);
00058 RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
00059
00060 std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
00061 CachingVertex<5> cachingVertex(linP, err, initialTracks,
00062 vertex.chi2());
00063
00064
00065
00066 if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
00067 {
00068 return estimateFittedTrack(cachingVertex, vertexTrack);
00069 } else {
00070 return estimateNFittedTrack(cachingVertex, vertexTrack);
00071 }
00072 }
00073
00074
00075
00076
00077
00078
00079 std::pair<bool, double>
00080 GsfVertexTrackCompatibilityEstimator::estimateFittedTrack
00081 (const CachingVertex<5> & v, const RefCountedVertexTrack track) const
00082 {
00083
00084
00085
00086 if (track->refittedStateAvailable()) return BDpair(true, track->smoothedChi2());
00087 throw VertexException
00088 ("GsfVertexTrackCompatibilityEstimator::vertex has to be smoothed.");
00089
00090
00091
00092
00093 }
00094
00095
00096
00097 std::pair<bool, double>
00098 GsfVertexTrackCompatibilityEstimator::estimateNFittedTrack
00099 (const CachingVertex<5> & v, const RefCountedVertexTrack track) const
00100 {
00101
00102
00103 CachingVertex<5> rVert = updator.add(v, track);
00104 if (!rVert.isValid()) return BDpair(false,-1.);
00105 return BDpair(true, rVert.totalChiSquared()-v.totalChiSquared());
00106 }
00107