Go to the documentation of this file.00001 #include "RecoTracker/TkSeedGenerator/interface/FastHelix.h"
00002 #include "RecoTracker/TkSeedGenerator/interface/FastLine.h"
00003 #include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
00004 #include "TrackingTools/TrajectoryParametrization/interface/CurvilinearTrajectoryError.h"
00005 #include "TrackingTools/TrajectoryParametrization/interface/CartesianTrajectoryError.h"
00006
00007 FreeTrajectoryState FastHelix::stateAtVertex() const {
00008
00009 if(isValid() && (fabs(tesla0.z()) > 1e-3))
00010 return helixStateAtVertex();
00011 else
00012 return straightLineStateAtVertex();
00013
00014 }
00015
00016 FreeTrajectoryState FastHelix::helixStateAtVertex() const {
00017
00018 GlobalPoint pMid(theMiddleHit);
00019 GlobalPoint v(theVertex);
00020
00021 double dydx = 0., dxdy = 0.;
00022 double pt = 0., px = 0., py = 0.;
00023
00024
00025
00026
00027
00028
00029 double rho = theCircle.rho();
00030
00031 pt = 0.01 * rho * (0.3*tesla0.z());
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 double arg1 = rho*rho - (v.x()-theCircle.x0())*(v.x()-theCircle.x0());
00045 double arg2 = rho*rho - (v.y()-theCircle.y0())*(v.y()-theCircle.y0());
00046 if (arg1<0.0 && arg2<0.0) {
00047 if(fabs(theCircle.n2()) > 0.) {
00048 dydx = -theCircle.n1()/theCircle.n2();
00049 px = pt/sqrt(1. + dydx*dydx);
00050 py = px*dydx;
00051 } else {
00052 px = 0.;
00053 py = pt;
00054 }
00055 } else if ( arg1>arg2 ) {
00056 if( v.y() > theCircle.y0() )
00057 dydx = -(v.x() - theCircle.x0()) / sqrt(arg1);
00058 else
00059 dydx = (v.x() - theCircle.x0()) / sqrt(arg1);
00060 px = pt/sqrt(1. + dydx*dydx);
00061 py = px*dydx;
00062 } else {
00063 if( v.x() > theCircle.x0() )
00064 dxdy = -(v.y() - theCircle.y0()) / sqrt(arg2);
00065 else
00066 dxdy = (v.y() - theCircle.y0()) / sqrt(arg2);
00067 py = pt/sqrt(1. + dxdy*dxdy);
00068 px = py*dxdy;
00069 }
00070
00071 if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00072 px *= -1.;
00073 py *= -1.;
00074 }
00075
00076
00077
00078
00079
00080
00081
00082 FastLine flfit(theOuterHit, theMiddleHit, theCircle.rho());
00083 double dzdrphi = -flfit.n1()/flfit.n2();
00084 double pz = pt*dzdrphi;
00085
00086
00087 GlobalVector magvtx=pSetup->inTesla(v);
00088 TrackCharge q =
00089 ((theCircle.x0()*py - theCircle.y0()*px) /
00090 (magvtx.z()) < 0.) ?
00091 -1 : 1;
00092
00093 AlgebraicSymMatrix C(5,1);
00094
00095
00096 if ( useBasisVertex ) {
00097 return FTS(GlobalTrajectoryParameters(basisVertex,
00098 GlobalVector(px, py, pz),
00099 q,
00100 &(*pSetup)),
00101 CurvilinearTrajectoryError(C));
00102 } else {
00103 double z_0 = -flfit.c()/flfit.n2();
00104 return FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(),v.y(),z_0),
00105 GlobalVector(px, py, pz),
00106 q,
00107 &(*pSetup)),
00108 CurvilinearTrajectoryError(C));
00109 }
00110
00111 }
00112
00113 FreeTrajectoryState FastHelix::straightLineStateAtVertex() const {
00114
00115
00116
00117 GlobalPoint pMid(theMiddleHit);
00118 GlobalPoint v(theVertex);
00119
00120 double dydx = 0.;
00121 double pt = 0., px = 0., py = 0.;
00122
00123 if(fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
00124 pt = 1.e+4;
00125 if(fabs(theCircle.n2()) > 0.) {
00126 dydx = -theCircle.n1()/theCircle.n2();
00127 }
00128 px = pt/sqrt(1. + dydx*dydx);
00129 py = px*dydx;
00130
00131 if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00132 px *= -1.;
00133 py *= -1.;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143 FastLine flfit(theOuterHit, theMiddleHit);
00144 double dzdr = -flfit.n1()/flfit.n2();
00145 double pz = pt*dzdr;
00146
00147 TrackCharge q = 1;
00148 AlgebraicSymMatrix66 C = AlgebraicMatrixID();
00149
00150
00151 if ( useBasisVertex ) {
00152 return FTS(GlobalTrajectoryParameters(basisVertex,
00153 GlobalVector(px, py, pz),
00154 q,
00155 &(*pSetup)),
00156 CartesianTrajectoryError(C));
00157 } else {
00158 double z_0 = -flfit.c()/flfit.n2();
00159 return FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0),
00160 GlobalVector(px, py, pz),
00161 q,
00162 &(*pSetup)),
00163 CartesianTrajectoryError());
00164 }
00165 }