CMS 3D CMS Logo

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   n.Unit(); // reduce n to a unit vector
00055   double  c = -(n[0]*x[0] + n[1]*x[1] + n[2]*x[2]);
00056   //  c = -(n[0]*y[0] + n[1]*y[1] + n[2]*y[2]);
00057   //  c = -(n[0]*z[0] + n[1]*z[1] + n[2]*z[2]);
00058   
00059   theN1 = n[0];
00060   theN2 = n[1];
00061   theC = c;
00062 
00063   if(fabs(c + n[2]) < 1.e-5) {
00064     // numeric limit
00065     // circle is more a straight line...
00066     theValid = false;
00067     return;
00068   }
00069 
00070   double x0 = -n[0] / (2.*(c + n[2]));
00071   double y0 = -n[1] / (2.*(c + n[2]));
00072   double rho = 
00073     sqrt((n[0]*n[0] + n[1]*n[1] - 4.*c*(c + n[2]))) / fabs(2.*(c + n[2]));
00074   
00075   theX0 = theNorm*x0;
00076   theY0 = theNorm*y0;
00077   theRho = theNorm*rho;
00078 
00079 }
00080 
00081 AlgebraicVector3 FastCircle::transform(const GlobalPoint& aPoint) const {
00082 
00083   AlgebraicVector3 riemannPoint;
00084 
00085   double R = aPoint.perp();
00086   R /= theNorm;
00087   double phi = 0.;
00088   if(R > 0.) phi = aPoint.phi();
00089  
00090   double fact = R/(1+R*R); // let's factorize the common factor out
00091   riemannPoint[0] = fact*cos(phi);
00092   riemannPoint[1] = fact*sin(phi);
00093   riemannPoint[2] = fact*R;
00094   
00095   return riemannPoint;
00096 }

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