12 #include "cetlib_except/exception.h" 29 const std::shared_ptr<const Interactor>& interactor)
53 const std::shared_ptr<const Surface>& psurf,
59 std::optional<double> result{std::nullopt};
70 if (!dedx || pinv == 0.)
71 result =
short_vec_prop(trk, psurf, dir, dedx, prop_matrix, noise_matrix);
82 if (prop_matrix) *prop_matrix = ublas::identity_matrix<TrackVector::value_type>(nvec);
87 noise_matrix->resize(nvec, nvec,
false);
88 noise_matrix->clear();
99 TrackMatrix* plocal_prop_matrix = (prop_matrix == 0 ? 0 : &local_prop_matrix);
101 TrackError* plocal_noise_matrix = (noise_matrix == 0 ? 0 : &local_noise_matrix);
122 result = std::nullopt;
130 double mass = trk.
Mass();
132 double e = std::hypot(p, mass);
133 double t = p * p / (e + mass);
135 double smax = 0.1 * t / dedx;
137 throw cet::exception(
"Propagator") << __func__ <<
": maximum step " << smax <<
"\n";
141 if (smax < 0.3) smax = 0.3;
159 std::shared_ptr<const Surface> pstep;
173 double frac = smax /
std::abs(*dist);
175 xyz[0] = xyz0[0] + frac * (xyz1[0] - xyz0[0]);
176 xyz[1] = xyz0[1] + frac * (xyz1[1] - xyz0[1]);
177 xyz[2] = xyz0[2] + frac * (xyz1[2] - xyz0[2]);
187 pstep = std::shared_ptr<const Surface>(
188 new SurfXYZPlane(xyz[0], xyz[1], xyz[2], mom[0], mom[1], mom[2]));
193 dist =
short_vec_prop(trk, pstep, dir, doDedx, plocal_prop_matrix, plocal_noise_matrix);
208 if (prop_matrix != 0) {
209 TrackMatrix temp = prod(*plocal_prop_matrix, *prop_matrix);
215 if (noise_matrix != 0) {
216 TrackMatrix temp = prod(*noise_matrix, trans(*plocal_prop_matrix));
217 TrackMatrix temp2 = prod(*plocal_prop_matrix, temp);
218 *noise_matrix = ublas::symmetric_adaptor<TrackMatrix>(temp2);
219 *noise_matrix += *plocal_noise_matrix;
225 result = std::make_optional(s);
250 const std::shared_ptr<const Surface>& psurf,
259 std::optional<double> result;
262 result =
vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
272 <<
"Input track and reference track not on same surface.\n";
283 if (prop_matrix == 0) prop_matrix = &prop_temp;
288 result =
vec_prop(*ref, psurf, dir, doDedx, prop_matrix, noise_matrix);
303 throw cet::exception(
"Propagator") << __func__ <<
": surface mismatch";
309 result = std::nullopt;
344 const std::shared_ptr<const Surface>& psurf,
353 if (prop_matrix == 0) prop_matrix = &prop_temp;
354 std::optional<double> result =
lin_prop(tre, psurf, dir, doDedx, ref, prop_matrix, 0);
361 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
383 const std::shared_ptr<const Surface>& psurf,
392 std::optional<double> result =
393 lin_prop(tre, psurf, dir, doDedx, ref, &prop_matrix, &noise_matrix);
400 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
401 newerr += noise_matrix;
455 if (pinv == 0.)
return std::make_optional(0.);
459 std::optional<double> result{std::nullopt};
464 double e1 = std::hypot(p1, mass);
466 double emid = e1 + 0.5 * de;
468 double pmid = std::sqrt(emid * emid - mass * mass);
471 double p2 = std::sqrt(e2 * e2 - mass * mass);
472 double pinv2 = 1. / p2;
473 if (pinv < 0.) pinv2 = -pinv2;
477 result = std::make_optional(pinv2);
481 if (deriv != 0) *deriv = pinv2 * pinv2 * pinv2 * e2 / (pinv * pinv * pinv * e1);
const TrackError & getError() const
Track error matrix.
Utilities related to art service access.
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.
constexpr auto abs(T v)
Returns the absolute value of the argument.
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::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.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
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)
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.