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 #include "MagneticField/Engine/interface/MagneticField.h"
00007 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00008
00009 FastHelix::FastHelix(const GlobalPoint& outerHit,
00010 const GlobalPoint& middleHit,
00011 const GlobalPoint& aVertex,
00012 const edm::EventSetup& iSetup) : theOuterHit(outerHit),
00013 theMiddleHit(middleHit),
00014 theVertex(aVertex),
00015 theCircle(outerHit,
00016 middleHit,
00017 aVertex) {
00018
00019 iSetup.get<IdealMagneticFieldRecord>().get(pSetup);
00020 tesla0=pSetup->inTesla(GlobalPoint(0,0,0));
00021 }
00022
00023 FreeTrajectoryState FastHelix::stateAtVertex() const {
00024
00025 if(isValid() && (fabs(tesla0.z()) > 1e-3))
00026 return helixStateAtVertex();
00027 else
00028 return straightLineStateAtVertex();
00029
00030 }
00031
00032 FreeTrajectoryState FastHelix::helixStateAtVertex() const {
00033
00034 GlobalPoint pMid(theMiddleHit);
00035 GlobalPoint v(theVertex);
00036
00037 double dydx = 0.;
00038 double pt = 0., px = 0., py = 0.;
00039
00040
00041
00042
00043
00044
00045 double rho = theCircle.rho();
00046
00047 pt = 0.01 * rho * (0.3*tesla0.z());
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 double root = sqrt(rho*rho - (v.x()-theCircle.x0())*(v.x()-theCircle.x0()));
00059 if((v.y() - theCircle.y0()) > 0.)
00060 dydx = -(v.x() - theCircle.x0()) / root;
00061 else
00062 dydx = (v.x() - theCircle.x0()) / root;
00063
00064 px = pt/sqrt(1. + dydx*dydx);
00065 py = px*dydx;
00066
00067 if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00068 px *= -1.;
00069 py *= -1.;
00070 }
00071
00072
00073
00074
00075
00076
00077
00078 FastLine flfit(theOuterHit, theMiddleHit, theCircle.rho());
00079 double z_0 = -flfit.c()/flfit.n2();
00080 double dzdrphi = -flfit.n1()/flfit.n2();
00081 double pz = pt*dzdrphi;
00082
00083
00084
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 FTS atVertex = FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0),
00096 GlobalVector(px, py, pz),
00097 q,
00098 &(*pSetup)),
00099 CurvilinearTrajectoryError(C));
00100
00101
00102
00103 return atVertex;
00104 }
00105
00106 FreeTrajectoryState FastHelix::straightLineStateAtVertex() const {
00107
00108
00109
00110 GlobalPoint pMid(theMiddleHit);
00111 GlobalPoint v(theVertex);
00112
00113 double dydx = 0.;
00114 double pt = 0., px = 0., py = 0.;
00115
00116 if(fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
00117 pt = 1.e+4;
00118 if(fabs(theCircle.n2()) > 0.) {
00119 dydx = -theCircle.n1()/theCircle.n2();
00120 }
00121 px = pt/sqrt(1. + dydx*dydx);
00122 py = px*dydx;
00123
00124 if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00125 px *= -1.;
00126 py *= -1.;
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136 FastLine flfit(theOuterHit, theMiddleHit);
00137 double z_0 = -flfit.c()/flfit.n2();
00138 double dzdr = -flfit.n1()/flfit.n2();
00139 double pz = pt*dzdr;
00140
00141 TrackCharge q = 1;
00142 AlgebraicSymMatrix66 C = AlgebraicMatrixID();
00143
00144 FTS atVertex = FTS(GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0),
00145 GlobalVector(px, py, pz),
00146 q,
00147 &(*pSetup)),
00148 CartesianTrajectoryError());
00149
00150 return atVertex;
00151 }