11 TrackStatePropagator::TrackStatePropagator(
double minStep,
15 double wrongDirDistTolerance,
18 , fMaxElossFrac(maxElossFrac)
21 , fWrongDirDistTolerance(wrongDirDistTolerance)
22 , fPropPinvErr(propPinvErr)
24 larprop = lar::providerFrom<detinfo::LArPropertiesService>();
60 SVector5 par5d = tmpState.parameters();
64 SMatrix55 pm = ROOT::Math::SMatrixIdentity();
80 const double mass = origin.
mass();
81 const double p = 1. / par5d[4];
82 const double e = std::hypot(p, mass);
83 const double t = e - mass;
85 const double range = t / dedx;
88 if (domcs && smax > 0 &&
std::abs(s) > smax) {
93 s = (s > 0 ? smax : -smax);
119 if (dodedx) {
apply_dedx(par5d(4), detProp, dedx, e, origin.
mass(), s, deriv); }
124 cov5d = ROOT::Math::Similarity(pm, cov5d);
125 cov5d = cov5d + noise_matrix;
134 double& dw2dw1)
const 141 const double sinA2 = target.
sinAlpha();
142 const double cosA2 = target.
cosAlpha();
145 const double sinB2 = target.
sinBeta();
146 const double cosB2 = target.
cosBeta();
147 const double sindB = -sinB1 * cosB2 + cosB1 * sinB2;
148 const double cosdB = cosB1 * cosB2 + sinB1 * sinB2;
149 const double ruu = cosA1 * cosA2 + sinA1 * sinA2 * cosdB;
150 const double ruv = sinA2 * sindB;
151 const double ruw = sinA1 * cosA2 - cosA1 * sinA2 * cosdB;
152 const double rvu = -sinA1 * sindB;
153 const double rvv = cosdB;
154 const double rvw = cosA1 * sindB;
155 const double rwu = cosA1 * sinA2 - sinA1 * cosA2 * cosdB;
156 const double rwv = -cosA2 * sindB;
157 const double rww = sinA1 * sinA2 + cosA1 * cosA2 * cosdB;
158 dw2dw1 = par5[2] * rwu + par5[3] * rwv + rww;
163 const double dudw2 = (par5[2] * ruu + par5[3] * ruv + ruw) / dw2dw1;
164 const double dvdw2 = (par5[2] * rvu + par5[3] * rvv + rvw) / dw2dw1;
167 pm(0, 0) = ruu - dudw2 * rwu;
168 pm(1, 0) = rvu - dvdw2 * rwu;
173 pm(0, 1) = ruv - dudw2 * rwv;
174 pm(1, 1) = rvv - dvdw2 * rwv;
181 pm(2, 2) = (ruu - dudw2 * rwu) / dw2dw1;
182 pm(3, 2) = (rvu - dvdw2 * rwu) / dw2dw1;
187 pm(2, 3) = (ruv - dudw2 * rwv) / dw2dw1;
188 pm(3, 3) = (rvv - dvdw2 * rwv) / dw2dw1;
207 ROOT::Math::Similarity(pm, origin.
covariance()),
209 isTrackAlongPlaneDir,
221 if (targdir.Dot(origmom.Unit()) == 0) {
226 double s = targdir.Dot(targpos - origpos) / targdir.Dot(origmom.Unit());
238 double sperp = targdir.Dot(targpos - origpos);
251 if (targdir.Dot(origmom.Unit()) == 0) {
253 return std::pair<double, double>(DBL_MAX, DBL_MAX);
256 double sperp = targdir.Dot(targpos - origpos);
258 double s = sperp / targdir.Dot(origmom.Unit());
260 return std::pair<double, double>(s, sperp);
272 if (pinv == 0.)
return;
274 const double emid = e1 - 0.5 * s * dedx;
276 const double pmid = std::sqrt(emid * emid - mass * mass);
277 const double e2 = e1 - 0.001 * s * detProp.
Eloss(pmid, mass,
fTcut);
279 const double p2 = std::sqrt(e2 * e2 - mass * mass);
280 double pinv2 = 1. / p2;
281 if (pinv < 0.) pinv2 = -pinv2;
283 deriv = pinv2 * pinv2 * pinv2 * e2 / (pinv * pinv * pinv * e1);
305 if (pinv == 0. || s == 0.)
return true;
308 if (range > 100.) range = 100.;
309 const double p2 = p * p;
317 const double betainv = std::sqrt(1. + pinv * pinv * mass * mass);
318 const double theta_fact = (0.0136 * pinv * betainv) * (1. + 0.038 * std::log(range / x0));
319 const double theta02 = theta_fact * theta_fact *
std::abs(s / x0);
322 const double ufact2 = 1. + dudw * dudw;
323 const double vfact2 = 1. + dvdw * dvdw;
324 const double uvfact2 = 1. + dudw * dudw + dvdw * dvdw;
325 const double uvfact = std::sqrt(uvfact2);
326 const double uv = dudw * dvdw;
327 const double dist2_3 = s * s / 3.;
329 if (flipSign) dist_2 = -dist_2;
334 const double pinvvar = evar * e2 / (p2 * p2 * p2);
339 noise_matrix(0, 0) += dist2_3 * theta02 * ufact2;
340 noise_matrix(1, 0) += dist2_3 * theta02 * uv;
341 noise_matrix(1, 1) += dist2_3 * theta02 * vfact2;
344 noise_matrix(2, 2) += theta02 * uvfact2 * ufact2;
345 noise_matrix(3, 2) += theta02 * uvfact2 * uv;
346 noise_matrix(3, 3) += theta02 * uvfact2 * vfact2;
349 noise_matrix(2, 0) += dist_2 * theta02 * uvfact * ufact2;
350 noise_matrix(3, 1) += dist_2 * theta02 * uvfact * vfact2;
353 noise_matrix(2, 1) += dist_2 * theta02 * uvfact * uv;
354 noise_matrix(3, 0) += dist_2 * theta02 * uvfact * uv;
double cosAlpha() const
Return cached values of trigonometric function for angles defining the plane.
recob::tracking::Plane Plane
Class for track parameters (and errors) defined on a recob::tracking::Plane.
Vector_t const & direction() const
Reference direction orthogonal to the plane.
int fMaxNit
Maximum number of iterations.
double ElossVar(double mom, double mass) const
Energy loss fluctuation ( )
Utilities related to art service access.
const Vector_t & momentum() const
momentum of the track
const SVector5 & parameters() const
track parameters defined on the plane
recob::tracking::SMatrixSym55 SMatrixSym55
constexpr auto abs(T v)
Returns the absolute value of the argument.
double cosBeta() const
Return cached values of trigonometric function for angles defining the plane.
recob::tracking::SMatrix55 SMatrix55
TrackState propagateToPlane(bool &success, const detinfo::DetectorPropertiesData &detProp, const TrackState &origin, const Plane &target, bool dodedx, bool domcs, PropDirection dir=FORWARD) const
Main function for propagation of a TrackState to a Plane.
double distanceToPlane(bool &success, const Point_t &origpos, const Vector_t &origdir, const Plane &target) const
Distance of a TrackState (Point and Vector) to a Plane, along the TrackState direction.
bool apply_mcs(detinfo::DetectorPropertiesData const &detProp, double dudw, double dvdw, double pinv, double mass, double s, double range, double p, double e2, bool flipSign, SMatrixSym55 &noise_matrix) const
Apply multiple coulomb scattering.
recob::tracking::Point_t Point_t
double mass() const
mass hypthesis of the track
double fMinStep
Minimum propagation step length guaranteed.
void apply_dedx(double &pinv, detinfo::DetectorPropertiesData const &detProp, double dedx, double e1, double mass, double s, double &deriv) const
Apply energy loss.
const Point_t & position() const
position of the track
double fTcut
Maximum delta ray energy for dE/dx.
bool isTrackAlongPlaneDir() const
is the track momentum along the plane direction?
recob::tracking::SVector5 SVector5
PropDirection
Propagation direction enum.
int pID() const
particle id hypthesis of the track
Point_t const & position() const
Reference position on the plane.
TrackState rotateToPlane(bool &success, const TrackState &origin, const Plane &target) const
Rotation of a TrackState to a Plane (zero distance propagation)
Point_t propagatedPosByDistance(const Point_t &origpos, const Vector_t &origdir, double distance) const
Quick accesss to the propagated position given a distance.
double perpDistanceToPlane(bool &success, const Point_t &origpos, const Plane &target) const
Distance of a TrackState (Point) to a Plane along the direction orthogonal to the Plane...
double Density(double temperature=0.) const
Returns argon density at a given temperature.
std::pair< double, double > distancePairToPlane(bool &success, const Point_t &origpos, const Vector_t &origdir, const Plane &target) const
Return both direction types in one go.
const detinfo::LArProperties * larprop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
double Eloss(double mom, double mass, double tcut) const
Restricted mean energy loss (dE/dx)
bool fPropPinvErr
Propagate error on 1/p or not (in order to avoid infs, it should be set to false when 1/p not updated...
double fWrongDirDistTolerance
Allowed propagation distance in the wrong direction.
double sinAlpha() const
Return cached values of trigonometric function for angles defining the plane.
virtual double RadiationLength() const =0
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
cout<< "-> Edep in the target
double fMaxElossFrac
Maximum propagation step length based on fraction of energy loss.
double sinBeta() const
Return cached values of trigonometric function for angles defining the plane.
const Plane & plane() const
plane where the parameters are defined
recob::tracking::Vector_t Vector_t
constexpr Point origin()
Returns a origin position with a point of the specified type.