56 HepMatrix transform( 5, 5, 0 );
58 double tanDip = par.
tanDip();
59 double omega = par.
omega();
61 double darc = fltNew / sqrt( 1. + tanDip * tanDip );
62 double dphi = omega * darc;
63 double cosDphi =
cos( dphi );
64 double sinDphi =
sin( dphi );
68 transform[0][0] = cosDphi;
69 transform[0][1] = sinDphi / omega;
70 transform[0][2] = ( 1.0 - cosDphi ) / ( omega * omega );
74 transform[1][0] = -sinDphi * omega;
75 transform[1][1] = cosDphi;
76 transform[1][2] = sinDphi / omega;
80 transform[2][2] = 1.0;
84 transform[3][0] = -tanDip * sinDphi;
85 transform[3][1] = -tanDip * ( 1.0 - cosDphi ) / omega;
86 transform[3][2] = -tanDip * ( dphi - sinDphi ) / ( omega * omega );
88 transform[3][4] = darc;
106 double sign,
const BField& fieldmap ) {
114 register double phip, gamma, rho, pt;
115 static HepVector pars( 5 );
117 double px = pmom.x();
118 double py = pmom.y();
119 pt = sqrt( px * px + py * py );
121 if ( pt < 1.e-7 ) pt = 1.e-7;
122 if ( fabs( px ) < 1.e-7 ) px = ( px < 0.0 ) ? -1.e-7 : 1.e-7;
127 pars( 5 ) = pmom.z() / pt;
129 rho = 1. / pars( 3 );
130 phip = atan2( py, px );
131 double cosphip =
cos( phip );
132 double sinphip =
sin( phip );
135 atan( ( pos.x() * cosphip + pos.y() * sinphip ) /
136 ( 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 );
148 double sign,
const BField& fieldmap ) {
151 DifNumber xDF( pos.x(), 1, 6 ), yDF( pos.y(), 2, 6 ), zDF( pos.z(), 3, 6 );
156 static DifNumber phip, cosphip, sinphip, gamma;
161 invpt += pyDF * pyDF;
162 invpt = sqrt( invpt );
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;
194 atan( ( xDF * cosphip + yDF * sinphip ) / -pars( 1 ) );
196 pars( 1 ) /=
cos( gamma );
212 static HepSymMatrix posandmomErr( 6 );
213 static HepVector parsVec( 5 );
216 for ( i = 1; i <= 3; ++i )
219 for ( j = 1; j <= i; ++j )
222 posandmomErr.fast( i, j ) = pos.
covMatrix().fast( i, j );
223 posandmomErr.fast( i + 3, j + 3 ) = pmom.
covMatrix().fast( i, j );
225 for ( j = 1; j <= 3; ++j ) { posandmomErr.fast( j + 3, i ) = cxp( i, j ); }
227 for ( i = 1; i <= 5; ++i )
231 parsVec( i ) = pars( i ).number();
239 const HepMatrix& cxp,
double sign,
240 const BField& fieldmap ) {
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 ) );
280 pars( 2 ) = atan2( pyDF, pxDF );
285 pars( 1 ) -= xDF * pvyDF;
290 pars( 4 ) += yDF * pvyDF;
294 pars( 6 ) = pars( 4 );
295 pars( 6 ) *= pars( 3 );
298 pars( 4 ) *= -pars( 5 );
303 static HepSymMatrix posandmomErr( 6 );
304 static HepVector parsVec( 6 );
307 for ( i = 1; i <= 3; ++i )
310 for ( j = 1; j <= i; ++j )
313 posandmomErr.fast( i, j ) = pos.
covMatrix().fast( i, j );
314 posandmomErr.fast( i + 3, j + 3 ) = pmom.
covMatrix().fast( i, j );
316 for ( j = 1; j <= 3; ++j ) { posandmomErr.fast( j + 3, i ) = cxp( i, j ); }
318 for ( i = 1; i <= 6; ++i )
322 parsVec( i ) = pars( i ).number();
331 double d0 = hel.
d0();
332 double omega = hel.
omega();
333 double tanDip = hel.
tanDip();
337 if ( fabs( omega ) < 0.0001 ) omega = ( omega < 0.0 ) ? -0.0001 : 0.0001;
339 double stuff = (
rad *
rad - d0 * d0 ) / ( 1 + omega * d0 );
340 if ( stuff <= 0.0 )
return 0.;
342 if ( omega == 0. )
return sqrt( stuff );
343 double sinAngle = 0.5 * omega * sqrt( stuff );
345 if ( sinAngle < -1.0 || sinAngle > 1.0 ) { dist2d =
Constants::pi / fabs( omega ); }
346 else { dist2d = 2. * asin( sinAngle ) / omega; }
348 return dist2d * sqrt( 1. + tanDip * tanDip );