LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
trkf::Geometric3DVertexFitter Class Reference

3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tracks. More...

#include "Geometric3DVertexFitter.h"

Classes

struct  Config
 
struct  ParsCovsOnPlane
 
struct  TracksFromVertexSorter
 

Public Member Functions

 Geometric3DVertexFitter (const fhicl::Table< Config > &o, const fhicl::Table< TrackStatePropagator::Config > &p)
 
VertexWrapper fitPFP (size_t iPF, const art::ValidHandle< std::vector< recob::PFParticle > > &inputPFParticle, const std::unique_ptr< art::FindManyP< recob::Track > > &assocTracks) const
 
VertexWrapper fitTracks (const std::vector< art::Ptr< recob::Track > > &arttracks) const
 
VertexWrapper fitTracks (TrackRefVec &tracks) const
 
VertexWrapper fitTracksWithVtx (const std::vector< art::Ptr< recob::Track > > &tracks, const recob::tracking::Point_t &vtxPos) const
 
VertexWrapper fitTracksWithVtx (TrackRefVec &tracks, const recob::tracking::Point_t &vtxPos) const
 
VertexWrapper closestPointAlongTrack (const recob::Track &track, const recob::Track &other) const
 
VertexWrapper fitTwoTracks (const recob::Track &tk1, const recob::Track &tk2) const
 
void addTrackToVertex (VertexWrapper &vtx, const recob::Track &tk) const
 
std::vector< recob::VertexAssnMetacomputeMeta (const VertexWrapper &vtx)
 
std::vector< recob::VertexAssnMetacomputeMeta (const VertexWrapper &vtx, const std::vector< art::Ptr< recob::Track > > &arttracks)
 
std::vector< recob::VertexAssnMetacomputeMeta (const VertexWrapper &vtx, const TrackRefVec &trks)
 
double chi2 (const VertexWrapper &vtx, const recob::Track &tk) const
 
double ip (const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipErr (const VertexWrapper &vtx, const recob::Track &tk) const
 
double sip (const VertexWrapper &vtx, const recob::Track &tk) const
 
double pDist (const VertexWrapper &vtx, const recob::Track &tk) const
 
VertexWrapper unbiasedVertex (const VertexWrapper &vtx, const recob::Track &tk) const
 
double chi2Unbiased (const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipUnbiased (const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipErrUnbiased (const VertexWrapper &vtx, const recob::Track &tk) const
 
double sipUnbiased (const VertexWrapper &vtx, const recob::Track &tk) const
 
double pDistUnbiased (const VertexWrapper &vtx, const recob::Track &tk) const
 

Private Member Functions

double chi2 (const ParsCovsOnPlane &pcp) const
 
double ip (const ParsCovsOnPlane &pcp) const
 
double ipErr (const ParsCovsOnPlane &pcp) const
 
double sip (const ParsCovsOnPlane &pcp) const
 
ParsCovsOnPlane getParsCovsOnPlane (const trkf::VertexWrapper &vtx, const recob::Track &tk) const
 
std::pair< TrackState, double > weightedAverageState (ParsCovsOnPlane &pcop) const
 
std::pair< TrackState, double > weightedAverageState (SVector2 &par1, SVector2 &par2, SMatrixSym22 &cov1, SMatrixSym22 &cov2, recob::tracking::Plane &target) const
 

Private Attributes

std::unique_ptr< TrackStatePropagatorprop
 
int debugLevel
 
double sipCut
 

Detailed Description

3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tracks.

This algorithm fits vertices with following procedure. First, tracks are sorted based on their start positions and the number of hits. A vertex is created from the first two tracks: it is defined as the weighted average of the points of closest approaches of the two tracks. Then the other tracks are added, to the vertex: the updated vertex is defined as the weighted average of the n-1 track vertex position and the point of closest approach of the n-th track. Methods to obtain the (unbiased) propagation distance, impact parameter, impact parameter error, impact parameter significance, and chi2 of a track with respect to the vertex are provided.

Inputs are: a set of tracks; interface is provided allowing these to be passed directly of through a PFParticle hierarchy.

Outputs are: a VertexWrapper, containing the vertex and the reference to the tracks actually used in the fit; also methods to produce recob::VertexAssnMeta are provided.

For configuration options see Geometric3DVertexFitter::Config

Author
G. Cerati (FNAL, MicroBooNE)
Date
2017
Version
1.0

Definition at line 48 of file Geometric3DVertexFitter.h.

Constructor & Destructor Documentation

trkf::Geometric3DVertexFitter::Geometric3DVertexFitter ( const fhicl::Table< Config > &  o,
const fhicl::Table< TrackStatePropagator::Config > &  p 
)
inline

Member Function Documentation

void trkf::Geometric3DVertexFitter::addTrackToVertex ( trkf::VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 379 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::addTrackAndUpdateVertex(), recob::Track::CountValidPoints(), trkf::VertexWrapper::covariance(), debugLevel, getParsCovsOnPlane(), util::kBogusD, recob::Track::Length(), trkf::VertexWrapper::position(), recob::Track::Start(), recob::Track::StartDirection(), recob::Track::VertexCovarianceGlobal6D(), and weightedAverageState().

Referenced by fitTracks(), fitTracksWithVtx(), and Geometric3DVertexFitter().

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 }
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:38
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:39
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
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
SMatrixSym66 VertexCovarianceGlobal6D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:189
unsigned int CountValidPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:119
Vector_t StartDirection() const
Access to track direction at different points.
Definition: Track.h:138
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:174
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:130
recob::tracking::SMatrixSym33 SMatrixSym33
constexpr double kBogusD
obviously bogus double value
double trkf::Geometric3DVertexFitter::chi2 ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 418 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

Referenced by chi2Unbiased(), computeMeta(), Geometric3DVertexFitter(), and weightedAverageState().

419 {
420  return chi2(getParsCovsOnPlane(vtx, tk));
421 }
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double chi2(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::chi2 ( const ParsCovsOnPlane pcp) const
private

Definition at line 407 of file Geometric3DVertexFitter.cxx.

References trkf::Geometric3DVertexFitter::ParsCovsOnPlane::cov1, trkf::Geometric3DVertexFitter::ParsCovsOnPlane::cov2, trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par1, and trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par2.

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 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
double trkf::Geometric3DVertexFitter::chi2Unbiased ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 473 of file Geometric3DVertexFitter.cxx.

References chi2(), trkf::VertexWrapper::findTrack(), fitTracks(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by Geometric3DVertexFitter().

473  {
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 }
double chi2(const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
trkf::VertexWrapper trkf::Geometric3DVertexFitter::closestPointAlongTrack ( const recob::Track track,
const recob::Track other 
) const

Definition at line 181 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::addTrackAndUpdateVertex(), recob::Track::CountValidPoints(), debugLevel, recob::Track::Length(), recob::Track::ParticleId(), prop, recob::Track::Start(), recob::TrackTrajectory::Start(), recob::TrackTrajectory::StartDirection(), target, recob::Track::Trajectory(), trkf::TrackStatePropagator::UNKNOWN, recob::Track::VertexCovarianceGlobal6D(), recob::Track::VertexCovarianceLocal5D(), and recob::Track::VertexParametersLocal5D().

Referenced by computeMeta(), and Geometric3DVertexFitter().

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 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
int ParticleId() const
Access to various track properties.
Definition: Track.h:178
cout<< "-> Edep in the target
Definition: analysis.C:54
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:105
SMatrixSym66 VertexCovarianceGlobal6D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:189
unsigned int CountValidPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:119
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:174
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:130
std::unique_ptr< TrackStatePropagator > prop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
SVector5 VertexParametersLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:179
recob::tracking::SMatrixSym33 SMatrixSym33
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].
const SMatrixSym55 & VertexCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.h:213
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( const VertexWrapper vtx)

Definition at line 523 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::tracks().

Referenced by computeMeta(), Geometric3DVertexFitter(), and trkf::VertexFitter::produce().

524 {
525  return computeMeta(vtx, vtx.tracks());
526 }
std::vector< recob::VertexAssnMeta > computeMeta(const VertexWrapper &vtx)
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( const VertexWrapper vtx,
const std::vector< art::Ptr< recob::Track > > &  arttracks 
)

Definition at line 528 of file Geometric3DVertexFitter.cxx.

References computeMeta().

529 {
530  TrackRefVec tracks;
531  for (auto t : arttracks) tracks.push_back(*t);
532  return computeMeta(vtx, tracks);
533 }
std::vector< recob::VertexAssnMeta > computeMeta(const VertexWrapper &vtx)
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( const VertexWrapper vtx,
const TrackRefVec trks 
)

Definition at line 535 of file Geometric3DVertexFitter.cxx.

References chi2(), closestPointAlongTrack(), d, debugLevel, e, trkf::VertexWrapper::findTrack(), getParsCovsOnPlane(), recob::VertexAssnMeta::IncludedInFit, ip(), ipErr(), util::kBogusF, recob::VertexAssnMeta::NotUsedInFit, pDist(), trkf::VertexWrapper::tracksSize(), trkf::VertexWrapper::tracksWithoutElement(), and unbiasedVertex().

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 }
VertexWrapper closestPointAlongTrack(const recob::Track &track, const recob::Track &other) const
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double chi2(const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper unbiasedVertex(const VertexWrapper &vtx, const recob::Track &tk) const
size_t tracksSize() const
Definition: VertexWrapper.h:57
Class storing the meta-data for track-vertex association: status, propagation distance, impact parameter, impact parameter error, chi2.
Float_t d
Definition: plot.C:237
constexpr float kBogusF
obviously bogus float value
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
double ipErr(const VertexWrapper &vtx, const recob::Track &tk) const
Float_t e
Definition: plot.C:34
double ip(const VertexWrapper &vtx, const recob::Track &tk) const
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitPFP ( size_t  iPF,
const art::ValidHandle< std::vector< recob::PFParticle > > &  inputPFParticle,
const std::unique_ptr< art::FindManyP< recob::Track > > &  assocTracks 
) const

Definition at line 3 of file Geometric3DVertexFitter.cxx.

References recob::PFParticle::Daughters(), debugLevel, fitTracks(), recob::PFParticle::IsPrimary(), recob::PFParticle::NumDaughters(), and recob::PFParticle::PdgCode().

Referenced by Geometric3DVertexFitter().

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 }
STL namespace.
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracks ( const std::vector< art::Ptr< recob::Track > > &  arttracks) const

Definition at line 30 of file Geometric3DVertexFitter.cxx.

Referenced by chi2Unbiased(), fitPFP(), Geometric3DVertexFitter(), ipErrUnbiased(), ipUnbiased(), pDistUnbiased(), trkf::VertexFitter::produce(), sipUnbiased(), and unbiasedVertex().

31 {
32  TrackRefVec tracks;
33  for (auto t : arttracks) {
34  tracks.push_back(*t);
35  }
36  //
37  return fitTracks(tracks);
38 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracks ( TrackRefVec tracks) const

Definition at line 40 of file Geometric3DVertexFitter.cxx.

References addTrackToVertex(), d, debugLevel, fitTwoTracks(), trkf::VertexWrapper::isValid(), sip(), sipCut, std::swap(), and trkf::VertexWrapper::tracksSize().

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 }
void addTrackToVertex(VertexWrapper &vtx, const recob::Track &tk) const
Float_t d
Definition: plot.C:237
VertexWrapper fitTwoTracks(const recob::Track &tk1, const recob::Track &tk2) const
void swap(art::HLTGlobalStatus &lhs, art::HLTGlobalStatus &rhs)
double sip(const VertexWrapper &vtx, const recob::Track &tk) const
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracksWithVtx ( const std::vector< art::Ptr< recob::Track > > &  tracks,
const recob::tracking::Point_t vtxPos 
) const

Definition at line 88 of file Geometric3DVertexFitter.cxx.

Referenced by Geometric3DVertexFitter().

90 {
91  TrackRefVec tracks;
92  for (auto t : arttracks) {
93  tracks.push_back(*t);
94  }
95  //
96  return fitTracksWithVtx(tracks,vtxPos);
97 }
VertexWrapper fitTracksWithVtx(const std::vector< art::Ptr< recob::Track > > &tracks, const recob::tracking::Point_t &vtxPos) const
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracksWithVtx ( TrackRefVec tracks,
const recob::tracking::Point_t vtxPos 
) const

Definition at line 99 of file Geometric3DVertexFitter.cxx.

References addTrackToVertex(), debugLevel, fitTwoTracks(), sip(), and sipCut.

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 }
void addTrackToVertex(VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper fitTwoTracks(const recob::Track &tk1, const recob::Track &tk2) const
double sip(const VertexWrapper &vtx, const recob::Track &tk) const
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTwoTracks ( const recob::Track tk1,
const recob::Track tk2 
) const

Definition at line 232 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::addTrack(), trkf::VertexWrapper::addTrackAndUpdateVertex(), recob::Track::CountValidPoints(), trkf::VertexWrapper::covariance(), debugLevel, recob::tracking::Plane::direction(), util::kBogusD, recob::Track::Length(), recob::Track::ParticleId(), trkf::VertexWrapper::position(), recob::tracking::Plane::position(), prop, recob::Track::Start(), recob::TrackTrajectory::Start(), recob::TrackTrajectory::StartDirection(), target, recob::Track::Trajectory(), trkf::TrackStatePropagator::UNKNOWN, recob::Track::VertexCovarianceGlobal6D(), recob::Track::VertexCovarianceLocal5D(), recob::Track::VertexParametersLocal5D(), and weightedAverageState().

Referenced by fitTracks(), fitTracksWithVtx(), and Geometric3DVertexFitter().

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 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
int ParticleId() const
Access to various track properties.
Definition: Track.h:178
cout<< "-> Edep in the target
Definition: analysis.C:54
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:105
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
SMatrixSym66 VertexCovarianceGlobal6D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:189
unsigned int CountValidPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:119
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:174
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:130
std::unique_ptr< TrackStatePropagator > prop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
SVector5 VertexParametersLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:179
recob::tracking::SMatrixSym33 SMatrixSym33
constexpr double kBogusD
obviously bogus double value
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].
const SMatrixSym55 & VertexCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.h:213
trkf::Geometric3DVertexFitter::ParsCovsOnPlane trkf::Geometric3DVertexFitter::getParsCovsOnPlane ( const trkf::VertexWrapper vtx,
const recob::Track tk 
) const
private

Definition at line 331 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::covariance(), debugLevel, dir, recob::tracking::Plane::direction(), recob::tracking::Plane::Global6DToLocal5DCovariance(), recob::tracking::Plane::Global6DToLocal5DParameters(), recob::Track::ParticleId(), trkf::VertexWrapper::position(), recob::tracking::Plane::position(), prop, recob::TrackTrajectory::Start(), recob::TrackTrajectory::StartDirection(), target, recob::Track::Trajectory(), trkf::TrackStatePropagator::UNKNOWN, recob::Track::VertexCovarianceLocal5D(), and recob::Track::VertexParametersLocal5D().

Referenced by addTrackToVertex(), chi2(), computeMeta(), ip(), ipErr(), and sip().

331  {
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 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:38
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:39
int ParticleId() const
Access to various track properties.
Definition: Track.h:178
cout<< "-> Edep in the target
Definition: analysis.C:54
recob::tracking::Vector_t Vector_t
Definition: TrackState.h:19
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:105
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
std::unique_ptr< TrackStatePropagator > prop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
TDirectory * dir
Definition: macro.C:5
SVector5 VertexParametersLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:179
recob::tracking::SMatrixSym66 SMatrixSym66
Definition: TrackState.h:16
recob::tracking::SVector6 SVector6
Definition: TrackState.h:13
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].
const SMatrixSym55 & VertexCovarianceLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.h:213
double trkf::Geometric3DVertexFitter::ip ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 429 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

Referenced by computeMeta(), Geometric3DVertexFitter(), ipUnbiased(), and sip().

430 {
431  return ip(getParsCovsOnPlane(vtx, tk));
432 }
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double ip(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::ip ( const ParsCovsOnPlane pcp) const
private

Definition at line 423 of file Geometric3DVertexFitter.cxx.

References trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par1, and trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par2.

424 {
425  const SVector2 deltapar = pcp.par2 - pcp.par1;
426  return std::sqrt( deltapar[0]*deltapar[0] + deltapar[1]*deltapar[1] );
427 }
recob::tracking::SVector2 SVector2
double trkf::Geometric3DVertexFitter::ipErr ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 442 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

Referenced by computeMeta(), Geometric3DVertexFitter(), ipErrUnbiased(), and sip().

443 {
444  return ipErr(getParsCovsOnPlane(vtx, tk));
445 }
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double ipErr(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::ipErr ( const ParsCovsOnPlane pcp) const
private

Definition at line 434 of file Geometric3DVertexFitter.cxx.

References trkf::Geometric3DVertexFitter::ParsCovsOnPlane::cov1, trkf::Geometric3DVertexFitter::ParsCovsOnPlane::cov2, trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par1, and trkf::Geometric3DVertexFitter::ParsCovsOnPlane::par2.

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 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
double trkf::Geometric3DVertexFitter::ipErrUnbiased ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 493 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::findTrack(), fitTracks(), ipErr(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by Geometric3DVertexFitter().

493  {
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 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
double ipErr(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::ipUnbiased ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 483 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::findTrack(), fitTracks(), ip(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by Geometric3DVertexFitter().

483  {
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 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
double ip(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::pDist ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 457 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::position(), recob::TrackTrajectory::Start(), recob::TrackTrajectory::StartDirection(), and recob::Track::Trajectory().

Referenced by computeMeta(), Geometric3DVertexFitter(), and pDistUnbiased().

458 {
459  return tk.Trajectory().StartDirection().Dot(vtx.position()-tk.Trajectory().Start());
460 }
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:105
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].
double trkf::Geometric3DVertexFitter::pDistUnbiased ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 513 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::findTrack(), fitTracks(), pDist(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by Geometric3DVertexFitter().

513  {
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 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::sip ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 452 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

Referenced by fitTracks(), fitTracksWithVtx(), Geometric3DVertexFitter(), and sipUnbiased().

453 {
454  return sip(getParsCovsOnPlane(vtx, tk));
455 }
ParsCovsOnPlane getParsCovsOnPlane(const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double sip(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::sip ( const ParsCovsOnPlane pcp) const
private

Definition at line 447 of file Geometric3DVertexFitter.cxx.

References ip(), and ipErr().

448 {
449  return ip(pcp)/ipErr(pcp);
450 }
double ipErr(const VertexWrapper &vtx, const recob::Track &tk) const
double ip(const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::sipUnbiased ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 503 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::findTrack(), fitTracks(), sip(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by Geometric3DVertexFitter().

503  {
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 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
double sip(const VertexWrapper &vtx, const recob::Track &tk) const
trkf::VertexWrapper trkf::Geometric3DVertexFitter::unbiasedVertex ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 462 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::findTrack(), fitTracks(), trkf::VertexWrapper::tracksSize(), and trkf::VertexWrapper::tracksWithoutElement().

Referenced by computeMeta(), and Geometric3DVertexFitter().

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 }
VertexWrapper fitTracks(const std::vector< art::Ptr< recob::Track > > &arttracks) const
std::pair<TrackState, double> trkf::Geometric3DVertexFitter::weightedAverageState ( ParsCovsOnPlane pcop) const
inlineprivate
std::pair< trkf::TrackState, double > trkf::Geometric3DVertexFitter::weightedAverageState ( SVector2 par1,
SVector2 par2,
SMatrixSym22 cov1,
SMatrixSym22 cov2,
recob::tracking::Plane target 
) const
private

Definition at line 121 of file Geometric3DVertexFitter.cxx.

References chi2(), debugLevel, and util::kBogusD.

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 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
double chi2(const VertexWrapper &vtx, const recob::Track &tk) const
recob::tracking::SVector5 SVector5
Definition: TrackState.h:12
recob::tracking::SMatrixSym55 SMatrixSym55
constexpr double kBogusD
obviously bogus double value

Member Data Documentation

int trkf::Geometric3DVertexFitter::debugLevel
private
std::unique_ptr<TrackStatePropagator> trkf::Geometric3DVertexFitter::prop
private
double trkf::Geometric3DVertexFitter::sipCut
private

Definition at line 119 of file Geometric3DVertexFitter.h.

Referenced by fitTracks(), and fitTracksWithVtx().


The documentation for this class was generated from the following files: