CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoTracker/TkSeedGenerator/src/FastHelix.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkSeedGenerator/interface/FastHelix.h"
00002 #include "RecoTracker/TkSeedGenerator/interface/FastLine.h"
00003 
00004 void FastHelix::compute() {
00005   
00006   if(isValid() && (std::abs(tesla0) > 1e-3) && theCircle.rho()<maxRho)
00007     helixStateAtVertex();
00008   else 
00009     straightLineStateAtVertex();
00010     
00011 }
00012 
00013 void FastHelix::helixStateAtVertex() {
00014 
00015   // given the above rho>0.
00016   double rho = theCircle.rho();
00017   //remember (radius rho in cm):
00018   //rho = 
00019   //100. * pt * 
00020   //(10./(3.*MagneticField::inTesla(GlobalPoint(0., 0., 0.)).z()));
00021   
00022   // pt = 0.01 * rho * (0.3*MagneticField::inTesla(GlobalPoint(0.,0.,0.)).z());
00023   double cm2GeV = 0.01 * 0.3*tesla0;
00024   double pt = cm2GeV * rho; 
00025  
00026   // verify that rho is not toooo large
00027   double dcphi = ((outerHit().x()-theCircle.x0())*(middleHit().x()-theCircle.x0()) +
00028                  (outerHit().y()-theCircle.y0())*(middleHit().y()-theCircle.y0())
00029                  )/(rho*rho);
00030   if (std::abs(dcphi)>=1.f) { straightLineStateAtVertex(); return;}
00031   
00032   GlobalPoint pMid(middleHit());
00033   GlobalPoint v(vertex());
00034   
00035   // tangent in v (or the opposite...)
00036   double px = -cm2GeV * (v.y()-theCircle.y0());
00037   double py =  cm2GeV * (v.x()-theCircle.x0());
00038   // check sign with scalar product
00039   if(px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00040     px = -px;
00041     py = -py;
00042   } 
00043 
00044  
00045  
00046   //calculate z0, pz
00047   //(z, R*phi) linear relation in a helix
00048   //with R, phi defined as radius and angle w.r.t. centre of circle
00049   //in transverse plane
00050   //pz = pT*(dz/d(R*phi)))
00051   
00052 
00053   // VI 23/01/2012
00054   double dzdrphi = outerHit().z() - middleHit().z();
00055   dzdrphi /= rho*acos(dcphi);
00056   double pz = pt*dzdrphi;
00057 
00058 
00059   TrackCharge q = 1;
00060   if (theCircle.x0()*py - theCircle.y0()*px < 0) q =-q;
00061   if (tesla0 < 0.) q =-q;
00062 
00063   //VI
00064   if ( useBasisVertex ) {
00065     atVertex =  GlobalTrajectoryParameters(basisVertex, 
00066                                            GlobalVector(px, py, pz),
00067                                            q, 
00068                                            bField
00069                                            );
00070   } else {
00071     double z_0 =  middleHit().z();
00072     // assume v is before middleHit (opposite to outer)
00073     double ds = ( (v.x()-theCircle.x0())*(middleHit().x()-theCircle.x0()) +
00074                   (v.y()-theCircle.y0())*(middleHit().y()-theCircle.y0())
00075                   )/(rho*rho);
00076     if (std::abs(ds)<1.f) {
00077       ds = rho*acos(ds);
00078       z_0 -= ds*dzdrphi;
00079     } else { // line????
00080       z_0 -= std::sqrt((middleHit()-v).perp2()/(outerHit()-middleHit()).perp2())*(outerHit().z()-middleHit().z());
00081     }
00082     
00083     //double z_old = -flfit.c()/flfit.n2();
00084     // std::cout << "v:xyz, z,old,new " << v << "   " << z_old << " " << z_0 << std::endl;
00085 
00086     atVertex =  GlobalTrajectoryParameters(GlobalPoint(v.x(),v.y(),z_0), 
00087                                            GlobalVector(px, py, pz),
00088                                            q, 
00089                                            bField
00090                                            );
00091   }
00092   
00093 }
00094 
00095 void FastHelix::straightLineStateAtVertex() {
00096 
00097   //calculate GlobalTrajectoryParameters assuming straight line...
00098 
00099   GlobalPoint pMid(middleHit());
00100   GlobalPoint v(vertex());
00101 
00102   double dydx = 0.;
00103   double pt = 0., px = 0., py = 0.;
00104   
00105   if(fabs(theCircle.n1()) > 0. || fabs(theCircle.n2()) > 0.)
00106     pt = maxPt  ;// 10 TeV //else no pt
00107   if(fabs(theCircle.n2()) > 0.) {
00108     dydx = -theCircle.n1()/theCircle.n2(); //else px = 0 
00109   }
00110   px = pt/sqrt(1. + dydx*dydx);
00111   py = px*dydx;
00112   // check sign with scalar product
00113   if (px*(pMid.x() - v.x()) + py*(pMid.y() - v.y()) < 0.) {
00114     px *= -1.;
00115     py *= -1.;
00116   } 
00117 
00118   //calculate z_0 and pz at vertex using weighted mean
00119   //z = z(r) = z0 + (dz/dr)*r
00120   //tan(theta) = dr/dz = (dz/dr)^-1
00121   //theta = atan(1./dzdr)
00122   //p = pt/sin(theta)
00123   //pz = p*cos(theta) = pt/tan(theta) 
00124 
00125   FastLine flfit(outerHit(), middleHit());
00126   double dzdr = -flfit.n1()/flfit.n2();
00127   double pz = pt*dzdr; 
00128   
00129   TrackCharge q = 1;
00130   //VI
00131 
00132   if ( useBasisVertex ) {
00133     atVertex = GlobalTrajectoryParameters(basisVertex, 
00134                                           GlobalVector(px, py, pz),
00135                                           q, 
00136                                           bField
00137                                           );
00138   } else {
00139   double z_0 = -flfit.c()/flfit.n2();
00140   atVertex = GlobalTrajectoryParameters(GlobalPoint(v.x(), v.y(), z_0),
00141                                         GlobalVector(px, py, pz),
00142                                         q,
00143                                         bField
00144                                         );
00145   }
00146 }