File indexing completed on 2024-04-06 12:29:07
0001 #include "RecoVertex/GaussianSumVertexFit/interface/GsfVertexTrackCompatibilityEstimator.h"
0002 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
0003 #include <algorithm>
0004 using namespace reco;
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 std::pair<bool, double> GsfVertexTrackCompatibilityEstimator::estimate(const CachingVertex<5>& vertex,
0021 const RefCountedVertexTrack tr,
0022 unsigned int hint) const {
0023
0024 std::vector<RefCountedVertexTrack> tracks = vertex.tracks();
0025 std::vector<RefCountedVertexTrack>::iterator pos = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<5>(tr));
0026 if (pos != tracks.end()) {
0027 return estimateFittedTrack(vertex, *pos);
0028 } else {
0029 return estimateNFittedTrack(vertex, tr);
0030 }
0031 }
0032
0033 std::pair<bool, double> GsfVertexTrackCompatibilityEstimator::estimate(const CachingVertex<5>& vertex,
0034 const RefCountedLinearizedTrackState track,
0035 unsigned int hint) const {
0036 RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track, vertex.vertexState());
0037 return estimate(vertex, vertexTrack);
0038 }
0039
0040 std::pair<bool, double> GsfVertexTrackCompatibilityEstimator::estimate(const reco::Vertex& vertex,
0041 const reco::TransientTrack& track) const {
0042
0043 GlobalPoint linP(Basic3DVector<float>(vertex.position()));
0044
0045 RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, track);
0046 GlobalError err(vertex.covariance());
0047 VertexState vState(linP, err);
0048 RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
0049
0050 std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
0051 CachingVertex<5> cachingVertex(linP, err, initialTracks, vertex.chi2());
0052
0053
0054
0055 if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end()) {
0056 return estimateFittedTrack(cachingVertex, vertexTrack);
0057 } else {
0058 return estimateNFittedTrack(cachingVertex, vertexTrack);
0059 }
0060 }
0061
0062
0063
0064
0065 std::pair<bool, double> GsfVertexTrackCompatibilityEstimator::estimateFittedTrack(
0066 const CachingVertex<5>& v, const RefCountedVertexTrack track) const {
0067
0068
0069
0070 if (track->refittedStateAvailable())
0071 return BDpair(true, track->smoothedChi2());
0072 throw VertexException("GsfVertexTrackCompatibilityEstimator::vertex has to be smoothed.");
0073
0074
0075
0076
0077 }
0078
0079
0080
0081 std::pair<bool, double> GsfVertexTrackCompatibilityEstimator::estimateNFittedTrack(
0082 const CachingVertex<5>& v, const RefCountedVertexTrack track) const {
0083
0084
0085 CachingVertex<5> rVert = updator.add(v, track);
0086 if (!rVert.isValid())
0087 return BDpair(false, -1.);
0088 return BDpair(true, rVert.totalChiSquared() - v.totalChiSquared());
0089 }