Belle II Software development
CircleCenterXY.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
12#include <framework/geometry/B2Vector3.h>
13#include <framework/core/FrameworkExceptions.h>
14
15#define CIRCLECENTERXY_NAME CircleCenterXY
16
17namespace Belle2 {
22
26 template <typename PointType >
27 class CIRCLECENTERXY_NAME : public SelectionVariable< PointType, 3, B2Vector3D > {
28 public:
30 BELLE2_DEFINE_EXCEPTION(Straight_Line, "The hits are on a straight Line (or indistinguishably near to being on it).");
31
34
36 static B2Vector3D value(const PointType& a, const PointType& b, const PointType& c)
37 {
38 // calculates the intersection point using Cramer's rule.
39 // x_1+s*n_1==x_2+t*n_2 --> n_1 *s - n_2 *t == x_2 - x_1 --> http://en.wikipedia.org/wiki/Cramer%27s_rule
40 double inX = b.X() - c.X(); // x value of the normal vector of the inner segment (b-c)
41 double inY = b.Y() - c.Y(); // y value of the normal vector of the inner segment (b-c)
42 double outX = a.X() - b.X(); // x value of the normal vector of the outer segment (a-b)
43 double outY = a.Y() - b.Y(); // y value of the normal vector of the outer segment (a-b)
44
45 //searching solution for Ax = b, aij are the matrix elements of A, bi are elements of b
46 double a11 = inY;
47 double a12 = -inX;
48 double a21 = -outY;
49 double a22 = outX;
50 double b1 = b.X() + outX * 0.5 - (c.X() + inX * 0.5);
51 double b2 = b.Y() + outY * 0.5 - (c.Y() + inY * 0.5);
52
53 if (a11 * a22 == a12 * a21) { throw Straight_Line(); }
54
55 double s = (b1 * a22 - b2 * a21) / (a11 * a22 - a12 * a21); //the determinant is zero if the three hits are on a line in (x,y).
56
57 return B2Vector3D(c.X() + inX * 0.5 + s * inY, c.Y() + inY * 0.5 - s * inX, 0.);
58 }
59
60
61
62 };
63
65}
calculates the center of the circle for 3 hits in the XY plane and returns a B2Vector3 with the resul...
static B2Vector3D value(const PointType &a, const PointType &b, const PointType &c)
calculates an estimation of circleCenter position, result is returned as the x and y value of the B2V...
PUT_NAME_FUNCTION(CIRCLECENTERXY_NAME)
is replaced by "static const std:string name(void)" frunction which returns name of the Class
BELLE2_DEFINE_EXCEPTION(Straight_Line, "The hits are on a straight Line (or indistinguishably near to being on it).")
this exception is thrown by the CircleFit and occurs when the track is too straight.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:516
Abstract base class for different kinds of events.