17#include "CLHEP/Geometry/Point3D.h"
18#include "CLHEP/Matrix/Matrix.h"
19#include "CLHEP/Matrix/SymMatrix.h"
20#include "CLHEP/Vector/ThreeVector.h"
55 HepMatrix transform(5, 5, 0);
57 double tanDip = par.
tanDip();
58 double omega = par.
omega();
60 double darc = fltNew / sqrt(1. + tanDip * tanDip);
61 double dphi = omega * darc;
62 double cosDphi =
cos(dphi);
63 double sinDphi =
sin(dphi);
67 transform[0][0] = cosDphi;
68 transform[0][1] = sinDphi / omega;
69 transform[0][2] = (1.0-cosDphi) / (omega * omega);
73 transform[1][0] = -sinDphi * omega;
74 transform[1][1] = cosDphi;
75 transform[1][2] = sinDphi / omega;
79 transform[2][2] = 1.0;
83 transform[3][0] = -tanDip * sinDphi;
84 transform[3][1] = -tanDip * (1.0-cosDphi) / omega;
85 transform[3][2] = -tanDip * (dphi-sinDphi) / (omega*omega);
87 transform[3][4] = darc;
107 const Hep3Vector& pmom,
double sign,
const BField& fieldmap) {
115 register double phip,gamma,rho,pt;
116 static HepVector pars(5);
118 double px = pmom.x();
119 double py = pmom.y();
120 pt=sqrt(px*px+py*py);
122 if (pt < 1.e-7) pt = 1.e-7;
123 if (fabs(px) < 1.e-7) px = (px<0.0) ? -1.e-7 : 1.e-7;
132 double cosphip=
cos(phip);
double sinphip=
sin(phip);
134 gamma=atan((pos.x()*cosphip+pos.y()*sinphip)/
135 (pos.x()*sinphip-pos.y()*cosphip-rho));
139 pars(1)=(rho+pos.y()*cosphip-pos.x()*sinphip)/
cos(gamma)-rho;
140 pars(4)=pos.z()+rho*gamma*pars(5);
147 const BesVectorErr& pmom,
const HepMatrix& cxp,
double sign,
151 DifNumber xDF(pos.x(),1,6), yDF(pos.y(),2,6), zDF(pos.z(),3,6);
156 static DifNumber phip, cosphip, sinphip, gamma;
164 if (invpt < 1.e-7) invpt = 1.e-7;
165 if (fabs(pxDF) < 1.e-7) pxDF = pxDF<0?-1e-7:1e-7;
185 phip=atan2(pyDF,pxDF);
190 pars(1) += yDF*cosphip;
191 pars(1) -= xDF*sinphip;
193 gamma=atan((xDF*cosphip+yDF*sinphip)/ -pars(1));
195 pars(1) /=
cos(gamma);
213 static HepSymMatrix posandmomErr(6);
214 static HepVector parsVec(5);
217 for (i = 1; i <= 3; ++i) {
219 for (j = 1; j <= i; ++j) {
221 posandmomErr.fast(i,j) = pos.
covMatrix().fast(i,j);
222 posandmomErr.fast(i+3,j+3) = pmom.
covMatrix().fast(i,j);
224 for (j = 1; j <= 3; ++j) {
225 posandmomErr.fast(j+3,i) = cxp(i,j);
228 for (i = 1; i <= 5; ++i) {
231 parsVec(i) = pars(i).number();
239 const BesVectorErr& pmom,
const HepMatrix& cxp,
double sign,
243 DifNumber xDF(pos.x(),1,6), yDF(pos.y(),2,6), zDF(pos.z(),3,6);
254 if (pt < 1.e-14) pt = 1.e-14;
255 if (fabs(pxDF) < 1.e-7) pxDF = pxDF<0?-1e-7:1e-7;
261 pars(3) = sqrt(pars(3));
281 pars(2) = atan2(pyDF,pxDF);
286 pars(1) -= xDF*pvyDF;
291 pars(4) += yDF*pvyDF;
308 static HepSymMatrix posandmomErr(6);
309 static HepVector parsVec(6);
312 for (i = 1; i <= 3; ++i) {
314 for (j = 1; j <= i; ++j) {
316 posandmomErr.fast(i,j) = pos.
covMatrix().fast(i,j);
317 posandmomErr.fast(i+3,j+3) = pmom.
covMatrix().fast(i,j);
319 for (j = 1; j <= 3; ++j) {
320 posandmomErr.fast(j+3,i) = cxp(i,j);
323 for (i = 1; i <= 6; ++i) {
326 parsVec(i) = pars(i).number();
335 double d0 = hel.
d0();
336 double omega = hel.
omega();
337 double tanDip = hel.
tanDip();
341 if( fabs(omega) < 0.0001 ) omega = (omega<0.0) ? -0.0001 : 0.0001 ;
343 double stuff = (
rad*
rad - d0*d0 ) / (1 + omega * d0);
344 if (stuff <= 0.0)
return 0.;
346 if (omega == 0.)
return sqrt(stuff);
347 double sinAngle = 0.5 * omega * sqrt(stuff);
349 if (sinAngle < -1.0 || sinAngle > 1.0) {
352 dist2d = 2. * asin(sinAngle) / omega;
355 return dist2d * sqrt(1. + tanDip*tanDip);
double sin(const BesAngle a)
double cos(const BesAngle a)
double bFieldNominal() const
static const double cmTeslaToGeVc
const BesError & covMatrix() const
const BesError & covMatrix() const
HepMatrix jacobian() const
void cosAndSin(DifNumber &c, DifNumber &s) const
const HepSymMatrix & covariance() const
static HepMatrix jacobianExtrapolate(const TrkExchangePar &, double fltNew)
static NeutParams lineFromMomErr(const BesPointErr &vertex, const BesVectorErr &p, const HepMatrix &cxp, double sign, const BField &)
static double fltToRad(const TrkExchangePar &hel, double rad)
static HepSymMatrix extrapolateCov(TrkExchangePar &, double fltNew)
static TrkExchangePar helixFromMom(const HepPoint3D &vertex, const Hep3Vector &p, double sign, const BField &)
static TrkExchangePar helixFromMomErr(const BesPointErr &vertex, const BesVectorErr &p, const HepMatrix &cxp, double sign, const BField &)