12 #include "cetlib_except/exception.h"
32 (tcut >= 0. ? std::make_shared<InteractPlane const>(
detProp, tcut) :
33 std::shared_ptr<Interactor const>{})}
52 const std::shared_ptr<const Surface>& psurf,
60 std::optional<double> result{std::nullopt};
66 if (to == 0)
return result;
67 double x02 = to->
x0();
68 double y02 = to->
y0();
69 double z02 = to->
z0();
70 double phi2 = to->
phi();
87 TrackMatrix* plocal_prop_matrix = (prop_matrix == 0 ? 0 : &local_prop_matrix);
88 std::optional<double> result1 =
origin_vec_prop(trk, psurf, plocal_prop_matrix);
89 if (!result1)
return result1;
95 throw cet::exception(
"PropYZPlane")
96 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
99 double dudw1 = vec(2);
100 double dvdw1 = vec(3);
101 double pinv = vec(4);
113 double sinphi2 = std::sin(phi2);
114 double cosphi2 = std::cos(phi2);
119 double u2 = x01 - x02 + u1;
120 double v2 = (y01 - y02) * cosphi2 + (z01 - z02) * sinphi2 + v1;
121 double w2 = -(y01 - y02) * sinphi2 + (z01 - z02) * cosphi2;
125 double u2p = u2 - w2 * dudw1;
126 double v2p = v2 - w2 * dvdw1;
130 double s = -w2 * std::sqrt(1. + dudw1 * dudw1 + dvdw1 * dvdw1);
150 auto pinv2 = std::make_optional(pinv);
152 double* pderiv = (prop_matrix != 0 ? &deriv : 0);
165 result = std::make_optional(s);
169 if (prop_matrix != 0) {
171 pm.resize(vec.size(), vec.size(),
false);
208 *prop_matrix = prod(pm, *plocal_prop_matrix);
213 if (noise_matrix != 0) {
214 noise_matrix->resize(vec.size(), vec.size(),
false);
223 noise_matrix->clear();
258 std::optional<double>
260 const std::shared_ptr<const Surface>& porient,
265 std::optional<double> result{std::nullopt};
276 throw cet::exception(
"PropYZPlane")
277 <<
"Track state vector has wrong size" << vec.size() <<
"\n";
292 if (orient == 0)
return result;
293 double phi2 = orient->
phi();
294 std::shared_ptr<const Surface> porigin(
new SurfYZPlane(x02, y02, z02, phi2));
303 double phi1 =
from->phi();
308 result = std::make_optional(0.);
309 if (!ok)
return std::nullopt;
316 double phi1 =
from->phi();
321 result = std::make_optional(0.);
322 if (!ok)
return std::nullopt;
329 double theta1 =
from->theta();
330 double phi1 =
from->phi();
335 result = std::make_optional(0.);
336 if (!ok)
return std::nullopt;
349 result = std::nullopt;
368 double sindphi = std::sin(phi2 - phi1);
369 double cosdphi = std::cos(phi2 - phi1);
374 double phid1 = vec(2);
375 double eta1 = vec(3);
380 double rvv = cosdphi;
381 double rvw = sindphi;
383 double rwv = -sindphi;
384 double rww = cosdphi;
388 double sinphid1 = std::sin(phid1);
389 double cosphid1 = std::cos(phid1);
390 double sh1 = 1. / std::cosh(eta1);
391 double th1 = std::tanh(eta1);
395 double u1 = -r1 * sinphid1;
396 double w1 = r1 * cosphid1;
400 double du2 = sh1 * cosphid1;
401 double dv2 = th1 * cosdphi + sh1 * sinphid1 * sindphi;
402 double dw2 = -th1 * sindphi + sh1 * sinphid1 * cosdphi;
410 dir = Surface::TrackDirection::FORWARD;
412 dir = Surface::TrackDirection::BACKWARD;
418 double dudw2 = du2 / dw2;
419 double dvdw2 = dv2 / dw2;
423 if (prop_matrix != 0) {
425 pm.resize(vec.size(), vec.size(),
false);
431 double du1dr1 = -sinphid1;
432 double du1dphi1 = -w1;
434 double dw1dr1 = cosphid1;
435 double dw1dphi1 = u1;
437 double ddu1dphi1 = -sinphid1 * sh1;
438 double ddu1deta1 = -cosphid1 * sh1 * th1;
440 double ddv1deta1 = sh1 * sh1;
442 double ddw1dphi1 = cosphid1 * sh1;
443 double ddw1deta1 = -sinphid1 * sh1 * th1;
447 double du2dr1 = du1dr1;
448 double dv2dr1 = rvw * dw1dr1;
449 double dw2dr1 = rww * dw1dr1;
454 double du2dphi1 = du1dphi1;
455 double dv2dphi1 = rvw * dw1dphi1;
456 double dw2dphi1 = rww * dw1dphi1;
458 double ddu2dphi1 = ddu1dphi1;
459 double ddv2dphi1 = rvw * ddw1dphi1;
460 double ddw2dphi1 = rww * ddw1dphi1;
462 double ddu2deta1 = ddu1deta1;
463 double ddv2deta1 = rvv * ddv1deta1 + rvw * ddw1deta1;
464 double ddw2deta1 = rwv * ddv1deta1 + rww * ddw1deta1;
468 double ddudw2ddu2 = 1. / dw2;
469 double ddudw2ddw2 = -dudw2 / dw2;
471 double ddvdw2ddv2 = 1. / dw2;
472 double ddvdw2ddw2 = -dvdw2 / dw2;
476 double ddudw2dphi1 = ddudw2ddu2 * ddu2dphi1 + ddudw2ddw2 * ddw2dphi1;
477 double ddudw2deta1 = ddudw2ddu2 * ddu2deta1 + ddudw2ddw2 * ddw2deta1;
479 double ddvdw2dphi1 = ddvdw2ddv2 * ddv2dphi1 + ddvdw2ddw2 * ddw2dphi1;
480 double ddvdw2deta1 = ddvdw2ddv2 * ddv2deta1 + ddvdw2ddw2 * ddw2deta1;
490 double dstdr1 = -dw2dr1;
491 double dstdv1 = -dw2dv1;
492 double dstdphi1 = -dw2dphi1;
496 du2dr1 += dstdr1 * dudw2;
497 double du2dv1 = dstdv1 * dudw2;
498 du2dphi1 += dstdphi1 * dudw2;
500 dv2dr1 += dstdr1 * dvdw2;
501 dv2dv1 += dstdv1 * dvdw2;
502 dv2dphi1 += dstdphi1 * dvdw2;
520 pm(2, 2) = ddudw2dphi1;
521 pm(3, 2) = ddvdw2dphi1;
526 pm(2, 3) = ddudw2deta1;
527 pm(3, 3) = ddvdw2deta1;
560 double sindphi = std::sin(phi2 - phi1);
561 double cosdphi = std::cos(phi2 - phi1);
565 double dudw1 = vec(2);
566 double dvdw1 = vec(3);
577 double dw2dw1 = cosdphi - dvdw1 * sindphi;
578 if (dw2dw1 == 0.)
return false;
582 double dudw2 = dudw1 / dw2dw1;
583 double dvdw2 = (sindphi + dvdw1 * cosdphi) / dw2dw1;
591 default:
throw cet::exception(
"PropYZPlane") <<
"unexpected direction #" << ((int)dir) <<
"\n";
596 if (prop_matrix != 0) {
598 pm.resize(vec.size(), vec.size(),
false);
608 pm(0, 1) = dudw2 * sindphi;
609 pm(1, 1) = cosdphi + dvdw2 * sindphi;
616 pm(2, 2) = 1. / dw2dw1;
622 pm(2, 3) = dudw1 * sindphi / (dw2dw1 * dw2dw1);
623 pm(3, 3) = 1. / (dw2dw1 * dw2dw1);
657 double sinth1 = std::sin(theta1);
658 double costh1 = std::cos(theta1);
660 double sindphi = std::sin(phi2 - phi1);
661 double cosdphi = std::cos(phi2 - phi1);
665 double dudw1 = vec(2);
666 double dvdw1 = vec(3);
678 double rvu = -sinth1 * sindphi;
679 double rvv = cosdphi;
680 double rvw = costh1 * sindphi;
682 double rwu = -sinth1 * cosdphi;
683 double rwv = -sindphi;
684 double rww = costh1 * cosdphi;
691 double dw2dw1 = dudw1 * rwu + dvdw1 * rwv + rww;
692 if (dw2dw1 == 0.)
return false;
696 double dudw2 = (dudw1 * ruu + ruw) / dw2dw1;
697 double dvdw2 = (dudw1 * rvu + dvdw1 * rvv + rvw) / dw2dw1;
706 throw cet::exception(
"PropXYZPlane")
707 << __func__ <<
": unexpected direction #" << ((int)dir) <<
"\n";
712 if (prop_matrix != 0) {
714 pm.resize(vec.size(), vec.size(),
false);
718 pm(0, 0) = ruu - dudw2 * rwu;
719 pm(1, 0) = rvu - dvdw2 * rwu;
724 pm(0, 1) = -dudw2 * rwv;
725 pm(1, 1) = rvv - dvdw2 * rwv;
732 pm(2, 2) = (ruu - dudw2 * rwu) / dw2dw1;
733 pm(3, 2) = (rvu - dvdw2 * rwu) / dw2dw1;
738 pm(2, 3) = -dudw2 * rwv / dw2dw1;
739 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.
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 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.
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.
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)
const TrackVector & getVector() const
Track state vector.
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
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.
then echo File list $list not found else cat $list while read file do echo $file sed s
Surface::TrackDirection getDirection() const
Track direction.
Line surface perpendicular to x-axis.
bool isValid() const
Test if track is valid.
PropDirection
Propagation direction enum.