LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
InteractPlane.cxx
Go to the documentation of this file.
1 
11 #include <cmath>
12 
13 #include "cetlib_except/exception.h"
19 
20 namespace trkf {
21 
29  : Interactor(tcut), fDetProp{detProp}
30  {}
31 
68  bool InteractPlane::noise(const KTrack& trk, double s, TrackError& noise_matrix) const
69  {
70  // Get LAr service.
71 
72  auto const* larprop = lar::providerFrom<detinfo::LArPropertiesService>();
73 
74  // Make sure we are on a plane surface (throw exception if not).
75 
76  const SurfPlane* psurf = dynamic_cast<const SurfPlane*>(&*trk.getSurface());
77  if (psurf == nullptr)
78  throw cet::exception("InteractPlane") << "InteractPlane called for non-planar surface.\n";
79 
80  // Clear noise matrix.
81 
82  noise_matrix.clear();
83 
84  // Unpack track parameters.
85 
86  const TrackVector& vec = trk.getVector();
87  double dudw = vec[2];
88  double dvdw = vec[3];
89  double pinv = vec[4];
90  double mass = trk.Mass();
91 
92  // If distance is zero, or momentum is infinite, return zero noise.
93 
94  if (pinv == 0. || s == 0.) return true;
95 
96  // Make a crude estimate of the range of the track.
97 
98  double p = 1. / std::abs(pinv);
99  double p2 = p * p;
100  double e2 = p2 + mass * mass;
101  double e = std::sqrt(e2);
102  double t = e - mass;
103  double dedx = 0.001 * fDetProp.Eloss(p, mass, getTcut());
104  double range = t / dedx;
105  if (range > 100.) range = 100.;
106 
107  // Calculate the radiation length in cm.
108 
109  double x0 = larprop->RadiationLength() / fDetProp.Density();
110 
111  // Calculate projected rms scattering angle.
112  // Use the estimted range in the logarithm factor.
113  // Use the incremental propagation distance in the square root factor.
114 
115  double betainv = std::sqrt(1. + pinv * pinv * mass * mass);
116  double theta_fact = (0.0136 * pinv * betainv) * (1. + 0.038 * std::log(range / x0));
117  double theta02 = theta_fact * theta_fact * std::abs(s / x0);
118 
119  // Calculate some sommon factors needed for multiple scattering.
120 
121  double ufact2 = 1. + dudw * dudw;
122  double vfact2 = 1. + dvdw * dvdw;
123  double uvfact2 = 1. + dudw * dudw + dvdw * dvdw;
124  double uvfact = std::sqrt(uvfact2);
125  double uv = dudw * dvdw;
126  double dist2_3 = s * s / 3.;
127  double dist_2 = std::abs(s) / 2.;
128  if (trk.getDirection() == Surface::BACKWARD) dist_2 = -dist_2;
129 
130  // Calculate energy loss fluctuations.
131 
132  double evar = 1.e-6 * fDetProp.ElossVar(p, mass) * std::abs(s); // E variance (GeV^2).
133  double pinvvar = evar * e2 / (p2 * p2 * p2); // Inv. p variance (1/GeV^2)
134 
135  // Fill elements of noise matrix.
136 
137  // Position submatrix.
138 
139  noise_matrix(0, 0) = dist2_3 * theta02 * ufact2; // sigma^2(u,u)
140  noise_matrix(1, 0) = dist2_3 * theta02 * uv; // sigma^2(u,v)
141  noise_matrix(1, 1) = dist2_3 * theta02 * vfact2; // sigma^2(v,v)
142 
143  // Slope submatrix.
144 
145  noise_matrix(2, 2) = theta02 * uvfact2 * ufact2; // sigma^2(u', u')
146  noise_matrix(3, 2) = theta02 * uvfact2 * uv; // sigma^2(v', u')
147  noise_matrix(3, 3) = theta02 * uvfact2 * vfact2; // sigma^2(v', v')
148 
149  // Same-view position-slope correlations.
150 
151  noise_matrix(2, 0) = dist_2 * theta02 * uvfact * ufact2; // sigma^2(u', u)
152  noise_matrix(3, 1) = dist_2 * theta02 * uvfact * vfact2; // sigma^2(v', v)
153 
154  // Opposite-view position-slope correlations.
155 
156  noise_matrix(2, 1) = dist_2 * theta02 * uvfact * uv; // sigma^2(u', v)
157  noise_matrix(3, 0) = dist_2 * theta02 * uvfact * uv; // sigma^2(v', u)
158 
159  // Momentum correlations (zero).
160 
161  noise_matrix(4, 0) = 0.; // sigma^2(pinv, u)
162  noise_matrix(4, 1) = 0.; // sigma^2(pinv, v)
163  noise_matrix(4, 2) = 0.; // sigma^2(pinv, u')
164  noise_matrix(4, 3) = 0.; // sigma^2(pinv, v')
165 
166  // Energy loss fluctuations.
167 
168  noise_matrix(4, 4) = pinvvar; // sigma^2(pinv, pinv)
169 
170  // Done (success).
171 
172  return true;
173  }
174 
175 } // end namespace trkf
detinfo::DetectorPropertiesData const & fDetProp
Definition: InteractPlane.h:37
double ElossVar(double mom, double mass) const
Energy loss fluctuation ( )
Utilities related to art service access.
InteractPlane(detinfo::DetectorPropertiesData const &detProp, double tcut)
double Mass() const
Based on pdg code.
Definition: KTrack.cxx:116
const std::shared_ptr< const Surface > & getSurface() const
Surface.
Definition: KTrack.h:53
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
constexpr auto abs(T v)
Returns the absolute value of the argument.
double getTcut() const
Definition: Interactor.h:32
double Density(double temperature=0.) const
Returns argon density at a given temperature.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
double Eloss(double mom, double mass, double tcut) const
Restricted mean energy loss (dE/dx)
const TrackVector & getVector() const
Track state vector.
Definition: KTrack.h:54
Base class for Kalman filter planar surfaces.
Interactor for planar surfaces.
Surface::TrackDirection getDirection() const
Track direction.
Definition: KTrack.cxx:64
bool noise(const KTrack &trk, double s, TrackError &noise_matrix) const override
Calculate noise matrix.
Float_t e
Definition: plot.C:35
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33