CMS 3D CMS Logo

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