CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FastCircle Class Reference

#include <FastCircle.h>

Public Member Functions

double c () const
 
 FastCircle (const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex)
 
 FastCircle (const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex, double norm)
 
bool isValid () const
 
double n1 () const
 
double n2 () const
 
double rho () const
 
double x0 () const
 
double y0 () const
 
 ~FastCircle ()
 

Private Member Functions

void createCircleParameters ()
 
AlgebraicVector3 transform (const GlobalPoint &aPoint) const
 

Private Attributes

double theC
 
GlobalPoint theInnerPoint
 
double theN1
 
double theN2
 
double theNorm
 
GlobalPoint theOuterPoint
 
double theRho
 
bool theValid
 
GlobalPoint theVertexPoint
 
double theX0
 
double theY0
 

Detailed Description

Calculate circle parameters (x0, y0, rho) for a circle: (x-x0)^2 + (y-y0)^2 = rho^2 in Global Cartesian Coordinates in the (x,y) plane for a given set of GlobalPoints. It is done by mapping the points onto the Riemann Sphere and fit a plane to the transformed coordinates of the points. The method is described in:

A.Strandlie, J.Wroldsen, R.Fruehwirth, B.Lillekjendlie: Particle tracks fitted on the Riemann sphere Computer Physics Communications 131 (2000) 95-108, 18 January 2000

Implementation: Matthias Winkler, 14 February 2001

This implementation is a specialized version of the general Circle class for three points.

Update 14.02.2001: For 3 Points (2 RecHits + Vertex) the plain parameters n1*x + n2*y + n3*z + c = 0 are analytically calculable. Update 14.02.2001: In the case that a circle fit is not possible (points are along a straight line) the parameters of the straight line can be used: c + n1*x + n2*y = 0

Definition at line 33 of file FastCircle.h.

Constructor & Destructor Documentation

FastCircle::FastCircle ( const GlobalPoint outerHit,
const GlobalPoint middleHit,
const GlobalPoint aVertex 
)

Definition at line 3 of file FastCircle.cc.

References createCircleParameters().

5  :
6  theOuterPoint(outerHit),
7  theInnerPoint(middleHit),
8  theVertexPoint(aVertex),
9  theNorm(100.),
10  theX0(0.),
11  theY0(0.),
12  theRho(0.),
13  theN1(0.),
14  theN2(0.),
15  theC(0.),
16  theValid(true) {
17 
19 
20 }
double theNorm
Definition: FastCircle.h:71
void createCircleParameters()
Definition: FastCircle.cc:42
bool theValid
Definition: FastCircle.h:81
double theY0
Definition: FastCircle.h:74
double theC
Definition: FastCircle.h:79
double theN2
Definition: FastCircle.h:78
double theX0
Definition: FastCircle.h:73
GlobalPoint theInnerPoint
Definition: FastCircle.h:69
double theRho
Definition: FastCircle.h:75
GlobalPoint theOuterPoint
Definition: FastCircle.h:68
GlobalPoint theVertexPoint
Definition: FastCircle.h:70
double theN1
Definition: FastCircle.h:77
FastCircle::FastCircle ( const GlobalPoint outerHit,
const GlobalPoint middleHit,
const GlobalPoint aVertex,
double  norm 
)

Definition at line 22 of file FastCircle.cc.

References createCircleParameters().

25  :
26  theOuterPoint(outerHit),
27  theInnerPoint(middleHit),
28  theVertexPoint(aVertex),
29  theNorm(norm),
30  theX0(0.),
31  theY0(0.),
32  theRho(0.),
33  theN1(0.),
34  theN2(0.),
35  theC(0.),
36  theValid(true) {
37 
39 
40 }
double theNorm
Definition: FastCircle.h:71
void createCircleParameters()
Definition: FastCircle.cc:42
bool theValid
Definition: FastCircle.h:81
double theY0
Definition: FastCircle.h:74
double theC
Definition: FastCircle.h:79
double theN2
Definition: FastCircle.h:78
double theX0
Definition: FastCircle.h:73
GlobalPoint theInnerPoint
Definition: FastCircle.h:69
double theRho
Definition: FastCircle.h:75
GlobalPoint theOuterPoint
Definition: FastCircle.h:68
GlobalPoint theVertexPoint
Definition: FastCircle.h:70
double theN1
Definition: FastCircle.h:77
FastCircle::~FastCircle ( )
inline

Definition at line 46 of file FastCircle.h.

46 {}

Member Function Documentation

double FastCircle::c ( ) const
inline

Definition at line 64 of file FastCircle.h.

References theC.

Referenced by createCircleParameters().

64 {return theC;}
double theC
Definition: FastCircle.h:79
void FastCircle::createCircleParameters ( )
private

Definition at line 42 of file FastCircle.cc.

References c(), alignCSCRings::e, mag2(), n, rho(), mathSSE::sqrt(), theC, theInnerPoint, theN1, theN2, theNorm, theOuterPoint, theRho, theValid, theVertexPoint, theX0, theY0, transform(), vdt::x, x0(), detailsBasic3DVector::y, y0(), and detailsBasic3DVector::z.

Referenced by FastCircle().

42  {
43 
47 
49 
50  n[0] = x[1]*(y[2] - z[2]) + y[1]*(z[2] - x[2]) + z[1]*(x[2] - y[2]);
51  n[1] = -(x[0]*(y[2] - z[2]) + y[0]*(z[2] - x[2]) + z[0]*(x[2] - y[2]));
52  n[2] = x[0]*(y[1] - z[1]) + y[0]*(z[1] - x[1]) + z[0]*(x[1] - y[1]);
53 
54  double mag2 = n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
55  if (mag2 < 1.e-20) {
56  theValid = false;
57  return;
58  }
59  n.Unit(); // reduce n to a unit vector
60  double c = -(n[0]*x[0] + n[1]*x[1] + n[2]*x[2]);
61  // c = -(n[0]*y[0] + n[1]*y[1] + n[2]*y[2]);
62  // c = -(n[0]*z[0] + n[1]*z[1] + n[2]*z[2]);
63 
64  theN1 = n[0];
65  theN2 = n[1];
66  theC = c;
67 
68  if(fabs(c + n[2]) < 1.e-5) {
69  // numeric limit
70  // circle is more a straight line...
71  theValid = false;
72  return;
73  }
74 
75  double x0 = -n[0] / (2.*(c + n[2]));
76  double y0 = -n[1] / (2.*(c + n[2]));
77  double rho =
78  sqrt((n[0]*n[0] + n[1]*n[1] - 4.*c*(c + n[2]))) / fabs(2.*(c + n[2]));
79 
80  theX0 = theNorm*x0;
81  theY0 = theNorm*y0;
82  theRho = theNorm*rho;
83 
84 }
double theNorm
Definition: FastCircle.h:71
double x0() const
Definition: FastCircle.h:50
double rho() const
Definition: FastCircle.h:54
double double double z
bool theValid
Definition: FastCircle.h:81
AlgebraicVector3 transform(const GlobalPoint &aPoint) const
Definition: FastCircle.cc:86
double theY0
Definition: FastCircle.h:74
double theC
Definition: FastCircle.h:79
double c() const
Definition: FastCircle.h:64
T sqrt(T t)
Definition: SSEVec.h:46
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double theN2
Definition: FastCircle.h:78
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double theX0
Definition: FastCircle.h:73
GlobalPoint theInnerPoint
Definition: FastCircle.h:69
double theRho
Definition: FastCircle.h:75
GlobalPoint theOuterPoint
Definition: FastCircle.h:68
double y0() const
Definition: FastCircle.h:52
GlobalPoint theVertexPoint
Definition: FastCircle.h:70
double theN1
Definition: FastCircle.h:77
x
Definition: VDTMath.h:216
bool FastCircle::isValid ( void  ) const
inline
double FastCircle::n1 ( ) const
inline
double FastCircle::n2 ( ) const
inline
double FastCircle::rho ( ) const
inline
AlgebraicVector3 FastCircle::transform ( const GlobalPoint aPoint) const
private

Definition at line 86 of file FastCircle.cc.

References funct::cos(), PV3DBase< T, PVType, FrameType >::perp(), phi, PV3DBase< T, PVType, FrameType >::phi(), dttmaxenums::R, funct::sin(), and theNorm.

Referenced by createCircleParameters().

86  {
87 
88  AlgebraicVector3 riemannPoint;
89 
90  double R = aPoint.perp();
91  R /= theNorm;
92  double phi = 0.;
93  if(R > 0.) phi = aPoint.phi();
94 
95  double fact = R/(1+R*R); // let's factorize the common factor out
96  riemannPoint[0] = fact*cos(phi);
97  riemannPoint[1] = fact*sin(phi);
98  riemannPoint[2] = fact*R;
99 
100  return riemannPoint;
101 }
double theNorm
Definition: FastCircle.h:71
T perp() const
Definition: PV3DBase.h:71
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
ROOT::Math::SVector< double, 3 > AlgebraicVector3
Definition: DDAxes.h:10
double FastCircle::x0 ( ) const
inline
double FastCircle::y0 ( ) const
inline

Member Data Documentation

double FastCircle::theC
private

Definition at line 79 of file FastCircle.h.

Referenced by c(), and createCircleParameters().

GlobalPoint FastCircle::theInnerPoint
private

Definition at line 69 of file FastCircle.h.

Referenced by createCircleParameters().

double FastCircle::theN1
private

Definition at line 77 of file FastCircle.h.

Referenced by createCircleParameters(), and n1().

double FastCircle::theN2
private

Definition at line 78 of file FastCircle.h.

Referenced by createCircleParameters(), and n2().

double FastCircle::theNorm
private

Definition at line 71 of file FastCircle.h.

Referenced by createCircleParameters(), and transform().

GlobalPoint FastCircle::theOuterPoint
private

Definition at line 68 of file FastCircle.h.

Referenced by createCircleParameters().

double FastCircle::theRho
private

Definition at line 75 of file FastCircle.h.

Referenced by createCircleParameters(), and rho().

bool FastCircle::theValid
private

Definition at line 81 of file FastCircle.h.

Referenced by createCircleParameters(), and isValid().

GlobalPoint FastCircle::theVertexPoint
private

Definition at line 70 of file FastCircle.h.

Referenced by createCircleParameters().

double FastCircle::theX0
private

Definition at line 73 of file FastCircle.h.

Referenced by createCircleParameters(), and x0().

double FastCircle::theY0
private

Definition at line 74 of file FastCircle.h.

Referenced by createCircleParameters(), and y0().