16# if defined( __EXTENSIONS__ )
19# define __EXTENSIONS__
23#elif defined( __GNUC__ )
24# if defined( _XOPEN_SOURCE )
35#include "CLHEP/Matrix/DiagMatrix.h"
36#include "CLHEP/Matrix/Matrix.h"
37#include "CLHEP/Matrix/SymMatrix.h"
38#include "CLHEP/Matrix/Vector.h"
39#include "TrkReco/TCircle.h"
40#include "TrkReco/TMDCUtil.h"
41#include "TrkReco/TMDCWire.h"
42#include "TrkReco/TMDCWireHit.h"
43#include "TrkReco/TMDCWireHitMC.h"
44#include "TrkReco/TMLine.h"
45#include "TrkReco/TMLink.h"
47#include "TrkReco/TSegment.h"
48#include "TrkReco/TTrack.h"
53#include "MdcTables/HepevtTables.h"
54#include "MdcTables/MdcTables.h"
55#include "MdcTables/MdstTables.h"
56#include "MdcTables/TrkTables.h"
58#include "CLHEP/Matrix/Matrix.h"
59#include "GaudiKernel/Bootstrap.h"
60#include "GaudiKernel/IDataProviderSvc.h"
61#include "GaudiKernel/IInterface.h"
62#include "GaudiKernel/IMessageSvc.h"
63#include "GaudiKernel/ISvcLocator.h"
64#include "GaudiKernel/Kernel.h"
65#include "GaudiKernel/MsgStream.h"
66#include "GaudiKernel/Service.h"
67#include "GaudiKernel/SmartDataPtr.h"
68#include "GaudiKernel/StatusCode.h"
70using CLHEP::HepDiagMatrix;
71using CLHEP::HepMatrix;
72using CLHEP::HepSymMatrix;
73using CLHEP::HepVector;
88 , m_pmgnIMF( nullptr ) {
93 fitter( &TTrack::_fitter );
97 a[1] = fmod( atan2( _charge * ( c.
center().y() -
ORIGIN.y() ),
103 const double Bz = -1000 * getPmgnIMF()->getReferField();
104 a[2] = 333.564095 / ( c.
radius() * Bz );
112 for (
unsigned i = 0; i <
n; i++ )
_links[i]->track(
this );
128 , _charge( a._charge )
129 , _segments( a._segments )
130 , _helix( new
Helix( *a._helix ) )
133 , _name(
"copy of " + a._name )
136 , _mother( a._mother )
137 , _daughter( a._daughter )
138 , m_pmgnIMF( nullptr ) {}
163 , m_pmgnIMF( nullptr ) {
164 if ( _helix->kappa() > 0. ) _charge = 1.;
170 , _helix( new
Helix( h ) )
178 , m_pmgnIMF( nullptr ) {
181 fitter( &TTrack::_fitter );
183 if ( _helix->kappa() > 0. ) _charge = 1.;
196 , _name(
"empty track" )
200 , m_pmgnIMF( nullptr ) {}
204void TTrack::dump(
const std::string& msg,
const std::string& pre0 )
const {
206 if ( msg ==
"" ) def =
true;
207 std::string pre = pre0;
209 for (
unsigned i = 0; i < pre.length(); i++ ) tab +=
" ";
210 if ( def || msg.find(
"track" ) != std::string::npos ||
211 msg.find(
"detail" ) != std::string::npos )
213 std::cout << pre <<
p() <<
"(pt=" <<
pt() <<
")" << std::endl
214 << tab <<
"links=" <<
_links.length() <<
"(cores=" <<
nCores()
215 <<
"),chrg=" << _charge <<
",ndf=" << _ndf <<
",chi2=" << _chi2 << std::endl;
218 if ( msg.find(
"helix" ) != std::string::npos || msg.find(
"detail" ) != std::string::npos )
220 std::cout << pre <<
"pivot=" << _helix->pivot() <<
",center=" << _helix->center()
222 << pre <<
"helix=(" << _helix->a()[0] <<
"," << _helix->a()[1] <<
","
223 << _helix->a()[2] <<
"," << _helix->a()[3] <<
"," << _helix->a()[4] <<
")"
234 std::cout <<
"TTrack::movePivot !!! can't move a pivot"
235 <<
" because of no link";
236 std::cout << std::endl;
246 unsigned innerMost = 0;
247 unsigned innerMostLayer = ( *links )[0]->wire()->layerId();
249 for (
unsigned i = 1; i <
n; i++ )
251 TMLink* l = ( *links )[i];
260 HepPoint3D newPivot = ( *links )[innerMost]->positionOnWire();
262 _helix->pivot( newPivot );
270 for (
unsigned i = 0; i <
n; ++i )
272 if (
_links[i]->pull() > maxSigma ) bad.append(
_links[i] );
283int TTrack::HelCyl(
double rhole,
double rCyl,
double zb,
double zf,
double epsl,
double& phi,
308 if (
int( _charge ) == 0 )
310 std::cout <<
"HelCyl gets a straight line !!" << std::endl;
318 double rTrk = fabs( _helix->radius() );
320 double rPivot = fabs( _helix->pivot().perp() );
322 double phi0 = _helix->a()[1];
323 double tanl = _helix->a()[4];
333 if (
intersection( CenterTrk, _charge * rTrk, CenterCyl, rCyl, epsl, Cross1, Cross2 ) == 2 )
336 double phiCyl = atan2( _charge * ( CenterTrk.y() - Cross1.y() ),
337 _charge * ( CenterTrk.x() - Cross1.x() ) );
338 phiCyl = ( phiCyl > 0. ) ? phiCyl : phiCyl + 2. *
M_PI;
340 dPhi = phiCyl - phi0;
345 double PhiYobun = 1. / fabs( _helix->radius() );
346 double zero = 0.00001;
350 if ( dPhi > PhiYobun ) dPhi -= 2. *
M_PI;
351 if ( -2. *
M_PI -
zero <= dPhi <= ( -2. *
M_PI + PhiYobun ) ) dPhi += 2. *
M_PI;
356 if ( dPhi < -PhiYobun ) dPhi += 2. *
M_PI;
357 if ( 2. *
M_PI +
zero >= dPhi >= ( 2. *
M_PI - PhiYobun ) ) dPhi -= 2. *
M_PI;
360 if ( dPhi < -
M_PI ) dPhi += 2. *
M_PI;
361 if ( dPhi >=
M_PI ) dPhi -= 2. *
M_PI;
367 xp.setX( Cross1.x() );
368 xp.setY( Cross1.y() );
369 xp.setZ( _helix->x( dPhi ).z() );
372 if ( xp.z() > zb && xp.z() < zf )
385 if ( fabs( tanl ) < 0.1 )
405 dPhi = _charge * ( _helix->x( 0. ).z() - zee ) / rTrk / tanl;
410 if ( fabs( dPhi ) > 2. *
M_PI )
419 xp.setX( _helix->x( dPhi ).x() );
420 xp.setY( _helix->x( dPhi ).y() );
423 double test = xp.perp2() - rhole * rhole;
763 double rho = 333.564095 / ( kappa * Bz );
764 double tanLambda = a[4];
766 double sinPhi0 =
sin( phi0 );
767 double cosPhi0 =
cos( phi0 );
768 double sinPhi0dPhi =
sin( phi0 + dPhi );
769 double cosPhi0dPhi =
cos( phi0 + dPhi );
792 c =
HepPoint3D(
w.backwardPosition() - (
v *
w.backwardPosition() ) *
v );
798 dxdphi[0] = rho * sinPhi0dPhi;
799 dxdphi[1] = -rho * cosPhi0dPhi;
800 dxdphi[2] = -rho * tanLambda;
803 d2xdphi2[0] = rho * cosPhi0dPhi;
804 d2xdphi2[1] = rho * sinPhi0dPhi;
807 double dxdphi_dot_v = dxdphi[0] *
v.x() + dxdphi[1] *
v.y() + dxdphi[2] *
v.z();
808 double x_dot_v = x[0] *
v.x() + x[1] *
v.y() + x[2] *
v.z();
810 double dfdphi = -( dxdphi[0] - dxdphi_dot_v *
v.x() ) * dxdphi[0] -
811 ( dxdphi[1] - dxdphi_dot_v *
v.y() ) * dxdphi[1] -
812 ( dxdphi[2] - dxdphi_dot_v *
v.z() ) * dxdphi[2] -
813 ( x[0] - c[0] - x_dot_v *
v.x() ) * d2xdphi2[0] -
814 ( x[1] - c[1] - x_dot_v *
v.y() ) * d2xdphi2[1];
819 dxda_phi[0] = cosPhi0;
820 dxda_phi[1] = -( dRho + rho ) * sinPhi0 + rho * sinPhi0dPhi;
821 dxda_phi[2] = -( rho / kappa ) * ( cosPhi0 - cosPhi0dPhi );
826 dyda_phi[0] = sinPhi0;
827 dyda_phi[1] = ( dRho + rho ) * cosPhi0 - rho * cosPhi0dPhi;
828 dyda_phi[2] = -( rho / kappa ) * ( sinPhi0 - sinPhi0dPhi );
835 dzda_phi[2] = ( rho / kappa ) * tanLambda * dPhi;
837 dzda_phi[4] = -rho * dPhi;
841 d2xdphida[1] = rho * cosPhi0dPhi;
842 d2xdphida[2] = -( rho / kappa ) * sinPhi0dPhi;
848 d2ydphida[1] = rho * sinPhi0dPhi;
849 d2ydphida[2] = ( rho / kappa ) * cosPhi0dPhi;
856 d2zdphida[2] = ( rho / kappa ) * tanLambda;
861 for (
int i = 0; i < 5; i++ )
863 double d_dot_v =
v.x() * dxda_phi[i] +
v.y() * dyda_phi[i] +
v.z() * dzda_phi[i];
864 dfda[i] = -( dxda_phi[i] - d_dot_v *
v.x() ) * dxdphi[0] -
865 ( dyda_phi[i] - d_dot_v *
v.y() ) * dxdphi[1] -
866 ( dzda_phi[i] - d_dot_v *
v.z() ) * dxdphi[2] -
867 ( x[0] - c[0] - x_dot_v *
v.x() ) * d2xdphida[i] -
868 ( x[1] - c[1] - x_dot_v *
v.y() ) * d2ydphida[i] -
869 ( x[2] - c[2] - x_dot_v *
v.z() ) * d2zdphida[i];
870 dphida[i] = -dfda[i] / dfdphi;
874 dxda[0] = cosPhi0 + rho * sinPhi0dPhi * dphida[0];
875 dxda[1] = -( dRho + rho ) * sinPhi0 + rho * sinPhi0dPhi * ( 1. + dphida[1] );
876 dxda[2] = -rho / kappa * ( cosPhi0 - cosPhi0dPhi ) + rho * sinPhi0dPhi * dphida[2];
877 dxda[3] = rho * sinPhi0dPhi * dphida[3];
878 dxda[4] = rho * sinPhi0dPhi * dphida[4];
880 dyda[0] = sinPhi0 - rho * cosPhi0dPhi * dphida[0];
881 dyda[1] = ( dRho + rho ) * cosPhi0 - rho * cosPhi0dPhi * ( 1. + dphida[1] );
882 dyda[2] = -rho / kappa * ( sinPhi0 - sinPhi0dPhi ) - rho * cosPhi0dPhi * dphida[2];
883 dyda[3] = -rho * cosPhi0dPhi * dphida[3];
884 dyda[4] = -rho * cosPhi0dPhi * dphida[4];
886 dzda[0] = -rho * tanLambda * dphida[0];
887 dzda[1] = -rho * tanLambda * dphida[1];
888 dzda[2] = rho / kappa * tanLambda * dPhi - rho * tanLambda * dphida[2];
889 dzda[3] = 1. - rho * tanLambda * dphida[3];
890 dzda[4] = -rho * dPhi - rho * tanLambda * dphida[4];
898# ifdef TRKRECO_DEBUG_DETAIL
899 std::cout <<
" TTrack::fit2D(r-phi) ..." << std::endl;
904 if (
_links.length() < 4 )
return -1;
909 Vector da( 5 ), dxda( 5 ), dyda( 5 ), dzda( 5 );
910 Vector dDda( 5 ), dchi2da( 5 );
913 double chi2Old = 1.0e+99;
914 const double convergence = 1.0e-5;
921 while ( nTrial < 100 )
923# ifdef TRKRECO_DEBUG_DETAIL
924 if ( a[3] != 0. || a[4] != 0. )
925 cerr <<
"Error in 2D functions of TTrack : a = " << a << std::endl;
929 for (
unsigned j = 0; j < 5; ++j ) dchi2da[j] = 0.;
940 double dPhi = l->dPhi();
941 const HepPoint3D& onTrack = l->positionOnTrack();
942 const HepPoint3D& onWire = l->positionOnWire();
943# ifdef TRKRECO_DEBUG_DETAIL
944 if ( onTrack.z() != 0. )
945 cerr <<
"Error in 2D functions of TTrack : onTrack = " << onTrack << std::endl;
946 if ( onWire.z() != 0. )
947 cerr <<
"Error in 2D functions of TTrack : onWire = " << onWire << std::endl;
949 HepPoint3D onTrack2( onTrack.x(), onTrack.y(), 0. );
950 HepPoint3D onWire2( onWire.x(), onWire.y(), 0. );
954 if ( onWire2.cross( onTrack2 ).z() < 0. ) leftRight =
WireHitLeft;
955 double distance = h.distance( leftRight );
956 double eDistance = h.dDistance( leftRight );
957 double eDistance2 = eDistance * eDistance;
961 double vmag =
v.mag();
965 this->dxda2D( *l, dPhi, dxda, dyda, dzda );
969 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 5, 0 );
983 std::cout <<
" in fit2D " << onTrack <<
", " << onWire;
986 dchi2da += ( dDistance / eDistance2 ) * dDda;
987 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
988 double pChi2 = dDistance * dDistance / eDistance2;
992 l->update( onTrack2, onWire2, leftRight, pChi2 );
996 double change = chi2Old -
chi2;
997 if ( fabs( change ) < convergence )
break;
1000# ifdef TRKRECO_DEBUG_DETAIL
1001 std::cout <<
"chi2Old, chi2=" << chi2Old <<
" " <<
chi2 << std::endl;
1008 for (
unsigned j = 0; j < 5; ++j ) dchi2da[j] = 0.;
1019 double dPhi = l->dPhi();
1020 const HepPoint3D& onTrack = l->positionOnTrack();
1021 const HepPoint3D& onWire = l->positionOnWire();
1022 HepPoint3D onTrack2( onTrack.x(), onTrack.y(), 0. );
1023 HepPoint3D onWire2( onWire.x(), onWire.y(), 0. );
1027 if ( onWire2.cross( onTrack2 ).z() < 0. ) leftRight =
WireHitLeft;
1028 double distance = h.distance( leftRight );
1029 double eDistance = h.dDistance( leftRight );
1030 double eDistance2 = eDistance * eDistance;
1034 double vmag =
v.mag();
1035 double dDistance = vmag -
distance;
1038 this->dxda2D( *l, dPhi, dxda, dyda, dzda );
1041 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 5, 0 );
1044 std::cout <<
" in fit2D " << onTrack <<
", " << onWire;
1047 dchi2da += ( dDistance / eDistance2 ) * dDda;
1048 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
1049 double pChi2 = dDistance * dDistance / eDistance2;
1053 l->update( onTrack2, onWire2, leftRight, pChi2 );
1057# ifdef TRKRECO_DEBUG_DETAIL
1058 std::cout <<
"factor = " << factor << std::endl;
1059 std::cout <<
"chi2 = " <<
chi2 << std::endl;
1061 if ( factor < 0.01 )
break;
1067 f = dchi2da.sub( 1, 3 );
1068 e = d2chi2d2a.sub( 1, 3 );
1090 Ea[0][0] = Ec[0][0];
1091 Ea[0][1] = Ec[0][1];
1092 Ea[0][2] = Ec[0][2];
1093 Ea[1][1] = Ec[1][1];
1094 Ea[1][2] = Ec[1][2];
1095 Ea[2][2] = Ec[2][2];
1104 _ndf =
_links.length() - dim;
1514 const TMDCWireHit& h = *link.
hit();
1523 double vmag2 =
v.mag2();
1524 double vmag = sqrt( vmag2 );
1527 arcZList.removeAll();
1530 if ( vmag == 0. ) {
return -1; }
1532 double r = _helix->curv();
1537 double wv =
w.dot(
v );
1539 d2[0] = vmag2 *
R[0] *
R[0] +
1540 ( wv * wv - vmag2 *
w.mag2() );
1541 d2[1] = vmag2 *
R[1] *
R[1] +
1542 ( wv * wv - vmag2 *
w.mag2() );
1545 if ( d2[0] < 0. && d2[1] < 0. ) {
return -1; }
1547 bool ok_inner, ok_outer;
1554 if ( d2[0] >= 0. ) { d[0] = sqrt( d2[0] ); }
1555 else { ok_outer =
false; }
1556 if ( d2[1] >= 0. ) { d[1] = sqrt( d2[1] ); }
1557 else { ok_inner =
false; }
1562 for (
int i=0; i<2; i++){
1563 for (
int j=0; j<2; j++){
1571 ( -wv + d[0] ) / vmag2;
1573 ( -wv - d[0] ) / vmag2;
1574 z[0][0] = X.z() + l[0][0] * V.z();
1575 z[1][0] = X.z() + l[1][0] * V.z();
1581 ( -wv + d[1] ) / vmag2;
1583 ( -wv - d[1] ) / vmag2;
1584 z[0][1] = X.z() + l[0][1] * V.z();
1585 z[1][1] = X.z() + l[1][1] * V.z();
1592 p[0][0] =
x + l[0][0] *
v;
1593 p[1][0] =
x + l[1][0] *
v;
1596 p[0][0] -= drift / pc0.mag() * pc0;
1599 p[1][0] -= drift / pc1.mag() * pc1;
1603 p[0][1] =
x + l[0][1] *
v;
1604 p[1][1] =
x + l[1][1] *
v;
1607 p[0][1] += drift / pc0.mag() * pc0;
1610 p[1][1] += drift / pc1.mag() * pc1;
1622 ok_xy[0][0] =
false;
1623 ok_xy[1][0] =
false;
1632 ok_xy[0][1] =
false;
1633 ok_xy[1][1] =
false;
1637 if ( _charge * (
center.x() *
p[0][0].y() -
center.y() *
p[0][0].x() ) < 0. )
1638 ok_xy[0][0] =
false;
1639 if ( _charge * (
center.x() *
p[1][0].y() -
center.y() *
p[1][0].x() ) < 0. )
1640 ok_xy[1][0] =
false;
1644 if ( _charge * (
center.x() *
p[0][1].y() -
center.y() *
p[0][1].x() ) < 0. )
1645 ok_xy[0][1] =
false;
1646 if ( _charge * (
center.x() *
p[1][1].y() -
center.y() *
p[1][1].x() ) < 0. )
1647 ok_xy[1][1] =
false;
1649 if ( !ok_inner && ok_outer && ( !ok_xy[0][0] ) && ( !ok_xy[1][0] ) ) {
return -1; }
1650 if ( ok_inner && !ok_outer && ( !ok_xy[0][1] ) && ( !ok_xy[1][1] ) ) {
return -1; }
1653 std::cout <<
"Drift Dist. = " << h.distance(
WireHitLeft) << std::endl;
1654 std::cout <<
"outer ok? = " << ok_outer << std::endl;
1655 std::cout <<
"Z cand = " << z[0][0] <<
", " << z[1][0] << std::endl;
1656 std::cout <<
"inner ok? = " << ok_inner << std::endl;
1657 std::cout <<
"Z cand = " << z[0][1] <<
", " << z[1][1] << std::endl;
1665 ok_xy[0][0] =
false;
1671 ok_xy[1][0] =
false;
1677 ok_xy[0][1] =
false;
1683 ok_xy[1][1] =
false;
1685 if ( ( !ok_xy[0][0] ) && ( !ok_xy[1][0] ) && ( !ok_xy[0][1] ) && ( !ok_xy[1][1] ) )
1688 double cosdPhi, dPhi;
1694 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
1695 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
1696 else { dPhi =
M_PI; }
1699 arcZ->setX( r * dPhi );
1700 arcZ->setY( z[0][0] );
1701 arcZList.append( arcZ );
1707 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
1708 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
1709 else { dPhi =
M_PI; }
1712 arcZ->setX( r * dPhi );
1713 arcZ->setY( z[1][0] );
1714 arcZList.append( arcZ );
1720 if ( cosdPhi > 1.0 ) cosdPhi = 1.0;
1721 if ( cosdPhi < -1.0 ) cosdPhi = -1.0;
1723 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
1724 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
1725 else { dPhi =
M_PI; }
1728 arcZ->setX( r * dPhi );
1729 arcZ->setY( z[0][1] );
1730 arcZList.append( arcZ );
1736 if ( cosdPhi > 1.0 ) cosdPhi = 1.0;
1737 if ( cosdPhi < -1.0 ) cosdPhi = -1.0;
1738 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
1739 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
1740 else { dPhi =
M_PI; }
1743 arcZ->setX( r * dPhi );
1744 arcZ->setY( z[1][1] );
1745 arcZList.append( arcZ );
1748 if ( arcZList.length() == 1 || arcZList.length() == 2 ) {
return 0; }
1753 int flag1 = 0, flag2 = 0;
1754 double minZ = 9999999.;
1756 AList<HepPoint3D> arcZList1;
1757 AList<HepPoint3D> arcZList2;
1763 int n1 = arcZList1.length();
1764 int n2 = arcZList2.length();
1765 for (
int i = 0; i <
n1; i++ )
1767 for (
int j = 0; j <
n2; j++ )
1769 if ( fabs( arcZList1[i]->y() - arcZList2[j]->y() ) < minZ )
1771 minZ = fabs( arcZList1[i]->y() - arcZList2[j]->y() );
1780 if ( minZ == 9999999. )
1797# if defined( __GNUG__ )
1799 if ( ( *a )->x() < ( *b )->x() ) {
return 1; }
1800 else if ( ( *a )->x() == ( *b )->x() ) {
return 0; }
1804extern "C" int TArcOrder(
const void* av,
const void* bv ) {
1807 if ( ( *a )->x() < ( *b )->x() ) {
return 1; }
1808 else if ( ( *a )->x() == ( *b )->x() ) {
return 0; }
1820 int flag1 = 0, flag2 = 0, flag3 = 0;
1821 double minZ1 = 9999999.;
1822 double minZ2 = 9999999.;
1823 double minZ01 = 9999999.;
1824 double minZ12 = 9999999.;
1826 AList<HepPoint3D> arcZList1;
1827 AList<HepPoint3D> arcZList2;
1828 AList<HepPoint3D> arcZList3;
1833 if ( ( ok1 != 0 && ok2 != 0 && ok3 != 0 ) || ( ok1 == 0 && ok2 != 0 && ok3 != 0 ) ||
1834 ( ok1 != 0 && ok2 == 0 && ok3 != 0 ) || ( ok1 != 0 && ok2 != 0 && ok3 == 0 ) ||
1835 ( ok1 == 0 && ok2 != 0 && ok3 == 0 ) )
1842 if ( ok1 == 0 && ok2 == 0 && ok3 == 0 )
1846 int n1 = arcZList1.length();
1847 int n2 = arcZList2.length();
1848 int n3 = arcZList3.length();
1849 for (
int i = 0; i <
n1; i++ )
1851 for (
int j = 0; j <
n2; j++ )
1853 for (
int k = 0; k < n3; k++ )
1855 AList<HepPoint3D> arcZ;
1856 arcZ.append( *arcZList1[i] );
1857 arcZ.append( *arcZList2[j] );
1858 arcZ.append( *arcZList3[k] );
1859 arcZ.sort( TArcOrder );
1860 double z01 = fabs( arcZ[0]->y() - arcZ[1]->y() );
1861 double z12 = fabs( arcZ[1]->y() - arcZ[2]->y() );
1862 if ( z01 <= minZ1 && z12 <= minZ2 )
1873 if ( minZ1 == 9999999. || minZ2 == 9999999. )
1888 else if ( ok1 == 0 && ok2 == 0 && ok3 != 0 )
1890 int n1 = arcZList1.length();
1891 int n2 = arcZList2.length();
1892 for (
int i = 0; i <
n1; i++ )
1894 for (
int j = 0; j <
n2; j++ )
1896 if ( fabs( arcZList1[i]->y() - arcZList2[j]->y() ) < minZ01 )
1898 minZ01 = fabs( arcZList1[i]->y() - arcZList2[j]->y() );
1904 if ( minZ01 == 9999999. )
1917 else if ( ok1 != 0 && ok2 == 0 && ok3 == 0 )
1919 int n2 = arcZList2.length();
1920 int n3 = arcZList3.length();
1921 for (
int i = 0; i <
n2; i++ )
1923 for (
int j = 0; j < n3; j++ )
1925 if ( fabs( arcZList2[i]->y() - arcZList3[j]->y() ) < minZ12 )
1927 minZ12 = fabs( arcZList2[i]->y() - arcZList3[j]->y() );
1933 if ( minZ12 == 9999999. )
1954 HepAListDeleteAll( l1 );
1955 HepAListDeleteAll( l2 );
1960 HepAListDeleteAll( l1 );
1961 HepAListDeleteAll( l2 );
1962 HepAListDeleteAll( l3 );
1967 if ( list.length() == 0 )
return -1;
1971 double r = fabs( _helix->curv() );
1972 for (
unsigned i = 0, size = list.length(); i < size; ++i )
1980 double vmag2 =
v.mag2();
1981 double vmag = sqrt( vmag2 );
1983 for (
unsigned j = 0; j < 4; ++j ) list[i]->arcZ( tmp, j );
1986 if ( vmag == 0. )
continue;
1989 double R[2] = { r + drift, r - drift };
1990 double wv =
w.dot(
v );
1992 d2[0] = vmag2 * R[0] * R[0] +
1993 ( wv * wv - vmag2 *
w.mag2() );
1994 d2[1] = vmag2 * R[1] * R[1] +
1995 ( wv * wv - vmag2 *
w.mag2() );
1998 if ( d2[0] < 0. && d2[1] < 0. )
continue;
2000 bool ok_inner(
true );
2001 bool ok_outer(
true );
2002 double d[2] = { -1., -1. };
2004 if ( d2[0] >= 0. ) { d[0] = sqrt( d2[0] ); }
2005 else { ok_outer =
false; }
2006 if ( d2[1] >= 0. ) { d[1] = sqrt( d2[1] ); }
2007 else { ok_inner =
false; }
2012 for (
int i=0; i<2; i++){
2013 for (
int j=0; j<2; j++){
2020 l[0][0] = ( -wv + d[0] ) /
2022 l[1][0] = ( -wv - d[0] ) /
2024 z[0][0] = X.z() + l[0][0] * V.z();
2025 z[1][0] = X.z() + l[1][0] * V.z();
2030 l[0][1] = ( -wv + d[1] ) /
2032 l[1][1] = ( -wv - d[1] ) /
2034 z[0][1] = X.z() + l[0][1] * V.z();
2035 z[1][1] = X.z() + l[1][1] * V.z();
2045 p[0][0] = x + l[0][0] *
v;
2046 p[1][0] = x + l[1][0] *
v;
2053 p[0][0] -= drift / pc0.mag() * pc0;
2056 p[1][0] -= drift / pc1.mag() * pc1;
2061 p[0][1] = x + l[0][1] *
v;
2062 p[1][1] = x + l[1][1] *
v;
2069 p[0][1] += drift / pc0.mag() * pc0;
2072 p[1][1] += drift / pc1.mag() * pc1;
2084 ok_xy[0][0] =
false;
2085 ok_xy[1][0] =
false;
2094 ok_xy[0][1] =
false;
2095 ok_xy[1][1] =
false;
2099 if ( _charge * (
center.x() *
p[0][0].y() -
center.y() *
p[0][0].x() ) < 0. )
2100 ok_xy[0][0] =
false;
2101 if ( _charge * (
center.x() *
p[1][0].y() -
center.y() *
p[1][0].x() ) < 0. )
2102 ok_xy[1][0] =
false;
2106 if ( _charge * (
center.x() *
p[0][1].y() -
center.y() *
p[0][1].x() ) < 0. )
2107 ok_xy[0][1] =
false;
2108 if ( _charge * (
center.x() *
p[1][1].y() -
center.y() *
p[1][1].x() ) < 0. )
2109 ok_xy[1][1] =
false;
2111 if ( !ok_inner && ok_outer && ( !ok_xy[0][0] ) && ( !ok_xy[1][0] ) ) {
continue; }
2112 if ( ok_inner && !ok_outer && ( !ok_xy[0][1] ) && ( !ok_xy[1][1] ) ) {
continue; }
2119 ok_xy[0][0] =
false;
2125 ok_xy[1][0] =
false;
2131 ok_xy[0][1] =
false;
2137 ok_xy[1][1] =
false;
2139 if ( ( !ok_xy[0][0] ) && ( !ok_xy[1][0] ) && ( !ok_xy[0][1] ) && ( !ok_xy[1][1] ) )
2141 double cosdPhi, dPhi;
2148 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
2149 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
2150 else { dPhi =
M_PI; }
2151 list[i]->arcZ(
HepPoint3D( r * dPhi, z[0][0], 0. ), index );
2159 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
2160 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
2161 else { dPhi =
M_PI; }
2162 list[i]->arcZ(
HepPoint3D( r * dPhi, z[1][0], 0. ), index );
2170 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
2171 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
2172 else { dPhi =
M_PI; }
2173 list[i]->arcZ(
HepPoint3D( r * dPhi, z[0][1], 0. ), index );
2181 if ( fabs( cosdPhi ) < 1.0 ) { dPhi = acos( cosdPhi ); }
2182 else if ( cosdPhi >= 1.0 ) { dPhi = 0.; }
2183 else { dPhi =
M_PI; }
2184 list[i]->arcZ(
HepPoint3D( r * dPhi, z[1][1], 0. ), index );
2190 double gmaxX = -9999., gminX = 9999.;
2191 double gmaxY = -9999., gminY = 9999.;
2192 FILE * gnuplot, *
data;
2194 double dStep = 2. *
M_PI / step;
2195 if ( (
data = fopen(
"dat1",
"w" ) ) != NULL )
2199 for (
int ii = 0; ii < step; ++ii )
2201 double X = tp[0][0].x() + drift *
cos( dStep *
static_cast<double>( ii ) );
2202 double Y = tp[0][0].y() + drift *
sin( dStep *
static_cast<double>( ii ) );
2203 fprintf(
data,
"%lf, %lf\n", X, Y );
2204 if ( gmaxX < X ) gmaxX = X;
2205 if ( gminX > X ) gminX = X;
2206 if ( gmaxY < Y ) gmaxY = Y;
2207 if ( gminY > Y ) gminY = Y;
2212 if ( (
data = fopen(
"dat2",
"w" ) ) != NULL )
2216 for (
int ii = 0; ii < step; ++ii )
2218 double X = tp[1][0].x() + drift *
cos( dStep *
static_cast<double>( ii ) );
2219 double Y = tp[1][0].y() + drift *
sin( dStep *
static_cast<double>( ii ) );
2220 fprintf(
data,
"%lf, %lf\n", X, Y );
2221 if ( gmaxX < X ) gmaxX = X;
2222 if ( gminX > X ) gminX = X;
2223 if ( gmaxY < Y ) gmaxY = Y;
2224 if ( gminY > Y ) gminY = Y;
2229 if ( (
data = fopen(
"dat3",
"w" ) ) != NULL )
2233 for (
int ii = 0; ii < step; ++ii )
2235 double X = tp[0][1].x() + drift *
cos( dStep *
static_cast<double>( ii ) );
2236 double Y = tp[0][1].y() + drift *
sin( dStep *
static_cast<double>( ii ) );
2237 fprintf(
data,
"%lf, %lf\n", X, Y );
2238 if ( gmaxX < X ) gmaxX = X;
2239 if ( gminX > X ) gminX = X;
2240 if ( gmaxY < Y ) gmaxY = Y;
2241 if ( gminY > Y ) gminY = Y;
2246 if ( (
data = fopen(
"dat4",
"w" ) ) != NULL )
2250 for (
int ii = 0; ii < step; ++ii )
2252 double X = tp[1][1].x() + drift *
cos( dStep *
static_cast<double>( ii ) );
2253 double Y = tp[1][1].y() + drift *
sin( dStep *
static_cast<double>( ii ) );
2254 fprintf(
data,
"%lf, %lf\n", X, Y );
2255 if ( gmaxX < X ) gmaxX = X;
2256 if ( gminX > X ) gminX = X;
2257 if ( gmaxY < Y ) gmaxY = Y;
2258 if ( gminY > Y ) gminY = Y;
2265 double tD = tDist.mag();
2266 double vvvM = 1. /
v.mag();
2270 if ( (
data = fopen(
"dat5",
"w" ) ) != NULL )
2272 for (
int ii = 0; ii < step + 1; ++ii )
2278 fprintf(
data,
"%lf, %lf\n", X, Y );
2279 if ( gmaxX < X ) gmaxX = X;
2280 if ( gminX > X ) gminX = X;
2281 if ( gmaxY < Y ) gmaxY = Y;
2282 if ( gminY > Y ) gminY = Y;
2286 if ( (
data = fopen(
"dat6",
"w" ) ) != NULL )
2290 fprintf(
data,
"%lf, %lf\n", X, Y );
2291 if ( gmaxX < X ) gmaxX = X;
2292 if ( gminX > X ) gminX = X;
2293 if ( gmaxY < Y ) gmaxY = Y;
2294 if ( gminY > Y ) gminY = Y;
2297 if ( (
data = fopen(
"dat7",
"w" ) ) != NULL )
2301 fprintf(
data,
"%lf, %lf\n", X, Y );
2302 if ( gmaxX < X ) gmaxX = X;
2303 if ( gminX > X ) gminX = X;
2304 if ( gmaxY < Y ) gmaxY = Y;
2305 if ( gminY > Y ) gminY = Y;
2309 dStep = 2. *
M_PI / step;
2310 if ( (
data = fopen(
"dat8",
"w" ) ) != NULL )
2312 for (
int ii = 0; ii < step; ++ii )
2314 double X =
center.x() + r *
cos( dStep *
static_cast<double>( ii ) );
2315 double Y =
center.y() + r *
sin( dStep *
static_cast<double>( ii ) );
2316 fprintf(
data,
"%lf, %lf\n", X, Y );
2320 if ( (
data = fopen(
"dat9",
"w" ) ) != NULL )
2324 double X =
p[0][0].x();
2325 double Y =
p[0][0].y();
2326 fprintf(
data,
"%lf, %lf\n", X, Y );
2330 if ( (
data = fopen(
"dat10",
"w" ) ) != NULL )
2334 double X =
p[1][0].x();
2335 double Y =
p[1][0].y();
2336 fprintf(
data,
"%lf, %lf\n", X, Y );
2340 if ( (
data = fopen(
"dat11",
"w" ) ) != NULL )
2344 double X =
p[0][1].x();
2345 double Y =
p[0][1].y();
2346 fprintf(
data,
"%lf, %lf\n", X, Y );
2350 if ( (
data = fopen(
"dat12",
"w" ) ) != NULL )
2354 double X =
p[1][1].x();
2355 double Y =
p[1][1].y();
2356 fprintf(
data,
"%lf, %lf\n", X, Y );
2360 std::cout <<
"Drift Distance = " << drift <<
", xy1cm -> z" << V.z() /
v.mag()
2361 <<
"cm, xyDist(cm) = " << tD << std::endl;
2362 if ( tX.z() < 0. ) std::cout <<
"ERROR : F < B" << std::endl;
2363 if ( ( gnuplot = popen(
"gnuplot",
"w" ) ) != NULL )
2365 fprintf( gnuplot,
"set size 0.721,1.0 \n" );
2366 fprintf( gnuplot,
"set xrange [%f:%f] \n", gminX, gmaxX );
2367 fprintf( gnuplot,
"set yrange [%f:%f] \n", gminY, gmaxY );
2368 fprintf( gnuplot,
"plot \"dat1\" with line, \"dat2\" with line, \"dat3\" with line, "
2369 "\"dat4\" with line, \"dat5\" with "
2370 "line, \"dat6\", \"dat7\", \"dat8\" with line, \"dat9\", \"dat10\", "
2371 "\"dat11\", \"dat12\" \n" );
2388 double kappa = a[2];
2400 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2401 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2402 double dPhi = atan2( vCrs, vDot );
2429 const TMDCWire&
w = *link.
wire();
2433 double kappa = a[2];
2436 const double Bz = -1000 * getPmgnIMF()->getReferField();
2437 double rho = 333.564095 / ( kappa * Bz );
2441 double sinPhi0 =
sin( phi0 );
2442 double cosPhi0 =
cos( phi0 );
2443 double sinPhi0dPhi =
sin( phi0 + dPhi );
2444 double cosPhi0dPhi =
cos( phi0 + dPhi );
2448 double dmag2 = d.mag2();
2450 dphida[0] = ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
2451 dphida[1] = ( dRho + rho ) * ( cosPhi0 * d.x() + sinPhi0 * d.y() ) / dmag2 - 1.;
2452 dphida[2] = ( -rho / kappa ) * ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
2456 dxda[0] = cosPhi0 + rho * sinPhi0dPhi * dphida[0];
2457 dxda[1] = -( dRho + rho ) * sinPhi0 + rho * sinPhi0dPhi * ( 1. + dphida[1] );
2458 dxda[2] = -rho / kappa * ( cosPhi0 - cosPhi0dPhi ) + rho * sinPhi0dPhi * dphida[2];
2459 dxda[3] = rho * sinPhi0dPhi * dphida[3];
2460 dxda[4] = rho * sinPhi0dPhi * dphida[4];
2462 dyda[0] = sinPhi0 - rho * cosPhi0dPhi * dphida[0];
2463 dyda[1] = ( dRho + rho ) * cosPhi0 - rho * cosPhi0dPhi * ( 1. + dphida[1] );
2464 dyda[2] = -rho / kappa * ( sinPhi0 - sinPhi0dPhi ) - rho * cosPhi0dPhi * dphida[2];
2465 dyda[3] = -rho * cosPhi0dPhi * dphida[3];
2466 dyda[4] = -rho * cosPhi0dPhi * dphida[4];
2472 dzda[4] = -rho * dPhi;
2487 double r = fabs(_helix->curv());
2489 for(
unsigned i = 0, size = svdList.length(); i < size; ++i){
2493 if(fabs(cosdPhi) < 1.0){
2494 dPhi = acos(cosdPhi);
2495 }
else if(cosdPhi >= 1.0){
2501 svdList[i]->arcZ(tmp);
2507#if defined( __GNUG__ )
2509 if ( ( *a )->pt() < ( *b )->pt() )
return 1;
2510 else if ( ( *a )->pt() == ( *b )->pt() )
return 0;
2514extern "C" int SortByPt(
const void* av,
const void* bv ) {
2517 if ( ( *a )->pt() < ( *b )->pt() )
return 1;
2518 else if ( ( *a )->pt() == ( *b )->pt() )
return 0;
2525# ifdef TRKRECO_DEBUG_DETAIL
2526 std::cout <<
" TTrack::fit2D(r-phi) ..." << std::endl;
2534 unsigned nTrial( 0 );
2537 double chi2Old = 1.0e+99;
2540 Vector da( 5 ), dxda( 3 ), dyda( 3 );
2542 const double convergence = 1.0e-5;
2545 double factor = 1.0;
2546 unsigned usedWireNumber = 0;
2549 while ( nTrial < 100 )
2553 for (
unsigned j = 0; j < 3; ++j ) dchi2da[j] = 0.;
2561 if ( l->
fit2D() == 0 )
continue;
2566 double dPhi = l->
dPhi();
2569 HepPoint3D onTrack2( onTrack.x(), onTrack.y(), 0. );
2570 HepPoint3D onWire2( onWire.x(), onWire.y(), 0. );
2574 if ( onWire2.cross( onTrack2 ).z() < 0. ) leftRight =
WireHitLeft;
2576 double eDistance = h.
dDrift( leftRight );
2577 double eDistance2 = eDistance * eDistance;
2578 if ( eDistance == 0. )
2580 std::cout <<
"Error(?) : Drift Distance Error = 0 in fit2D of TrkReco." << std::endl;
2586 double vmag =
v.mag();
2587 double dDistance = vmag -
distance;
2590 if ( this->dxda2D( *l, dPhi, dxda, dyda ) != 0 )
continue;
2594 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 3, 0 );
2597 std::cout <<
" in fit2D " << onTrack <<
", " << onWire;
2601 dchi2da += ( dDistance / eDistance2 ) * dDda;
2602 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
2603 double pChi2 = dDistance * dDistance / eDistance2;
2607 l->
update( onTrack2, onWire2, leftRight, pChi2 );
2612 double kappa = _helix->a()[2];
2613 double phi0 = _helix->a()[1];
2619 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2620 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2621 double dPhi = atan2( vCrs, vDot );
2622 HepPoint3D onTrack( _helix->x( dPhi ).x(), _helix->x( dPhi ).y(), 0. );
2624 double eDistance = ipError;
2625 double eDistance2 = eDistance * eDistance;
2628 double vmag =
v.mag();
2629 double dDistance = vmag -
distance;
2631 if ( this->dxda2D( dPhi, dxda, dyda ) != 0 )
goto ipOff;
2633 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 3, 0 );
2634 if ( vmag <= 0.0 ) {
goto ipOff; }
2635 dchi2da += ( dDistance / eDistance2 ) * dDda;
2636 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
2637 double pChi2 = dDistance * dDistance / eDistance2;
2643 if ( usedWireNumber < 4 )
2650 double change = chi2Old -
chi2;
2651 if ( fabs( change ) < convergence )
break;
2654# ifdef TRKRECO_DEBUG_DETAIL
2655 std::cout <<
"chi2Old, chi2=" << chi2Old <<
" " <<
chi2 << std::endl;
2662 for (
unsigned j = 0; j < 3; ++j ) dchi2da[j] = 0.;
2670 if ( l->
fit2D() == 0 )
continue;
2675 double dPhi = l->
dPhi();
2678 HepPoint3D onTrack2( onTrack.x(), onTrack.y(), 0. );
2679 HepPoint3D onWire2( onWire.x(), onWire.y(), 0. );
2683 if ( onWire2.cross( onTrack2 ).z() < 0. ) leftRight =
WireHitLeft;
2685 double eDistance = h.
dDrift( leftRight );
2686 double eDistance2 = eDistance * eDistance;
2690 double vmag =
v.mag();
2691 double dDistance = vmag -
distance;
2694 if ( this->dxda2D( *l, dPhi, dxda, dyda ) != 0 )
continue;
2697 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 3, 0 );
2700 std::cout <<
" in fit2D " << onTrack <<
", " << onWire;
2704 dchi2da += ( dDistance / eDistance2 ) * dDda;
2705 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
2706 double pChi2 = dDistance * dDistance / eDistance2;
2710 l->
update( onTrack2, onWire2, leftRight, pChi2 );
2715 double kappa = _helix->a()[2];
2716 double phi0 = _helix->a()[1];
2722 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2723 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2724 double dPhi = atan2( vCrs, vDot );
2725 HepPoint3D onTrack( _helix->x( dPhi ).x(), _helix->x( dPhi ).y(), 0. );
2727 double eDistance = ipError;
2728 double eDistance2 = eDistance * eDistance;
2731 double vmag =
v.mag();
2732 double dDistance = vmag -
distance;
2734 if ( this->dxda2D( dPhi, dxda, dyda ) != 0 )
goto ipOff2;
2736 dDda = ( vmag > 0. ) ? (
v.x() * dxda +
v.y() * dyda ) / vmag :
Vector( 3, 0 );
2737 if ( vmag <= 0.0 ) {
goto ipOff2; }
2738 dchi2da += ( dDistance / eDistance2 ) * dDda;
2739 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
2740 double pChi2 = dDistance * dDistance / eDistance2;
2746 if ( usedWireNumber < 4 )
2753# ifdef TRKRECO_DEBUG_DETAIL
2754 std::cout <<
"factor = " << factor << std::endl;
2755 std::cout <<
"chi2 = " <<
chi2 << std::endl;
2757 if ( factor < 0.01 )
break;
2763 f = solve( d2chi2d2a, dchi2da );
2774 if ( err ) {
return err; }
2781 Ea[0][0] = Ec[0][0];
2782 Ea[0][1] = Ec[0][1];
2783 Ea[0][2] = Ec[0][2];
2784 Ea[1][1] = Ec[1][1];
2785 Ea[1][2] = Ec[1][2];
2786 Ea[2][2] = Ec[2][2];
2796 _ndf = usedWireNumber - dim;
2803 double gmaxX = -9999., gminX = 9999.;
2804 double gmaxY = -9999., gminY = 9999.;
2805 FILE * gnuplot, *
data;
2807 double dStep = 2. *
M_PI / step;
2808 for (
int i = 0, size =
_links.length(); i < size; ++i )
2811 double drift = l->
hit()->distance( 0 );
2812 char name[100] =
"dat";
2813 char counter[10] =
"";
2814 sprintf( counter,
"%02d", i );
2815 strcat(
name, counter );
2816 if ( (
data = fopen(
name,
"w" ) ) != NULL )
2818 for (
int ii = 0; ii < step; ++ii )
2824 fprintf(
data,
"%lf, %lf\n", X, Y );
2825 if ( gmaxX < X ) gmaxX = X;
2826 if ( gminX > X ) gminX = X;
2827 if ( gmaxY < Y ) gmaxY = Y;
2828 if ( gminY > Y ) gminY = Y;
2834 dStep = 2. *
M_PI / step;
2835 if ( (
data = fopen(
"datc",
"w" ) ) != NULL )
2837 for (
int ii = 0; ii < step; ++ii )
2840 _helix->center().x() + _helix->radius() *
cos( dStep *
static_cast<double>( ii ) );
2842 _helix->center().y() + _helix->radius() *
sin( dStep *
static_cast<double>( ii ) );
2843 fprintf(
data,
"%lf, %lf\n", X, Y );
2847 if ( ( gnuplot = popen(
"gnuplot",
"w" ) ) != NULL )
2849 fprintf( gnuplot,
"set size 0.721,1.0 \n" );
2850 fprintf( gnuplot,
"set xrange [%f:%f] \n", gminX, gmaxX );
2851 fprintf( gnuplot,
"set yrange [%f:%f] \n", gminY, gmaxY );
2852 if (
_links.length() == 4 )
2854 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2855 "\"dat02\" with line, "
2856 "\"dat03\" with line \n" );
2858 else if (
_links.length() == 5 )
2860 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2861 "\"dat02\" with line, "
2862 "\"dat03\" with line, \"dat04\" with line \n" );
2864 else if (
_links.length() == 6 )
2866 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2867 "\"dat02\" with line, "
2868 "\"dat03\" with line, \"dat04\" with line, \"dat05\" with line \n" );
2870 else if (
_links.length() == 7 )
2872 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2873 "\"dat02\" with line, "
2874 "\"dat03\" with line, \"dat04\" with line, \"dat05\" with line, "
2875 "\"dat06\" with line \n" );
2877 else if (
_links.length() == 8 )
2879 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2880 "\"dat02\" with line, \"dat03\" with "
2881 "line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with line, "
2882 "\"dat07\" with line \n" );
2884 else if (
_links.length() == 9 )
2886 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2887 "\"dat02\" with line, "
2888 "\"dat03\" with line, \"dat04\" with line, \"dat05\" with line, "
2889 "\"dat06\" with line, \"dat07\" "
2890 "with line, \"dat08\" with line \n" );
2892 else if (
_links.length() == 10 )
2894 fprintf( gnuplot,
"plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, "
2895 "\"dat02\" with line, "
2896 "\"dat03\" with line, \"dat04\" with line, \"dat05\" with line, "
2897 "\"dat06\" with line, \"dat07\" "
2898 "with line, \"dat08\" with line, \"dat09\" with line \n" );
2900 else if (
_links.length() >= 11 )
2903 "plot \"datc\" with line, \"dat00\" with line, \"dat01\" with line, \"dat02\" "
2905 "\"dat03\" with line, \"dat04\" with line, \"dat05\" with line, \"dat06\" with "
2907 "with line, \"dat08\" with line, \"dat09\" with line, \"dat10\" with line \n" );
2922 double kappa = _helix->a()[2];
2923 double phi0 = _helix->a()[1];
2930 double vCrs = v0.x() * v1.y() - v0.y() * v1.x();
2931 double vDot = v0.x() * v1.x() + v0.y() * v1.y();
2932 double dPhi = atan2( vCrs, vDot );
2934 xt = _helix->x( dPhi );
2943int TTrack::dxda2D(
const TMLink& link,
double dPhi,
Vector& dxda,
Vector& dyda )
const {
2946 double kappa = ( _helix->
a() )[2];
2949 std::cout <<
"Error(?) : kappa == 0 in dxda2D of TrkReco." << std::endl;
2952 const TMDCWire&
w = *link.
wire();
2953 double dRho = ( _helix->a() )[0];
2954 double phi0 = ( _helix->a() )[1];
2957 const double Bz = -1000 * getPmgnIMF()->getReferField();
2958 double rho = 333.564095 / ( kappa * Bz );
2960 double sinPhi0 =
sin( phi0 );
2961 double cosPhi0 =
cos( phi0 );
2962 double sinPhi0dPhi =
sin( phi0 + dPhi );
2963 double cosPhi0dPhi =
cos( phi0 + dPhi );
2968 double dmag2 = d.mag2();
2972 std::cout <<
"Error(?) : Distance(center-xyPosition) == 0 in dxda2D of TrkReco."
2977 dphida[0] = ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
2978 dphida[1] = ( dRho + rho ) * ( cosPhi0 * d.x() + sinPhi0 * d.y() ) / dmag2 - 1.;
2979 dphida[2] = ( -rho / kappa ) * ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
2981 dxda[0] = cosPhi0 + rho * sinPhi0dPhi * dphida[0];
2982 dxda[1] = -( dRho + rho ) * sinPhi0 + rho * sinPhi0dPhi * ( 1. + dphida[1] );
2983 dxda[2] = -rho / kappa * ( cosPhi0 - cosPhi0dPhi ) + rho * sinPhi0dPhi * dphida[2];
2985 dyda[0] = sinPhi0 - rho * cosPhi0dPhi * dphida[0];
2986 dyda[1] = ( dRho + rho ) * cosPhi0 - rho * cosPhi0dPhi * ( 1. + dphida[1] );
2987 dyda[2] = -rho / kappa * ( sinPhi0 - sinPhi0dPhi ) - rho * cosPhi0dPhi * dphida[2];
2992int TTrack::dxda2D(
double dPhi,
Vector& dxda,
Vector& dyda )
const {
2995 double kappa = ( _helix->a() )[2];
2998 std::cout <<
"Error(?) : kappa == 0 in dxda2D of TrkReco." << std::endl;
3001 double dRho = ( _helix->a() )[0];
3002 double phi0 = ( _helix->a() )[1];
3005 const double Bz = -1000 * getPmgnIMF()->getReferField();
3006 double rho = 333.564095 / ( kappa * Bz );
3008 double sinPhi0 =
sin( phi0 );
3009 double cosPhi0 =
cos( phi0 );
3010 double sinPhi0dPhi =
sin( phi0 + dPhi );
3011 double cosPhi0dPhi =
cos( phi0 + dPhi );
3016 double dmag2 = d.mag2();
3020 std::cout <<
"Error(?) : Distance(center-xyPosition) == 0 in dxda2D of TrkReco."
3025 dphida[0] = ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
3026 dphida[1] = ( dRho + rho ) * ( cosPhi0 * d.x() + sinPhi0 * d.y() ) / dmag2 - 1.;
3027 dphida[2] = ( -rho / kappa ) * ( sinPhi0 * d.x() - cosPhi0 * d.y() ) / dmag2;
3029 dxda[0] = cosPhi0 + rho * sinPhi0dPhi * dphida[0];
3030 dxda[1] = -( dRho + rho ) * sinPhi0 + rho * sinPhi0dPhi * ( 1. + dphida[1] );
3031 dxda[2] = -rho / kappa * ( cosPhi0 - cosPhi0dPhi ) + rho * sinPhi0dPhi * dphida[2];
3033 dyda[0] = sinPhi0 - rho * cosPhi0dPhi * dphida[0];
3034 dyda[1] = ( dRho + rho ) * cosPhi0 - rho * cosPhi0dPhi * ( 1. + dphida[1] );
3035 dyda[2] = -rho / kappa * ( sinPhi0 - sinPhi0dPhi ) - rho * cosPhi0dPhi * dphida[2];
3041unsigned TTrack::defineType(
void )
const {
3043 if (
pt() < 0.2 ) highPt =
false;
3045 if ( fabs(
impact() ) > 8.3 ) fromIP =
false;
3048 else if ( fromIP && ( !highPt ) )
return _type =
TrackTypeCurl;
3050 if ( ( fabs(
radius() ) * 2. + fabs(
impact() ) ) < 81. )
3064 return std::string(
"unknown " );
3068# define t_dot( a, b ) ( a[0] * b[0] + a[1] * b[1] + a[2] * b[2] )
3069# define t_dot2( a, b ) ( a[0] * b[0] + a[1] * b[1] )
3070# define t_print( a, b ) \
3071 std::cout << b << " = " << a[0] << " " << a[1] << " " << a[2] << std::endl;
3086 w.backwardPosition( wb );
3088 v[0] =
w.direction().x();
3089 v[1] =
w.direction().y();
3090 v[2] =
w.direction().z();
3092 if ( doSagCorrection )
3096 HepPoint3D wireBackwardPosition( wb[0], wb[1], wb[2] );
3097 w.wirePosition( link.
positionOnTrack().z(), xw, wireBackwardPosition, dir );
3104 wb[0] = wireBackwardPosition.x();
3105 wb[1] = wireBackwardPosition.y();
3106 wb[2] = wireBackwardPosition.z();
3111 _helix->x( 0., xt );
3112 double x0 = -xc.x();
3113 double y0 = -xc.y();
3114 double x1 = wp[0] + x0;
3115 double y1 = wp[1] + y0;
3118 double dPhi = atan2( x0 * y1 - y0 * x1, x0 * x1 + y0 * y1 );
3120 double kappa = _helix->kappa();
3121 double phi0 = _helix->phi0();
3133 double firstdfdphi = 0.;
3134 static bool first =
true;
3149 Gaudi::svcLocator()->service(
"MagneticFieldSvc", m_pmgnIMF );
3150 if ( m_pmgnIMF == NULL )
3152 std::cout << __FILE__ <<
" " << __LINE__ <<
" Unable to open Magnetic field service"
3155 const double Bz = -1000 * getPmgnIMF()->getReferField();
3156 double rho = 333.564095 / ( kappa * Bz );
3158 double tanLambda = _helix->tanl();
3162 const double convergence = 1.0e-5;
3164 unsigned nTrial = 0;
3165 while ( nTrial < 100 )
3173 l =
v[0] * t_x[0] +
v[1] * t_x[1] +
v[2] * t_x[2] -
v[0] * wb[0] -
v[1] * wb[1] -
3176 double rcosPhi = rho *
cos( phi0 + dPhi );
3177 double rsinPhi = rho *
sin( phi0 + dPhi );
3178 t_dXdPhi[0] = rsinPhi;
3179 t_dXdPhi[1] = -rcosPhi;
3180 t_dXdPhi[2] = -rho * tanLambda;
3183 double t_d2Xd2Phi[2];
3184 t_d2Xd2Phi[0] = rcosPhi;
3185 t_d2Xd2Phi[1] = rsinPhi;
3189 n[0] = t_x[0] - wb[0];
3190 n[1] = t_x[1] - wb[1];
3191 n[2] = t_x[2] - wb[2];
3194 a[0] =
n[0] - l *
v[0];
3195 a[1] =
n[1] - l *
v[1];
3196 a[2] =
n[2] - l *
v[2];
3197 double dfdphi = a[0] * t_dXdPhi[0] + a[1] * t_dXdPhi[1] + a[2] * t_dXdPhi[2];
3203 firstdfdphi = dfdphi;
3209 std::cout <<
"TTrack::approach ... " <<
w.name() <<
" "
3210 <<
"dfdphi(0)=" << firstdfdphi <<
",(" << nTrial <<
")=" << dfdphi << endl;
3215 if ( fabs( dfdphi ) < convergence )
break;
3217 double dv =
v[0] * t_dXdPhi[0] +
v[1] * t_dXdPhi[1] +
v[2] * t_dXdPhi[2];
3219 t_dXdPhi[0] * t_dXdPhi[0] + t_dXdPhi[1] * t_dXdPhi[1] + t_dXdPhi[2] * t_dXdPhi[2];
3220 double d2fd2phi = t0 - dv * dv + a[0] * t_d2Xd2Phi[0] + a[1] * t_d2Xd2Phi[1];
3223 dPhi -= dfdphi / d2fd2phi;
3399 double wwmag2 = ww.mag2();
3400 double wwmag = sqrt( wwmag2 );
3404#ifdef TRKRECO_DEBUG_DETAIL
3405 std::cout <<
"old lr " << lr << endl;
3406 std::cout <<
"old X " << X << endl;
3407 std::cout <<
"link.leftRight " << link.
leftRight() << endl;
3418 const double Bz = -1000 * getPmgnIMF()->getReferField();
3419#ifdef TRKRECO_DEBUG_DETAIL
3420 std::cout <<
"charge " << _charge <<
" Bz " << Bz << endl;
3422 if ( _charge * Bz > 0 )
3452 double vmag2 =
v.mag2();
3453 double vmag = sqrt( vmag2 );
3455 double r = _helix->curv();
3456 double wv =
w.dot(
v );
3459 double d2 = wv * wv - vmag2 * (
w.mag2() - r * r );
3460#ifdef TRKRECO_DEBUG_DETAIL
3461 std::cout <<
"lr " << lr << endl;
3464 std::cout <<
"X " << X << endl;
3465 std::cout <<
"center " <<
center << endl;
3466 std::cout <<
"xx " << xx << endl;
3467 std::cout <<
"ww " << ww << endl;
3468 std::cout <<
"TTrack::wire direction:" << h.
wire()->
direction() << endl;
3469 std::cout <<
"x " << x << endl;
3470 std::cout <<
"w " <<
w << endl;
3471 std::cout <<
"sz,Track::vmag:" << vmag <<
", helix_r:" << r <<
", wv:" << wv
3472 <<
", d:" << sqrt( d2 ) << endl;
3482 std::cout <<
"TTrack !!! stereo: 0. > d2 = " << d2 <<
" " << link.
leftRight() << std::endl;
3486 double d = sqrt( d2 );
3490 l[0] = ( -wv + d ) / vmag2;
3491 l[1] = ( -wv - d ) / vmag2;
3498 z[0] = X.z() + l[0] * V.z();
3499 z[1] = X.z() + l[1] * V.z();
3500#ifdef TRKRECO_DEBUG_DETAIL
3501 std::cout <<
"X.z():" << X.z() << endl;
3502 std::cout <<
"szPosition::z(0) " << z[0] <<
" z(1)" << z[1] <<
" leftRight "
3504 std::cout <<
"szPosition::wire backwardPosition and forwardPosition:"
3507 std::cout <<
" l0, l1 = " << l[0] <<
", " << l[1] << std::endl;
3508 std::cout <<
" z0, z1 = " << z[0] <<
", " << z[1] << std::endl;
3550 if ( ( !ok[0] ) && ( !ok[1] ) )
3558 p[0] = x + l[0] *
v;
3559 p[1] = x + l[1] *
v;
3572 if ( ok[1] ) best = 1;
3577 if ( fabs( cosdPhi ) <= 1.0 ) { dPhi = acos( cosdPhi ); }
3578 else if ( cosdPhi > 1.0 ) { dPhi = 0.0; }
3579 else { dPhi =
M_PI; }
3582 tmp.setX( r * dPhi );
3583 tmp.setY( z[best] );
3593 unsigned n =
links.length();
3598 if ( !
n )
return -1;
3600 float minDist =
links[0]->drift();
3601#ifdef TRKRECO_DEBUG_DETAIL
3602 std::cout <<
"minDist szPosition TTrack:" << minDist << endl;
3604 for (
unsigned i = 1; i <
n; i++ )
3606 if (
links[i]->hit()->drift() < minDist )
3608 minDist =
links[i]->drift();
3609#ifdef TRKRECO_DEBUG_DETAIL
3610 std::cout <<
"minDist szPosition TTrack:" << minDist << endl;
3621#ifdef TRKRECO_DEBUG_DETAIL
3622 std::cout <<
"err of szPosition TTrack:" << err << endl;
3624 if ( err )
return -2;
3636 if ( fabs( cosdPhi ) <= 1.0 ) { dPhi = acos( cosdPhi ); }
3637 else if ( cosdPhi > 1.0 ) { dPhi = 0.0; }
3638 else { dPhi =
M_PI; }
3641 sz.setX( _helix->curv() * dPhi );
3652 for (
unsigned i = 0; i <
n; i++ )
3659 std::cout <<
"TTrack::assign !!! hit(" << h->
wire()->
name();
3660 std::cout <<
") already assigned" << std::endl;
3673 StatusCode scmgn = Gaudi::svcLocator()->service(
"MagneticFieldSvc", m_pmgnIMF );
3674 if ( scmgn != StatusCode::SUCCESS )
3675 { std::cout <<
"Unable to open Magnetic field service" << std::endl; }
3682 Hep3Vector p(
t.pivot[0],
t.pivot[1],
t.pivot[2] );
3683 HepSymMatrix er( 5, 0 );
3684 a( 1 ) =
t.helix[0];
3685 a( 2 ) =
t.helix[1];
3686 a( 3 ) =
t.helix[2];
3687 a( 4 ) =
t.helix[3];
3688 a( 5 ) =
t.helix[4];
3689 er( 1, 1 ) =
t.error[0];
3690 er( 2, 1 ) =
t.error[1];
3691 er( 2, 2 ) =
t.error[2];
3692 er( 3, 1 ) =
t.error[3];
3693 er( 3, 2 ) =
t.error[4];
3694 er( 3, 3 ) =
t.error[5];
3695 er( 4, 1 ) =
t.error[6];
3696 er( 4, 2 ) =
t.error[7];
3697 er( 4, 3 ) =
t.error[8];
3698 er( 4, 4 ) =
t.error[9];
3699 er( 5, 1 ) =
t.error[10];
3700 er( 5, 2 ) =
t.error[11];
3701 er( 5, 3 ) =
t.error[12];
3702 er( 5, 4 ) =
t.error[13];
3703 er( 5, 5 ) =
t.error[14];
3704 return Helix( p, a, er );
3709 Hep3Vector p(
t.pivot[0],
t.pivot[1],
t.pivot[2] );
3710 HepSymMatrix er( 5, 0 );
3711 a( 1 ) =
t.helix[0];
3712 a( 2 ) =
t.helix[1];
3713 a( 3 ) =
t.helix[2];
3714 a( 4 ) =
t.helix[3];
3715 a( 5 ) =
t.helix[4];
3716 er( 1, 1 ) =
t.error[0];
3717 er( 2, 1 ) =
t.error[1];
3718 er( 2, 2 ) =
t.error[2];
3719 er( 3, 1 ) =
t.error[3];
3720 er( 3, 2 ) =
t.error[4];
3721 er( 3, 3 ) =
t.error[5];
3722 er( 4, 1 ) =
t.error[6];
3723 er( 4, 2 ) =
t.error[7];
3724 er( 4, 3 ) =
t.error[8];
3725 er( 4, 4 ) =
t.error[9];
3726 er( 5, 1 ) =
t.error[10];
3727 er( 5, 2 ) =
t.error[11];
3728 er( 5, 3 ) =
t.error[12];
3729 er( 5, 4 ) =
t.error[13];
3730 er( 5, 5 ) =
t.error[14];
3731 return Helix( p, a, er );
3736 Hep3Vector p(
t.pivot_x,
t.pivot_y,
t.pivot_z );
3737 HepSymMatrix er( 5, 0 );
3738 a( 1 ) =
t.helix[0];
3739 a( 2 ) =
t.helix[1];
3740 a( 3 ) =
t.helix[2];
3741 a( 4 ) =
t.helix[3];
3742 a( 5 ) =
t.helix[4];
3743 er( 1, 1 ) =
t.error[0];
3744 er( 2, 1 ) =
t.error[1];
3745 er( 2, 2 ) =
t.error[2];
3746 er( 3, 1 ) =
t.error[3];
3747 er( 3, 2 ) =
t.error[4];
3748 er( 3, 3 ) =
t.error[5];
3749 er( 4, 1 ) =
t.error[6];
3750 er( 4, 2 ) =
t.error[7];
3751 er( 4, 3 ) =
t.error[8];
3752 er( 4, 4 ) =
t.error[9];
3753 er( 5, 1 ) =
t.error[10];
3754 er( 5, 2 ) =
t.error[11];
3755 er( 5, 3 ) =
t.error[12];
3756 er( 5, 4 ) =
t.error[13];
3757 er( 5, 5 ) =
t.error[14];
3758 return Helix( p, a, er );
3766 float chrg = hIp.
a()[2] / fabs( hIp.
a()[2] );
3768 if ( chrg > 0. )
s =
"+";
3772 x[0] = fabs( hIp.
a()[0] );
3774 x[2] = 1. / fabs( hIp.
a()[2] );
3775 x[3] = ( 1. / fabs( hIp.
a()[2] ) ) * hIp.
a()[4];
3777 if ( ( x[0] < 2. ) && ( fabs( x[1] ) < 4. ) )
s +=
"i ";
3780 for (
unsigned i = 0; i < 4; i++ )
3784 if ( x[i] < 0. )
s +=
"-";
3787 int y = int( fabs( x[i] ) );
3788 s += std::to_string( y ) +
".";
3789 float z = fabs( x[i] );
3790 for (
unsigned j = 0; j < 3; j++ )
3793 y = ( int( z ) % 10 );
3794 s += std::to_string( y );
3802 return TrackStatus(
t.finder(),
t.type(),
t.quality(),
t.fitting(), 0, 0 );
3809 return std::string(
"" );
3819 return std::string(
"" );
3822std::string
TrackStatus(
unsigned md,
unsigned mk,
unsigned mq,
unsigned ms,
unsigned mm,
3831 if (
f ==
"" )
f =
"?";
3841 if ( k ==
"" ) k =
"?";
3848 if ( b ==
"" ) b =
"ok";
3855 if (
s ==
"" )
s =
"?";
3863 std::string p =
" ";
3864 return f + p + k + p + b + p +
s + p + std::to_string( m ) + p + std::to_string( d );
3869 unsigned n = cores.length();
3871 unsigned nA =
n - nS;
3889 s +=
"a" + std::to_string(
int( nA ) );
3890 s +=
" s" + std::to_string(
int( nS ) );
3891 s +=
" n" + std::to_string(
int(
n ) );
3895 if ( x < 0. )
s +=
" -";
3898 int y = int( fabs( x ) );
3899 s += std::to_string( y ) +
".";
3900 float z = fabs( x );
3901 for (
unsigned j = 0; j < 1; j++ )
3904 y = ( int( z ) % 10 );
3905 s += std::to_string( y );
3915 for (
unsigned i = 0; i < 11; i++ )
3917 nh += std::to_string(
n[i] );
3918 if ( i % 2 ) nh +=
"-";
3919 else if ( i < 10 ) nh +=
",";
3930 bool positive =
true;
3931 if ( e[0][0] <= 0. ) positive =
false;
3932 else if (
e2.determinant() <= 0. ) positive =
false;
3933 else if ( e3.determinant() <= 0. ) positive =
false;
3934 else if ( e4.determinant() <= 0. ) positive =
false;
3935 else if ( e.determinant() <= 0. ) positive =
false;
3941 for (
unsigned i = 0; i < 5; i++ )
3943 if ( std::isnan( a[i] ) )
return true;
3945 for (
unsigned i = 0; i < 5; i++ )
3946 for (
unsigned j = 0; j <= i; j++ )
3948 if ( std::isnan( Ea[i][j] ) )
return true;
3954 if (
t.idhep == 11 ) charge = -1;
3955 else if (
t.idhep == -11 ) charge = 1;
3956 else if (
t.idhep == 13 ) charge = -1;
3957 else if (
t.idhep == -13 ) charge = 1;
3958 else if (
t.idhep == 211 ) charge = 1;
3959 else if (
t.idhep == -211 ) charge = -1;
3960 else if (
t.idhep == 321 ) charge = 1;
3961 else if (
t.idhep == -321 ) charge = -1;
3962 else if (
t.idhep == 2212 ) charge = 1;
3963 else if (
t.idhep == -2212 ) charge = -1;
3966 std::cout <<
"Track2Helix(gen_hepevt) !!! charge of id=";
3967 std::cout <<
t.idhep <<
" is unknown" << std::endl;
3970 Hep3Vector mom(
t.P[0],
t.P[1],
t.P[2] );
3971 Hep3Vector pos(
t.V[0] / 10.,
t.V[1] / 10.,
t.V[2] / 10. );
3972 return Helix( pos, mom, charge );
HepGeom::Vector3D< double > HepVector3D
HepGeom::Point3D< double > HepPoint3D
sprintf(cut, "kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_" "pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per saves r n generator level $ !Flag for chat level in !Latex Output unit
double sin(const BesAngle a)
double cos(const BesAngle a)
CLHEP::HepSymMatrix SymMatrix
int intersection(const HepPoint3D &c1, double r1, const HepPoint3D &c2, double r2, double eps, HepPoint3D &x1, HepPoint3D &x2)
Circle utilities.
const HepPoint3D ORIGIN
Constants.
void NHitsSuperLayer(const AList< TMLink > &links, unsigned nHits[11])
returns # of hits per super layer.
unsigned NStereoHits(const AList< TMLink > &links)
returns # of stereo hits.
#define TrackFitCdcKalman
#define TrackFitSvdCdcKalman
#define TrackQualityAfterKink
#define TrackQualityCosmic
#define TrackTypeUndefined
#define TrackTrackManager
#define TrackTypeIncomingCosmic
#define TrackOldConformalFinder
#define TrackQualityOutsideCurler
#define TrackTypeOutgoingCosmic
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
HepGeom::Point3D< double > HepPoint3D
Helix Track2Helix(const MdcTrk_localz &t)
int SortByPt(const void *av, const void *bv)
Utility functions.
std::string TrackInformation(const TTrack &t)
std::string TrackStatus(const TTrack &t)
returns string of track status.
std::string TrackLayerUsage(const TTrack &t)
bool PositiveDefinite(const Helix &h)
Error matrix validity.
std::string TrackKinematics(const Helix &h)
bool HelixHasNan(const Helix &h)
Helix parameter validity.
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
const HepSymMatrix & Ea(void) const
returns error matrix.
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
virtual double getReferField()=0
A class to represent a circle in tracking.
double radius(void) const
returns radius.
const HepPoint3D & center(void) const
returns position of center.
A class to fit a TTrackBase object to a helix.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
unsigned state(void) const
returns state.
const TTrack *const track(void) const
assigns a pointer to a TTrack.
float dDrift(unsigned) const
returns drift distance error.
float drift(unsigned) const
returns drift distance.
const TMDCWire *const wire(void) const
returns a pointer to a TMDCWire.
A class to represent a wire in MDC.
unsigned layerId(void) const
returns layer id.
const HepVector3D & direction(void) const
returns direction vector of the wire.
const HepPoint3D & xyPosition(void) const
returns middle position of a wire. z componet is 0.
const HepPoint3D & forwardPosition(void) const
returns position in forward endplate.
const HepPoint3D & backwardPosition(void) const
returns position in backward endplate.
std::string name(void) const
returns name.
A class to relate TMDCWireHit and TTrack objects.
const HepPoint3D & positionOnWire(void) const
returns the closest point on wire to a track.
const HepPoint3D & positionOnTrack(void) const
returns the closest point on track to wire.
unsigned leftRight(void) const
returns left-right. 0:left, 1:right, 2:wire
const TMDCWireHit * hit(void) const
returns a pointer to a hit.
const unsigned fit2D(const unsigned &)
void update(const HepPoint3D &onTrack, const HepPoint3D &onWire, unsigned leftRight, double pull)
sets results of fitting.
double dPhi(void) const
returns dPhi to the closest point.
const HepPoint3D & position(void) const
returns position.
const TMDCWire *const wire(void) const
returns a pointer to a wire.
A class to represent a track in tracking.
A class to relate TMDCWireHit and TTrack objects.
virtual double distance(const TMLink &) const
returns distance to a position of TMLink in TMLink space.
virtual void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
const AList< TMLink > & links(unsigned mask=0) const
const TMFitter *const fitter(void) const
returns a pointer to a default fitter.
unsigned nCores(unsigned mask=0) const
returns # of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
const AList< TMLink > & cores(unsigned mask=0) const
returns a list of masked TMLinks for fit. 'mask' will be applied if mask is not 0.
A class to represent a track in tracking.
void assign(unsigned maskForWireHit)
assigns wire hits to this track.
const Helix & helix(void) const
returns helix parameter.
unsigned ndf(void) const
returns NDF.
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
int stereoHitForCurl(TMLink &link, AList< HepPoint3D > &arcZList) const
const std::string & name(void) const
returns/sets name.
TPoint2D center(void) const
returns position of helix center.
unsigned quality(void) const
sets/returns quality.
TTrack()
Default constructor.
int fit2D(unsigned=0, double=0.1, double=0.015)
fits itself. Error was happened if return value is not zero.
double radius(void) const
returns signed radius.
int HelCyl(double rhole, double rcyl, double zb, double zf, double epsl, double &phi, HepPoint3D &xp) const
returns a cathode hit list.
double impact(void) const
returns signed impact parameter to the origin.
double pt(void) const
returns Pt.
int approach(TMLink &) const
void refine2D(AList< TMLink > &list, float maxSigma)
fits itself with cathode hits.
int approach2D(TMLink &) const
void movePivot(void)
moves pivot to the inner most hit.
double chi2(void) const
returns chi2.
int szPosition(TMLink &link) const
calculates arc length and z for a stereo hit.
double charge(void) const
returns charge.
virtual ~TTrack()
Destructor.
void deleteListForCurl(AList< HepPoint3D > &l1, AList< HepPoint3D > &l2) const
Hep3Vector p(void) const
returns momentum.
complex_t R(double Q2, double M2, double G, double Mp2, double Mm2)