LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
TrackStatePropagator.h
Go to the documentation of this file.
1 #ifndef TRACKSTATEPROPAGATOR_H
2 #define TRACKSTATEPROPAGATOR_H
3 
4 #include "fhiclcpp/types/Atom.h"
5 #include "fhiclcpp/types/Table.h"
9 
10 #include <utility>
11 
12 namespace detinfo {
13  class DetectorPropertiesData;
14  class LArProperties;
15 }
16 
17 namespace trkf {
18 
37 
39  public:
44 
45  struct Config {
46  using Name = fhicl::Name;
48  fhicl::Atom<double> minStep{Name("minStep"),
49  Comment("Minimum propagation step length guaranteed."),
50  1.0};
51  fhicl::Atom<double> maxElossFrac{
52  Name("maxElossFrac"),
53  Comment("Maximum propagation step length based on fraction of energy loss."),
54  0.1};
56  Name("maxNit"),
57  Comment("Maximum number of iterations when applying material effects."),
58  10};
59  fhicl::Atom<double> tcut{Name("tcut"), Comment("Maximum delta ray energy for dE/dx."), 10.};
60  fhicl::Atom<double> wrongDirDistTolerance{
61  Name("wrongDirDistTolerance"),
62  Comment("Allowed propagation distance in the wrong direction."),
63  0.01};
64  fhicl::Atom<bool> propPinvErr{
65  Name("propPinvErr"),
66  Comment("Propagate error on 1/p or not (in order to avoid infs, it should be set to false "
67  "when 1/p not updated)."),
68  false};
69  };
71 
73  enum PropDirection { FORWARD = 0, BACKWARD = 1, UNKNOWN = 2 };
74 
76  TrackStatePropagator(double minStep,
77  double maxElossFrac,
78  int maxNit,
79  double tcut,
80  double wrongDirDistTolerance,
81  bool propPinvErr);
82 
84  explicit TrackStatePropagator(Parameters const& p)
85  : TrackStatePropagator(p().minStep(),
86  p().maxElossFrac(),
87  p().maxNit(),
88  p().tcut(),
89  p().wrongDirDistTolerance(),
90  p().propPinvErr())
91  {}
92 
94  TrackState propagateToPlane(bool& success,
95  const detinfo::DetectorPropertiesData& detProp,
96  const TrackState& origin,
97  const Plane& target,
98  bool dodedx,
99  bool domcs,
100  PropDirection dir = FORWARD) const;
101 
103  TrackState rotateToPlane(bool& success, const TrackState& origin, const Plane& target) const
104  {
105  double dw2dw1 = 0.;
106  return rotateToPlane(success, origin, target, dw2dw1);
107  }
108 
111  const Vector_t& origdir,
112  double distance) const
113  {
114  return origpos + distance * origdir;
115  }
116 
118  double distanceToPlane(bool& success,
120  const Point_t& origpos,
121  const Vector_t& origdir,
122  const Plane& target) const;
123  double distanceToPlane(bool& success, const TrackState& origin, const Plane& target) const
124  {
125  return distanceToPlane(success, origin.position(), origin.momentum().Unit(), target);
126  }
128 
130  double perpDistanceToPlane(bool& success, const Point_t& origpos, const Plane& target) const;
132  double perpDistanceToPlane(bool& success, const TrackState& origin, const Plane& target) const
133  {
134  return perpDistanceToPlane(success, origin.position(), target);
135  }
137 
139  std::pair<double, double> distancePairToPlane(bool& success,
141  const Point_t& origpos,
142  const Vector_t& origdir,
143  const Plane& target) const;
144  std::pair<double, double> distancePairToPlane(bool& success,
145  const TrackState& origin,
146  const Plane& target) const
147  {
148  return distancePairToPlane(success, origin.position(), origin.momentum().Unit(), target);
149  }
151 
153  void apply_dedx(double& pinv,
154  detinfo::DetectorPropertiesData const& detProp,
155  double dedx,
156  double e1,
157  double mass,
158  double s,
159  double& deriv) const;
160 
162  bool apply_mcs(detinfo::DetectorPropertiesData const& detProp,
163  double dudw,
164  double dvdw,
165  double pinv,
166  double mass,
167  double s,
168  double range,
169  double p,
170  double e2,
171  bool flipSign,
172  SMatrixSym55& noise_matrix) const;
173 
175  double getTcut() const { return fTcut; }
176 
177  private:
179  TrackState rotateToPlane(bool& success,
180  const TrackState& origin,
181  const Plane& target,
182  double& dw2dw1) const;
183 
184  double fMinStep;
185  double fMaxElossFrac;
186  int fMaxNit;
187  double fTcut;
189  bool
192  };
193 }
194 
195 #endif
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Definition: TrackState.h:93
double perpDistanceToPlane(bool &success, const TrackState &origin, const Plane &target) const
Distance of a TrackState (Point) to a Plane along the direction orthogonal to the Plane...
int fMaxNit
Maximum number of iterations.
const Vector_t & momentum() const
momentum of the track
Definition: TrackState.h:116
recob::tracking::SMatrixSym55 SMatrixSym55
Definition: TrackState.h:15
TrackStatePropagator(Parameters const &p)
Constructor from Parameters (fhicl::Table<Config>).
Class for propagation of a trkf::TrackState to a recob::tracking::Plane.
recob::tracking::Point_t Point_t
double fMinStep
Minimum propagation step length guaranteed.
const Point_t & position() const
position of the track
Definition: TrackState.h:114
double fTcut
Maximum delta ray energy for dE/dx.
PropDirection
Propagation direction enum.
recob::tracking::SVector6 SVector6
TrackState rotateToPlane(bool &success, const TrackState &origin, const Plane &target) const
Rotation of a TrackState to a Plane (zero distance propagation)
ROOT::Math::SVector< Double32_t, 6 > SVector6
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< Coord_t >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space. See recob::tracking::Coord_t for more details on the ...
Definition: TrackingTypes.h:31
Point_t propagatedPosByDistance(const Point_t &origpos, const Vector_t &origdir, double distance) const
Quick accesss to the propagated position given a distance.
std::pair< double, double > distancePairToPlane(bool &success, const TrackState &origin, const Plane &target) const
Return both direction types in one go.
General LArSoft Utilities.
const detinfo::LArProperties * larprop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
Definition: TrackingPlane.h:37
bool fPropPinvErr
Propagate error on 1/p or not (in order to avoid infs, it should be set to false when 1/p not updated...
TDirectory * dir
Definition: macro.C:5
double fWrongDirDistTolerance
Allowed propagation distance in the wrong direction.
double distanceToPlane(bool &success, const TrackState &origin, const Plane &target) const
Distance of a TrackState (Point and Vector) to a Plane, along the TrackState direction.
cout<< "-> Edep in the target
Definition: analysis.C:53
double fMaxElossFrac
Maximum propagation step length based on fraction of energy loss.
recob::tracking::Plane Plane
Definition: TrackState.h:17
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
recob::tracking::Vector_t Vector_t
constexpr Point origin()
Returns a origin position with a point of the specified type.
Definition: geo_vectors.h:229
double getTcut() const
get Tcut parameter used in DetectorPropertiesService Eloss method