Geometric3DVertexFitter.h
Go to the documentation of this file.
1 #ifndef GEOMETRIC3DVERTEXFITTER_H
2 #define GEOMETRIC3DVERTEXFITTER_H
3 
5 #include "canvas/Persistency/Common/FindManyP.h"
7 #include "fhiclcpp/types/Atom.h"
8 #include "fhiclcpp/types/Table.h"
9 
14 
15 namespace detinfo {
16  class DetectorPropertiesData;
17 }
18 
19 namespace trkf {
20 
25 
26  /**
27  * @file larreco/RecoAlg/Geometric3DVertexFitter.h
28  * @class trkf::Geometric3DVertexFitter
29  *
30  * @brief 3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tracks.
31  *
32  * This algorithm fits vertices with following procedure.
33  * First, tracks are sorted based on their start positions and the number of hits.
34  * 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.
35  * Then the other tracks are added, to the vertex: the updated vertex is defined as the weighted average
36  * of the n-1 track vertex position and the point of closest approach of the n-th track.
37  * Methods to obtain the (unbiased) propagation distance, impact parameter, impact parameter error, impact parameter significance, and chi2
38  * of a track with respect to the vertex are provided.
39  *
40  * Inputs are: a set of tracks; interface is provided allowing these to be passed directly of through a PFParticle hierarchy.
41  *
42  * Outputs are: a VertexWrapper, containing the vertex and the reference to the tracks actually used in the fit;
43  * also methods to produce recob::VertexAssnMeta are provided.
44  *
45  * For configuration options see Geometric3DVertexFitter#Config
46  *
47  * @author G. Cerati (FNAL, MicroBooNE)
48  * @date 2017
49  * @version 1.0
50  */
51 
53  public:
54  struct Config {
55  using Name = fhicl::Name;
57  fhicl::Atom<int> debugLevel{
58  Name("debugLevel"),
59  Comment("Debugging level: 0 for no printouts, 1 for minimal, 2 for full.")};
61  Name("sipCut"),
62  Comment(
63  "Cut on maximum impact parameter significance to use the track in the vertex fit.")};
64  };
65 
67  TracksFromVertexSorter(const recob::tracking::Point_t& vtxPos) : vtxPos_(vtxPos) {}
68  bool
69  operator()(std::reference_wrapper<const recob::Track> a,
70  std::reference_wrapper<const recob::Track> b) const
71  {
72  return ((a.get().Trajectory().Start() - vtxPos_).Mag2() <
73  (b.get().Trajectory().Start() - vtxPos_).Mag2());
74  }
75 
76  private:
78  };
79 
80  struct ParsCovsOnPlane {
82  const SVector2& p2,
83  const SMatrixSym22& c1,
84  const SMatrixSym22& c2,
86  : par1(p1), par2(p2), cov1(c1), cov2(c2), plane(p)
87  {}
88  SVector2 par1, par2;
91  };
92 
93  // Constructor
96  : debugLevel(o().debugLevel()), sipCut(o().sipCut())
97  {
98  prop = std::make_unique<TrackStatePropagator>(p);
99  }
100 
101  VertexWrapper fitPFP(detinfo::DetectorPropertiesData const& detProp,
102  size_t iPF,
103  const art::ValidHandle<std::vector<recob::PFParticle>>& inputPFParticle,
104  const std::unique_ptr<art::FindManyP<recob::Track>>& assocTracks) const;
105  VertexWrapper fitTracks(detinfo::DetectorPropertiesData const& detProp,
106  const std::vector<art::Ptr<recob::Track>>& arttracks) const;
107  VertexWrapper fitTracks(detinfo::DetectorPropertiesData const& detProp,
108  TrackRefVec& tracks) const;
109  VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const& detProp,
110  const std::vector<art::Ptr<recob::Track>>& tracks,
111  const recob::tracking::Point_t& vtxPos) const;
112  VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const& detProp,
113  TrackRefVec& tracks,
114  const recob::tracking::Point_t& vtxPos) const;
115  VertexWrapper closestPointAlongTrack(detinfo::DetectorPropertiesData const& detProp,
116  const recob::Track& track,
117  const recob::Track& other) const;
118  VertexWrapper fitTwoTracks(detinfo::DetectorPropertiesData const& detProp,
119  const recob::Track& tk1,
120  const recob::Track& tk2) const;
121 
122  void addTrackToVertex(detinfo::DetectorPropertiesData const& detProp,
123  VertexWrapper& vtx,
124  const recob::Track& tk) const;
125 
126  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
127  const VertexWrapper& vtx);
128  std::vector<recob::VertexAssnMeta> computeMeta(
129  detinfo::DetectorPropertiesData const& detProp,
130  const VertexWrapper& vtx,
131  const std::vector<art::Ptr<recob::Track>>& arttracks);
132  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
133  const VertexWrapper& vtx,
134  const TrackRefVec& trks);
135 
136  double chi2(detinfo::DetectorPropertiesData const& detProp,
137  const VertexWrapper& vtx,
138  const recob::Track& tk) const;
139  double ip(detinfo::DetectorPropertiesData const& detProp,
140  const VertexWrapper& vtx,
141  const recob::Track& tk) const;
142  double ipErr(detinfo::DetectorPropertiesData const& detProp,
143  const VertexWrapper& vtx,
144  const recob::Track& tk) const;
145  double sip(detinfo::DetectorPropertiesData const& detProp,
146  const VertexWrapper& vtx,
147  const recob::Track& tk) const;
148  double pDist(const VertexWrapper& vtx, const recob::Track& tk) const;
149 
150  VertexWrapper unbiasedVertex(detinfo::DetectorPropertiesData const& detProp,
151  const VertexWrapper& vtx,
152  const recob::Track& tk) const;
153  double chi2Unbiased(detinfo::DetectorPropertiesData const& detProp,
154  const VertexWrapper& vtx,
155  const recob::Track& tk) const;
156  double ipUnbiased(detinfo::DetectorPropertiesData const& detProp,
157  const VertexWrapper& vtx,
158  const recob::Track& tk) const;
159  double ipErrUnbiased(detinfo::DetectorPropertiesData const& detProp,
160  const VertexWrapper& vtx,
161  const recob::Track& tk) const;
162  double sipUnbiased(detinfo::DetectorPropertiesData const& detProp,
163  const VertexWrapper& vtx,
164  const recob::Track& tk) const;
165  double pDistUnbiased(detinfo::DetectorPropertiesData const& detProp,
166  const VertexWrapper& vtx,
167  const recob::Track& tk) const;
168 
169  private:
170  std::unique_ptr<TrackStatePropagator> prop;
172  double sipCut;
173 
174  double chi2(const ParsCovsOnPlane& pcp) const;
175  double ip(const ParsCovsOnPlane& pcp) const;
176  double ipErr(const ParsCovsOnPlane& pcp) const;
177  double sip(const ParsCovsOnPlane& pcp) const;
178  ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const& detProp,
179  const trkf::VertexWrapper& vtx,
180  const recob::Track& tk) const;
181  std::pair<TrackState, double>
183  {
184  return weightedAverageState(pcop.par1, pcop.par2, pcop.cov1, pcop.cov2, pcop.plane);
185  };
186  std::pair<TrackState, double> weightedAverageState(SVector2& par1,
187  SVector2& par2,
188  SMatrixSym22& cov1,
189  SMatrixSym22& cov2,
191  };
192 
193 }
194 
195 #endif
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
TracksFromVertexSorter(const recob::tracking::Point_t &vtxPos)
ParsCovsOnPlane(const SVector2 &p1, const SVector2 &p2, const SMatrixSym22 &c1, const SMatrixSym22 &c2, const recob::tracking::Plane &p)
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
recob::tracking::SVector2 SVector2
struct vector vector
ChannelGroupService::Name Name
recob::tracking::SMatrixSym22 SMatrixSym22
ROOT::Math::SMatrix< Double32_t, 3, 3, ROOT::Math::MatRepSym< Double32_t, 3 > > SMatrixSym33
Definition: TrackingTypes.h:84
ROOT::Math::SVector< Double32_t, 3 > SVector3
Definition: TrackingTypes.h:93
recob::tracking::SVector3 SVector3
3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tra...
const double a
ROOT::Math::SVector< Double32_t, 2 > SVector2
Definition: TrackingTypes.h:94
std::unique_ptr< TrackStatePropagator > prop
p
Definition: test.py:223
General LArSoft Utilities.
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
bool operator()(std::reference_wrapper< const recob::Track > a, std::reference_wrapper< const recob::Track > b) const
Geometric3DVertexFitter(const fhicl::Table< Config > &o, const fhicl::Table< TrackStatePropagator::Config > &p)
Definition: tracks.py:1
#define Comment
static bool * b
Definition: config.cpp:1043
ROOT::Math::SMatrix< Double32_t, 2, 2, ROOT::Math::MatRepSym< Double32_t, 2 > > SMatrixSym22
Definition: TrackingTypes.h:83
recob::tracking::SMatrixSym33 SMatrixSym33
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space. See recob::tracking::Coord_t for more detai...
Definition: TrackingTypes.h:26
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
Definition: Track.h:49
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26