CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/RecoTracker/TkSeedGenerator/src/FastCircle.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkSeedGenerator/interface/FastCircle.h"
00002 
00003 FastCircle::FastCircle(const GlobalPoint& outerHit,
00004                        const GlobalPoint& middleHit,
00005                        const GlobalPoint& aVertex) : 
00006   theOuterPoint(outerHit), 
00007   theInnerPoint(middleHit), 
00008   theVertexPoint(aVertex), 
00009   theNorm(100.), 
00010   theX0(0.), 
00011   theY0(0.), 
00012   theRho(0.),
00013   theN1(0.),
00014   theN2(0.),
00015   theC(0.),
00016   theValid(true) {
00017 
00018   createCircleParameters();
00019   
00020 }
00021 
00022 FastCircle::FastCircle(const GlobalPoint& outerHit,
00023                        const GlobalPoint& middleHit,
00024                        const GlobalPoint& aVertex,
00025                        double norm) : 
00026   theOuterPoint(outerHit), 
00027   theInnerPoint(middleHit), 
00028   theVertexPoint(aVertex), 
00029   theNorm(norm), 
00030   theX0(0.), 
00031   theY0(0.), 
00032   theRho(0.),
00033   theN1(0.),
00034   theN2(0.),
00035   theC(0.),
00036   theValid(true) {
00037 
00038   createCircleParameters();
00039   
00040 }
00041 
00042 void FastCircle::createCircleParameters() {
00043   
00044   AlgebraicVector3 x = transform(theOuterPoint);
00045   AlgebraicVector3 y = transform(theInnerPoint);
00046   AlgebraicVector3 z = transform(theVertexPoint);
00047 
00048   AlgebraicVector3 n;
00049 
00050   n[0] =   x[1]*(y[2] - z[2]) + y[1]*(z[2] - x[2]) + z[1]*(x[2] - y[2]);
00051   n[1] = -(x[0]*(y[2] - z[2]) + y[0]*(z[2] - x[2]) + z[0]*(x[2] - y[2]));
00052   n[2] =   x[0]*(y[1] - z[1]) + y[0]*(z[1] - x[1]) + z[0]*(x[1] - y[1]);
00053 
00054   double mag2 = n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
00055   if (mag2 < 1.e-20) {
00056     theValid = false;
00057     return;
00058   }
00059   n.Unit(); // reduce n to a unit vector
00060   double  c = -(n[0]*x[0] + n[1]*x[1] + n[2]*x[2]);
00061   //  c = -(n[0]*y[0] + n[1]*y[1] + n[2]*y[2]);
00062   //  c = -(n[0]*z[0] + n[1]*z[1] + n[2]*z[2]);
00063   
00064   theN1 = n[0];
00065   theN2 = n[1];
00066   theC = c;
00067 
00068   if(fabs(c + n[2]) < 1.e-5) {
00069     // numeric limit
00070     // circle is more a straight line...
00071     theValid = false;
00072     return;
00073   }
00074 
00075   double x0 = -n[0] / (2.*(c + n[2]));
00076   double y0 = -n[1] / (2.*(c + n[2]));
00077   double rho = 
00078     sqrt((n[0]*n[0] + n[1]*n[1] - 4.*c*(c + n[2]))) / fabs(2.*(c + n[2]));
00079   
00080   theX0 = theNorm*x0;
00081   theY0 = theNorm*y0;
00082   theRho = theNorm*rho;
00083 
00084 }
00085 
00086 AlgebraicVector3 FastCircle::transform(const GlobalPoint& aPoint) const {
00087 
00088   AlgebraicVector3 riemannPoint;
00089 
00090   double R = aPoint.perp();
00091   R /= theNorm;
00092   double phi = 0.;
00093   if(R > 0.) phi = aPoint.phi();
00094  
00095   double fact = R/(1+R*R); // let's factorize the common factor out
00096   riemannPoint[0] = fact*cos(phi);
00097   riemannPoint[1] = fact*sin(phi);
00098   riemannPoint[2] = fact*R;
00099   
00100   return riemannPoint;
00101 }