CMS 3D CMS Logo

KalmanVertexTrackCompatibilityEstimator.cc

Go to the documentation of this file.
00001 #include "RecoVertex/KalmanVertexFit/interface/KalmanVertexTrackCompatibilityEstimator.h"
00002 #include "RecoVertex/VertexPrimitives/interface/ConvertError.h"
00003 #include "TrackingTools/TransientTrack/interface/TrackTransientTrack.h"
00004 #include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
00005 #include <algorithm>
00006 using namespace reco;
00007 
00008 
00009 template <unsigned int N>
00010 float KalmanVertexTrackCompatibilityEstimator<N>::estimate(const CachingVertex<N> & vertex,
00011                          const RefCountedVertexTrack tr) const
00012 {
00013 //checking if the track passed really belongs to the vertex
00014   vector<RefCountedVertexTrack> tracks = vertex.tracks();
00015   typename vector<RefCountedVertexTrack>::iterator pos 
00016     = find_if(tracks.begin(), tracks.end(), VertexTrackEqual<N>(tr));
00017  if(pos != tracks.end()) {
00018    return estimateFittedTrack(vertex,*pos);
00019  } else {
00020    return estimateNFittedTrack(vertex,tr);
00021  }
00022 } 
00023 
00024 
00025 template <unsigned int N>
00026 float KalmanVertexTrackCompatibilityEstimator<N>::estimate(const CachingVertex<N> & vertex, 
00027                          const RefCountedLinearizedTrackState track) const
00028 {
00029   RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track,
00030                                                  vertex.vertexState());
00031   return estimate(vertex, vertexTrack);
00032 }
00033 
00034 
00035 template <unsigned int N>
00036 float KalmanVertexTrackCompatibilityEstimator<N>::estimate(const reco::Vertex & vertex, 
00037                          const reco::TransientTrack & track) const
00038 {       
00039 //   GlobalPoint linP(vertex.position().x(), vertex.position().z(),vertex.position().z());
00040     GlobalPoint linP(Basic3DVector<float> (vertex.position()));
00041 
00042   LinearizedTrackStateFactory lTrackFactory;
00043   RefCountedLinearizedTrackState linTrack = 
00044                         lTrackFactory.linearizedTrackState(linP, track);
00045   GlobalError err(RecoVertex::convertError(vertex.covariance()));
00046   VertexState vState(linP, err);
00047   RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
00048 
00049   vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
00050   CachingVertex<N> cachingVertex(linP, err, initialTracks,
00051                             vertex.chi2());
00052   // FIXME: this should work also for tracks without a persistent ref.
00053 //   return estimateNFittedTrack(cachingVertex, vertexTrack);
00054   if (find(vertex.tracks_begin(), vertex.tracks_end(), track.trackBaseRef()) != vertex.tracks_end())
00055   {
00056     return estimateFittedTrack(cachingVertex, vertexTrack);
00057   } else {
00058     return estimateNFittedTrack(cachingVertex, vertexTrack);
00059   }
00060 }
00061 
00062 
00063 
00064 // methods to calculate track<-->vertex compatibility
00065 // with the track belonging to the vertex
00066 
00067 template <unsigned int N>
00068 float KalmanVertexTrackCompatibilityEstimator<N>::estimateFittedTrack
00069                 (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
00070 {
00071   //remove track from the vertex using the vertex updator
00072   // Using the update instead of the remove methode, we can specify a weight which
00073   // is different than then one which the vertex track has been defined with.
00074   //CachingVertex rVert = updator.remove(v, track);
00075   RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
00076 //   cout << newSmoothedTrack->smoothedChi2()<<" "<<estimateDifference(v,rVert,newSmoothedTrack)<<endl;
00077 //   return estimateDifference(v,rVert,newSmoothedTrack);
00078   return newSmoothedTrack->smoothedChi2();
00079 }
00080 
00081 // method calculating track<-->vertex compatibility
00082 //with the track not belonging to vertex
00083 template <unsigned int N>
00084 float KalmanVertexTrackCompatibilityEstimator<N>::estimateNFittedTrack
00085         (const CachingVertex<N> & v, const RefCountedVertexTrack track) const
00086 {
00087   // Using the update instead of the add methode, we can specify a weight which
00088   // is different than then one which the vertex track has been defined with.
00089   CachingVertex<N> rVert = updator.add(v, track);
00090   return (rVert.totalChiSquared()-v.totalChiSquared());
00091 }   
00092 
00093 
00094 
00095 template <unsigned int N>
00096 float KalmanVertexTrackCompatibilityEstimator<N>::estimateDifference
00097         (const CachingVertex<N> & more, const CachingVertex<N> & less, 
00098          const RefCountedVertexTrack track) const
00099 {
00100   return helper.vertexChi2(less, more) + helper.trackParameterChi2(track);
00101 }
00102 
00103 template class KalmanVertexTrackCompatibilityEstimator<5>;

Generated on Tue Jun 9 17:46:06 2009 for CMSSW by  doxygen 1.5.4