PropAny.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file PropAny.cxx
4 ///
5 /// \brief Propagate between any two surfaces.
6 ///
7 /// \author H. Greenlee
8 ///
9 ////////////////////////////////////////////////////////////////////////
10 
12 #include "cetlib_except/exception.h"
17 
18 namespace trkf {
19 
20  /// Constructor.
21  ///
22  /// Arguments.
23  ///
24  /// tcut - Delta ray energy cutoff for calculating dE/dx.
25  /// doDedx - dE/dx enable flag.
26  ///
27  PropAny::PropAny(detinfo::DetectorPropertiesData const& detProp, double tcut, bool doDedx)
28  : Propagator(detProp,
29  tcut,
30  doDedx,
31  (tcut >= 0 ? std::make_shared<InteractPlane const>(detProp, tcut) :
32  std::shared_ptr<Interactor const>{}))
33  , fPropYZLine(detProp, tcut, doDedx)
34  , fPropYZPlane(detProp, tcut, doDedx)
35  , fPropXYZPlane(detProp, tcut, doDedx)
36  {}
37 
38  /// Propagate without error.
39  /// Optionally return propagation matrix and noise matrix.
40  /// This method tests the type of the destination surface, and calls
41  /// the corresponding typed propagator.
42  ///
43  /// Arguments:
44  ///
45  /// trk - Track to propagate.
46  /// psurf - Destination surface.
47  /// dir - Propagation direction (FORWARD, BACKWARD, or UNKNOWN).
48  /// doDedx - dE/dx enable/disable flag.
49  /// prop_matrix - Pointer to optional propagation matrix.
50  /// noise_matrix - Pointer to optional noise matrix.
51  ///
52  /// Returned value: propagation distance + success flag.
53  ///
54  std::optional<double>
56  const std::shared_ptr<const Surface>& psurf,
58  bool doDedx,
59  TrackMatrix* prop_matrix,
60  TrackError* noise_matrix) const
61  {
62  // Default result.
63 
64  std::optional<double> result{std::nullopt};
65 
66  // Test the type of the destination surface.
67 
68  if (dynamic_cast<const SurfYZLine*>(&*psurf))
69  result = fPropYZLine.short_vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
70  else if (dynamic_cast<const SurfYZPlane*>(&*psurf))
71  result = fPropYZPlane.short_vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
72  else if (dynamic_cast<const SurfXYZPlane*>(&*psurf))
73  result = fPropXYZPlane.short_vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
74  else
75  throw cet::exception("PropAny") << "Destination surface has unknown type.\n";
76 
77  // Done.
78 
79  return result;
80  }
81 
82  /// Propagate without error to dynamically generated origin surface.
83  /// Optionally return propagation matrix.
84  ///
85  /// Arguments:
86  ///
87  /// trk - Track to propagate.
88  /// porient - Orientation surface.
89  /// prop_matrix - Pointer to optional propagation matrix.
90  ///
91  /// Returned value: propagation distance + success flag.
92  ///
93  /// Propagation distance is always zero after successful propagation.
94  ///
95  std::optional<double>
97  const std::shared_ptr<const Surface>& porient,
98  TrackMatrix* prop_matrix) const
99  {
100  // Default result.
101 
102  std::optional<double> result{std::nullopt};
103 
104  // Test the type of the destination surface.
105 
106  if (dynamic_cast<const SurfYZLine*>(&*porient))
107  result = fPropYZLine.origin_vec_prop(trk, porient, prop_matrix);
108  else if (dynamic_cast<const SurfYZPlane*>(&*porient))
109  result = fPropYZPlane.origin_vec_prop(trk, porient, prop_matrix);
110  else if (dynamic_cast<const SurfXYZPlane*>(&*porient))
111  result = fPropXYZPlane.origin_vec_prop(trk, porient, prop_matrix);
112  else
113  throw cet::exception("PropAny") << "Destination surface has unknown type.\n";
114 
115  // Done.
116 
117  return result;
118  }
119 
120 } // end namespace trkf
virtual std::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const override
Propagate without error to surface whose origin parameters coincide with track position.
Definition: PropAny.cxx:96
static QCString result
General planar surface.
std::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const override
Propagate without error to surface whose origin parameters coincide with track position.
Definition: PropYZLine.cxx:267
std::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const override
Propagate without error to surface whose origin parameters coincide with track position.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
Planar surface parallel to x-axis.
STL namespace.
PropYZPlane fPropYZPlane
Definition: PropAny.h:53
string dir
std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const override
Propagate without error.
PropYZLine fPropYZLine
Underlying propagators.
Definition: PropAny.h:52
std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const override
Propagate without error.
Definition: PropYZLine.cxx:51
Propagate between any two surfaces.
PropXYZPlane fPropXYZPlane
Definition: PropAny.h:54
std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const override
Propagate without error.
Definition: PropAny.cxx:55
std::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const override
Propagate without error to surface whose origin parameters coincide with track position.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
Interactor for planar surfaces.
std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const override
Propagate without error.
Definition: PropYZPlane.cxx:51
Line surface perpendicular to x-axis.
PropAny(detinfo::DetectorPropertiesData const &detProp, double tcut, bool doDedx)
Constructor.
Definition: PropAny.cxx:27
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
PropDirection
Propagation direction enum.
Definition: Propagator.h:94