Belle II Software  release-05-01-25
CircleCenterXY.h
1 /**************************************************************************
2 * BASF2 (Belle Analysis Framework 2) *
3 * Copyright(C) 2014 - Belle II Collaboration *
4 * *
5 * Author: The Belle II Collaboration *
6 * Contributors: Jakob Lettenbichler (jakob.lettenbichler@oeaw.ac.at) *
7 * Thomas Lueck (lueck@pi.infn.it) *
8 * *
9 * This software is provided "as is" without any warranty. *
10 **************************************************************************/
11 
12 #pragma once
13 
14 #include <tracking/trackFindingVXD/filterMap/filterFramework/SelectionVariable.h>
15 #include <framework/geometry/B2Vector3.h>
16 #include <framework/core/FrameworkExceptions.h>
17 
18 #define CIRCLECENTERXY_NAME CircleCenterXY
19 
20 namespace Belle2 {
29  template <typename PointType >
30  class CIRCLECENTERXY_NAME : public SelectionVariable< PointType, 3, B2Vector3<double> > {
31  public:
33  BELLE2_DEFINE_EXCEPTION(Straight_Line, "The hits are on a straight Line (or indistinguishably near to being on it).");
34 
37 
39  static B2Vector3<double> value(const PointType& a, const PointType& b, const PointType& c)
40  {
41  // calculates the intersection point using Cramer's rule.
42  // 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
43  double inX = b.X() - c.X(); // x value of the normal vector of the inner segment (b-c)
44  double inY = b.Y() - c.Y(); // y value of the normal vector of the inner segment (b-c)
45  double outX = a.X() - b.X(); // x value of the normal vector of the outer segment (a-b)
46  double outY = a.Y() - b.Y(); // y value of the normal vector of the outer segment (a-b)
47 
48  //searching solution for Ax = b, aij are the matrix elements of A, bi are elements of b
49  double a11 = inY;
50  double a12 = -inX;
51  double a21 = -outY;
52  double a22 = outX;
53  double b1 = b.X() + outX * 0.5 - (c.X() + inX * 0.5);
54  double b2 = b.Y() + outY * 0.5 - (c.Y() + inY * 0.5);
55 
56  if (a11 * a22 == a12 * a21) { throw Straight_Line(); }
57 
58  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).
59 
60  return B2Vector3<double>(c.X() + inX * 0.5 + s * inY, c.Y() + inY * 0.5 - s * inX, 0.);
61  }
62 
63 
64 
65  };
66 
68 }
Belle2::CIRCLECENTERXY_NAME
calculates the center of the circle for 3 hits in the XY plane and returns a B2Vector3 with the resul...
Definition: CircleCenterXY.h:30
Belle2::CIRCLECENTERXY_NAME::BELLE2_DEFINE_EXCEPTION
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.
Belle2::B2Vector3< double >
Belle2::CIRCLECENTERXY_NAME::PUT_NAME_FUNCTION
PUT_NAME_FUNCTION(CIRCLECENTERXY_NAME)
is replaced by "static const std:string name(void)" frunction which returns name of the Class
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::SelectionVariable
Base class of the selection variable objects used for pair filtering.
Definition: SelectionVariable.h:54
Belle2::CIRCLECENTERXY_NAME::value
static B2Vector3< double > 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...
Definition: CircleCenterXY.h:39