InteractGeneral.cxx
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////
2 ///
3 /// \file InteractGeneral.cxx
4 ///
5 /// \brief Interactor for general surfaces.
6 ///
7 /// \author H. Greenlee
8 ///
9 ////////////////////////////////////////////////////////////////////////
10 
13 #include <cmath>
14 
15 namespace trkf {
16 
17  /// Constructor.
18  ///
19  /// Arguments:
20  ///
21  /// tcut - Maximum delta ray energy.
22  ///
24  : Interactor(tcut), fInteract(detProp, tcut), fProp(detProp, -1., false)
25  {}
26 
27  /// Calculate noise matrix.
28  ///
29  /// Arguments:
30  ///
31  /// trk - Original track.
32  /// s - Path distance.
33  /// noise_matrix - Resultant noise matrix.
34  ///
35  /// Returns: True if success.
36  ///
37  /// Currently calculate noise from multiple scattering only.
38  ///
39  /// Note about multiple scattering calculation:
40  ///
41  /// We make a zero distance propagation to a plane surface
42  /// (SurfXYZPlane) that is normal to the track direction.
43  /// Then calculate the noise matrix on that surface and
44  /// transform back to the original surface.
45  ///
46  bool
47  InteractGeneral::noise(const KTrack& trk, double s, TrackError& noise_matrix) const
48  {
49  // Get track position and direction.
50 
51  double xyz[3];
52  double mom[3];
53  trk.getPosition(xyz);
54  trk.getMomentum(mom);
55 
56  // Generate a SurfXYZPlane with origin at current track position, and
57  // normal to current track direction.
58 
59  std::shared_ptr<Surface> psurf(
60  new SurfXYZPlane(xyz[0], xyz[1], xyz[2], mom[0], mom[1], mom[2]));
61 
62  // Propagate track to newly created surface (zero-distance propagation).
63 
64  TrackMatrix prop_matrix;
65  KTrack temp_trk = trk;
66  std::optional<double> result =
67  fProp.short_vec_prop(temp_trk, psurf, Propagator::UNKNOWN, false, &prop_matrix);
68 
69  // Return failure if propagation did not succeed.
70 
71  if (!result) return false;
72 
73  // Calculate noise on plane surface.
74 
75  TrackError plane_noise(5);
76  fInteract.noise(temp_trk, s, plane_noise);
77 
78  // Transform noise matrix to original surface using inverse of propagation matrix.
79 
80  invert(prop_matrix);
81  TrackMatrix temp = prod(plane_noise, trans(prop_matrix));
82  TrackMatrix temp2 = prod(prop_matrix, temp);
83  noise_matrix = ublas::symmetric_adaptor<TrackMatrix>(temp2);
84 
85  // Done (success).
86 
87  return true;
88  }
89 } // end namespace trkf
Interactor for planar surfaces.
static QCString result
General planar surface.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
InteractGeneral(detinfo::DetectorPropertiesData const &detProp, double tcut)
void getPosition(double xyz[3]) const
Get position of track.
Definition: KTrack.cxx:171
bool invert(ublas::matrix< T, L, A > &m)
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
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
void getMomentum(double mom[3]) const
Get momentum vector of track.
Definition: KTrack.cxx:218
bool noise(const KTrack &trk, double s, TrackError &noise_matrix) const override
Calculate noise matrix.
bool noise(const KTrack &trk, double s, TrackError &noise_matrix) const override
static QCString * s
Definition: config.cpp:1042
InteractPlane fInteract