CMS 3D CMS Logo

KalmanVertexTrackCompatibilityEstimator.cc
Go to the documentation of this file.
4 #include <algorithm>
5 using namespace reco;
6 
7 template <unsigned int N>
9  const CachingVertex<N> &vertex, const RefCountedVertexTrack tr, unsigned int hint) const {
10  //checking if the track passed really belongs to the vertex
11 
12  const std::vector<RefCountedVertexTrack> &tracks = vertex.tracksRef();
13 
14  if (tracks.empty())
15  return estimateNFittedTrack(vertex, tr);
16 
17  if (hint < tracks.size()) {
19  if (d(tracks[hint]))
20  return estimateFittedTrack(vertex, tracks[hint]);
21  }
22 
23  typename std::vector<RefCountedVertexTrack>::const_iterator pos =
24  find_if(tracks.begin(), tracks.end(), VertexTrackEqual<N>(tr));
25  if (pos != tracks.end()) {
26  return estimateFittedTrack(vertex, *pos);
27  } else {
28  return estimateNFittedTrack(vertex, tr);
29  }
30 }
31 
32 template <unsigned int N>
34  const CachingVertex<N> &vertex, const RefCountedLinearizedTrackState track, unsigned int hint) const {
35  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(track, vertex.vertexState());
36  return estimate(vertex, vertexTrack, hint);
37 }
38 
39 template <unsigned int N>
41  const reco::Vertex &vertex, 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  LinearizedTrackStateFactory lTrackFactory;
46  RefCountedLinearizedTrackState linTrack = lTrackFactory.linearizedTrackState(linP, track);
47  GlobalError err(vertex.covariance());
48  VertexState vState(linP, err);
49  RefCountedVertexTrack vertexTrack = vTrackFactory.vertexTrack(linTrack, vState);
50 
51  std::vector<RefCountedVertexTrack> initialTracks(1, vertexTrack);
52  CachingVertex<N> cachingVertex(linP, err, initialTracks, vertex.chi2());
53  // FIXME: this should work also for tracks without a persistent ref.
54  // return estimateNFittedTrack(cachingVertex, vertexTrack);
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 
65 template <unsigned int N>
68  const RefCountedVertexTrack track) const {
69  //remove track from the vertex using the vertex updator
70  // Using the update instead of the remove methode, we can specify a weight which
71  // is different than then one which the vertex track has been defined with.
72  //CachingVertex rVert = updator.remove(v, track);
73  RefCountedVertexTrack newSmoothedTrack = trackUpdator.update(v, track);
74  // std::cout << newSmoothedTrack->smoothedChi2()<<" "<<estimateDifference(v,rVert,newSmoothedTrack)<<std::endl;
75  // return estimateDifference(v,rVert,newSmoothedTrack);
76  return BDpair(true, newSmoothedTrack->smoothedChi2());
77 }
78 
79 // method calculating track<-->vertex compatibility
80 //with the track not belonging to vertex
81 template <unsigned int N>
84  const RefCountedVertexTrack track) const {
85  // Using the update instead of the add methode, we can specify a weight which
86  // is different than then one which the vertex track has been defined with.
87  CachingVertex<N> rVert = updator.add(v, track);
88  if (!rVert.isValid())
89  return BDpair(false, -1.);
90  return BDpair(true, rVert.totalChiSquared() - v.totalChiSquared());
91 }
92 
93 template <unsigned int N>
96  const CachingVertex<N> &less,
97  const RefCountedVertexTrack track) const {
98  BDpair trackRes = helper.trackParameterChi2(track);
99  return BDpair(trackRes.first, trackRes.second + helper.vertexChi2(less, more));
100 }
101 
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
KalmanVertexTrackCompatibilityEstimator.h
LinearizedTrackStateFactory.h
CachingVertex
Definition: CachingVertex.h:22
KalmanVertexTrackCompatibilityEstimator::estimateNFittedTrack
BDpair estimateNFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
Definition: KalmanVertexTrackCompatibilityEstimator.cc:83
pos
Definition: PixelAliasList.h:18
ReferenceCountingPointer
Definition: ReferenceCounted.h:60
KalmanVertexTrackCompatibilityEstimator::estimateFittedTrack
BDpair estimateFittedTrack(const CachingVertex< N > &v, const RefCountedVertexTrack track) const
Definition: KalmanVertexTrackCompatibilityEstimator.cc:67
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
findQualityFiles.v
v
Definition: findQualityFiles.py:179
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
LinearizedTrackStateFactory::linearizedTrackState
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
Definition: LinearizedTrackStateFactory.cc:9
LinearizedTrackStateFactory
Definition: LinearizedTrackStateFactory.h:14
KalmanVertexTrackCompatibilityEstimator
Definition: KalmanVertexTrackCompatibilityEstimator.h:24
Point3DBase< float, GlobalTag >
CachingVertex::totalChiSquared
float totalChiSquared() const
Definition: CachingVertex.h:159
HLT_FULL_cff.updator
updator
Definition: HLT_FULL_cff.py:123
bphysicsOniaDQM_cfi.vertex
vertex
Definition: bphysicsOniaDQM_cfi.py:7
helper
Definition: helper.py:1
KalmanVertexTrackCompatibilityEstimator::estimateDifference
BDpair estimateDifference(const CachingVertex< N > &more, const CachingVertex< N > &less, const RefCountedVertexTrack track) const
Definition: KalmanVertexTrackCompatibilityEstimator.cc:95
TrackTransientTrack.h
KalmanVertexTrackCompatibilityEstimator::estimate
BDpair estimate(const CachingVertex< N > &vrt, const RefCountedVertexTrack track, unsigned int hint=UINT_MAX) const override
Definition: KalmanVertexTrackCompatibilityEstimator.cc:8
GlobalErrorBase< double, ErrorMatrixTag >
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
reco::TransientTrack
Definition: TransientTrack.h:19
VertexState
Definition: VertexState.h:13
CachingVertex::isValid
bool isValid() const
Definition: CachingVertex.h:154
ztail.d
d
Definition: ztail.py:151
VertexTrackEqual
Definition: VertexTrack.h:114
KalmanVertexTrackCompatibilityEstimator::BDpair
std::pair< bool, double > BDpair
Definition: KalmanVertexTrackCompatibilityEstimator.h:29
Basic3DVector< float >
reco::Vertex
Definition: Vertex.h:35