12 #include "cetlib_except/exception.h" 32 (tcut >= 0. ? std::make_shared<InteractPlane const>(detProp, tcut) :
33 std::shared_ptr<Interactor const>{})}
51 const std::shared_ptr<const Surface>& psurf,
59 std::optional<double> result{std::nullopt};
65 if (to == 0)
return result;
66 double x02 = to->
x0();
67 double y02 = to->
y0();
68 double z02 = to->
z0();
69 double phi2 = to->
phi();
86 TrackMatrix* plocal_prop_matrix = (prop_matrix == 0 ? 0 : &local_prop_matrix);
87 std::optional<double> result1 =
origin_vec_prop(trk, psurf, plocal_prop_matrix);
88 if (!result1)
return result1;
95 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
98 double dudw1 = vec(2);
99 double dvdw1 = vec(3);
100 double pinv = vec(4);
112 double sinphi2 = std::sin(phi2);
113 double cosphi2 = std::cos(phi2);
118 double u2 = x01 - x02 + u1;
119 double v2 = (y01 - y02) * cosphi2 + (z01 - z02) * sinphi2 + v1;
120 double w2 = -(y01 - y02) * sinphi2 + (z01 - z02) * cosphi2;
124 double u2p = u2 - w2 * dudw1;
125 double v2p = v2 - w2 * dvdw1;
129 double s = -w2 * std::sqrt(1. + dudw1 * dudw1 + dvdw1 * dvdw1);
149 auto pinv2 = std::make_optional(pinv);
151 double* pderiv = (prop_matrix != 0 ? &deriv : 0);
164 result = std::make_optional(s);
168 if (prop_matrix != 0) {
170 pm.resize(vec.size(), vec.size(),
false);
207 *prop_matrix = prod(pm, *plocal_prop_matrix);
212 if (noise_matrix != 0) {
213 noise_matrix->resize(vec.size(), vec.size(),
false);
222 noise_matrix->clear();
258 const std::shared_ptr<const Surface>& porient,
263 std::optional<double> result{std::nullopt};
275 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
290 if (orient == 0)
return result;
291 double phi2 = orient->
phi();
292 std::shared_ptr<const Surface> porigin(
new SurfYZPlane(x02, y02, z02, phi2));
301 double phi1 = from->phi();
306 result = std::make_optional(0.);
307 if (!ok)
return std::nullopt;
314 double phi1 = from->phi();
319 result = std::make_optional(0.);
320 if (!ok)
return std::nullopt;
327 double theta1 = from->theta();
328 double phi1 = from->phi();
333 result = std::make_optional(0.);
334 if (!ok)
return std::nullopt;
347 result = std::nullopt;
365 double sindphi = std::sin(phi2 - phi1);
366 double cosdphi = std::cos(phi2 - phi1);
371 double phid1 = vec(2);
372 double eta1 = vec(3);
377 double rvv = cosdphi;
378 double rvw = sindphi;
380 double rwv = -sindphi;
381 double rww = cosdphi;
385 double sinphid1 = std::sin(phid1);
386 double cosphid1 = std::cos(phid1);
387 double sh1 = 1. / std::cosh(eta1);
388 double th1 = std::tanh(eta1);
392 double u1 = -r1 * sinphid1;
393 double w1 = r1 * cosphid1;
397 double du2 = sh1 * cosphid1;
398 double dv2 = th1 * cosdphi + sh1 * sinphid1 * sindphi;
399 double dw2 = -th1 * sindphi + sh1 * sinphid1 * cosdphi;
407 dir = Surface::TrackDirection::FORWARD;
409 dir = Surface::TrackDirection::BACKWARD;
415 double dudw2 = du2 / dw2;
416 double dvdw2 = dv2 / dw2;
420 if (prop_matrix != 0) {
422 pm.resize(vec.size(), vec.size(),
false);
428 double du1dr1 = -sinphid1;
429 double du1dphi1 = -w1;
431 double dw1dr1 = cosphid1;
432 double dw1dphi1 = u1;
434 double ddu1dphi1 = -sinphid1 * sh1;
435 double ddu1deta1 = -cosphid1 * sh1 * th1;
437 double ddv1deta1 = sh1 * sh1;
439 double ddw1dphi1 = cosphid1 * sh1;
440 double ddw1deta1 = -sinphid1 * sh1 * th1;
444 double du2dr1 = du1dr1;
445 double dv2dr1 = rvw * dw1dr1;
446 double dw2dr1 = rww * dw1dr1;
451 double du2dphi1 = du1dphi1;
452 double dv2dphi1 = rvw * dw1dphi1;
453 double dw2dphi1 = rww * dw1dphi1;
455 double ddu2dphi1 = ddu1dphi1;
456 double ddv2dphi1 = rvw * ddw1dphi1;
457 double ddw2dphi1 = rww * ddw1dphi1;
459 double ddu2deta1 = ddu1deta1;
460 double ddv2deta1 = rvv * ddv1deta1 + rvw * ddw1deta1;
461 double ddw2deta1 = rwv * ddv1deta1 + rww * ddw1deta1;
465 double ddudw2ddu2 = 1. / dw2;
466 double ddudw2ddw2 = -dudw2 / dw2;
468 double ddvdw2ddv2 = 1. / dw2;
469 double ddvdw2ddw2 = -dvdw2 / dw2;
473 double ddudw2dphi1 = ddudw2ddu2 * ddu2dphi1 + ddudw2ddw2 * ddw2dphi1;
474 double ddudw2deta1 = ddudw2ddu2 * ddu2deta1 + ddudw2ddw2 * ddw2deta1;
476 double ddvdw2dphi1 = ddvdw2ddv2 * ddv2dphi1 + ddvdw2ddw2 * ddw2dphi1;
477 double ddvdw2deta1 = ddvdw2ddv2 * ddv2deta1 + ddvdw2ddw2 * ddw2deta1;
487 double dstdr1 = -dw2dr1;
488 double dstdv1 = -dw2dv1;
489 double dstdphi1 = -dw2dphi1;
493 du2dr1 += dstdr1 * dudw2;
494 double du2dv1 = dstdv1 * dudw2;
495 du2dphi1 += dstdphi1 * dudw2;
497 dv2dr1 += dstdr1 * dvdw2;
498 dv2dv1 += dstdv1 * dvdw2;
499 dv2dphi1 += dstdphi1 * dvdw2;
517 pm(2, 2) = ddudw2dphi1;
518 pm(3, 2) = ddvdw2dphi1;
523 pm(2, 3) = ddudw2deta1;
524 pm(3, 3) = ddvdw2deta1;
556 double sindphi = std::sin(phi2 - phi1);
557 double cosdphi = std::cos(phi2 - phi1);
561 double dudw1 = vec(2);
562 double dvdw1 = vec(3);
573 double dw2dw1 = cosdphi - dvdw1 * sindphi;
574 if (dw2dw1 == 0.)
return false;
578 double dudw2 = dudw1 / dw2dw1;
579 double dvdw2 = (sindphi + dvdw1 * cosdphi) / dw2dw1;
587 default:
throw cet::exception(
"PropYZPlane") <<
"unexpected direction #" << ((int)dir) <<
"\n";
592 if (prop_matrix != 0) {
594 pm.resize(vec.size(), vec.size(),
false);
604 pm(0, 1) = dudw2 * sindphi;
605 pm(1, 1) = cosdphi + dvdw2 * sindphi;
612 pm(2, 2) = 1. / dw2dw1;
618 pm(2, 3) = dudw1 * sindphi / (dw2dw1 * dw2dw1);
619 pm(3, 3) = 1. / (dw2dw1 * dw2dw1);
652 double sinth1 = std::sin(theta1);
653 double costh1 = std::cos(theta1);
655 double sindphi = std::sin(phi2 - phi1);
656 double cosdphi = std::cos(phi2 - phi1);
660 double dudw1 = vec(2);
661 double dvdw1 = vec(3);
673 double rvu = -sinth1 * sindphi;
674 double rvv = cosdphi;
675 double rvw = costh1 * sindphi;
677 double rwu = -sinth1 * cosdphi;
678 double rwv = -sindphi;
679 double rww = costh1 * cosdphi;
686 double dw2dw1 = dudw1 * rwu + dvdw1 * rwv + rww;
687 if (dw2dw1 == 0.)
return false;
691 double dudw2 = (dudw1 * ruu + ruw) / dw2dw1;
692 double dvdw2 = (dudw1 * rvu + dvdw1 * rvv + rvw) / dw2dw1;
702 << __func__ <<
": unexpected direction #" << ((int)dir) <<
"\n";
707 if (prop_matrix != 0) {
709 pm.resize(vec.size(), vec.size(),
false);
713 pm(0, 0) = ruu - dudw2 * rwu;
714 pm(1, 0) = rvu - dvdw2 * rwu;
719 pm(0, 1) = -dudw2 * rwv;
720 pm(1, 1) = rvv - dvdw2 * rwv;
727 pm(2, 2) = (ruu - dudw2 * rwu) / dw2dw1;
728 pm(3, 2) = (rvu - dvdw2 * rwu) / dw2dw1;
733 pm(2, 3) = -dudw2 * rwv / dw2dw1;
734 pm(3, 3) = (rvv - dvdw2 * rwv) / dw2dw1;
TrackDirection
Track direction enum.
bool transformXYZPlane(double theta1, double phi1, double phi2, TrackVector &vec, Surface::TrackDirection &dir, TrackMatrix *prop_matrix) const
Transform xyz plane -> yz plane.
Propagate to PropYZPlane surface.
double Mass() const
Based on pdg code.
const std::shared_ptr< const Surface > & getSurface() const
Surface.
double z0() const
Z origin.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
double x0() const
X origin.
void setVector(const TrackVector &vec)
Set state vector.
void setDirection(Surface::TrackDirection dir)
Set direction.
Planar surface parallel to x-axis.
const std::shared_ptr< const Interactor > & getInteractor() const
void setSurface(const std::shared_ptr< const Surface > &psurf)
Set surface.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
void getPosition(double xyz[3]) const
Get position of track.
double y0() const
Y origin.
bool transformYZPlane(double phi1, double phi2, TrackVector &vec, Surface::TrackDirection &dir, TrackMatrix *prop_matrix) const
Transform yz plane -> yz plane.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
bool transformYZLine(double phi1, double phi2, TrackVector &vec, Surface::TrackDirection &dir, TrackMatrix *prop_matrix) const
Transform yz line -> yz plane.
PropYZPlane(detinfo::DetectorPropertiesData const &detProp, double tcut, bool doDedx)
std::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const override
Propagate without error to surface whose origin parameters coincide with track position.
const TrackVector & getVector() const
Track state vector.
std::optional< double > dedx_prop(double pinv, double mass, double s, double *deriv=0) const
Method to calculate updated momentum due to dE/dx.
double phi() const
Rotation angle about x-axis.
Interactor for planar surfaces.
std::optional< double > short_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &surf, Propagator::PropDirection dir, bool doDedx, TrackMatrix *prop_matrix=0, TrackError *noise_matrix=0) const override
Propagate without error.
Surface::TrackDirection getDirection() const
Track direction.
Line surface perpendicular to x-axis.
cet::coded_exception< error, detail::translate > exception
bool isValid() const
Test if track is valid.
PropDirection
Propagation direction enum.