RecoPixelVertexing
PixelTrackFitting
src
CircleFromThreePoints.cc
Go to the documentation of this file.
1
#include "
RecoPixelVertexing/PixelTrackFitting/interface/CircleFromThreePoints.h
"
2
3
CircleFromThreePoints::CircleFromThreePoints
(
const
GlobalPoint
&
inner
,
4
const
GlobalPoint
& mid,
5
const
GlobalPoint
&
outer
,
6
double
precision
) {
7
// move to frame where inner.x() == inner.y() == 0;
8
Vector2D
b
(mid.
x
() -
inner
.x(), mid.
y
() -
inner
.y());
9
Vector2D
c
(
outer
.x() -
inner
.x(),
outer
.y() -
inner
.y());
10
init
(
b
,
c
,
Vector2D
(
inner
.x(),
inner
.y()),
precision
);
11
}
12
13
void
CircleFromThreePoints::init
(
const
Vector2D
&
b
,
const
Vector2D
&
c
,
const
Vector2D
&
offset
,
double
precision
) {
14
double
b2
=
b
.mag2();
15
double
c2 =
c
.mag2();
16
17
double
oX(0), oY(0);
18
bool
solved =
false
;
19
if
(fabs(
b
.x()) > fabs(
b
.y())) {
// solve for y first
20
double
k
=
c
.x() /
b
.x();
21
double
div = 2 * (
k
*
b
.y() -
c
.y());
22
if
(fabs(div) <
precision
)
23
theCurvature
= 0;
// if the 3 points lie on a line
24
else
{
25
oY = (
k
*
b2
- c2) / div;
26
oX =
b2
/ (2 *
b
.x()) -
b
.y() /
b
.x() * oY;
27
solved =
true
;
28
}
29
}
else
{
// solve for x first
30
double
k
=
c
.y() /
b
.y();
31
double
div = 2 * (
k
*
b
.x() -
c
.x());
32
if
(fabs(div) <
precision
)
33
theCurvature
= 0;
// if the 3 points lie on a line
34
else
{
35
oX = (
k
*
b2
- c2) / div;
36
oY =
b2
/ (2 *
b
.y()) -
b
.x() /
b
.y() * oX;
37
solved =
true
;
38
}
39
}
40
if
(solved) {
41
theCurvature
= 1. /
sqrt
(oX * oX + oY * oY);
42
double
xC = oX +
offset
.x();
43
double
yC = oY +
offset
.y();
44
theCenter
=
Vector2D
(xC, yC);
45
// thePhi = acos(xC/sqrt(xC*xC + yC*yC));
46
47
// if (xC<0.) thePhi = thePhi - PI;
48
// cout << setiosflags(ios::showpoint | ios::fixed);
49
//
50
// cout << "CircleFromThreePoints::init curv = " << theCurvature << endl;
51
// cout << "CircleFromThreePoints::init center prime = " << oX << " " << oY << endl;
52
// cout << "CircleFromThreePoints::init offset = " << offset.x() << " " << offset.y() << endl;
53
// cout << "CircleFromThreePoints::init center = " << theCenter.x()<< " " << theCenter.y() << endl;
54
//
55
// float d = sqrt(theCenter.x()*theCenter.x()+theCenter.y()*theCenter.y());
56
// cout << "CircleFromThreePoints::init dfloat = " << setw(10) << setprecision(5) << d << endl;
57
// cout << "CircleFromThreePoints::init radius = " << 1/theCurvature << endl;
58
}
59
}
boostedTaus_cff.precision
precision
Definition:
boostedTaus_cff.py:29
CircleFromThreePoints::theCurvature
float theCurvature
Definition:
CircleFromThreePoints.h:53
PV3DBase::x
T x() const
Definition:
PV3DBase.h:59
b2
static constexpr float b2
Definition:
L1EGammaCrystalsEmulatorProducer.cc:83
SurfaceOrientation::inner
Definition:
Surface.h:19
mathSSE::sqrt
T sqrt(T t)
Definition:
SSEVec.h:19
CircleFromThreePoints.h
dqmdumpme.k
k
Definition:
dqmdumpme.py:60
Point3DBase< float, GlobalTag >
b
double b
Definition:
hdecay.h:118
Basic2DVector< float >
CircleFromThreePoints::init
void init(const Vector2D &b, const Vector2D &c, const Vector2D &offset, double precision)
Definition:
CircleFromThreePoints.cc:13
PV3DBase::y
T y() const
Definition:
PV3DBase.h:60
CircleFromThreePoints::theCenter
Vector2D theCenter
Definition:
CircleFromThreePoints.h:54
CircleFromThreePoints::CircleFromThreePoints
CircleFromThreePoints()
dummy
Definition:
CircleFromThreePoints.h:21
CircleFromThreePoints::Vector2D
Basic2DVector< float > Vector2D
Definition:
CircleFromThreePoints.h:23
c
auto & c
Definition:
CAHitNtupletGeneratorKernelsImpl.h:56
SurfaceOrientation::outer
Definition:
Surface.h:19
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition:
hltrates_dqm_sourceclient-live_cfg.py:82
Generated for CMSSW Reference Manual by
1.8.16