LArSoft  v09_90_00
Liquid Argon Software toolkit - https://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 (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::VertexAssnMetacomputeMeta (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
 
std::vector< recob::VertexAssnMetacomputeMeta (detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const std::vector< art::Ptr< recob::Track >> &arttracks)
 
std::vector< recob::VertexAssnMetacomputeMeta (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< 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 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 101 of file Geometric3DVertexFitter.h.

References fhicl::other, track, and lar::dump::vector().

103  : debugLevel(o().debugLevel()), sipCut(o().sipCut())
104  {
105  prop = std::make_unique<TrackStatePropagator>(p);
106  }
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 425 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(), and fitTracksWithVtx().

428 {
429 
430  if (debugLevel > 0) {
431  std::cout << "adding track with start=" << tk.Start() << " dir=" << tk.StartDirection()
432  << " length=" << tk.Length() << " points=" << tk.CountValidPoints() << std::endl;
433  std::cout << "covariance=\n" << tk.VertexCovarianceGlobal6D() << std::endl;
434  }
435 
436  ParsCovsOnPlane pcp = getParsCovsOnPlane(detProp, vtx, tk);
437  std::pair<TrackState, double> was = weightedAverageState(pcp);
438  if (was.second <= (util::kBogusD - 1.)) { return; }
439 
440  const int ndof = 2; // Each measurement is 2D because it is defined on a plane
442  was.first.position(), was.first.covariance6D().Sub<SMatrixSym33>(0, 0), was.second, ndof, tk);
443 
444  if (debugLevel > 0) {
445  std::cout << "updvtxpos=" << vtx.position() << std::endl;
446  std::cout << "updvtxcov=\n" << vtx.covariance() << std::endl;
447  std::cout << "add chi2=" << was.second << std::endl;
448  }
449 }
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:43
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:44
void addTrackAndUpdateVertex(const recob::tracking::Point_t &pos, const recob::tracking::SMatrixSym33 &cov, double chi2, int ndof, const recob::Track &tk)
Definition: VertexWrapper.h:49
SMatrixSym66 VertexCovarianceGlobal6D() const
Accessors to track parameters and covariance matrices in Local5D and Global6D coordinates.
Definition: Track.cxx:81
unsigned int CountValidPoints() const
Various functions related to the presence and the number of (valid) points.
Definition: Track.h:146
Vector_t StartDirection() const
Access to track direction at different points.
Definition: Track.h:165
double Length(size_t p=0) const
Access to various track properties.
Definition: Track.h:207
Point_t const & Start() const
Access to track position at different points.
Definition: Track.h:157
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
double trkf::Geometric3DVertexFitter::chi2 ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 463 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

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

466 {
467  return chi2(getParsCovsOnPlane(detProp, vtx, tk));
468 }
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
double trkf::Geometric3DVertexFitter::chi2 ( const ParsCovsOnPlane pcp) const
private

Definition at line 451 of file Geometric3DVertexFitter.cxx.

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

453 {
454  const SVector2 deltapar = pcp.par2 - pcp.par1;
455  SMatrixSym22 covsum = (pcp.cov2 + pcp.cov1);
456 
457  bool invertok = covsum.Invert();
458  if (!invertok) return -1.;
459 
460  return ROOT::Math::Similarity(deltapar, covsum);
461 }
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 531 of file Geometric3DVertexFitter.cxx.

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

534 {
535  auto ittoerase = vtx.findTrack(tk);
536  if (ittoerase == vtx.tracksSize()) { return chi2(detProp, vtx, tk); }
537  else {
538  auto tks = vtx.tracksWithoutElement(ittoerase);
539  return chi2(detProp, fitTracks(detProp, tks), tk);
540  }
541 }
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
trkf::VertexWrapper trkf::Geometric3DVertexFitter::closestPointAlongTrack ( detinfo::DetectorPropertiesData const &  detProp,
const recob::Track track,
const recob::Track other 
) const

Definition at line 201 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().

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

Definition at line 591 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::tracks().

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

594 {
595  return computeMeta(detProp, vtx, vtx.tracks());
596 }
std::vector< recob::VertexAssnMeta > computeMeta(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
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 598 of file Geometric3DVertexFitter.cxx.

References computeMeta().

602 {
603  TrackRefVec tracks;
604  for (auto t : arttracks)
605  tracks.push_back(*t);
606  return computeMeta(detProp, vtx, tracks);
607 }
std::vector< recob::VertexAssnMeta > computeMeta(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
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 609 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().

613 {
614  std::vector<recob::VertexAssnMeta> result;
615  for (auto tk : trks) {
616  float d = util::kBogusF;
617  float i = util::kBogusF;
618  float e = util::kBogusF;
619  float c = util::kBogusF;
620  auto ittoerase = vtx.findTrack(tk);
621  if (debugLevel > 1)
622  std::cout << "computeMeta for vertex with ntracks=" << vtx.tracksSize() << std::endl;
623  auto ubvtx = unbiasedVertex(detProp, vtx, tk.get());
624  if (debugLevel > 1)
625  std::cout << "got unbiased vertex with ntracks=" << ubvtx.tracksSize()
626  << " isValid=" << ubvtx.isValid() << std::endl;
627  if (ubvtx.isValid()) {
628  d = pDist(ubvtx, tk.get());
629  auto pcop = getParsCovsOnPlane(detProp, ubvtx, tk.get());
630  i = ip(pcop);
631  e = ipErr(pcop);
632  c = chi2(pcop);
633  if (debugLevel > 1)
634  std::cout << "unbiasedVertex d=" << d << " i=" << i << " e=" << e << " c=" << c
635  << std::endl;
636  }
637  else if (vtx.tracksSize() == 2 && ittoerase != vtx.tracksSize()) {
638  auto tks = vtx.tracksWithoutElement(ittoerase);
639  auto fakevtx = closestPointAlongTrack(detProp, tks[0], tk);
640  d = pDist(fakevtx, tk.get());
641  // these will be identical for the two tracks (modulo numerical instabilities in the matrix inversion for the chi2)
642  auto pcop = getParsCovsOnPlane(detProp, fakevtx, tk.get());
643  i = ip(pcop);
644  e = ipErr(pcop);
645  c = chi2(pcop);
646  if (debugLevel > 1)
647  std::cout << "closestPointAlongTrack d=" << d << " i=" << i << " e=" << e << " c=" << c
648  << std::endl;
649  }
650  if (ittoerase == vtx.tracksSize()) {
651  result.push_back(recob::VertexAssnMeta(d, i, e, c, recob::VertexAssnMeta::NotUsedInFit));
652  }
653  else {
654  result.push_back(recob::VertexAssnMeta(d, i, e, c, recob::VertexAssnMeta::IncludedInFit));
655  }
656  }
657  return result;
658 }
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
size_t tracksSize() const
Definition: VertexWrapper.h:67
Class storing the meta-data for track-vertex association: status, propagation distance, impact parameter, impact parameter error, chi2.
Float_t d
Definition: plot.C:235
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
Float_t e
Definition: plot.C:35
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 3 of file Geometric3DVertexFitter.cxx.

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

8 {
9  using namespace std;
10  art::Ptr<recob::PFParticle> pfp(inputPFParticle, iPF);
11  if (debugLevel > 1)
12  std::cout << "pfp#" << iPF << " PdgCode=" << pfp->PdgCode() << " IsPrimary=" << pfp->IsPrimary()
13  << " NumDaughters=" << pfp->NumDaughters() << std::endl;
14  if (pfp->IsPrimary() == false || pfp->NumDaughters() < 2) return 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 
26  if (size(tracks) < 2) { return VertexWrapper{}; }
27 
28  return fitTracks(detProp, tracks);
29 }
STL namespace.
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, 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 ( detinfo::DetectorPropertiesData const &  detProp,
const std::vector< art::Ptr< recob::Track >> &  arttracks 
) const

Definition at line 31 of file Geometric3DVertexFitter.cxx.

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

34 {
35  TrackRefVec tracks;
36  for (auto t : arttracks) {
37  tracks.push_back(*t);
38  }
39  return fitTracks(detProp, tracks);
40 }
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, 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 ( detinfo::DetectorPropertiesData const &  detProp,
TrackRefVec tracks 
) const

Definition at line 42 of file Geometric3DVertexFitter.cxx.

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

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

105 {
106  TrackRefVec tracks;
107  for (auto t : arttracks) {
108  tracks.push_back(*t);
109  }
110  return fitTracksWithVtx(detProp, tracks, vtxPos);
111 }
VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const &detProp, 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 ( detinfo::DetectorPropertiesData const &  detProp,
TrackRefVec tracks,
const recob::tracking::Point_t vtxPos 
) const

Definition at line 113 of file Geometric3DVertexFitter.cxx.

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

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

Definition at line 261 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(), and fitTracksWithVtx().

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

Definition at line 369 of file Geometric3DVertexFitter.cxx.

References trkf::VertexWrapper::covariance(), debugLevel, dir, recob::tracking::Plane::direction(), larg4::dist(), 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().

373 {
374  auto start = tk.Trajectory().Start();
375  auto dir = tk.Trajectory().StartDirection();
376 
377  auto vtxpos = vtx.position();
378  auto vtxcov = vtx.covariance();
379 
380  auto dist = dir.Dot(vtxpos - start);
381 
382  //by construction vtxpos also lies on this plane
383  recob::tracking::Plane target(start + dist * dir, dir);
384 
385  recob::tracking::Plane plane(start, dir);
386  trkf::TrackState state(
387  tk.VertexParametersLocal5D(), tk.VertexCovarianceLocal5D(), plane, true, tk.ParticleId());
388  bool propok = true;
389  state = prop->propagateToPlane(
390  propok, detProp, state, target, true, true, trkf::TrackStatePropagator::UNKNOWN);
391 
392  if (debugLevel > 0) {
393  std::cout << "input vtx=" << vtxpos << std::endl;
394  std::cout << "input cov=\n" << vtxcov << std::endl;
395  std::cout << "track pca=" << start + dist * dir << " dist=" << dist << std::endl;
396  std::cout << "target pos=" << target.position() << " dir=" << target.direction() << std::endl;
397  }
398 
399  //rotate the vertex position and covariance to the target plane
400  SVector6 vtxpar6(vtxpos.X(), vtxpos.Y(), vtxpos.Z(), 0, 0, 0);
401  SMatrixSym66 vtxcov66;
402  vtxcov66.Place_at(vtxcov, 0, 0);
403 
404  auto vtxpar5 = target.Global6DToLocal5DParameters(vtxpar6);
405  SVector2 par1(vtxpar5[0], vtxpar5[1]);
406  SVector2 par2(state.parameters()[0], state.parameters()[1]);
407 
408  //here we neglect that to find dist, the vertex is used...
409  SMatrixSym22 cov1 =
410  target.Global6DToLocal5DCovariance(vtxcov66, false, Vector_t()).Sub<SMatrixSym22>(0, 0);
411  SMatrixSym22 cov2 = state.covariance().Sub<SMatrixSym22>(0, 0);
412 
413  if (debugLevel > 1) {
414  std::cout << "vtxpar5=" << vtxpar5 << std::endl;
415  std::cout << "state.parameters()=" << state.parameters() << std::endl;
416  std::cout << "vtx covariance=\n" << vtxcov66 << std::endl;
417  std::cout << "trk covariance=\n" << state.covariance6D() << std::endl;
418  std::cout << "cov1=\n" << cov1 << std::endl;
419  std::cout << "cov2=\n" << cov2 << std::endl;
420  }
421 
422  return ParsCovsOnPlane(par1, par2, cov1, cov2, target);
423 }
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:93
const recob::tracking::Point_t & position() const
Definition: VertexWrapper.h:43
const recob::tracking::SMatrixSym33 & covariance() const
Definition: VertexWrapper.h:44
int ParticleId() const
Access to various track properties.
Definition: Track.h:211
recob::tracking::Vector_t Vector_t
Definition: TrackState.h:19
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:132
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
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.
Definition: Track.cxx:69
cout<< "-> Edep in the target
Definition: analysis.C:53
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:252
double trkf::Geometric3DVertexFitter::ip ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 477 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

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

480 {
481  return ip(getParsCovsOnPlane(detProp, vtx, tk));
482 }
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
double trkf::Geometric3DVertexFitter::ip ( const ParsCovsOnPlane pcp) const
private

Definition at line 470 of file Geometric3DVertexFitter.cxx.

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

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

Definition at line 493 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

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

496 {
497  return ipErr(getParsCovsOnPlane(detProp, vtx, tk));
498 }
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
double trkf::Geometric3DVertexFitter::ipErr ( const ParsCovsOnPlane pcp) const
private

Definition at line 484 of file Geometric3DVertexFitter.cxx.

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

486 {
487  SVector2 deltapar = pcp.par2 - pcp.par1;
488  deltapar /= std::sqrt(deltapar[0] * deltapar[0] + deltapar[1] * deltapar[1]);
489  SMatrixSym22 covsum = (pcp.cov2 + pcp.cov1);
490  return std::sqrt(ROOT::Math::Similarity(deltapar, covsum));
491 }
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 555 of file Geometric3DVertexFitter.cxx.

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

558 {
559  auto ittoerase = vtx.findTrack(tk);
560  if (ittoerase == vtx.tracksSize()) { return ipErr(detProp, vtx, tk); }
561  else {
562  auto tks = vtx.tracksWithoutElement(ittoerase);
563  return ipErr(detProp, fitTracks(detProp, tks), tk);
564  }
565 }
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
double trkf::Geometric3DVertexFitter::ipUnbiased ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 543 of file Geometric3DVertexFitter.cxx.

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

546 {
547  auto ittoerase = vtx.findTrack(tk);
548  if (ittoerase == vtx.tracksSize()) { return ip(detProp, vtx, tk); }
549  else {
550  auto tks = vtx.tracksWithoutElement(ittoerase);
551  return ip(detProp, fitTracks(detProp, tks), tk);
552  }
553 }
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
double trkf::Geometric3DVertexFitter::pDist ( const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 513 of file Geometric3DVertexFitter.cxx.

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

Referenced by computeMeta(), and pDistUnbiased().

514 {
515  return tk.Trajectory().StartDirection().Dot(vtx.position() - tk.Trajectory().Start());
516 }
const recob::TrackTrajectory & Trajectory() const
Access to the stored recob::TrackTrajectory.
Definition: Track.h:132
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 579 of file Geometric3DVertexFitter.cxx.

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

582 {
583  auto ittoerase = vtx.findTrack(tk);
584  if (ittoerase == vtx.tracksSize()) { return pDist(vtx, tk); }
585  else {
586  auto tks = vtx.tracksWithoutElement(ittoerase);
587  return pDist(fitTracks(detProp, tks), tk);
588  }
589 }
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
double trkf::Geometric3DVertexFitter::sip ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 506 of file Geometric3DVertexFitter.cxx.

References getParsCovsOnPlane().

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

509 {
510  return sip(getParsCovsOnPlane(detProp, vtx, tk));
511 }
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
double trkf::Geometric3DVertexFitter::sip ( const ParsCovsOnPlane pcp) const
private

Definition at line 500 of file Geometric3DVertexFitter.cxx.

References ip(), and ipErr().

502 {
503  return ip(pcp) / ipErr(pcp);
504 }
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 567 of file Geometric3DVertexFitter.cxx.

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

570 {
571  auto ittoerase = vtx.findTrack(tk);
572  if (ittoerase == vtx.tracksSize()) { return sip(detProp, vtx, tk); }
573  else {
574  auto tks = vtx.tracksWithoutElement(ittoerase);
575  return sip(detProp, fitTracks(detProp, tks), tk);
576  }
577 }
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
trkf::VertexWrapper trkf::Geometric3DVertexFitter::unbiasedVertex ( detinfo::DetectorPropertiesData const &  detProp,
const VertexWrapper vtx,
const recob::Track tk 
) const

Definition at line 518 of file Geometric3DVertexFitter.cxx.

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

Referenced by computeMeta().

522 {
523  auto ittoerase = vtx.findTrack(tk);
524  if (ittoerase == vtx.tracksSize()) { return vtx; }
525  else {
526  auto tks = vtx.tracksWithoutElement(ittoerase);
527  return fitTracks(detProp, tks);
528  }
529 }
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, 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 137 of file Geometric3DVertexFitter.cxx.

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

143 {
144  SVector2 deltapar = par2 - par1;
145  SMatrixSym22 covsum = (cov2 + cov1);
146 
147  if (debugLevel > 1) {
148  std::cout << "par1=" << par1 << std::endl;
149  std::cout << "par2=" << par2 << std::endl;
150  std::cout << "deltapar=" << deltapar << std::endl;
151 
152  std::cout << "cov1=\n" << cov1 << std::endl;
153  std::cout << "cov2=\n" << cov2 << std::endl;
154  std::cout << "covsum=\n" << covsum << std::endl;
155  }
156 
157  if (debugLevel > 1) {
158  double det1;
159  bool d1ok = cov1.Det2(det1);
160  std::cout << "cov1 det=" << det1 << " ok=" << d1ok << std::endl;
161  double det2;
162  bool d2ok = cov2.Det2(det2);
163  std::cout << "cov2 det=" << det2 << " ok=" << d2ok << std::endl;
164  double detsum;
165  bool dsok = covsum.Det2(detsum);
166  std::cout << "covsum det=" << detsum << " ok=" << dsok << std::endl;
167  }
168 
169  bool invertok = covsum.Invert();
170  if (!invertok) {
171  SVector5 vtxpar5(0, 0, 0, 0, 0);
172  SMatrixSym55 vtxcov55;
173  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
174  return std::make_pair(vtxstate, util::kBogusD);
175  }
176  auto k = cov1 * covsum;
177 
178  if (debugLevel > 1) {
179  std::cout << "inverted covsum=\n" << covsum << std::endl;
180  std::cout << "k=\n" << k << std::endl;
181  }
182 
183  SVector2 vtxpar2 = par1 + k * deltapar;
184  SMatrixSym22 vtxcov22 = cov1 - ROOT::Math::SimilarityT(cov1, covsum);
185 
186  if (debugLevel > 1) {
187  std::cout << "vtxpar2=" << vtxpar2 << std::endl;
188  std::cout << "vtxcov22=\n" << vtxcov22 << std::endl;
189  }
190 
191  auto chi2 = ROOT::Math::Similarity(deltapar, covsum);
192 
193  SVector5 vtxpar5(vtxpar2[0], vtxpar2[1], 0, 0, 0);
194  SMatrixSym55 vtxcov55;
195  vtxcov55.Place_at(vtxcov22, 0, 0);
196  TrackState vtxstate(vtxpar5, vtxcov55, target, true, 0);
197 
198  return std::make_pair(vtxstate, chi2);
199 }
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

Member Data Documentation

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

Definition at line 179 of file Geometric3DVertexFitter.h.

Referenced by fitTracks(), and fitTracksWithVtx().


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