BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TLine2D Class Reference

A class to represent a line in 2D. More...

#include <TLine2D.h>

Public Member Functions

 TLine2D ()
 Constructors.
 TLine2D (double slope, double yOffset)
 TLine2D (const AList< TPoint2D > &)
virtual ~TLine2D ()
 Destructor.
double slope (void) const
double yOffset (void) const
double xOffset (void) const
double slope (double)
double yOffset (double)
int fit (void)
double det (void) const
double distance (const TPoint2D &) const
void append (const TPoint2D &)
void remove (const TPoint2D &)
const CAList< TPoint2D > & list (void) const
 TLine2D ()
 Constructors.
 TLine2D (double slope, double yOffset)
 TLine2D (const AList< TPoint2D > &)
virtual ~TLine2D ()
 Destructor.
double slope (void) const
double yOffset (void) const
double xOffset (void) const
double slope (double)
double yOffset (double)
int fit (void)
double det (void) const
double distance (const TPoint2D &) const
void append (const TPoint2D &)
void remove (const TPoint2D &)
const CAList< TPoint2D > & list (void) const
 TLine2D ()
 Constructors.
 TLine2D (double slope, double yOffset)
 TLine2D (const AList< TPoint2D > &)
virtual ~TLine2D ()
 Destructor.
double slope (void) const
double yOffset (void) const
double xOffset (void) const
double slope (double)
double yOffset (double)
int fit (void)
double det (void) const
double distance (const TPoint2D &) const
void append (const TPoint2D &)
void remove (const TPoint2D &)
const CAList< TPoint2D > & list (void) const

Detailed Description

A class to represent a line in 2D.

Definition at line 28 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

Constructor & Destructor Documentation

◆ TLine2D() [1/9]

TLine2D::TLine2D ( )

Constructors.

Definition at line 30 of file TLine2D.cxx.

30: _slope( 1 ), _yOffset( 0 ), _det( 0 ), _list( 0 ) {}

◆ TLine2D() [2/9]

TLine2D::TLine2D ( double slope,
double yOffset )

Definition at line 32 of file TLine2D.cxx.

32: _slope( a ), _yOffset( b ), _det( 0 ), _list( 0 ) {}

◆ TLine2D() [3/9]

TLine2D::TLine2D ( const AList< TPoint2D > & a)

Definition at line 34 of file TLine2D.cxx.

34 : _slope( 1 ), _yOffset( 0 ), _det( 0 ) {
35 _list = new CAList<TPoint2D>();
36 _list->append( a );
37}

◆ ~TLine2D() [1/3]

TLine2D::~TLine2D ( )
virtual

Destructor.

Definition at line 39 of file TLine2D.cxx.

39 {
40 if ( _list ) delete _list;
41}

◆ TLine2D() [4/9]

TLine2D::TLine2D ( )

Constructors.

◆ TLine2D() [5/9]

TLine2D::TLine2D ( double slope,
double yOffset )

◆ TLine2D() [6/9]

TLine2D::TLine2D ( const AList< TPoint2D > & )

◆ ~TLine2D() [2/3]

virtual TLine2D::~TLine2D ( )
virtual

Destructor.

◆ TLine2D() [7/9]

TLine2D::TLine2D ( )

Constructors.

◆ TLine2D() [8/9]

TLine2D::TLine2D ( double slope,
double yOffset )

◆ TLine2D() [9/9]

TLine2D::TLine2D ( const AList< TPoint2D > & )

◆ ~TLine2D() [3/3]

virtual TLine2D::~TLine2D ( )
virtual

Destructor.

Member Function Documentation

◆ append() [1/3]

void TLine2D::append ( const TPoint2D & a)

Definition at line 43 of file TLine2D.cxx.

43 {
44 if ( !_list ) _list = new CAList<TPoint2D>();
45 _list->append( a );
46}

◆ append() [2/3]

void TLine2D::append ( const TPoint2D & )

◆ append() [3/3]

void TLine2D::append ( const TPoint2D & )

◆ det() [1/3]

double TLine2D::det ( void ) const

◆ det() [2/3]

double TLine2D::det ( void ) const

◆ det() [3/3]

double TLine2D::det ( void ) const

◆ distance() [1/3]

double TLine2D::distance ( const TPoint2D & p) const

Definition at line 100 of file TLine2D.cxx.

100 {
101 double ydif = p.y() - _yOffset;
102 double vmag = sqrt( 1. + _slope * _slope );
103 double dot = ( p.x() + ydif * _slope ) / vmag;
104 double xmag2 = p.x() * p.x() + ydif * ydif;
105 return sqrt( xmag2 - dot * dot );
106}

◆ distance() [2/3]

double TLine2D::distance ( const TPoint2D & ) const

◆ distance() [3/3]

double TLine2D::distance ( const TPoint2D & ) const

◆ fit() [1/3]

int TLine2D::fit ( void )

Definition at line 58 of file TLine2D.cxx.

58 {
59 if ( !_list ) return -1;
60
61 unsigned n = _list->length();
62 if ( !n ) return -1;
63
64 if ( n == 2 )
65 {
66 double x0 = ( *_list )[0]->x();
67 double y0 = ( *_list )[0]->y();
68 double x1 = ( *_list )[1]->x();
69 double y1 = ( *_list )[1]->y();
70 if ( x0 == x1 ) return -2;
71 _slope = ( y0 - y1 ) / ( x0 - x1 );
72 _yOffset = -_slope * x1 + y1;
73
74 return 0;
75 }
76
77 double sum = double( n );
78 double sumX = 0., sumY = 0., sumX2 = 0., sumXY = 0., sumY2 = 0.;
79 for ( unsigned i = 0; i < n; i++ )
80 {
81 const TPoint2D& p = *( *_list )[i];
82 double x = p.x();
83 double y = p.y();
84 sumX += x;
85 sumY += y;
86 sumX2 += x * x;
87 sumXY += x * y;
88 sumY2 += y * y;
89 }
90
91 _det = sum * sumX2 - sumX * sumX;
92 if ( _det == 0. ) return -3;
93
94 _slope = ( sumXY * sum - sumX * sumY ) / _det;
95 _yOffset = ( sumX2 * sumY - sumX * sumXY ) / _det;
96
97 return 0;
98}
const Int_t n
Double_t x[10]

◆ fit() [2/3]

int TLine2D::fit ( void )

◆ fit() [3/3]

int TLine2D::fit ( void )

◆ list() [1/3]

const CAList< TPoint2D > & TLine2D::list ( void ) const

Definition at line 53 of file TLine2D.cxx.

53 {
54 if ( !_list ) _list = new CAList<TPoint2D>();
55 return *_list;
56}

◆ list() [2/3]

const CAList< TPoint2D > & TLine2D::list ( void ) const

◆ list() [3/3]

const CAList< TPoint2D > & TLine2D::list ( void ) const

◆ remove() [1/3]

void TLine2D::remove ( const TPoint2D & a)

Definition at line 48 of file TLine2D.cxx.

48 {
49 if ( !_list ) return;
50 _list->remove( a );
51}

◆ remove() [2/3]

void TLine2D::remove ( const TPoint2D & )

◆ remove() [3/3]

void TLine2D::remove ( const TPoint2D & )

◆ slope() [1/6]

double TLine2D::slope ( double a)
inline

Definition at line 83 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

83{ return _slope = a; }

◆ slope() [2/6]

double TLine2D::slope ( double )

◆ slope() [3/6]

double TLine2D::slope ( double )

◆ slope() [4/6]

double TLine2D::slope ( void ) const
inline

Definition at line 77 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

77{ return _slope; }

Referenced by TLine2D().

◆ slope() [5/6]

double TLine2D::slope ( void ) const

◆ slope() [6/6]

double TLine2D::slope ( void ) const

◆ xOffset() [1/3]

double TLine2D::xOffset ( void ) const
inline

Definition at line 81 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

81{ return -_yOffset / _slope; }

◆ xOffset() [2/3]

double TLine2D::xOffset ( void ) const

◆ xOffset() [3/3]

double TLine2D::xOffset ( void ) const

◆ yOffset() [1/6]

double TLine2D::yOffset ( double a)
inline

Definition at line 85 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

85{ return _yOffset = a; }

◆ yOffset() [2/6]

double TLine2D::yOffset ( double )

◆ yOffset() [3/6]

double TLine2D::yOffset ( double )

◆ yOffset() [4/6]

double TLine2D::yOffset ( void ) const
inline

Definition at line 79 of file InstallArea/x86_64-el9-gcc13-dbg/include/TrkReco/TLine2D.h.

79{ return _yOffset; }

Referenced by TLine2D().

◆ yOffset() [5/6]

double TLine2D::yOffset ( void ) const

◆ yOffset() [6/6]

double TLine2D::yOffset ( void ) const

The documentation for this class was generated from the following files: