LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Geometric3DVertexFitter.cxx
Go to the documentation of this file.
2 
3 trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitPFP(size_t iPF, const art::ValidHandle<std::vector<recob::PFParticle> >& inputPFParticle,
4  const std::unique_ptr<art::FindManyP<recob::Track> >& assocTracks) const
5 {
6  using namespace std;
7  //
8  art::Ptr<recob::PFParticle> pfp(inputPFParticle, iPF);
9  //
10  if (debugLevel>1) std::cout << "pfp#" << iPF << " PdgCode=" << pfp->PdgCode()
11  << " IsPrimary=" << pfp->IsPrimary()
12  << " NumDaughters=" << pfp->NumDaughters()
13  << std::endl;
14  if (pfp->IsPrimary()==false || pfp->NumDaughters()<2) VertexWrapper();
15 
16  TrackRefVec tracks;
17 
18  auto& pfd = pfp->Daughters();
19  for (auto ipfd : pfd) {
20  vector< art::Ptr<recob::Track> > pftracks = assocTracks->at(ipfd);
21  for (auto t : pftracks) {
22  tracks.push_back(*t);
23  }
24  }
25  if (tracks.size()<2) return VertexWrapper();
26  //
27  return fitTracks(tracks);
28 }
29 
31 {
32  TrackRefVec tracks;
33  for (auto t : arttracks) {
34  tracks.push_back(*t);
35  }
36  //
37  return fitTracks(tracks);
38 }
39 
41 {
42  if (debugLevel>0) std::cout << "fitting vertex with ntracks=" << tracks.size() << std::endl;
43  if (tracks.size()<2) return VertexWrapper();
44  // sort tracks by number of hits
45  std::sort(tracks.begin(), tracks.end(), [](std::reference_wrapper<const recob::Track> a, std::reference_wrapper<const recob::Track> b) {
46  return a.get().CountValidPoints() > b.get().CountValidPoints();}
47  );
48  //find pair with closest start positions and put them upfront
49  unsigned int tk0 = tracks.size();
50  unsigned int tk1 = tracks.size();
51  float mind = FLT_MAX;
52  for (unsigned int i=0;i<tracks.size()-1;i++) {
53  for (unsigned int j=i+1;j<tracks.size();j++) {
54  float d = (tracks[i].get().Trajectory().Start()-tracks[j].get().Trajectory().Start()).Mag2();
55  if (debugLevel>1) std::cout << "test i=" << i << " start=" << tracks[i].get().Trajectory().Start() << " j=" << j << " start=" << tracks[j].get().Trajectory().Start() << " d=" << d << " mind=" << mind << " tk0=" << tk0 << " tk1=" << tk1 << std::endl;
56  if (d<mind) {
57  mind=d;
58  tk0 = i;
59  tk1 = j;
60  }
61  }
62  }
63  if (tk0>1 || tk1>1) {
64  if (tk0>1 && tk1>1) {
65  std::swap(tracks[0],tracks[tk0]);
66  std::swap(tracks[1],tracks[tk1]);
67  }
68  if (tk0==0) std::swap(tracks[1],tracks[tk1]);
69  if (tk0==1) std::swap(tracks[0],tracks[tk1]);
70  if (tk1==0) std::swap(tracks[1],tracks[tk0]);
71  if (tk1==1) std::swap(tracks[0],tracks[tk0]);
72  }
73  //
74  // find vertex between the first two tracks
75  VertexWrapper vtx = fitTwoTracks(tracks[0], tracks[1]);
76  if (vtx.isValid()==false || vtx.tracksSize()<2) return vtx;
77  //
78  // then add other tracks and update vertex measurement
79  for (auto tk = tracks.begin()+2; tk<tracks.end(); ++tk) {
80  auto sipv = sip(vtx, *tk);
81  if (debugLevel>1) std::cout << "sip=" << sipv << std::endl;
82  if (sipv>sipCut) continue;
83  addTrackToVertex(vtx, *tk);
84  }
85  return vtx;
86 }
87 
89  const recob::tracking::Point_t& vtxPos) const
90 {
91  TrackRefVec tracks;
92  for (auto t : arttracks) {
93  tracks.push_back(*t);
94  }
95  //
96  return fitTracksWithVtx(tracks,vtxPos);
97 }
98 
100  const recob::tracking::Point_t& vtxPos) const
101 {
102  if (debugLevel>0) std::cout << "fitting vertex with ntracks=" << tracks.size() << std::endl;
103  if (tracks.size()<2) return VertexWrapper();
104  // sort tracks by proximity to input vertex
105  std::sort(tracks.begin(), tracks.end(), TracksFromVertexSorter(vtxPos) );
106  //
107  // find vertex between the first two tracks
108  VertexWrapper vtx = fitTwoTracks(tracks[0], tracks[1]);
109  if (vtx.isValid()==false || vtx.tracks().size()<2) return vtx;
110  //
111  // then add other tracks and update vertex measurement
112  for (auto tk = tracks.begin()+2; tk<tracks.end(); ++tk) {
113  auto sipv = sip(vtx, *tk);
114  if (debugLevel>1) std::cout << "sip=" << sipv << std::endl;
115  if (sipv>sipCut) continue;
116  addTrackToVertex(vtx, *tk);
117  }
118  return vtx;
119 }
120 
121 std::pair<trkf::TrackState, double> trkf::Geometric3DVertexFitter::weightedAverageState(SVector2& par1, SVector2& par2,
122  SMatrixSym22& cov1, SMatrixSym22& cov2,
124 {
125  SVector2 deltapar = par2 - par1;
126  SMatrixSym22 covsum = (cov2+cov1);
127  //
128  if (debugLevel>1) {
129  std::cout << "par1=" << par1 << std::endl;
130  std::cout << "par2=" << par2 << std::endl;
131  std::cout << "deltapar=" << deltapar << std::endl;
132  //
133  std::cout << "cov1=\n" << cov1 << std::endl;
134  std::cout << "cov2=\n" << cov2 << std::endl;
135  std::cout << "covsum=\n" << covsum << std::endl;
136  }
137  //
138  if (debugLevel>1) {
139  double det1;
140  bool d1ok = cov1.Det2(det1);
141  std::cout << "cov1 det=" << det1 << " ok=" << d1ok << std::endl;
142  double det2;
143  bool d2ok = cov2.Det2(det2);
144  std::cout << "cov2 det=" << det2 << " ok=" << d2ok << std::endl;
145  double detsum;
146  bool dsok = covsum.Det2(detsum);
147  std::cout << "covsum det=" << detsum << " ok=" << dsok << std::endl;
148  }
149  //
150  bool invertok = covsum.Invert();
151  if (!invertok) {
152  SVector5 vtxpar5(0,0,0,0,0);
153  SMatrixSym55 vtxcov55;
154  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
155  return std::make_pair(vtxstate, util::kBogusD);
156  }
157  auto k = cov1*covsum;
158 
159  if (debugLevel>1) {
160  std::cout << "inverted covsum=\n" << covsum << std::endl;
161  std::cout << "k=\n" << k << std::endl;
162  }
163 
164  SVector2 vtxpar2 = par1 + k*deltapar;
165  SMatrixSym22 vtxcov22 = cov1 - ROOT::Math::SimilarityT(cov1,covsum);
166 
167  if (debugLevel>1) {
168  std::cout << "vtxpar2=" << vtxpar2 << std::endl;
169  std::cout << "vtxcov22=\n" << vtxcov22 << std::endl;
170  }
171 
172  auto chi2 = ROOT::Math::Similarity(deltapar,covsum);
173 
174  SVector5 vtxpar5(vtxpar2[0],vtxpar2[1],0,0,0);
175  SMatrixSym55 vtxcov55;vtxcov55.Place_at(vtxcov22,0,0);
176  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
177 
178  return std::make_pair(vtxstate, chi2);
179 }
180 
182 {
183  // find the closest approach point along track
184  const auto& start1 = track.Trajectory().Start();
185  const auto& start2 = other.Trajectory().Start();
186 
187  const auto dir1 = track.Trajectory().StartDirection();
188  const auto dir2 = other.Trajectory().StartDirection();
189 
190  if (debugLevel>0) {
191  std::cout << "track1 with start=" << start1 << " dir=" << dir1
192  << " length=" << track.Length() << " points=" << track.CountValidPoints()
193  << std::endl;
194  std::cout << "covariance=\n" << track.VertexCovarianceGlobal6D() << std::endl;
195  std::cout << "track2 with start=" << start2 << " dir=" << dir2
196  << " length=" << other.Length() << " points=" << other.CountValidPoints()
197  << std::endl;
198  std::cout << "covariance=\n" << other.VertexCovarianceGlobal6D() << std::endl;
199  }
200 
201  const auto dpos = start1-start2;
202  const auto dotd1d2 = dir1.Dot(dir2);
203  const auto dotdpd1 = dpos.Dot(dir1);
204  const auto dotdpd2 = dpos.Dot(dir2);
205  const auto dist2 = ( dotd1d2*dotdpd1 - dotdpd2 )/( dotd1d2*dotd1d2 - 1 );
206  const auto dist1 = ( dotd1d2*dist2 - dotdpd1 );
207 
208  if (debugLevel>0) {
209  std::cout << "track1 pca=" << start1+dist1*dir1 << " dist=" << dist1 << std::endl;
210  std::cout << "track2 pca=" << start2+dist2*dir2 << " dist=" << dist2 << std::endl;
211  }
212 
213  //by construction both point of closest approach on the two lines lie on this plane
214  recob::tracking::Plane target(start1+dist1*dir1, dir1);
215 
216  recob::tracking::Plane plane1(start1, dir1);
217  trkf::TrackState state1(track.VertexParametersLocal5D(), track.VertexCovarianceLocal5D(), plane1, true, track.ParticleId());
218  bool propok1 = true;
219  state1 = prop->propagateToPlane(propok1, state1, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
220  if (!propok1) {
221  std::cout << "failed propagation, return track1 start pos=" << track.Start() << std::endl;
222  VertexWrapper vtx;
223  vtx.addTrackAndUpdateVertex(track.Start(), track.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0,0), 0, 0, track);
224  return vtx;
225  } else {
226  VertexWrapper vtx;
227  vtx.addTrackAndUpdateVertex(state1.position(), state1.covariance6D().Sub<SMatrixSym33>(0,0), 0, 0, track);
228  return vtx;
229  }
230 }
231 
233 {
234  // find the closest approach points
235  auto start1 = tk1.Trajectory().Start();
236  auto start2 = tk2.Trajectory().Start();
237 
238  auto dir1 = tk1.Trajectory().StartDirection();
239  auto dir2 = tk2.Trajectory().StartDirection();
240 
241  if (debugLevel>0) {
242  std::cout << "track1 with start=" << start1 << " dir=" << dir1
243  << " length=" << tk1.Length() << " points=" << tk1.CountValidPoints()
244  << std::endl;
245  std::cout << "covariance=\n" << tk1.VertexCovarianceGlobal6D() << std::endl;
246  std::cout << "track2 with start=" << start2 << " dir=" << dir2
247  << " length=" << tk2.Length() << " points=" << tk2.CountValidPoints()
248  << std::endl;
249  std::cout << "covariance=\n" << tk2.VertexCovarianceGlobal6D() << std::endl;
250  }
251 
252  auto dpos = start1-start2;
253  auto dotd1d2 = dir1.Dot(dir2);
254 
255  auto dotdpd1 = dpos.Dot(dir1);
256  auto dotdpd2 = dpos.Dot(dir2);
257 
258  auto dist2 = ( dotd1d2*dotdpd1 - dotdpd2 )/( dotd1d2*dotd1d2 - 1 );
259  auto dist1 = ( dotd1d2*dist2 - dotdpd1 );
260 
261  //by construction both point of closest approach on the two lines lie on this plane
262  recob::tracking::Plane target(start1+dist1*dir1, dir1);
263 
264  recob::tracking::Plane plane1(start1, dir1);
265  trkf::TrackState state1(tk1.VertexParametersLocal5D(), tk1.VertexCovarianceLocal5D(), plane1, true, tk1.ParticleId());
266  bool propok1 = true;
267  state1 = prop->propagateToPlane(propok1, state1, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
268  if (!propok1) {
269  std::cout << "failed propagation, return track1 start pos=" << tk1.Start() << std::endl;
270  VertexWrapper vtx;
271  vtx.addTrackAndUpdateVertex(tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0,0), 0, 0, tk1);
272  return vtx;
273  }
274 
275  recob::tracking::Plane plane2(start2, dir2);
276  trkf::TrackState state2(tk2.VertexParametersLocal5D(), tk2.VertexCovarianceLocal5D(), plane2, true, tk2.ParticleId());
277  bool propok2 = true;
278  state2 = prop->propagateToPlane(propok2, state2, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
279  if (!propok2) {
280  std::cout << "failed propagation, return track1 start pos=" << tk1.Start() << std::endl;
281  VertexWrapper vtx;
282  vtx.addTrackAndUpdateVertex(tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0,0), 0, 0, tk1);
283  return vtx;
284  }
285 
286  if (debugLevel>0) {
287  std::cout << "track1 pca=" << start1+dist1*dir1 << " dist=" << dist1 << std::endl;
288  std::cout << "track2 pca=" << start2+dist2*dir2 << " dist=" << dist2 << std::endl;
289  }
290 
291  //here we neglect that to find dist1 and dist2 one track depends on the other...
292  SMatrixSym22 cov1 = state1.covariance().Sub<SMatrixSym22>(0,0);
293  SMatrixSym22 cov2 = state2.covariance().Sub<SMatrixSym22>(0,0);
294 
295  if (debugLevel>1) {
296  std::cout << "target pos=" << target.position() << " dir=" << target.direction() << std::endl;
297  //test if orthogonal
298  auto dcp = state1.position()-state2.position();
299  std::cout << "dot dcp-dir1=" << dcp.Dot(tk1.Trajectory().StartDirection()) << std::endl;
300  std::cout << "dot dcp-dir2=" << dcp.Dot(tk2.Trajectory().StartDirection()) << std::endl;
301  //
302  std::cout << "cov1=" << cov1 << std::endl;
303  std::cout << "cov2=" << cov2 << std::endl;
304  }
305 
306  SVector2 par1(state1.parameters()[0],state1.parameters()[1]);
307  SVector2 par2(state2.parameters()[0],state2.parameters()[1]);
308 
309  std::pair<TrackState, double> was = weightedAverageState(par1, par2, cov1, cov2, target);
310  if (was.second <= (util::kBogusD-1)) {
311  std::cout << "failed inversion, return track1 start pos=" << tk1.Start() << std::endl;
312  VertexWrapper vtx;
313  vtx.addTrackAndUpdateVertex(tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0,0), 0, 0, tk1);
314  return vtx;
315  }
316 
317  const int ndof = 1; //1=2*2-3; each measurement is 2D because it is defined on a plane
318  trkf::VertexWrapper vtx(was.first.position(), was.first.covariance6D().Sub<SMatrixSym33>(0,0), was.second, ndof);
319  vtx.addTrack(tk1);
320  vtx.addTrack(tk2);
321 
322  if (debugLevel>0) {
323  std::cout << "vtxpos=" << vtx.position() << std::endl;
324  std::cout << "vtxcov=\n" << vtx.covariance() << std::endl;
325  std::cout << "chi2=" << was.second << std::endl;
326  }
327 
328  return vtx;
329 }
330 
332  auto start = tk.Trajectory().Start();
333  auto dir = tk.Trajectory().StartDirection();
334 
335  auto vtxpos = vtx.position();
336  auto vtxcov = vtx.covariance();
337 
338  auto dist = dir.Dot(vtxpos-start);
339 
340  //by construction vtxpos also lies on this plane
341  recob::tracking::Plane target(start+dist*dir, dir);
342 
343  recob::tracking::Plane plane(start, dir);
344  trkf::TrackState state(tk.VertexParametersLocal5D(), tk.VertexCovarianceLocal5D(), plane, true, tk.ParticleId());
345  bool propok = true;
346  state = prop->propagateToPlane(propok, state, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
347 
348  if (debugLevel>0) {
349  std::cout << "input vtx=" << vtxpos << std::endl;
350  std::cout << "input cov=\n" << vtxcov << std::endl;
351  std::cout << "track pca=" << start+dist*dir << " dist=" << dist << std::endl;
352  std::cout << "target pos=" << target.position() << " dir=" << target.direction() << std::endl;
353  }
354 
355  //rotate the vertex position and covariance to the target plane
356  SVector6 vtxpar6(vtxpos.X(),vtxpos.Y(),vtxpos.Z(),0,0,0);
357  SMatrixSym66 vtxcov66;vtxcov66.Place_at(vtxcov,0,0);
358 
359  auto vtxpar5 = target.Global6DToLocal5DParameters(vtxpar6);
360  SVector2 par1(vtxpar5[0],vtxpar5[1]);
361  SVector2 par2(state.parameters()[0],state.parameters()[1]);
362 
363  //here we neglect that to find dist, the vertex is used...
364  SMatrixSym22 cov1 = target.Global6DToLocal5DCovariance(vtxcov66,false,Vector_t()).Sub<SMatrixSym22>(0,0);
365  SMatrixSym22 cov2 = state.covariance().Sub<SMatrixSym22>(0,0);
366 
367  if (debugLevel>1) {
368  std::cout << "vtxpar5=" << vtxpar5 << std::endl;
369  std::cout << "state.parameters()=" << state.parameters() << std::endl;
370  std::cout << "vtx covariance=\n" << vtxcov66 << std::endl;
371  std::cout << "trk covariance=\n" << state.covariance6D() << std::endl;
372  std::cout << "cov1=\n" << cov1 << std::endl;
373  std::cout << "cov2=\n" << cov2 << std::endl;
374  }
375 
376  return ParsCovsOnPlane(par1,par2,cov1,cov2,target);
377 }
378 
380 {
381 
382  if (debugLevel>0) {
383  std::cout << "adding track with start=" << tk.Start() << " dir=" << tk.StartDirection()
384  << " length=" << tk.Length() << " points=" << tk.CountValidPoints()
385  << std::endl;
386  std::cout << "covariance=\n" << tk.VertexCovarianceGlobal6D() << std::endl;
387  }
388 
389  ParsCovsOnPlane pcp = getParsCovsOnPlane(vtx, tk);
390  std::pair<TrackState, double> was = weightedAverageState(pcp);
391  if (was.second <= (util::kBogusD-1.)) {
392  return;
393  }
394 
395  const int ndof = 2;// Each measurement is 2D because it is defined on a plane
396  vtx.addTrackAndUpdateVertex(was.first.position(), was.first.covariance6D().Sub<SMatrixSym33>(0,0), was.second, ndof, tk);
397 
398  if (debugLevel>0) {
399  std::cout << "updvtxpos=" << vtx.position() << std::endl;
400  std::cout << "updvtxcov=\n" << vtx.covariance() << std::endl;
401  std::cout << "add chi2=" << was.second << std::endl;
402  }
403 
404  return;
405 }
406 
408 {
409  const SVector2 deltapar = pcp.par2 - pcp.par1;
410  SMatrixSym22 covsum = (pcp.cov2+pcp.cov1);
411  //
412  bool invertok = covsum.Invert();
413  if (!invertok) return -1.;
414  //
415  return ROOT::Math::Similarity(deltapar,covsum);
416 }
417 
419 {
420  return chi2(getParsCovsOnPlane(vtx, tk));
421 }
422 
424 {
425  const SVector2 deltapar = pcp.par2 - pcp.par1;
426  return std::sqrt( deltapar[0]*deltapar[0] + deltapar[1]*deltapar[1] );
427 }
428 
430 {
431  return ip(getParsCovsOnPlane(vtx, tk));
432 }
433 
435 {
436  SVector2 deltapar = pcp.par2 - pcp.par1;
437  deltapar/=std::sqrt( deltapar[0]*deltapar[0] + deltapar[1]*deltapar[1] );
438  SMatrixSym22 covsum = (pcp.cov2+pcp.cov1);
439  return std::sqrt(ROOT::Math::Similarity(deltapar,covsum));
440 }
441 
443 {
444  return ipErr(getParsCovsOnPlane(vtx, tk));
445 }
446 
448 {
449  return ip(pcp)/ipErr(pcp);
450 }
451 
453 {
454  return sip(getParsCovsOnPlane(vtx, tk));
455 }
456 
458 {
459  return tk.Trajectory().StartDirection().Dot(vtx.position()-tk.Trajectory().Start());
460 }
461 
463 {
464  auto ittoerase = vtx.findTrack(tk);
465  if (ittoerase == vtx.tracksSize()) {
466  return vtx;
467  } else {
468  auto tks = vtx.tracksWithoutElement(ittoerase);
469  return fitTracks(tks);
470  }
471 }
472 
474  auto ittoerase = vtx.findTrack(tk);
475  if (ittoerase == vtx.tracksSize()) {
476  return chi2(vtx,tk);
477  } else {
478  auto tks = vtx.tracksWithoutElement(ittoerase);
479  return chi2(fitTracks(tks),tk);
480  }
481 }
482 
484  auto ittoerase = vtx.findTrack(tk);
485  if (ittoerase == vtx.tracksSize()) {
486  return ip(vtx,tk);
487  } else {
488  auto tks = vtx.tracksWithoutElement(ittoerase);
489  return ip(fitTracks(tks),tk);
490  }
491 }
492 
494  auto ittoerase = vtx.findTrack(tk);
495  if (ittoerase == vtx.tracksSize()) {
496  return ipErr(vtx,tk);
497  } else {
498  auto tks = vtx.tracksWithoutElement(ittoerase);
499  return ipErr(fitTracks(tks),tk);
500  }
501 }
502 
504  auto ittoerase = vtx.findTrack(tk);
505  if (ittoerase == vtx.tracksSize()) {
506  return sip(vtx,tk);
507  } else {
508  auto tks = vtx.tracksWithoutElement(ittoerase);
509  return sip(fitTracks(tks),tk);
510  }
511 }
512 
514  auto ittoerase = vtx.findTrack(tk);
515  if (ittoerase == vtx.tracksSize()) {
516  return pDist(vtx,tk);
517  } else {
518  auto tks = vtx.tracksWithoutElement(ittoerase);
519  return pDist(fitTracks(tks),tk);
520  }
521 }
522 
523 std::vector<recob::VertexAssnMeta> trkf::Geometric3DVertexFitter::computeMeta(const VertexWrapper& vtx)
524 {
525  return computeMeta(vtx, vtx.tracks());
526 }
527 
528 std::vector<recob::VertexAssnMeta> trkf::Geometric3DVertexFitter::computeMeta(const VertexWrapper& vtx, const std::vector< art::Ptr<recob::Track> >& arttracks)
529 {
530  TrackRefVec tracks;
531  for (auto t : arttracks) tracks.push_back(*t);
532  return computeMeta(vtx, tracks);
533 }
534 
535 std::vector<recob::VertexAssnMeta> trkf::Geometric3DVertexFitter::computeMeta(const VertexWrapper& vtx, const TrackRefVec& trks)
536 {
537  std::vector<recob::VertexAssnMeta> result;
538  for (auto tk : trks) {
539  float d = util::kBogusF;
540  float i = util::kBogusF;
541  float e = util::kBogusF;
542  float c = util::kBogusF;
543  auto ittoerase = vtx.findTrack(tk);
544  if (debugLevel>1) std::cout << "computeMeta for vertex with ntracks=" << vtx.tracksSize() << std::endl;
545  auto ubvtx = unbiasedVertex(vtx,tk.get());
546  if (debugLevel>1) std::cout << "got unbiased vertex with ntracks=" << ubvtx.tracksSize() << " isValid=" << ubvtx.isValid() << std::endl;
547  if (ubvtx.isValid()) {
548  d = pDist(ubvtx, tk.get());
549  auto pcop = getParsCovsOnPlane(ubvtx, tk.get());
550  i = ip(pcop);
551  e = ipErr(pcop);
552  c = chi2(pcop);
553  if (debugLevel>1) std::cout << "unbiasedVertex d=" << d << " i=" << i << " e=" << e << " c=" << c << std::endl;
554  } else if (vtx.tracksSize()==2 && ittoerase != vtx.tracksSize()) {
555  auto tks = vtx.tracksWithoutElement(ittoerase);
556  auto fakevtx = closestPointAlongTrack(tks[0],tk);
557  d = pDist(fakevtx, tk.get());
558  // these will be identical for the two tracks (modulo numerical instabilities in the matrix inversion for the chi2)
559  auto pcop = getParsCovsOnPlane(fakevtx, tk.get());
560  i = ip(pcop);
561  e = ipErr(pcop);
562  c = chi2(pcop);
563  if (debugLevel>1) std::cout << "closestPointAlongTrack d=" << d << " i=" << i << " e=" << e << " c=" << c << std::endl;
564  }
565  if (ittoerase == vtx.tracksSize()) {
567  } else {
569  }
570  }
571  return result;
572 }
double sipUnbiased(const VertexWrapper &vtx, const recob::Track &tk) const
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:38
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
Vector_t const & direction() const
Reference direction orthogonal to the plane.
Definition: TrackingPlane.h:70
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
TrackRefVec tracksWithoutElement(size_t element) const
Definition: VertexWrapper.h:59
const std::vector< size_t > & Daughters() const
Returns the collection of daughter particles.
Definition: PFParticle.h:114
VertexWrapper closestPointAlongTrack(const recob::Track &track, const recob::Track &other) const
int NumDaughters() const
Returns the number of daughter particles flowing from this one.
Definition: PFParticle.h:89
VertexWrapper fitTracksWithVtx(const std::vector< art::Ptr< recob::Track > > &tracks, const recob::tracking::Point_t &vtxPos) const
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:39
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
int ParticleId() const
Access to various track properties.
Definition: Track.h:174
cout<< "-> Edep in the target
Definition: analysis.C:54
bool isValid() const
Definition: VertexWrapper.h:37
recob::tracking::Vector_t Vector_t
Definition: TrackState.h:19
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:101
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
void addTrack(const recob::Track &tk)
Definition: VertexWrapper.h:43
void addTrackAndUpdateVertex(const recob::tracking::Point_t &pos, const recob::tracking::SMatrixSym33 &cov, double chi2, int ndof, const recob::Track &tk)
Definition: VertexWrapper.h:44
recob::tracking::SMatrixSym22 SMatrixSym22
double chi2(const VertexWrapper &vtx, const recob::Track &tk) const
SVector5 Global6DToLocal5DParameters(const SVector6 &par6d) const
Function to convert parameters from global to local coordinates. Local coordinates are on the plane w...
Definition: TrackingPlane.h:74
VertexWrapper unbiasedVertex(const VertexWrapper &vtx, const recob::Track &tk) const
STL namespace.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
void addTrackToVertex(VertexWrapper &vtx, const recob::Track &tk) const
SMatrixSym66 VertexCovarianceGlobal6D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:83
std::vector< recob::VertexAssnMeta > computeMeta(const VertexWrapper &vtx)
unsigned int CountValidPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:115
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
size_t tracksSize() const
Definition: VertexWrapper.h:57
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
Vector_t StartDirection() const
Access to track direction at different points.
Definition: Track.h:134
const TrackRefVec & tracks() const
Definition: VertexWrapper.h:58
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:170
recob::tracking::SVector5 SVector5
Definition: TrackState.h:12
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:126
Point_t const & position() const
Reference position on the plane.
Definition: TrackingPlane.h:66
double pDistUnbiased(const VertexWrapper &vtx, const recob::Track &tk) const
Class storing the meta-data for track-vertex association: status, propagation distance, impact parameter, impact parameter error, chi2.
std::unique_ptr< TrackStatePropagator > prop
Float_t d
Definition: plot.C:237
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
VertexWrapper fitTwoTracks(const recob::Track &tk1, const recob::Track &tk2) const
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
double ipUnbiased(const VertexWrapper &vtx, const recob::Track &tk) const
constexpr float kBogusF
obviously bogus float value
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
TDirectory * dir
Definition: macro.C:5
double sip(const VertexWrapper &vtx, const recob::Track &tk) const
SVector5 VertexParametersLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:73
recob::tracking::SMatrixSym66 SMatrixSym66
Definition: TrackState.h:16
recob::tracking::SMatrixSym33 SMatrixSym33
recob::tracking::SVector6 SVector6
Definition: TrackState.h:13
constexpr double kBogusD
obviously bogus double value
SMatrixSym55 Global6DToLocal5DCovariance(SMatrixSym66 cov6d, bool hasMomentum, const Vector_t &trackMomOrDir) const
Translate track covariance from global to local coordinates. The track momentum (or direction) is nee...
double ipErr(const VertexWrapper &vtx, const recob::Track &tk) const
size_t findTrack(const recob::Track &tk) const
Definition: VertexWrapper.h:50
Float_t e
Definition: plot.C:34
Vector_t StartDirection() const
Returns the direction of the trajectory at the first point.
Point_t const & Start() const
Returns the position of the first valid point of the trajectory [cm].
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
Float_t track
Definition: plot.C:34
double chi2Unbiased(const VertexWrapper &vtx, const recob::Track &tk) const
const SMatrixSym55 & VertexCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.h:209
VertexWrapper fitPFP(size_t iPF, const art::ValidHandle< std::vector< recob::PFParticle > > &inputPFParticle, const std::unique_ptr< art::FindManyP< recob::Track > > &assocTracks) const
double ipErrUnbiased(const VertexWrapper &vtx, const recob::Track &tk) const
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:52
double ip(const VertexWrapper &vtx, const recob::Track &tk) const
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26