17 #include "cetlib_except/exception.h" 52 boost::optional<double>
54 const std::shared_ptr<const Surface>& psurf,
62 boost::optional<double> result(
false, 0.);
70 double x02 = to->
x0();
71 double y02 = to->
y0();
72 double z02 = to->
z0();
73 double phi2 = to->
phi();
90 TrackMatrix* plocal_prop_matrix = (prop_matrix==0 ? 0 : &local_prop_matrix);
91 boost::optional<double> result1 =
origin_vec_prop(trk, psurf, plocal_prop_matrix);
100 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
103 double phid1 = vec(2);
104 double eta1 = vec(3);
105 double pinv = vec(4);
109 double sinphid1 = std::sin(phid1);
110 double cosphid1 = std::cos(phid1);
111 double sh1 = std::sinh(eta1);
112 double ch1 = std::cosh(eta1);
113 double sinphi2 = std::sin(phi2);
114 double cosphi2 = std::cos(phi2);
118 double u1 = -r1 * sinphid1;
119 double w1 = r1 * cosphid1;
123 double u2 = x01 - x02 + u1;
124 double v2 = (y01 - y02) * cosphi2 + (z01 - z02) * sinphi2 + v1;
125 double w2 = -(y01 - y02) * sinphi2 + (z01 - z02) * cosphi2 + w1;
129 double r2 = w2 * cosphid1 - u2 * sinphid1;
133 double d2 = -(w2 * sinphid1 + u2 * cosphid1);
138 double v2p = v2 + d2 * sh1;
163 boost::optional<double> pinv2(
true, pinv);
165 double* pderiv = (prop_matrix != 0 ? &deriv : 0);
178 result = boost::optional<double>(
true,
s);
182 if(prop_matrix != 0) {
184 pm.resize(vec.size(), vec.size(),
false);
221 *prop_matrix = prod(pm, *plocal_prop_matrix);
226 if(noise_matrix != 0) {
227 noise_matrix->resize(vec.size(), vec.size(),
false);
232 return boost::optional<double>(
false, 0.);
236 noise_matrix->clear();
271 boost::optional<double>
273 const std::shared_ptr<const Surface>& porient,
278 boost::optional<double> result(
false, 0.);
290 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
307 double phi2 = orient->
phi();
308 std::shared_ptr<const Surface> porigin(
new SurfYZLine(x02, y02, z02, phi2));
317 double phi1 = from->phi();
322 result = boost::optional<double>(ok, 0.);
331 double phi1 = from->phi();
336 result = boost::optional<double>(ok, 0.);
345 double theta1 = from->theta();
346 double phi1 = from->phi();
351 result = boost::optional<double>(ok, 0.);
366 result = boost::optional<double>(
false, 0.);
383 double sindphi = std::sin(phi2 - phi1);
384 double cosdphi = std::cos(phi2 - phi1);
389 double phid1 = vec(2);
390 double eta1 = vec(3);
395 double rvv = cosdphi;
396 double rvw = sindphi;
398 double rwv = -sindphi;
399 double rww = cosdphi;
403 double sinphid1 = std::sin(phid1);
404 double cosphid1 = std::cos(phid1);
405 double sh1 = 1. / std::cosh(eta1);
406 double th1 = std::tanh(eta1);
410 double u1 = -r1 * sinphid1;
411 double w1 = r1 * cosphid1;
415 double du2 = sh1*cosphid1;
416 double dv2 = th1*cosdphi + sh1*sinphid1*sindphi;
417 double dw2 = -th1*sindphi + sh1*sinphid1*cosdphi;
418 double duw2 = std::hypot(du2, dw2);
422 double phid2 = atan2(dw2, du2);
423 double eta2 = std::asinh(dv2 / duw2);
427 if(prop_matrix != 0) {
429 pm.resize(vec.size(), vec.size(),
false);
435 double du1dr1 = -sinphid1;
436 double du1dphi1 = -w1;
438 double dw1dr1 = cosphid1;
439 double dw1dphi1 = u1;
441 double ddu1dphi1 = -sinphid1*sh1;
442 double ddu1deta1 = -cosphid1*sh1*th1;
444 double ddv1deta1 = sh1*sh1;
446 double ddw1dphi1 = cosphid1*sh1;
447 double ddw1deta1 = -sinphid1*sh1*th1;
451 double du2dr1 = du1dr1;
452 double dv2dr1 = rvw*dw1dr1;
453 double dw2dr1 = rww*dw1dr1;
458 double du2dphi1 = du1dphi1;
459 double dv2dphi1 = rvw*dw1dphi1;
460 double dw2dphi1 = rww*dw1dphi1;
462 double ddu2dphi1 = ddu1dphi1;
463 double ddv2dphi1 = rvw*ddw1dphi1;
464 double ddw2dphi1 = rww*ddw1dphi1;
466 double ddu2deta1 = ddu1deta1;
467 double ddv2deta1 = rvv*ddv1deta1 + rvw*ddw1deta1;
468 double ddw2deta1 = rwv*ddv1deta1 + rww*ddw1deta1;
472 double dr2du2 = -dw2/duw2;
473 double dr2dw2 = du2/duw2;
475 double dphi2ddu2 = -dw2/(duw2*duw2);
476 double dphi2ddw2 = du2/(duw2*duw2);
478 double deta2ddv2 = 1./(duw2*duw2);
482 double dr2dr1 = dr2du2*du2dr1 + dr2dw2*dw2dr1;
483 double dr2dv1 = dr2dw2*dw2dv1;
484 double dr2dphi1 = dr2du2*du2dphi1 + dr2dw2*dw2dphi1;
486 double dphi2dphi1 = dphi2ddu2*ddu2dphi1 + dphi2ddw2*ddw2dphi1;
487 double dphi2deta1 = dphi2ddu2*ddu2deta1 + dphi2ddw2*ddw2deta1;
489 double deta2dphi1 = deta2ddv2*ddv2dphi1;
490 double deta2deta1 = deta2ddv2*ddv2deta1;
502 double dsdu2 = -du2/(duw2*duw2);
503 double dsdw2 = -dw2/(duw2*duw2);
507 double dsdr1 = dsdu2*du2dr1 + dsdw2*dw2dr1;
508 double dsdv1 = dsdw2*dw2dv1;
509 double dsdphi1 = dsdu2*du2dphi1 + dsdw2*dw2dphi1;
515 dv2dphi1 += dv2*dsdphi1;
533 pm(2,2) = dphi2dphi1;
534 pm(3,2) = deta2dphi1;
539 pm(2,3) = dphi2deta1;
540 pm(3,3) = deta2deta1;
571 double sindphi = std::sin(phi2 - phi1);
572 double cosdphi = std::cos(phi2 - phi1);
576 double dudw1 = vec(2);
577 double dvdw1 = vec(3);
590 double rvv = cosdphi;
591 double rvw = sindphi;
593 double rwv = -sindphi;
594 double rww = cosdphi;
598 double dw1 = dirf / std::sqrt(1. + dudw1*dudw1 + dvdw1*dvdw1);
599 double du1 = dudw1 * dw1;
600 double dv1 = dvdw1 * dw1;
605 double dv2 = rvv*dv1 + rvw*dw1;
606 double dw2 = rwv*dv1 + rww*dw1;
607 double duw2 = std::hypot(du2, dw2);
611 double phid2 = atan2(dw2, du2);
612 double eta2 = std::asinh(dv2 / duw2);
616 if(prop_matrix != 0) {
618 pm.resize(vec.size(), vec.size(),
false);
624 double ddu1ddudw1 = (1. + dvdw1*dvdw1) * dw1*dw1*dw1;
625 double ddu1ddvdw1 = -dudw1 * dvdw1 * dw1*dw1*dw1;
627 double ddv1ddudw1 = -dudw1 * dvdw1 * dw1*dw1*dw1;
628 double ddv1ddvdw1 = (1. + dudw1*dudw1) * dw1*dw1*dw1;
630 double ddw1ddudw1 = -dudw1 * dw1*dw1*dw1;
631 double ddw1ddvdw1 = -dvdw1 * dw1*dw1*dw1;
638 double ddu2ddudw1 = ddu1ddudw1;
639 double ddv2ddudw1 = rvv*ddv1ddudw1 + rvw*ddw1ddudw1;
640 double ddw2ddudw1 = rwv*ddv1ddudw1 + rww*ddw1ddudw1;
642 double ddu2ddvdw1 = ddu1ddvdw1;
643 double ddv2ddvdw1 = rvv*ddv1ddvdw1 + rvw*ddw1ddvdw1;
644 double ddw2ddvdw1 = rwv*ddv1ddvdw1 + rww*ddw1ddvdw1;
648 double dr2du2 = -dw2/duw2;
649 double dr2dw2 = du2/duw2;
651 double dphi2ddu2 = -dw2/(duw2*duw2);
652 double dphi2ddw2 = du2/(duw2*duw2);
654 double deta2ddv2 = 1./(duw2*duw2);
658 double dr2du1 = dr2du2;
659 double dr2dv1 = dr2dw2*dw2dv1;
661 double dphi2ddudw1 = dphi2ddu2*ddu2ddudw1 + dphi2ddw2*ddw2ddudw1;
662 double dphi2ddvdw1 = dphi2ddu2*ddu2ddvdw1 + dphi2ddw2*ddw2ddvdw1;
664 double deta2ddudw1 = deta2ddv2*ddv2ddudw1;
665 double deta2ddvdw1 = deta2ddv2*ddv2ddvdw1;
677 double dsdu2 = -du2/(duw2*duw2);
678 double dsdw2 = -dw2/(duw2*duw2);
682 double dsdu1 = dsdu2;
683 double dsdv1 = dsdw2*dw2dv1;
687 double dv2du1 = dv2*dsdu1;
706 pm(2,2) = dphi2ddudw1;
707 pm(3,2) = deta2ddudw1;
712 pm(2,3) = dphi2ddvdw1;
713 pm(3,3) = deta2ddvdw1;
744 double sinth1 = std::sin(theta1);
745 double costh1 = std::cos(theta1);
747 double sindphi = std::sin(phi2 - phi1);
748 double cosdphi = std::cos(phi2 - phi1);
752 double dudw1 = vec(2);
753 double dvdw1 = vec(3);
769 double rvu = -sinth1*sindphi;
770 double rvv = cosdphi;
771 double rvw = costh1*sindphi;
773 double rwu = -sinth1*cosdphi;
774 double rwv = -sindphi;
775 double rww = costh1*cosdphi;
779 double dw1 = dirf / std::sqrt(1. + dudw1*dudw1 + dvdw1*dvdw1);
780 double du1 = dudw1 * dw1;
781 double dv1 = dvdw1 * dw1;
785 double du2 = ruu*du1 + ruw*dw1;
786 double dv2 = rvu*du1 + rvv*dv1 + rvw*dw1;
787 double dw2 = rwu*du1 + rwv*dv1 + rww*dw1;
788 double duw2 = std::hypot(du2, dw2);
792 double phid2 = atan2(dw2, du2);
793 double eta2 = std::asinh(dv2 / duw2);
797 if(prop_matrix != 0) {
799 pm.resize(vec.size(), vec.size(),
false);
805 double ddu1ddudw1 = (1. + dvdw1*dvdw1) * dw1*dw1*dw1;
806 double ddu1ddvdw1 = -dudw1 * dvdw1 * dw1*dw1*dw1;
808 double ddv1ddudw1 = -dudw1 * dvdw1 * dw1*dw1*dw1;
809 double ddv1ddvdw1 = (1. + dudw1*dudw1) * dw1*dw1*dw1;
811 double ddw1ddudw1 = -dudw1 * dw1*dw1*dw1;
812 double ddw1ddvdw1 = -dvdw1 * dw1*dw1*dw1;
823 double ddu2ddudw1 = ruu*ddu1ddudw1 + ruw*ddw1ddudw1;
824 double ddv2ddudw1 = rvu*ddu1ddudw1 + rvv*ddv1ddudw1 + rvw*ddw1ddudw1;
825 double ddw2ddudw1 = rwu*ddu1ddudw1 + rwv*ddv1ddudw1 + rww*ddw1ddudw1;
827 double ddu2ddvdw1 = ruu*ddu1ddvdw1 + ruw*ddw1ddvdw1;
828 double ddv2ddvdw1 = rvu*ddu1ddvdw1 + rvv*ddv1ddvdw1 + rvw*ddw1ddvdw1;
829 double ddw2ddvdw1 = rwu*ddu1ddvdw1 + rwv*ddv1ddvdw1 + rww*ddw1ddvdw1;
833 double dr2du2 = -dw2/duw2;
834 double dr2dw2 = du2/duw2;
836 double dphi2ddu2 = -dw2/(duw2*duw2);
837 double dphi2ddw2 = du2/(duw2*duw2);
839 double deta2ddv2 = 1./(duw2*duw2);
843 double dr2du1 = dr2du2*du2du1 + dr2dw2*dw2du1;
844 double dr2dv1 = dr2dw2*dw2dv1;
846 double dphi2ddudw1 = dphi2ddu2*ddu2ddudw1 + dphi2ddw2*ddw2ddudw1;
847 double dphi2ddvdw1 = dphi2ddu2*ddu2ddvdw1 + dphi2ddw2*ddw2ddvdw1;
849 double deta2ddudw1 = deta2ddv2*ddv2ddudw1;
850 double deta2ddvdw1 = deta2ddv2*ddv2ddvdw1;
862 double dsdu2 = -du2/(duw2*duw2);
863 double dsdw2 = -dw2/(duw2*duw2);
867 double dsdu1 = dsdu2*du2du1 + dsdw2*dw2du1;
868 double dsdv1 = dsdw2*dw2dv1;
891 pm(2,2) = dphi2ddudw1;
892 pm(3,2) = deta2ddudw1;
897 pm(2,3) = dphi2ddvdw1;
898 pm(3,3) = deta2ddvdw1;
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 line.
virtual boost::optional< double > origin_vec_prop(KTrack &trk, const std::shared_ptr< const Surface > &porient, TrackMatrix *prop_matrix=0) const
Propagate without error to surface whose origin parameters coincide with track position.
Interactor for planar surfaces.
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.
bool transformYZLine(double phi1, double phi2, TrackVector &vec, Surface::TrackDirection &dir, TrackMatrix *prop_matrix) const
Transform yz line -> yz line.
void setVector(const TrackVector &vec)
Set state vector.
void setDirection(Surface::TrackDirection dir)
Set direction.
Planar surface parallel to x-axis.
boost::optional< double > dedx_prop(double pinv, double mass, double s, double *deriv=0) const
Method to calculate updated momentum due to dE/dx.
const std::shared_ptr< const Interactor > & getInteractor() const
boost::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
Propagate without error.
void setSurface(const std::shared_ptr< const Surface > &psurf)
Set surface.
Propagate to SurfYZLine surface.
void getPosition(double xyz[3]) const
Get position of track.
bool transformYZPlane(double phi1, double phi2, TrackVector &vec, Surface::TrackDirection &dir, TrackMatrix *prop_matrix) const
Transform yz plane -> yz line.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
PropYZLine(double tcut, bool doDedx)
Constructor.
double z0() const
Z origin.
virtual ~PropYZLine()
Destructor.
const TrackVector & getVector() const
Track state vector.
double x0() const
X origin.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
Surface::TrackDirection getDirection() const
Track direction.
double phi() const
Rotation angle about x-axis.
double y0() const
Y origin.
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.