CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FastCircle.cc
Go to the documentation of this file.
3 
5  const GlobalPoint& middleHit,
6  const GlobalPoint& aVertex) :
7  theOuterPoint(outerHit),
8  theInnerPoint(middleHit),
9  theVertexPoint(aVertex),
10  theNorm(128.),
11  theX0(0.),
12  theY0(0.),
13  theRho(0.),
14  theN1(0.),
15  theN2(0.),
16  theC(0.),
17  theValid(true) {
18 
20 
21 }
22 
24  const GlobalPoint& middleHit,
25  const GlobalPoint& aVertex,
26  double norm) :
27  theOuterPoint(outerHit),
28  theInnerPoint(middleHit),
29  theVertexPoint(aVertex),
30  theNorm(norm),
31  theX0(0.),
32  theY0(0.),
33  theRho(0.),
34  theN1(0.),
35  theN2(0.),
36  theC(0.),
37  theValid(true) {
38 
40 
41 }
42 
43 namespace {
44  inline
45  AlgebraicVector3 transform(const GlobalPoint& aPoint, float norm) {
46 
47  AlgebraicVector3 riemannPoint;
48 
49  auto p = aPoint.basicVector()/norm;
50  float R2 = p.perp2();
51  float fact = 1.f/(1.f+R2); // let's factorize the common factor out
52  riemannPoint[0] = fact*p.x();
53  riemannPoint[1] = fact*p.y();
54  riemannPoint[2] = fact*R2;
55 
56  return riemannPoint;
57  }
58 
59 
60 }
61 
63 
67 
69 
70  n[0] = x[1]*(y[2] - z[2]) + y[1]*(z[2] - x[2]) + z[1]*(x[2] - y[2]);
71  n[1] = -(x[0]*(y[2] - z[2]) + y[0]*(z[2] - x[2]) + z[0]*(x[2] - y[2]));
72  n[2] = x[0]*(y[1] - z[1]) + y[0]*(z[1] - x[1]) + z[0]*(x[1] - y[1]);
73 
74  double mag2 = n[0]*n[0]+n[1]*n[1]+n[2]*n[2];
75  if (mag2 < 1.e-20) {
76  theValid = false;
77  return;
78  }
79  n.Unit(); // reduce n to a unit vector
80  double c = -(n[0]*x[0] + n[1]*x[1] + n[2]*x[2]);
81  // c = -(n[0]*y[0] + n[1]*y[1] + n[2]*y[2]);
82  // c = -(n[0]*z[0] + n[1]*z[1] + n[2]*z[2]);
83 
84  theN1 = n[0];
85  theN2 = n[1];
86  theC = c;
87 
88  if(fabs(c + n[2]) < 1.e-5) {
89  // numeric limit
90  // circle is more a straight line...
91  theValid = false;
92  return;
93  }
94 
95  double x0 = -n[0] / (2.*(c + n[2]));
96  double y0 = -n[1] / (2.*(c + n[2]));
97  double rho =
98  sqrt((n[0]*n[0] + n[1]*n[1] - 4.*c*(c + n[2]))) / fabs(2.*(c + n[2]));
99 
100  theX0 = theNorm*x0;
101  theY0 = theNorm*y0;
102  theRho = theNorm*rho;
103 
104 }
105 
double theNorm
Definition: FastCircle.h:76
double x0() const
Definition: FastCircle.h:50
void createCircleParameters()
Definition: FastCircle.cc:62
FastCircle(const GlobalPoint &outerHit, const GlobalPoint &middleHit, const GlobalPoint &aVertex)
Definition: FastCircle.cc:4
double rho() const
Definition: FastCircle.h:54
bool theValid
Definition: FastCircle.h:86
double theY0
Definition: FastCircle.h:79
double theC
Definition: FastCircle.h:84
double c() const
Definition: FastCircle.h:64
T sqrt(T t)
Definition: SSEVec.h:18
T mag2() const
The vector magnitude squared. Equivalent to vec.dot(vec)
double theN2
Definition: FastCircle.h:83
ROOT::Math::SVector< double, 3 > AlgebraicVector3
double theX0
Definition: FastCircle.h:78
GlobalPoint theInnerPoint
Definition: FastCircle.h:74
double theRho
Definition: FastCircle.h:80
GlobalPoint theOuterPoint
Definition: FastCircle.h:73
const double fact
double y0() const
Definition: FastCircle.h:52
GlobalPoint theVertexPoint
Definition: FastCircle.h:75
double theN1
Definition: FastCircle.h:82
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:56