12 #include "cetlib_except/exception.h" 29 const std::shared_ptr<const Interactor>& interactor)
54 const std::shared_ptr<const Surface>& psurf,
60 std::optional<double>
result{std::nullopt};
71 if (!dedx || pinv == 0.)
83 if (prop_matrix) *prop_matrix = ublas::identity_matrix<TrackVector::value_type>(nvec);
88 noise_matrix->resize(nvec, nvec,
false);
89 noise_matrix->clear();
100 TrackMatrix* plocal_prop_matrix = (prop_matrix == 0 ? 0 : &local_prop_matrix);
102 TrackError* plocal_noise_matrix = (noise_matrix == 0 ? 0 : &local_noise_matrix);
131 double mass = trk.
Mass();
134 double t = p * p / (e + mass);
136 double smax = 0.1 * t / dedx;
138 throw cet::exception(
"Propagator") << __func__ <<
": maximum step " << smax <<
"\n";
142 if (smax < 0.3) smax = 0.3;
160 std::shared_ptr<const Surface> pstep;
174 double frac = smax /
std::abs(*dist);
176 xyz[0] = xyz0[0] + frac * (xyz1[0] - xyz0[0]);
177 xyz[1] = xyz0[1] + frac * (xyz1[1] - xyz0[1]);
178 xyz[2] = xyz0[2] + frac * (xyz1[2] - xyz0[2]);
188 pstep = std::shared_ptr<const Surface>(
189 new SurfXYZPlane(xyz[0], xyz[1], xyz[2], mom[0], mom[1], mom[2]));
194 dist =
short_vec_prop(trk, pstep, dir, doDedx, plocal_prop_matrix, plocal_noise_matrix);
209 if (prop_matrix != 0) {
216 if (noise_matrix != 0) {
218 TrackMatrix temp2 = prod(*plocal_prop_matrix, temp);
219 *noise_matrix = ublas::symmetric_adaptor<TrackMatrix>(temp2);
220 *noise_matrix += *plocal_noise_matrix;
226 result = std::make_optional(s);
250 std::optional<double>
252 const std::shared_ptr<const Surface>& psurf,
261 std::optional<double>
result;
264 result =
vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
274 <<
"Input track and reference track not on same surface.\n";
285 if (prop_matrix == 0) prop_matrix = &prop_temp;
290 result =
vec_prop(*ref, psurf, dir, doDedx, prop_matrix, noise_matrix);
305 throw cet::exception(
"Propagator") << __func__ <<
": surface mismatch";
311 result = std::nullopt;
345 std::optional<double>
347 const std::shared_ptr<const Surface>& psurf,
356 if (prop_matrix == 0) prop_matrix = &prop_temp;
357 std::optional<double>
result =
lin_prop(tre, psurf, dir, doDedx, ref, prop_matrix, 0);
364 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
385 std::optional<double>
387 const std::shared_ptr<const Surface>& psurf,
396 std::optional<double>
result =
397 lin_prop(tre, psurf, dir, doDedx, ref, &prop_matrix, &noise_matrix);
404 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
405 newerr += noise_matrix;
451 std::optional<double>
457 if (pinv == 0.)
return std::make_optional(0.);
461 std::optional<double>
result{std::nullopt};
468 double emid = e1 + 0.5 * de;
470 double pmid = std::sqrt(emid * emid - mass * mass);
473 double p2 = std::sqrt(e2 * e2 - mass * mass);
474 double pinv2 = 1. / p2;
475 if (pinv < 0.) pinv2 = -pinv2;
479 result = std::make_optional(pinv2);
483 if (deriv != 0) *deriv = pinv2 * pinv2 * pinv2 * e2 / (pinv * pinv * pinv * e1);
const TrackError & getError() const
Track error matrix.
double Mass() const
Based on pdg code.
const std::shared_ptr< const Surface > & getSurface() const
Surface.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
void setVector(const TrackVector &vec)
Set state vector.
void setDirection(Surface::TrackDirection dir)
Set direction.
double fTcut
Maximum delta ray energy for dE/dx.
virtual std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const =0
Propagate without error (short distance).
virtual ~Propagator()
Destructor.
void setError(const TrackError &err)
Set error matrix.
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
std::optional< double > vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const
Propagate without error (long distance).
std::optional< double > noise_prop(KETrack &tre, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, KTrack *ref=0) const
Propagate with error and noise.
void setSurface(const std::shared_ptr< const Surface > &psurf)
Set surface.
detinfo::DetectorPropertiesData const & fDetProp
std::optional< double > lin_prop(KTrack &trk, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, KTrack *ref=0, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const
Linearized propagate without error.
void getPosition(double xyz[3]) const
Get position of track.
std::optional< double > err_prop(KETrack &tre, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, KTrack *ref=0, TrackMatrix *prop_matrix=0) const
Propagate with error, but without noise.
Base class for Kalman filter track propagator.
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.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
std::optional< double > dedx_prop(double pinv, double mass, double s, double *deriv=0) const
Method to calculate updated momentum due to dE/dx.
void getMomentum(double mom[3]) const
Get momentum vector of track.
Surface::TrackDirection getDirection() const
Track direction.
std::shared_ptr< const Interactor > fInteractor
Interactor (for calculating noise).
bool fDoDedx
Energy loss enable flag.
Propagator(detinfo::DetectorPropertiesData const &detProp, double tcut, bool doDedx, const std::shared_ptr< const Interactor > &interactor)
Constructor.
cet::coded_exception< error, detail::translate > exception
bool isValid() const
Test if track is valid.
PropDirection
Propagation direction enum.