All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geometric3DVertexFitter.h
Go to the documentation of this file.
1 #ifndef GEOMETRIC3DVERTEXFITTER_H
2 #define GEOMETRIC3DVERTEXFITTER_H
3 
4 #include "art/Framework/Principal/Handle.h"
5 #include "canvas/Persistency/Common/FindManyP.h"
6 #include "canvas/Persistency/Common/Ptr.h"
7 #include "fhiclcpp/types/Atom.h"
8 #include "fhiclcpp/types/Comment.h"
9 #include "fhiclcpp/types/Name.h"
10 #include "fhiclcpp/types/Table.h"
11 
17 
18 namespace detinfo {
19  class DetectorPropertiesData;
20 }
21 
22 #include <functional> // std::reference_wrapper<>
23 #include <memory>
24 #include <utility> // std::pair<>
25 #include <vector>
26 
27 namespace trkf {
28 
33 
34  /**
35  * @file larreco/RecoAlg/Geometric3DVertexFitter.h
36  * @class trkf::Geometric3DVertexFitter
37  *
38  * @brief 3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tracks.
39  *
40  * This algorithm fits vertices with following procedure.
41  * First, tracks are sorted based on their start positions and the number of hits.
42  * 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.
43  * Then the other tracks are added, to the vertex: the updated vertex is defined as the weighted average
44  * of the n-1 track vertex position and the point of closest approach of the n-th track.
45  * Methods to obtain the (unbiased) propagation distance, impact parameter, impact parameter error, impact parameter significance, and chi2
46  * of a track with respect to the vertex are provided.
47  *
48  * Inputs are: a set of tracks; interface is provided allowing these to be passed directly of through a PFParticle hierarchy.
49  *
50  * Outputs are: a VertexWrapper, containing the vertex and the reference to the tracks actually used in the fit;
51  * also methods to produce recob::VertexAssnMeta are provided.
52  *
53  * For configuration options see Geometric3DVertexFitter#Config
54  *
55  * @author G. Cerati (FNAL, MicroBooNE)
56  * @date 2017
57  * @version 1.0
58  */
59 
61  public:
62  struct Config {
63  using Name = fhicl::Name;
64  using Comment = fhicl::Comment;
65  fhicl::Atom<int> debugLevel{
66  Name("debugLevel"),
67  Comment("Debugging level: 0 for no printouts, 1 for minimal, 2 for full.")};
68  fhicl::Atom<double> sipCut{
69  Name("sipCut"),
70  Comment(
71  "Cut on maximum impact parameter significance to use the track in the vertex fit.")};
72  };
73 
76  bool
77  operator()(std::reference_wrapper<const recob::Track> a,
78  std::reference_wrapper<const recob::Track> b) const
79  {
80  return ((a.get().Trajectory().Start() - vtxPos_).Mag2() <
81  (b.get().Trajectory().Start() - vtxPos_).Mag2());
82  }
83 
84  private:
86  };
87 
88  struct ParsCovsOnPlane {
90  const SVector2& p2,
91  const SMatrixSym22& c1,
92  const SMatrixSym22& c2,
94  : par1(p1), par2(p2), cov1(c1), cov2(c2), plane(p)
95  {}
99  };
100 
101  // Constructor
102  Geometric3DVertexFitter(const fhicl::Table<Config>& o,
103  const fhicl::Table<TrackStatePropagator::Config>& p)
104  : debugLevel(o().debugLevel()), sipCut(o().sipCut())
105  {
106  prop = std::make_unique<TrackStatePropagator>(p);
107  }
108 
110  size_t iPF,
111  const art::ValidHandle<std::vector<recob::PFParticle>>& inputPFParticle,
112  const std::unique_ptr<art::FindManyP<recob::Track>>& assocTracks) const;
114  const std::vector<art::Ptr<recob::Track>>& arttracks) const;
116  TrackRefVec& tracks) const;
118  const std::vector<art::Ptr<recob::Track>>& tracks,
119  const recob::tracking::Point_t& vtxPos) const;
122  const recob::tracking::Point_t& vtxPos) const;
124  const recob::Track& track,
125  const recob::Track& other) const;
127  const recob::Track& tk1,
128  const recob::Track& tk2) const;
129 
131  VertexWrapper& vtx,
132  const recob::Track& tk) const;
133 
134  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
135  const VertexWrapper& vtx);
136  std::vector<recob::VertexAssnMeta> computeMeta(
138  const VertexWrapper& vtx,
139  const std::vector<art::Ptr<recob::Track>>& arttracks);
140  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
141  const VertexWrapper& vtx,
142  const TrackRefVec& trks);
143 
145  const VertexWrapper& vtx,
146  const recob::Track& tk) const;
148  const VertexWrapper& vtx,
149  const recob::Track& tk) const;
151  const VertexWrapper& vtx,
152  const recob::Track& tk) const;
154  const VertexWrapper& vtx,
155  const recob::Track& tk) const;
156  double pDist(const VertexWrapper& vtx, const recob::Track& tk) const;
157 
159  const VertexWrapper& vtx,
160  const recob::Track& tk) const;
162  const VertexWrapper& vtx,
163  const recob::Track& tk) const;
165  const VertexWrapper& vtx,
166  const recob::Track& tk) const;
168  const VertexWrapper& vtx,
169  const recob::Track& tk) const;
171  const VertexWrapper& vtx,
172  const recob::Track& tk) const;
174  const VertexWrapper& vtx,
175  const recob::Track& tk) const;
176 
177  private:
178  std::unique_ptr<TrackStatePropagator> prop;
180  double sipCut;
181 
182  double chi2(const ParsCovsOnPlane& pcp) const;
183  double ip(const ParsCovsOnPlane& pcp) const;
184  double ipErr(const ParsCovsOnPlane& pcp) const;
185  double sip(const ParsCovsOnPlane& pcp) const;
187  const trkf::VertexWrapper& vtx,
188  const recob::Track& tk) const;
189  std::pair<TrackState, double>
191  {
192  return weightedAverageState(pcop.par1, pcop.par2, pcop.cov1, pcop.cov2, pcop.plane);
193  };
194  std::pair<TrackState, double> weightedAverageState(SVector2& par1,
195  SVector2& par2,
196  SMatrixSym22& cov1,
197  SMatrixSym22& cov2,
198  recob::tracking::Plane& target) const;
199  };
200 
201 }
202 
203 #endif
void addTrackToVertex(detinfo::DetectorPropertiesData const &detProp, VertexWrapper &vtx, const recob::Track &tk) const
std::pair< TrackState, double > weightedAverageState(ParsCovsOnPlane &pcop) const
double sip(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) 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)
ClusterModuleLabel join with tracks
VertexWrapper closestPointAlongTrack(detinfo::DetectorPropertiesData const &detProp, const recob::Track &track, const recob::Track &other) const
VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &tracks, const recob::tracking::Point_t &vtxPos) const
Wrapper class to facilitate vertex production.
Definition: VertexWrapper.h:28
recob::tracking::SVector2 SVector2
pdgs p
Definition: selectors.fcl:22
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
process_name use argoneut_mc_hitfinder track
std::vector< recob::VertexAssnMeta > computeMeta(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx)
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
recob::tracking::SVector3 SVector3
double sipUnbiased(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
process_name gaushit a
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:265
3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tra...
VertexWrapper fitTwoTracks(detinfo::DetectorPropertiesData const &detProp, const recob::Track &tk1, const recob::Track &tk2) const
ROOT::Math::SVector< Double32_t, 2 > SVector2
Definition: TrackingTypes.h:94
std::unique_ptr< TrackStatePropagator > prop
double pDistUnbiased(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
BEGIN_PROLOG vertical distance to the surface Name
VertexWrapper fitTracks(detinfo::DetectorPropertiesData const &detProp, const std::vector< art::Ptr< recob::Track >> &arttracks) const
ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const &detProp, const trkf::VertexWrapper &vtx, const recob::Track &tk) const
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
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
Geometric3DVertexFitter(const fhicl::Table< Config > &o, const fhicl::Table< TrackStatePropagator::Config > &p)
double pDist(const VertexWrapper &vtx, const recob::Track &tk) const
double chi2(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
ROOT::Math::SMatrix< Double32_t, 2, 2, ROOT::Math::MatRepSym< Double32_t, 2 > > SMatrixSym22
Definition: TrackingTypes.h:83
recob::tracking::SMatrixSym33 SMatrixSym33
double ipUnbiased(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
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
physics associatedGroupsWithLeft p1
auto const detProp
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a &quot;fitted&quot; track:
double chi2Unbiased(detinfo::DetectorPropertiesData const &detProp, const VertexWrapper &vtx, const recob::Track &tk) const
std::vector< std::reference_wrapper< const recob::Track > > TrackRefVec
Definition: VertexWrapper.h:26