4 #include "cetlib_except/exception.h" 5 #include "boost/optional.hpp" 11 TrackStatePropagator::TrackStatePropagator(
double minStep,
double maxElossFrac,
int maxNit,
double tcut,
double wrongDirDistTolerance,
bool propPinvErr) :
13 fMaxElossFrac(maxElossFrac),
16 fWrongDirDistTolerance(wrongDirDistTolerance),
17 fPropPinvErr(propPinvErr)
20 larprop = lar::providerFrom<detinfo::LArPropertiesService>();
31 double distance = distpair.first;
32 double sperp = distpair.second;
47 SVector5 par5d = tmpState.parameters();
51 SMatrix55 pm = ROOT::Math::SMatrixIdentity();
67 const double mass = origin.
mass();
68 const double p = 1./par5d[4];
69 const double e = std::hypot(p, mass);
70 const double t = e - mass;
72 const double range = t / dedx;
75 if (domcs && smax>0 && std::abs(s)>smax) {
80 s = (s>0 ? smax : -smax);
82 }
else arrived =
true;
88 bool ok =
apply_mcs(par5d[2], par5d[3], par5d[4], origin.
mass(),
s, range, p, e*
e, flip, noise_matrix);
101 cov5d = ROOT::Math::Similarity(pm,cov5d);
102 cov5d = cov5d+noise_matrix;
113 const double sinA2 = target.
sinAlpha();
114 const double cosA2 = target.
cosAlpha();
117 const double sinB2 = target.
sinBeta();
118 const double cosB2 = target.
cosBeta();
119 const double sindB = -sinB1*cosB2 + cosB1*sinB2;
120 const double cosdB = cosB1*cosB2 + sinB1*sinB2;
121 const double ruu = cosA1*cosA2 + sinA1*sinA2*cosdB;
122 const double ruv = sinA2*sindB;
123 const double ruw = sinA1*cosA2 - cosA1*sinA2*cosdB;
124 const double rvu = -sinA1*sindB;
125 const double rvv = cosdB;
126 const double rvw = cosA1*sindB;
127 const double rwu = cosA1*sinA2 - sinA1*cosA2*cosdB;
128 const double rwv = -cosA2*sindB;
129 const double rww = sinA1*sinA2 + cosA1*cosA2*cosdB;
130 dw2dw1 = par5[2]*rwu + par5[3]*rwv + rww;
135 const double dudw2 = (par5[2]*ruu + par5[3]*ruv + ruw) / dw2dw1;
136 const double dvdw2 = (par5[2]*rvu + par5[3]*rvv + rvw) / dw2dw1;
139 pm(0,0) = ruu - dudw2*rwu;
140 pm(1,0) = rvu - dvdw2*rwu;
145 pm(0,1) = ruv - dudw2*rwv;
146 pm(1,1) = rvv - dvdw2*rwv;
153 pm(2,2) = (ruu - dudw2*rwu) / dw2dw1;
154 pm(3,2) = (rvu - dvdw2*rwu) / dw2dw1;
159 pm(2,3) = (ruv - dudw2*rwv) / dw2dw1;
160 pm(3,3) = (rvv - dvdw2*rwv) / dw2dw1;
182 if (targdir.Dot(origmom.Unit())==0) {
187 double s = targdir.Dot(targpos-origpos)/targdir.Dot(origmom.Unit());
196 double sperp = targdir.Dot(targpos-origpos);
205 if (targdir.Dot(origmom.Unit())==0) {
207 return std::pair<double, double>(DBL_MAX,DBL_MAX);
210 double sperp = targdir.Dot(targpos-origpos);
212 double s = sperp/targdir.Dot(origmom.Unit());
214 return std::pair<double, double>(
s,sperp);
220 if (pinv == 0.)
return;
222 const double emid = e1 - 0.5 * s * dedx;
224 const double pmid = std::sqrt(emid*emid - mass*mass);
227 const double p2 = std::sqrt(e2*e2 - mass*mass);
228 double pinv2 = 1./p2;
229 if(pinv < 0.) pinv2 = -pinv2;
231 deriv = pinv2*pinv2*pinv2 * e2 / (pinv*pinv*pinv * e1);
242 if(pinv == 0. || s == 0.)
246 if(range > 100.) range = 100.;
247 const double p2 = p*p;
255 const double betainv = std::sqrt(1. + pinv*pinv * mass*mass);
256 const double theta_fact = (0.0136 * pinv * betainv) * (1. + 0.038 * std::log(range/x0));
257 const double theta02 = theta_fact*theta_fact * std::abs(s/x0);
260 const double ufact2 = 1. + dudw*dudw;
261 const double vfact2 = 1. + dvdw*dvdw;
262 const double uvfact2 = 1. + dudw*dudw + dvdw*dvdw;
263 const double uvfact = std::sqrt(uvfact2);
264 const double uv = dudw * dvdw;
265 const double dist2_3 = s*s / 3.;
266 double dist_2 = std::abs(s) / 2.;
267 if(flipSign) dist_2 = -dist_2;
272 const double pinvvar = evar * e2 / (p2*p2*p2);
277 noise_matrix(0,0) += dist2_3 * theta02 * ufact2;
278 noise_matrix(1,0) += dist2_3 * theta02 * uv;
279 noise_matrix(1,1) += dist2_3 * theta02 * vfact2;
282 noise_matrix(2,2) += theta02 * uvfact2 * ufact2;
283 noise_matrix(3,2) += theta02 * uvfact2 * uv;
284 noise_matrix(3,3) += theta02 * uvfact2 * vfact2;
287 noise_matrix(2,0) += dist_2 * theta02 * uvfact * ufact2;
288 noise_matrix(3,1) += dist_2 * theta02 * uvfact * vfact2;
291 noise_matrix(2,1) += dist_2 * theta02 * uvfact * uv;
292 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.
virtual double ElossVar(double mom, double mass) const =0
Energy loss fluctuation ( )
cout<< "-> Edep in the target
const Vector_t & momentum() const
momentum of the track
const SVector5 & parameters() const
track parameters defined on the plane
recob::tracking::SMatrixSym55 SMatrixSym55
double cosBeta() const
Return cached values of trigonometric function for angles defining the plane.
recob::tracking::SMatrix55 SMatrix55
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.
recob::tracking::Point_t Point_t
double mass() const
mass hypthesis of the track
double fMinStep
Minimum propagation step length guaranteed.
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?
virtual double Eloss(double mom, double mass, double tcut) const =0
Restricted mean energy loss ( )
bool apply_mcs(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::SVector5 SVector5
PropDirection
Propagation direction enum.
int pID() const
particle id hypthesis of the track
virtual ~TrackStatePropagator()
Destructor.
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...
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.
virtual double Density(double temperature) const =0
Returns argon density at a given temperature.
const detinfo::LArProperties * larprop
Class defining a plane for tracking. It provides various functionalities to convert track parameters ...
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
void apply_dedx(double &pinv, double dedx, double e1, double mass, double s, double &deriv) const
Apply energy loss.
const SMatrixSym55 & covariance() const
track parameter covariance matrix on the plane
TrackState propagateToPlane(bool &success, const TrackState &origin, const Plane &target, bool dodedx, bool domcs, PropDirection dir=FORWARD) const
Main function for propagation of a TrackState to a Plane.
const detinfo::DetectorProperties * detprop
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.