CMS 3D CMS Logo

FastHelix.cc

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 #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   //remember (radius rho in cm):
00041   //rho = 
00042   //100. * pt * 
00043   //(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
00044   
00045   double rho = theCircle.rho();
00046   // pt = 0.01 * rho * (0.3*MagneticField::inTesla(GlobalPoint(0.,0.,0.)).z());
00047   pt = 0.01 * rho * (0.3*tesla0.z());
00048   //  pt = 0.01 * rho * (0.3*GlobalPoint(0.,0.,0.).MagneticField().z());
00049 
00050   // (py/px)|x=v.x() = (dy/dx)|x=v.x()
00051   //remember:
00052   //y(x) = +-sqrt(rho^2 - (x-x0)^2) + y0 
00053   //y(x) =  sqrt(rho^2 - (x-x0)^2) + y0  if y(x) >= y0 
00054   //y(x) = -sqrt(rho^2 - (x-x0)^2) + y0  if y(x) < y0
00055   //=> (dy/dx) = -(x-x0)/sqrt(Q)  if y(x) >= y0
00056   //   (dy/dx) =  (x-x0)/sqrt(Q)  if y(x) < y0
00057   //with Q = rho^2 - (x-x0)^2
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   // check sign with scalar product
00067   if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00068     px *= -1.;
00069     py *= -1.;
00070   } 
00071 
00072   //calculate z0, pz
00073   //(z, R*phi) linear relation in a helix
00074   //with R, phi defined as radius and angle w.r.t. centre of circle
00075   //in transverse plane
00076   //pz = pT*(dz/d(R*phi)))
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   //get sign of particle
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   //MP
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   //calculate FTS assuming straight line...
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;// 10 TeV //else no pt
00118   if(fabs(theCircle.n2()) > 0.) {
00119     dydx = -theCircle.n1()/theCircle.n2(); //else px = 0 
00120   }
00121   px = pt/sqrt(1. + dydx*dydx);
00122   py = px*dydx;
00123   // check sign with scalar product
00124   if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00125     px *= -1.;
00126     py *= -1.;
00127   } 
00128 
00129   //calculate z_0 and pz at vertex using weighted mean
00130   //z = z(r) = z0 + (dz/dr)*r
00131   //tan(theta) = dr/dz = (dz/dr)^-1
00132   //theta = atan(1./dzdr)
00133   //p = pt/sin(theta)
00134   //pz = p*cos(theta) = pt/tan(theta) 
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   //MP
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 }

Generated on Tue Jun 9 17:45:57 2009 for CMSSW by  doxygen 1.5.4