14 #include "cetlib_except/exception.h" 26 const std::shared_ptr<const Interactor>& interactor) :
29 fInteractor(interactor)
53 const std::shared_ptr<const Surface>& psurf,
61 auto result = boost::make_optional<double>(
false, 0.);
72 if(!dedx || pinv == 0.)
73 result =
short_vec_prop(trk, psurf, dir, dedx, prop_matrix, noise_matrix);
83 auto const * detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
89 *prop_matrix = ublas::identity_matrix<TrackVector::value_type>(nvec);
94 noise_matrix->resize(nvec, nvec,
false);
95 noise_matrix->clear();
106 TrackMatrix* plocal_prop_matrix = (prop_matrix==0 ? 0 : &local_prop_matrix);
108 TrackError* plocal_noise_matrix = (noise_matrix==0 ? 0 : &local_noise_matrix);
129 result = boost::optional<double>(
false, 0.);
137 double mass = trk.
Mass();
138 double p = 1./std::abs(pinv);
139 double e = std::hypot(p, mass);
140 double t = p*p / (e + mass);
141 double dedx = 0.001 * detprop->Eloss(p, mass,
fTcut);
142 double smax = 0.1 * t / dedx;
144 throw cet::exception(
"Propagator") << __func__ <<
": maximum step " << smax <<
"\n";
155 boost::optional<double> dist =
short_vec_prop(trktest, psurf, dir,
false, 0, 0);
167 std::shared_ptr<const Surface> pstep;
168 if(std::abs(*dist) <= smax) {
181 double frac = smax / std::abs(*dist);
183 xyz[0] = xyz0[0] + frac * (xyz1[0] - xyz0[0]);
184 xyz[1] = xyz0[1] + frac * (xyz1[1] - xyz0[1]);
185 xyz[2] = xyz0[2] + frac * (xyz1[2] - xyz0[2]);
195 pstep = std::shared_ptr<const Surface>(
new SurfXYZPlane(xyz[0], xyz[1], xyz[2],
196 mom[0], mom[1], mom[2]));
202 plocal_prop_matrix, plocal_noise_matrix);
217 if(prop_matrix != 0) {
218 TrackMatrix temp = prod(*plocal_prop_matrix, *prop_matrix);
224 if(noise_matrix != 0) {
225 TrackMatrix temp = prod(*noise_matrix, trans(*plocal_prop_matrix));
226 TrackMatrix temp2 = prod(*plocal_prop_matrix, temp);
227 *noise_matrix = ublas::symmetric_adaptor<TrackMatrix>(temp2);
228 *noise_matrix += *plocal_noise_matrix;
234 result = boost::optional<double>(
true,
s);
259 const std::shared_ptr<const Surface>& psurf,
268 boost::optional<double> result;
271 result =
vec_prop(trk, psurf, dir, doDedx, prop_matrix, noise_matrix);
281 "Input track and reference track not on same surface.\n";
293 prop_matrix = &prop_temp;
298 result =
vec_prop(*ref, psurf, dir, doDedx, prop_matrix, noise_matrix);
313 throw cet::exception(
"Propagator") << __func__ <<
": surface mismatch";
319 result = boost::optional<double>(
false, 0.);
355 const std::shared_ptr<const Surface>& psurf,
365 prop_matrix = &prop_temp;
366 boost::optional<double> result =
lin_prop(tre, psurf, dir, doDedx, ref, prop_matrix, 0);
373 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
395 const std::shared_ptr<const Surface>& psurf,
404 boost::optional<double> result =
lin_prop(tre, psurf, dir, doDedx, ref,
405 &prop_matrix, &noise_matrix);
412 TrackError newerr = ublas::symmetric_adaptor<TrackMatrix>(temp2);
413 newerr += noise_matrix;
460 double s,
double* deriv)
const 466 return boost::optional<double>(
true, 0.);
470 boost::optional<double> result(
false, 0.);
474 auto const * detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
478 double p1 = 1./std::abs(pinv);
479 double e1 = std::hypot(p1, mass);
480 double de = -0.001 * s * detprop->Eloss(p1, mass,
fTcut);
481 double emid = e1 + 0.5 * de;
483 double pmid = std::sqrt(emid*emid - mass*mass);
484 double e2 = e1 - 0.001 * s * detprop->Eloss(pmid, mass,
fTcut);
486 double p2 = std::sqrt(e2*e2 - mass*mass);
487 double pinv2 = 1./p2;
493 result = boost::optional<double>(
true, pinv2);
498 *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.
boost::optional< double > dedx_prop(double pinv, double mass, double s, double *deriv=0) const
Method to calculate updated momentum due to dE/dx.
double fTcut
Maximum delta ray energy for dE/dx.
virtual ~Propagator()
Destructor.
void setError(const TrackError &err)
Set error matrix.
boost::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.
boost::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.
void setSurface(const std::shared_ptr< const Surface > &psurf)
Set surface.
void getPosition(double xyz[3]) const
Get position of track.
Propagator(double tcut, bool doDedx, const std::shared_ptr< const Interactor > &interactor)
Constructor.
Base class for Kalman filter track propagator.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
boost::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).
const TrackVector & getVector() const
Track state vector.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
void getMomentum(double mom[3]) const
Get momentum vector of track.
Surface::TrackDirection getDirection() const
Track direction.
boost::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.
virtual boost::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).
cet::coded_exception< error, detail::translate > exception
bool isValid() const
Test if track is valid.
PropDirection
Propagation direction enum.