LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Geometric3DVertexFitter.h
Go to the documentation of this file.
1 #ifndef GEOMETRIC3DVERTEXFITTER_H
2 #define GEOMETRIC3DVERTEXFITTER_H
3 
7 #include "fhiclcpp/types/Atom.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 
61  public:
62  struct Config {
63  using Name = fhicl::Name;
65  fhicl::Atom<int> debugLevel{
66  Name("debugLevel"),
67  Comment("Debugging level: 0 for no printouts, 1 for minimal, 2 for full.")};
69  Name("sipCut"),
70  Comment(
71  "Cut on maximum impact parameter significance to use the track in the vertex fit.")};
72  };
73 
75  TracksFromVertexSorter(const recob::tracking::Point_t& vtxPos) : vtxPos_(vtxPos) {}
76  bool operator()(std::reference_wrapper<const recob::Track> a,
77  std::reference_wrapper<const recob::Track> b) const
78  {
79  return ((a.get().Trajectory().Start() - vtxPos_).Mag2() <
80  (b.get().Trajectory().Start() - vtxPos_).Mag2());
81  }
82 
83  private:
85  };
86 
87  struct ParsCovsOnPlane {
89  const SVector2& p2,
90  const SMatrixSym22& c1,
91  const SMatrixSym22& c2,
92  const recob::tracking::Plane& p)
93  : par1(p1), par2(p2), cov1(c1), cov2(c2), plane(p)
94  {}
95  SVector2 par1, par2;
98  };
99 
100  // Constructor
103  : debugLevel(o().debugLevel()), sipCut(o().sipCut())
104  {
105  prop = std::make_unique<TrackStatePropagator>(p);
106  }
107 
108  VertexWrapper fitPFP(detinfo::DetectorPropertiesData const& detProp,
109  size_t iPF,
110  const art::ValidHandle<std::vector<recob::PFParticle>>& inputPFParticle,
111  const std::unique_ptr<art::FindManyP<recob::Track>>& assocTracks) const;
112  VertexWrapper fitTracks(detinfo::DetectorPropertiesData const& detProp,
113  const std::vector<art::Ptr<recob::Track>>& arttracks) const;
114  VertexWrapper fitTracks(detinfo::DetectorPropertiesData const& detProp,
115  TrackRefVec& tracks) const;
116  VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const& detProp,
117  const std::vector<art::Ptr<recob::Track>>& tracks,
118  const recob::tracking::Point_t& vtxPos) const;
119  VertexWrapper fitTracksWithVtx(detinfo::DetectorPropertiesData const& detProp,
120  TrackRefVec& tracks,
121  const recob::tracking::Point_t& vtxPos) const;
122  VertexWrapper closestPointAlongTrack(detinfo::DetectorPropertiesData const& detProp,
123  const recob::Track& track,
124  const recob::Track& other) const;
125  VertexWrapper fitTwoTracks(detinfo::DetectorPropertiesData const& detProp,
126  const recob::Track& tk1,
127  const recob::Track& tk2) const;
128 
129  void addTrackToVertex(detinfo::DetectorPropertiesData const& detProp,
130  VertexWrapper& vtx,
131  const recob::Track& tk) const;
132 
133  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
134  const VertexWrapper& vtx);
135  std::vector<recob::VertexAssnMeta> computeMeta(
136  detinfo::DetectorPropertiesData const& detProp,
137  const VertexWrapper& vtx,
138  const std::vector<art::Ptr<recob::Track>>& arttracks);
139  std::vector<recob::VertexAssnMeta> computeMeta(detinfo::DetectorPropertiesData const& detProp,
140  const VertexWrapper& vtx,
141  const TrackRefVec& trks);
142 
143  double chi2(detinfo::DetectorPropertiesData const& detProp,
144  const VertexWrapper& vtx,
145  const recob::Track& tk) const;
146  double ip(detinfo::DetectorPropertiesData const& detProp,
147  const VertexWrapper& vtx,
148  const recob::Track& tk) const;
149  double ipErr(detinfo::DetectorPropertiesData const& detProp,
150  const VertexWrapper& vtx,
151  const recob::Track& tk) const;
152  double sip(detinfo::DetectorPropertiesData const& detProp,
153  const VertexWrapper& vtx,
154  const recob::Track& tk) const;
155  double pDist(const VertexWrapper& vtx, const recob::Track& tk) const;
156 
157  VertexWrapper unbiasedVertex(detinfo::DetectorPropertiesData const& detProp,
158  const VertexWrapper& vtx,
159  const recob::Track& tk) const;
160  double chi2Unbiased(detinfo::DetectorPropertiesData const& detProp,
161  const VertexWrapper& vtx,
162  const recob::Track& tk) const;
163  double ipUnbiased(detinfo::DetectorPropertiesData const& detProp,
164  const VertexWrapper& vtx,
165  const recob::Track& tk) const;
166  double ipErrUnbiased(detinfo::DetectorPropertiesData const& detProp,
167  const VertexWrapper& vtx,
168  const recob::Track& tk) const;
169  double sipUnbiased(detinfo::DetectorPropertiesData const& detProp,
170  const VertexWrapper& vtx,
171  const recob::Track& tk) const;
172  double pDistUnbiased(detinfo::DetectorPropertiesData const& detProp,
173  const VertexWrapper& vtx,
174  const recob::Track& tk) const;
175 
176  private:
177  std::unique_ptr<TrackStatePropagator> prop;
179  double sipCut;
180 
181  double chi2(const ParsCovsOnPlane& pcp) const;
182  double ip(const ParsCovsOnPlane& pcp) const;
183  double ipErr(const ParsCovsOnPlane& pcp) const;
184  double sip(const ParsCovsOnPlane& pcp) const;
185  ParsCovsOnPlane getParsCovsOnPlane(detinfo::DetectorPropertiesData const& detProp,
186  const trkf::VertexWrapper& vtx,
187  const recob::Track& tk) const;
188  std::pair<TrackState, double> weightedAverageState(ParsCovsOnPlane& pcop) const
189  {
190  return weightedAverageState(pcop.par1, pcop.par2, pcop.cov1, pcop.cov2, pcop.plane);
191  };
192  std::pair<TrackState, double> weightedAverageState(SVector2& par1,
193  SVector2& par2,
194  SMatrixSym22& cov1,
195  SMatrixSym22& cov2,
197  };
198 
199 }
200 
201 #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
recob::tracking::SMatrixSym22 SMatrixSym22
recob::tracking::SVector3 SVector3
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Definition: DumpUtils.h:289
ROOT::Math::SVector< Double32_t, 2 > SVector2
3D vertex fitter based on the geometric properties (start position, direction, covariance) of the tra...
TCanvas * c1
Definition: plotHisto.C:7
ROOT::Math::SMatrix< Double32_t, 3, 3, ROOT::Math::MatRepSym< Double32_t, 3 >> SMatrixSym33
TCanvas * c2
Definition: plot_hist.C:75
std::unique_ptr< TrackStatePropagator > prop
ROOT::Math::SMatrix< Double32_t, 2, 2, ROOT::Math::MatRepSym< Double32_t, 2 >> SMatrixSym22
ROOT::Math::SVector< Double32_t, 3 > SVector3
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)
cout<< "-> Edep in the target
Definition: analysis.C:53
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:27
Float_t track
Definition: plot.C:35
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