All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
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 (detinfo::DetectorPropertiesData const &detProp, size_t iPF, const art::ValidHandle< std::vector< recob::PFParticle >> &inputPFParticle, const std::unique_ptr< art::FindManyP< recob::Track >> &assocTracks) const
 
VertexWrapper fitTracks (detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
 
VertexWrapper fitTracks (detinfo::DetectorPropertiesData const &detProp, TrackRefVec &tracks) const
 
VertexWrapper fitTracksWithVtx (detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &tracks, const recob::tracking::Point_t &vtxPos) const
 
VertexWrapper fitTracksWithVtx (detinfo::DetectorPropertiesData const &detProp, TrackRefVec &tracks, const recob::tracking::Point_t &vtxPos) const
 
VertexWrapper closestPointAlongTrack (detinfo::DetectorPropertiesData const &detProp, const recob::Track &track, const recob::Track &other) const
 
VertexWrapper fitTwoTracks (detinfo::DetectorPropertiesData const &detProp, const recob::Track &tk1, const recob::Track &tk2) const
 
void addTrackToVertex (detinfo::DetectorPropertiesData const &detProp, VertexWrapper &vtx, const recob::Track &tk) const
 
std::vector
< recob::VertexAssnMeta
computeMeta (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
 
std::vector
< recob::VertexAssnMeta
computeMeta (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const std::vector< art::Ptr< recob::Track >> &arttracks)
 
std::vector
< recob::VertexAssnMeta
computeMeta (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const TrackRefVec &trks)
 
double chi2 (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double ip (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipErr (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double sip (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double pDist (const VertexWrapper &vtx, const recob::Track &tk) const
 
VertexWrapper unbiasedVertex (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double chi2Unbiased (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipUnbiased (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double ipErrUnbiased (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double sipUnbiased (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
 
double pDistUnbiased (detinfo::DetectorPropertiesData const &detProp, 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 (detinfo::DetectorPropertiesData const &detProp, 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
< TrackStatePropagator
prop
 
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 60 of file Geometric3DVertexFitter.h.

Constructor & Destructor Documentation

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

Definition at line 102 of file Geometric3DVertexFitter.h.

104  : debugLevel(o().debugLevel()), sipCut(o().sipCut())
105  {
106  prop = std::make_unique<TrackStatePropagator>(p);
107  }
pdgs p
Definition: selectors.fcl:22
std::unique_ptr< TrackStatePropagator > prop

Member Function Documentation

void trkf::Geometric3DVertexFitter::addTrackToVertex ( detinfo::DetectorPropertiesData const &  detProp,
trkf::VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 429 of file Geometric3DVertexFitter.cxx.

432 {
433 
434  if (debugLevel > 0) {
435  std::cout << "adding track with start=" << tk.Start() << " dir=" << tk.StartDirection()
436  << " length=" << tk.Length() << " points=" << tk.CountValidPoints() << std::endl;
437  std::cout << "covariance=\n" << tk.VertexCovarianceGlobal6D() << std::endl;
438  }
439 
440  ParsCovsOnPlane pcp = getParsCovsOnPlane(detProp, vtx, tk);
441  std::pair<TrackState, double> was = weightedAverageState(pcp);
442  if (was.second <= (util::kBogusD - 1.)) { return; }
443 
444  const int ndof = 2; // Each measurement is 2D because it is defined on a plane
446  was.first.position(), was.first.covariance6D().Sub<SMatrixSym33>(0, 0), was.second, ndof, tk);
447 
448  if (debugLevel > 0) {
449  std::cout << "updvtxpos=" << vtx.position() << std::endl;
450  std::cout << "updvtxcov=\n" << vtx.covariance() << std::endl;
451  std::cout << "add chi2=" << was.second << std::endl;
452  }
453 }
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
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
unsigned int CountValidPoints() const
Vector_t StartDirection() const
Access to track direction at different points.
double Length(size_t p=0) const
Access to various track properties.
Point_t const & Start() const
Access to track position at different points.
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
recob::tracking::SMatrixSym33 SMatrixSym33
constexpr double kBogusD
obviously bogus double value
BEGIN_PROLOG could also be cout
auto const detProp
double trkf::Geometric3DVertexFitter::chi2 ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 468 of file Geometric3DVertexFitter.cxx.

471 {
472  return chi2(getParsCovsOnPlane(detProp, vtx, tk));
473 }
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
double chi2(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
double trkf::Geometric3DVertexFitter::chi2 ( const ParsCovsOnPlane pcp) const
private

Definition at line 456 of file Geometric3DVertexFitter.cxx.

457 {
458  const SVector2 deltapar = pcp.par2 - pcp.par1;
459  SMatrixSym22 covsum = (pcp.cov2 + pcp.cov1);
460 
461  bool invertok = covsum.Invert();
462  if (!invertok) return -1.;
463 
464  return ROOT::Math::Similarity(deltapar, covsum);
465 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
double trkf::Geometric3DVertexFitter::chi2Unbiased ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 542 of file Geometric3DVertexFitter.cxx.

545 {
546  auto ittoerase = vtx.findTrack(tk);
547  if (ittoerase == vtx.tracksSize()) { return chi2(detProp, vtx, tk); }
548  else {
549  auto tks = vtx.tracksWithoutElement(ittoerase);
550  return chi2(detProp, fitTracks(detProp, tks), tk);
551  }
552 }
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
double chi2(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
trkf::VertexWrapper trkf::Geometric3DVertexFitter::closestPointAlongTrack ( detinfo::DetectorPropertiesData const &  detProp,
const recob::Track track,
const recob::Track other 
) const

Definition at line 204 of file Geometric3DVertexFitter.cxx.

208 {
209  // find the closest approach point along track
210  const auto& start1 = track.Trajectory().Start();
211  const auto& start2 = other.Trajectory().Start();
212 
213  const auto dir1 = track.Trajectory().StartDirection();
214  const auto dir2 = other.Trajectory().StartDirection();
215 
216  if (debugLevel > 0) {
217  std::cout << "track1 with start=" << start1 << " dir=" << dir1 << " length=" << track.Length()
218  << " points=" << track.CountValidPoints() << std::endl;
219  std::cout << "covariance=\n" << track.VertexCovarianceGlobal6D() << std::endl;
220  std::cout << "track2 with start=" << start2 << " dir=" << dir2 << " length=" << other.Length()
221  << " points=" << other.CountValidPoints() << std::endl;
222  std::cout << "covariance=\n" << other.VertexCovarianceGlobal6D() << std::endl;
223  }
224 
225  const auto dpos = start1 - start2;
226  const auto dotd1d2 = dir1.Dot(dir2);
227  const auto dotdpd1 = dpos.Dot(dir1);
228  const auto dotdpd2 = dpos.Dot(dir2);
229  const auto dist2 = (dotd1d2 * dotdpd1 - dotdpd2) / (dotd1d2 * dotd1d2 - 1);
230  const auto dist1 = (dotd1d2 * dist2 - dotdpd1);
231 
232  if (debugLevel > 0) {
233  std::cout << "track1 pca=" << start1 + dist1 * dir1 << " dist=" << dist1 << std::endl;
234  std::cout << "track2 pca=" << start2 + dist2 * dir2 << " dist=" << dist2 << std::endl;
235  }
236 
237  //by construction both point of closest approach on the two lines lie on this plane
238  recob::tracking::Plane target(start1 + dist1 * dir1, dir1);
239 
240  recob::tracking::Plane plane1(start1, dir1);
242  track.VertexCovarianceLocal5D(),
243  plane1,
244  true,
245  track.ParticleId());
246  bool propok1 = true;
247  state1 = prop->propagateToPlane(
248  propok1, detProp, state1, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
249  if (!propok1) {
250  std::cout << "failed propagation, return track1 start pos=" << track.Start() << std::endl;
251  VertexWrapper vtx;
252  vtx.addTrackAndUpdateVertex(
253  track.Start(), track.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0, 0), 0, 0, track);
254  return vtx;
255  }
256  else {
257  VertexWrapper vtx;
258  vtx.addTrackAndUpdateVertex(
259  state1.position(), state1.covariance6D().Sub<SMatrixSym33>(0, 0), 0, 0, track);
260  return vtx;
261  }
262 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
SMatrixSym66 VertexCovarianceGlobal6D() const
unsigned int CountValidPoints() const
double Length(size_t p=0) const
Access to various track properties.
Point_t const & Start() const
Access to track position at different points.
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.
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
BEGIN_PROLOG could also be cout
auto const detProp
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx 
)

Definition at line 607 of file Geometric3DVertexFitter.cxx.

609 {
610  return computeMeta(detProp, vtx, vtx.tracks());
611 }
std::vector< recob::VertexAssnMeta > computeMeta(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
auto const detProp
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const std::vector< art::Ptr< recob::Track >> &  arttracks 
)

Definition at line 614 of file Geometric3DVertexFitter.cxx.

617 {
619  for (auto t : arttracks)
620  tracks.push_back(*t);
621  return computeMeta(detProp, vtx, tracks);
622 }
ClusterModuleLabel join with tracks
std::vector< recob::VertexAssnMeta > computeMeta(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
auto const detProp
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
std::vector< recob::VertexAssnMeta > trkf::Geometric3DVertexFitter::computeMeta ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const TrackRefVec trks 
)

Definition at line 625 of file Geometric3DVertexFitter.cxx.

628 {
629  std::vector<recob::VertexAssnMeta> result;
630  for (auto tk : trks) {
631  float d = util::kBogusF;
632  float i = util::kBogusF;
633  float e = util::kBogusF;
634  float c = util::kBogusF;
635  auto ittoerase = vtx.findTrack(tk);
636  if (debugLevel > 1)
637  std::cout << "computeMeta for vertex with ntracks=" << vtx.tracksSize() << std::endl;
638  auto ubvtx = unbiasedVertex(detProp, vtx, tk.get());
639  if (debugLevel > 1)
640  std::cout << "got unbiased vertex with ntracks=" << ubvtx.tracksSize()
641  << " isValid=" << ubvtx.isValid() << std::endl;
642  if (ubvtx.isValid()) {
643  d = pDist(ubvtx, tk.get());
644  auto pcop = getParsCovsOnPlane(detProp, ubvtx, tk.get());
645  i = ip(pcop);
646  e = ipErr(pcop);
647  c = chi2(pcop);
648  if (debugLevel > 1)
649  std::cout << "unbiasedVertex d=" << d << " i=" << i << " e=" << e << " c=" << c
650  << std::endl;
651  }
652  else if (vtx.tracksSize() == 2 && ittoerase != vtx.tracksSize()) {
653  auto tks = vtx.tracksWithoutElement(ittoerase);
654  auto fakevtx = closestPointAlongTrack(detProp, tks[0], tk);
655  d = pDist(fakevtx, tk.get());
656  // these will be identical for the two tracks (modulo numerical instabilities in the matrix inversion for the chi2)
657  auto pcop = getParsCovsOnPlane(detProp, fakevtx, tk.get());
658  i = ip(pcop);
659  e = ipErr(pcop);
660  c = chi2(pcop);
661  if (debugLevel > 1)
662  std::cout << "closestPointAlongTrack d=" << d << " i=" << i << " e=" << e << " c=" << c
663  << std::endl;
664  }
665  if (ittoerase == vtx.tracksSize()) {
666  result.push_back(recob::VertexAssnMeta(d, i, e, c, recob::VertexAssnMeta::NotUsedInFit));
667  }
668  else {
669  result.push_back(recob::VertexAssnMeta(d, i, e, c, recob::VertexAssnMeta::IncludedInFit));
670  }
671  }
672  return result;
673 }
VertexWrapper closestPointAlongTrack(detinfo::DetectorPropertiesData const &detProp, const recob::Track &track, const recob::Track &other) const
double ip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
double ipErr(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper unbiasedVertex(detinfo::DetectorPropertiesData const &detProp, 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.
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
constexpr float kBogusF
obviously bogus float value
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
double chi2(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
do i e
BEGIN_PROLOG could also be cout
auto const detProp
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitPFP ( detinfo::DetectorPropertiesData const &  detProp,
size_t  iPF,
const art::ValidHandle< std::vector< recob::PFParticle >> &  inputPFParticle,
const std::unique_ptr< art::FindManyP< recob::Track >> &  assocTracks 
) const

Definition at line 4 of file Geometric3DVertexFitter.cxx.

9 {
10  using namespace std;
11  art::Ptr<recob::PFParticle> pfp(inputPFParticle, iPF);
12  if (debugLevel > 1)
13  std::cout << "pfp#" << iPF << " PdgCode=" << pfp->PdgCode() << " IsPrimary=" << pfp->IsPrimary()
14  << " NumDaughters=" << pfp->NumDaughters() << std::endl;
15  if (pfp->IsPrimary() == false || pfp->NumDaughters() < 2) return VertexWrapper();
16 
18 
19  auto& pfd = pfp->Daughters();
20  for (auto ipfd : pfd) {
21  vector<art::Ptr<recob::Track>> pftracks = assocTracks->at(ipfd);
22  for (auto t : pftracks) {
23  tracks.push_back(*t);
24  }
25  }
26 
27  if (size(tracks) < 2) { return VertexWrapper{}; }
28 
29  return fitTracks(detProp, tracks);
30 }
double std(const std::vector< short > &wf, const double ped_mean, size_t start, size_t nsample)
Definition: UtilFunc.cxx:42
ClusterModuleLabel join with tracks
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
BEGIN_PROLOG could also be cout
auto const detProp
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracks ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< recob::Track >> &  arttracks 
) const

Definition at line 33 of file Geometric3DVertexFitter.cxx.

35 {
37  for (auto t : arttracks) {
38  tracks.push_back(*t);
39  }
40  return fitTracks(detProp, tracks);
41 }
ClusterModuleLabel join with tracks
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
auto const detProp
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracks ( detinfo::DetectorPropertiesData const &  detProp,
TrackRefVec tracks 
) const

Definition at line 44 of file Geometric3DVertexFitter.cxx.

46 {
47  if (debugLevel > 0) std::cout << "fitting vertex with ntracks=" << tracks.size() << std::endl;
48  if (tracks.size() < 2) return VertexWrapper();
49 
50  // sort tracks by number of hits
51  std::sort(
52  tracks.begin(),
53  tracks.end(),
54  [](std::reference_wrapper<const recob::Track> a, std::reference_wrapper<const recob::Track> b) {
55  return a.get().CountValidPoints() > b.get().CountValidPoints();
56  });
57 
58  //find pair with closest start positions and put them upfront
59  unsigned int tk0 = tracks.size();
60  unsigned int tk1 = tracks.size();
61  float mind = FLT_MAX;
62  for (unsigned int i = 0; i < tracks.size() - 1; i++) {
63  for (unsigned int j = i + 1; j < tracks.size(); j++) {
64  float d =
65  (tracks[i].get().Trajectory().Start() - tracks[j].get().Trajectory().Start()).Mag2();
66  if (debugLevel > 1)
67  std::cout << "test i=" << i << " start=" << tracks[i].get().Trajectory().Start()
68  << " j=" << j << " start=" << tracks[j].get().Trajectory().Start() << " d=" << d
69  << " mind=" << mind << " tk0=" << tk0 << " tk1=" << tk1 << std::endl;
70  if (d < mind) {
71  mind = d;
72  tk0 = i;
73  tk1 = j;
74  }
75  }
76  }
77  if (tk0 > 1 || tk1 > 1) {
78  if (tk0 > 1 && tk1 > 1) {
79  std::swap(tracks[0], tracks[tk0]);
80  std::swap(tracks[1], tracks[tk1]);
81  }
82  if (tk0 == 0) std::swap(tracks[1], tracks[tk1]);
83  if (tk0 == 1) std::swap(tracks[0], tracks[tk1]);
84  if (tk1 == 0) std::swap(tracks[1], tracks[tk0]);
85  if (tk1 == 1) std::swap(tracks[0], tracks[tk0]);
86  }
87 
88  // find vertex between the first two tracks
89  VertexWrapper vtx = fitTwoTracks(detProp, tracks[0], tracks[1]);
90  if (vtx.isValid() == false || vtx.tracksSize() < 2) return vtx;
91 
92  // then add other tracks and update vertex measurement
93  for (auto tk = tracks.begin() + 2; tk < tracks.end(); ++tk) {
94  auto sipv = sip(detProp, vtx, *tk);
95  if (debugLevel > 1) std::cout << "sip=" << sipv << std::endl;
96  if (sipv > sipCut) continue;
97  addTrackToVertex(detProp, vtx, *tk);
98  }
99  return vtx;
100 }
void addTrackToVertex(detinfo::DetectorPropertiesData const &detProp, VertexWrapper &vtx, const recob::Track &tk) const
double sip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
ClusterModuleLabel join with tracks
process_name gaushit a
VertexWrapper fitTwoTracks(detinfo::DetectorPropertiesData const &detProp, const recob::Track &tk1, const recob::Track &tk2) const
BEGIN_PROLOG could also be cout
auto const detProp
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracksWithVtx ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< recob::Track >> &  tracks,
const recob::tracking::Point_t vtxPos 
) const

Definition at line 103 of file Geometric3DVertexFitter.cxx.

107 {
109  for (auto t : arttracks) {
110  tracks.push_back(*t);
111  }
112  return fitTracksWithVtx(detProp, tracks, vtxPos);
113 }
ClusterModuleLabel join with tracks
VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &tracks, const recob::tracking::Point_t &vtxPos) const
auto const detProp
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTracksWithVtx ( detinfo::DetectorPropertiesData const &  detProp,
TrackRefVec tracks,
const recob::tracking::Point_t vtxPos 
) const

Definition at line 116 of file Geometric3DVertexFitter.cxx.

119 {
120  if (debugLevel > 0) std::cout << "fitting vertex with ntracks=" << tracks.size() << std::endl;
121  if (tracks.size() < 2) return VertexWrapper();
122  // sort tracks by proximity to input vertex
123  std::sort(tracks.begin(), tracks.end(), TracksFromVertexSorter(vtxPos));
124 
125  // find vertex between the first two tracks
126  VertexWrapper vtx = fitTwoTracks(detProp, tracks[0], tracks[1]);
127  if (vtx.isValid() == false || vtx.tracks().size() < 2) return vtx;
128 
129  // then add other tracks and update vertex measurement
130  for (auto tk = tracks.begin() + 2; tk < tracks.end(); ++tk) {
131  auto sipv = sip(detProp, vtx, *tk);
132  if (debugLevel > 1) std::cout << "sip=" << sipv << std::endl;
133  if (sipv > sipCut) continue;
134  addTrackToVertex(detProp, vtx, *tk);
135  }
136  return vtx;
137 }
void addTrackToVertex(detinfo::DetectorPropertiesData const &detProp, VertexWrapper &vtx, const recob::Track &tk) const
double sip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
ClusterModuleLabel join with tracks
VertexWrapper fitTwoTracks(detinfo::DetectorPropertiesData const &detProp, const recob::Track &tk1, const recob::Track &tk2) const
BEGIN_PROLOG could also be cout
auto const detProp
trkf::VertexWrapper trkf::Geometric3DVertexFitter::fitTwoTracks ( detinfo::DetectorPropertiesData const &  detProp,
const recob::Track tk1,
const recob::Track tk2 
) const

Definition at line 265 of file Geometric3DVertexFitter.cxx.

268 {
269  // find the closest approach points
270  auto start1 = tk1.Trajectory().Start();
271  auto start2 = tk2.Trajectory().Start();
272 
273  auto dir1 = tk1.Trajectory().StartDirection();
274  auto dir2 = tk2.Trajectory().StartDirection();
275 
276  if (debugLevel > 0) {
277  std::cout << "track1 with start=" << start1 << " dir=" << dir1 << " length=" << tk1.Length()
278  << " points=" << tk1.CountValidPoints() << std::endl;
279  std::cout << "covariance=\n" << tk1.VertexCovarianceGlobal6D() << std::endl;
280  std::cout << "track2 with start=" << start2 << " dir=" << dir2 << " length=" << tk2.Length()
281  << " points=" << tk2.CountValidPoints() << std::endl;
282  std::cout << "covariance=\n" << tk2.VertexCovarianceGlobal6D() << std::endl;
283  }
284 
285  auto dpos = start1 - start2;
286  auto dotd1d2 = dir1.Dot(dir2);
287 
288  auto dotdpd1 = dpos.Dot(dir1);
289  auto dotdpd2 = dpos.Dot(dir2);
290 
291  auto dist2 = (dotd1d2 * dotdpd1 - dotdpd2) / (dotd1d2 * dotd1d2 - 1);
292  auto dist1 = (dotd1d2 * dist2 - dotdpd1);
293 
294  //by construction both point of closest approach on the two lines lie on this plane
295  recob::tracking::Plane target(start1 + dist1 * dir1, dir1);
296 
297  recob::tracking::Plane plane1(start1, dir1);
298  trkf::TrackState state1(
299  tk1.VertexParametersLocal5D(), tk1.VertexCovarianceLocal5D(), plane1, true, tk1.ParticleId());
300  bool propok1 = true;
301  state1 = prop->propagateToPlane(
302  propok1, detProp, state1, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
303  if (!propok1) {
304  std::cout << "failed propagation, return track1 start pos=" << tk1.Start() << std::endl;
305  VertexWrapper vtx;
306  vtx.addTrackAndUpdateVertex(
307  tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0, 0), 0, 0, tk1);
308  return vtx;
309  }
310 
311  recob::tracking::Plane plane2(start2, dir2);
312  trkf::TrackState state2(
313  tk2.VertexParametersLocal5D(), tk2.VertexCovarianceLocal5D(), plane2, true, tk2.ParticleId());
314  bool propok2 = true;
315  state2 = prop->propagateToPlane(
316  propok2, detProp, state2, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
317  if (!propok2) {
318  std::cout << "failed propagation, return track1 start pos=" << tk1.Start() << std::endl;
319  VertexWrapper vtx;
320  vtx.addTrackAndUpdateVertex(
321  tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0, 0), 0, 0, tk1);
322  return vtx;
323  }
324 
325  if (debugLevel > 0) {
326  std::cout << "track1 pca=" << start1 + dist1 * dir1 << " dist=" << dist1 << std::endl;
327  std::cout << "track2 pca=" << start2 + dist2 * dir2 << " dist=" << dist2 << std::endl;
328  }
329 
330  //here we neglect that to find dist1 and dist2 one track depends on the other...
331  SMatrixSym22 cov1 = state1.covariance().Sub<SMatrixSym22>(0, 0);
332  SMatrixSym22 cov2 = state2.covariance().Sub<SMatrixSym22>(0, 0);
333 
334  if (debugLevel > 1) {
335  std::cout << "target pos=" << target.position() << " dir=" << target.direction() << std::endl;
336  //test if orthogonal
337  auto dcp = state1.position() - state2.position();
338  std::cout << "dot dcp-dir1=" << dcp.Dot(tk1.Trajectory().StartDirection()) << std::endl;
339  std::cout << "dot dcp-dir2=" << dcp.Dot(tk2.Trajectory().StartDirection()) << std::endl;
340 
341  std::cout << "cov1=" << cov1 << std::endl;
342  std::cout << "cov2=" << cov2 << std::endl;
343  }
344 
345  SVector2 par1(state1.parameters()[0], state1.parameters()[1]);
346  SVector2 par2(state2.parameters()[0], state2.parameters()[1]);
347 
348  std::pair<TrackState, double> was = weightedAverageState(par1, par2, cov1, cov2, target);
349  if (was.second <= (util::kBogusD - 1)) {
350  std::cout << "failed inversion, return track1 start pos=" << tk1.Start() << std::endl;
351  VertexWrapper vtx;
352  vtx.addTrackAndUpdateVertex(
353  tk1.Start(), tk1.VertexCovarianceGlobal6D().Sub<SMatrixSym33>(0, 0), 0, 0, tk1);
354  return vtx;
355  }
356 
357  const int ndof = 1; //1=2*2-3; each measurement is 2D because it is defined on a plane
359  was.first.position(), was.first.covariance6D().Sub<SMatrixSym33>(0, 0), was.second, ndof);
360  vtx.addTrack(tk1);
361  vtx.addTrack(tk2);
362 
363  if (debugLevel > 0) {
364  std::cout << "vtxpos=" << vtx.position() << std::endl;
365  std::cout << "vtxcov=\n" << vtx.covariance() << std::endl;
366  std::cout << "chi2=" << was.second << std::endl;
367  }
368 
369  return vtx;
370 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:79
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
SMatrixSym66 VertexCovarianceGlobal6D() const
unsigned int CountValidPoints() const
double Length(size_t p=0) const
Access to various track properties.
Point_t const & Start() const
Access to track position at different points.
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.
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
BEGIN_PROLOG could also be cout
auto const detProp
trkf::Geometric3DVertexFitter::ParsCovsOnPlane trkf::Geometric3DVertexFitter::getParsCovsOnPlane ( detinfo::DetectorPropertiesData const &  detProp,
const trkf::VertexWrapper vtx,
const recob::Track tk 
) const
private

Definition at line 373 of file Geometric3DVertexFitter.cxx.

376 {
377  auto start = tk.Trajectory().Start();
378  auto dir = tk.Trajectory().StartDirection();
379 
380  auto vtxpos = vtx.position();
381  auto vtxcov = vtx.covariance();
382 
383  auto dist = dir.Dot(vtxpos - start);
384 
385  //by construction vtxpos also lies on this plane
386  recob::tracking::Plane target(start + dist * dir, dir);
387 
388  recob::tracking::Plane plane(start, dir);
390  tk.VertexParametersLocal5D(), tk.VertexCovarianceLocal5D(), plane, true, tk.ParticleId());
391  bool propok = true;
392  state = prop->propagateToPlane(
393  propok, detProp, state, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
394 
395  if (debugLevel > 0) {
396  std::cout << "input vtx=" << vtxpos << std::endl;
397  std::cout << "input cov=\n" << vtxcov << std::endl;
398  std::cout << "track pca=" << start + dist * dir << " dist=" << dist << std::endl;
399  std::cout << "target pos=" << target.position() << " dir=" << target.direction() << std::endl;
400  }
401 
402  //rotate the vertex position and covariance to the target plane
403  SVector6 vtxpar6(vtxpos.X(), vtxpos.Y(), vtxpos.Z(), 0, 0, 0);
404  SMatrixSym66 vtxcov66;
405  vtxcov66.Place_at(vtxcov, 0, 0);
406 
407  auto vtxpar5 = target.Global6DToLocal5DParameters(vtxpar6);
408  SVector2 par1(vtxpar5[0], vtxpar5[1]);
409  SVector2 par2(state.parameters()[0], state.parameters()[1]);
410 
411  //here we neglect that to find dist, the vertex is used...
412  SMatrixSym22 cov1 =
413  target.Global6DToLocal5DCovariance(vtxcov66, false, Vector_t()).Sub<SMatrixSym22>(0, 0);
414  SMatrixSym22 cov2 = state.covariance().Sub<SMatrixSym22>(0, 0);
415 
416  if (debugLevel > 1) {
417  std::cout << "vtxpar5=" << vtxpar5 << std::endl;
418  std::cout << "state.parameters()=" << state.parameters() << std::endl;
419  std::cout << "vtx covariance=\n" << vtxcov66 << std::endl;
420  std::cout << "trk covariance=\n" << state.covariance6D() << std::endl;
421  std::cout << "cov1=\n" << cov1 << std::endl;
422  std::cout << "cov2=\n" << cov2 << std::endl;
423  }
424 
425  return ParsCovsOnPlane(par1, par2, cov1, cov2, target);
426 }
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
recob::tracking::Vector_t Vector_t
Definition: TrackState.h:19
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
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
tuple dir
Definition: dropbox.py:28
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
SVector5 VertexParametersLocal5D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
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
BEGIN_PROLOG could also be cout
auto const detProp
double trkf::Geometric3DVertexFitter::ip ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 483 of file Geometric3DVertexFitter.cxx.

486 {
487  return ip(getParsCovsOnPlane(detProp, vtx, tk));
488 }
double ip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
double trkf::Geometric3DVertexFitter::ip ( const ParsCovsOnPlane pcp) const
private

Definition at line 476 of file Geometric3DVertexFitter.cxx.

477 {
478  const SVector2 deltapar = pcp.par2 - pcp.par1;
479  return std::sqrt(deltapar[0] * deltapar[0] + deltapar[1] * deltapar[1]);
480 }
recob::tracking::SVector2 SVector2
double trkf::Geometric3DVertexFitter::ipErr ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 501 of file Geometric3DVertexFitter.cxx.

504 {
505  return ipErr(getParsCovsOnPlane(detProp, vtx, tk));
506 }
double ipErr(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
double trkf::Geometric3DVertexFitter::ipErr ( const ParsCovsOnPlane pcp) const
private

Definition at line 491 of file Geometric3DVertexFitter.cxx.

493 {
494  SVector2 deltapar = pcp.par2 - pcp.par1;
495  deltapar /= std::sqrt(deltapar[0] * deltapar[0] + deltapar[1] * deltapar[1]);
496  SMatrixSym22 covsum = (pcp.cov2 + pcp.cov1);
497  return std::sqrt(ROOT::Math::Similarity(deltapar, covsum));
498 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
double trkf::Geometric3DVertexFitter::ipErrUnbiased ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 568 of file Geometric3DVertexFitter.cxx.

571 {
572  auto ittoerase = vtx.findTrack(tk);
573  if (ittoerase == vtx.tracksSize()) { return ipErr(detProp, vtx, tk); }
574  else {
575  auto tks = vtx.tracksWithoutElement(ittoerase);
576  return ipErr(detProp, fitTracks(detProp, tks), tk);
577  }
578 }
double ipErr(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
auto const detProp
double trkf::Geometric3DVertexFitter::ipUnbiased ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 555 of file Geometric3DVertexFitter.cxx.

558 {
559  auto ittoerase = vtx.findTrack(tk);
560  if (ittoerase == vtx.tracksSize()) { return ip(detProp, vtx, tk); }
561  else {
562  auto tks = vtx.tracksWithoutElement(ittoerase);
563  return ip(detProp, fitTracks(detProp, tks), tk);
564  }
565 }
double ip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
auto const detProp
double trkf::Geometric3DVertexFitter::pDist ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 523 of file Geometric3DVertexFitter.cxx.

524 {
525  return tk.Trajectory().StartDirection().Dot(vtx.position() - tk.Trajectory().Start());
526 }
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
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 ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 594 of file Geometric3DVertexFitter.cxx.

597 {
598  auto ittoerase = vtx.findTrack(tk);
599  if (ittoerase == vtx.tracksSize()) { return pDist(vtx, tk); }
600  else {
601  auto tks = vtx.tracksWithoutElement(ittoerase);
602  return pDist(fitTracks(detProp, tks), tk);
603  }
604 }
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
double trkf::Geometric3DVertexFitter::sip ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 515 of file Geometric3DVertexFitter.cxx.

518 {
519  return sip(getParsCovsOnPlane(detProp, vtx, tk));
520 }
double sip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
auto const detProp
double trkf::Geometric3DVertexFitter::sip ( const ParsCovsOnPlane pcp) const
private

Definition at line 509 of file Geometric3DVertexFitter.cxx.

510 {
511  return ip(pcp) / ipErr(pcp);
512 }
double ip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
double ipErr(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
double trkf::Geometric3DVertexFitter::sipUnbiased ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 581 of file Geometric3DVertexFitter.cxx.

584 {
585  auto ittoerase = vtx.findTrack(tk);
586  if (ittoerase == vtx.tracksSize()) { return sip(detProp, vtx, tk); }
587  else {
588  auto tks = vtx.tracksWithoutElement(ittoerase);
589  return sip(detProp, fitTracks(detProp, tks), tk);
590  }
591 }
double sip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
auto const detProp
trkf::VertexWrapper trkf::Geometric3DVertexFitter::unbiasedVertex ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 529 of file Geometric3DVertexFitter.cxx.

532 {
533  auto ittoerase = vtx.findTrack(tk);
534  if (ittoerase == vtx.tracksSize()) { return vtx; }
535  else {
536  auto tks = vtx.tracksWithoutElement(ittoerase);
537  return fitTracks(detProp, tks);
538  }
539 }
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
auto const detProp
std::pair<TrackState, double> trkf::Geometric3DVertexFitter::weightedAverageState ( ParsCovsOnPlane pcop) const
inlineprivate

Definition at line 190 of file Geometric3DVertexFitter.h.

191  {
192  return weightedAverageState(pcop.par1, pcop.par2, pcop.cov1, pcop.cov2, pcop.plane);
193  };
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
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 140 of file Geometric3DVertexFitter.cxx.

145 {
146  SVector2 deltapar = par2 - par1;
147  SMatrixSym22 covsum = (cov2 + cov1);
148 
149  if (debugLevel > 1) {
150  std::cout << "par1=" << par1 << std::endl;
151  std::cout << "par2=" << par2 << std::endl;
152  std::cout << "deltapar=" << deltapar << std::endl;
153 
154  std::cout << "cov1=\n" << cov1 << std::endl;
155  std::cout << "cov2=\n" << cov2 << std::endl;
156  std::cout << "covsum=\n" << covsum << std::endl;
157  }
158 
159  if (debugLevel > 1) {
160  double det1;
161  bool d1ok = cov1.Det2(det1);
162  std::cout << "cov1 det=" << det1 << " ok=" << d1ok << std::endl;
163  double det2;
164  bool d2ok = cov2.Det2(det2);
165  std::cout << "cov2 det=" << det2 << " ok=" << d2ok << std::endl;
166  double detsum;
167  bool dsok = covsum.Det2(detsum);
168  std::cout << "covsum det=" << detsum << " ok=" << dsok << std::endl;
169  }
170 
171  bool invertok = covsum.Invert();
172  if (!invertok) {
173  SVector5 vtxpar5(0, 0, 0, 0, 0);
174  SMatrixSym55 vtxcov55;
175  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
176  return std::make_pair(vtxstate, util::kBogusD);
177  }
178  auto k = cov1 * covsum;
179 
180  if (debugLevel > 1) {
181  std::cout << "inverted covsum=\n" << covsum << std::endl;
182  std::cout << "k=\n" << k << std::endl;
183  }
184 
185  SVector2 vtxpar2 = par1 + k * deltapar;
186  SMatrixSym22 vtxcov22 = cov1 - ROOT::Math::SimilarityT(cov1, covsum);
187 
188  if (debugLevel > 1) {
189  std::cout << "vtxpar2=" << vtxpar2 << std::endl;
190  std::cout << "vtxcov22=\n" << vtxcov22 << std::endl;
191  }
192 
193  auto chi2 = ROOT::Math::Similarity(deltapar, covsum);
194 
195  SVector5 vtxpar5(vtxpar2[0], vtxpar2[1], 0, 0, 0);
196  SMatrixSym55 vtxcov55;
197  vtxcov55.Place_at(vtxcov22, 0, 0);
198  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
199 
200  return std::make_pair(vtxstate, chi2);
201 }
recob::tracking::SVector2 SVector2
recob::tracking::SMatrixSym22 SMatrixSym22
recob::tracking::SVector5 SVector5
Definition: TrackState.h:12
recob::tracking::SMatrixSym55 SMatrixSym55
double chi2(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
constexpr double kBogusD
obviously bogus double value
pdgs k
Definition: selectors.fcl:22
BEGIN_PROLOG could also be cout

Member Data Documentation

int trkf::Geometric3DVertexFitter::debugLevel
private

Definition at line 179 of file Geometric3DVertexFitter.h.

std::unique_ptr<TrackStatePropagator> trkf::Geometric3DVertexFitter::prop
private

Definition at line 178 of file Geometric3DVertexFitter.h.

double trkf::Geometric3DVertexFitter::sipCut
private

Definition at line 180 of file Geometric3DVertexFitter.h.


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