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 dudw1 = vec(2);
104 double dvdw1 = vec(3);
105 double pinv = vec(4);
117 double sinphi2 = std::sin(phi2);
118 double cosphi2 = std::cos(phi2);
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;
129 double u2p = u2 - w2 * dudw1;
130 double v2p = v2 - w2 * dvdw1;
134 double s = -w2 * std::sqrt(1. + dudw1*dudw1 + dvdw1*dvdw1);
156 boost::optional<double> pinv2(
true, pinv);
158 double* pderiv = (prop_matrix != 0 ? &deriv : 0);
171 result = boost::optional<double>(
true,
s);
175 if(prop_matrix != 0) {
177 pm.resize(vec.size(), vec.size(),
false);
214 *prop_matrix = prod(pm, *plocal_prop_matrix);
219 if(noise_matrix != 0) {
220 noise_matrix->resize(vec.size(), vec.size(),
false);
225 return boost::optional<double>(
false, 0.);
229 noise_matrix->clear();
264 boost::optional<double>
266 const std::shared_ptr<const Surface>& porient,
271 boost::optional<double> result(
false, 0.);
283 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
300 double phi2 = orient->
phi();
301 std::shared_ptr<const Surface> porigin(
new SurfYZPlane(x02, y02, z02, phi2));
310 double phi1 = from->phi();
315 result = boost::optional<double>(ok, 0.);
324 double phi1 = from->phi();
329 result = boost::optional<double>(ok, 0.);
338 double theta1 = from->theta();
339 double phi1 = from->phi();
344 result = boost::optional<double>(ok, 0.);
359 result = boost::optional<double>(
false, 0.);
376 double sindphi = std::sin(phi2 - phi1);
377 double cosdphi = std::cos(phi2 - phi1);
382 double phid1 = vec(2);
383 double eta1 = vec(3);
388 double rvv = cosdphi;
389 double rvw = sindphi;
391 double rwv = -sindphi;
392 double rww = cosdphi;
396 double sinphid1 = std::sin(phid1);
397 double cosphid1 = std::cos(phid1);
398 double sh1 = 1. / std::cosh(eta1);
399 double th1 = std::tanh(eta1);
403 double u1 = -r1 * sinphid1;
404 double w1 = r1 * cosphid1;
408 double du2 = sh1*cosphid1;
409 double dv2 = th1*cosdphi + sh1*sinphid1*sindphi;
410 double dw2 = -th1*sindphi + sh1*sinphid1*cosdphi;
418 dir = Surface::TrackDirection::FORWARD;
420 dir = Surface::TrackDirection::BACKWARD;
426 double dudw2 = du2 / dw2;
427 double dvdw2 = dv2 / dw2;
431 if(prop_matrix != 0) {
433 pm.resize(vec.size(), vec.size(),
false);
439 double du1dr1 = -sinphid1;
440 double du1dphi1 = -w1;
442 double dw1dr1 = cosphid1;
443 double dw1dphi1 = u1;
445 double ddu1dphi1 = -sinphid1*sh1;
446 double ddu1deta1 = -cosphid1*sh1*th1;
448 double ddv1deta1 = sh1*sh1;
450 double ddw1dphi1 = cosphid1*sh1;
451 double ddw1deta1 = -sinphid1*sh1*th1;
455 double du2dr1 = du1dr1;
456 double dv2dr1 = rvw*dw1dr1;
457 double dw2dr1 = rww*dw1dr1;
462 double du2dphi1 = du1dphi1;
463 double dv2dphi1 = rvw*dw1dphi1;
464 double dw2dphi1 = rww*dw1dphi1;
466 double ddu2dphi1 = ddu1dphi1;
467 double ddv2dphi1 = rvw*ddw1dphi1;
468 double ddw2dphi1 = rww*ddw1dphi1;
470 double ddu2deta1 = ddu1deta1;
471 double ddv2deta1 = rvv*ddv1deta1 + rvw*ddw1deta1;
472 double ddw2deta1 = rwv*ddv1deta1 + rww*ddw1deta1;
476 double ddudw2ddu2 = 1. / dw2;
477 double ddudw2ddw2 = -dudw2 / dw2;
479 double ddvdw2ddv2 = 1. / dw2;
480 double ddvdw2ddw2 = -dvdw2 / dw2;
484 double ddudw2dphi1 = ddudw2ddu2*ddu2dphi1 + ddudw2ddw2*ddw2dphi1;
485 double ddudw2deta1 = ddudw2ddu2*ddu2deta1 + ddudw2ddw2*ddw2deta1;
487 double ddvdw2dphi1 = ddvdw2ddv2*ddv2dphi1 + ddvdw2ddw2*ddw2dphi1;
488 double ddvdw2deta1 = ddvdw2ddv2*ddv2deta1 + ddvdw2ddw2*ddw2deta1;
498 double dstdr1 = -dw2dr1;
499 double dstdv1 = -dw2dv1;
500 double dstdphi1 = -dw2dphi1;
504 du2dr1 += dstdr1 * dudw2;
505 double du2dv1 = dstdv1 * dudw2;
506 du2dphi1 += dstdphi1 * dudw2;
508 dv2dr1 += dstdr1 * dvdw2;
509 dv2dv1 += dstdv1 * dvdw2;
510 dv2dphi1 += dstdphi1 * dvdw2;
528 pm(2,2) = ddudw2dphi1;
529 pm(3,2) = ddvdw2dphi1;
534 pm(2,3) = ddudw2deta1;
535 pm(3,3) = ddvdw2deta1;
566 double sindphi = std::sin(phi2 - phi1);
567 double cosdphi = std::cos(phi2 - phi1);
571 double dudw1 = vec(2);
572 double dvdw1 = vec(3);
584 double dw2dw1 = cosdphi - dvdw1 * sindphi;
590 double dudw2 = dudw1 / dw2dw1;
591 double dvdw2 = (sindphi + dvdw1 * cosdphi) / dw2dw1;
605 <<
"unexpected direction #" << ((int) dir) <<
"\n";
610 if(prop_matrix != 0) {
612 pm.resize(vec.size(), vec.size(),
false);
622 pm(0,1) = dudw2 * sindphi;
623 pm(1,1) = cosdphi + dvdw2 * sindphi;
630 pm(2,2) = 1. / dw2dw1;
636 pm(2,3) = dudw1 * sindphi / (dw2dw1*dw2dw1);
637 pm(3,3) = 1. / (dw2dw1*dw2dw1);
668 double sinth1 = std::sin(theta1);
669 double costh1 = std::cos(theta1);
671 double sindphi = std::sin(phi2 - phi1);
672 double cosdphi = std::cos(phi2 - phi1);
676 double dudw1 = vec(2);
677 double dvdw1 = vec(3);
690 double rvu = -sinth1*sindphi;
691 double rvv = cosdphi;
692 double rvw = costh1*sindphi;
694 double rwu = -sinth1*cosdphi;
695 double rwv = -sindphi;
696 double rww = costh1*cosdphi;
703 double dw2dw1 = dudw1*rwu + dvdw1*rwv + rww;
709 double dudw2 = (dudw1*ruu + ruw) / dw2dw1;
710 double dvdw2 = (dudw1*rvu + dvdw1*rvv + rvw) / dw2dw1;
724 << __func__ <<
": unexpected direction #" << ((int) dir) <<
"\n";
729 if(prop_matrix != 0) {
731 pm.resize(vec.size(), vec.size(),
false);
735 pm(0,0) = ruu - dudw2*rwu;
736 pm(1,0) = rvu - dvdw2*rwu;
741 pm(0,1) = -dudw2*rwv;
742 pm(1,1) = rvv - dvdw2*rwv;
749 pm(2,2) = (ruu - dudw2*rwu) / dw2dw1;
750 pm(3,2) = (rvu - dvdw2*rwu) / dw2dw1;
755 pm(2,3) = -dudw2*rwv / dw2dw1;
756 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.
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
void setSurface(const std::shared_ptr< const Surface > &psurf)
Set surface.
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.
const TrackVector & getVector() const
Track state vector.
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.
PropYZPlane(double tcut, bool doDedx)
Constructor.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
double phi() const
Rotation angle about x-axis.
Interactor for planar surfaces.
Surface::TrackDirection getDirection() const
Track direction.
Line surface perpendicular to x-axis.
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.
virtual ~PropYZPlane()
Destructor.
cet::coded_exception< error, detail::translate > exception
bool isValid() const
Test if track is valid.
PropDirection
Propagation direction enum.