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

A class to fit a TTrackBase object to a line. More...

#include <TRobustLineFitter.h>

Inheritance diagram for TRobustLineFitter:

Public Member Functions

 TRobustLineFitter (const std::string &name)
 Constructor.
virtual ~TRobustLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
virtual int fit (TTrackBase &) const
 TRobustLineFitter (const std::string &name)
 Constructor.
virtual ~TRobustLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
virtual int fit (TTrackBase &) const
 TRobustLineFitter (const std::string &name)
 Constructor.
virtual ~TRobustLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
virtual int fit (TTrackBase &) const
Public Member Functions inherited from TLineFitter
 TLineFitter (const std::string &name)
 Constructor.
virtual ~TLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
 TLineFitter (const std::string &name)
 Constructor.
virtual ~TLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
 TLineFitter (const std::string &name)
 Constructor.
virtual ~TLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
double a (void) const
double b (void) const
double det (void) const
Public Member Functions inherited from TMFitter
 TMFitter (const std::string &name)
 Constructor.
virtual ~TMFitter ()
 Destructor.
const std::string & name (void) const
 returns name.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 TMFitter (const std::string &name)
 Constructor.
virtual ~TMFitter ()
 Destructor.
const std::string & name (void) const
 returns name.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 TMFitter (const std::string &name)
 Constructor.
virtual ~TMFitter ()
 Destructor.
const std::string & name (void) const
 returns name.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const

Additional Inherited Members

Protected Member Functions inherited from TMFitter
void fitDone (TTrackBase &) const
 sets the fitted flag. (Bad implementation)
void fitDone (TTrackBase &) const
 sets the fitted flag. (Bad implementation)
void fitDone (TTrackBase &) const
 sets the fitted flag. (Bad implementation)

Detailed Description

A class to fit a TTrackBase object to a line.

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

Constructor & Destructor Documentation

◆ TRobustLineFitter() [1/3]

TRobustLineFitter::TRobustLineFitter ( const std::string & name)

Constructor.

Definition at line 37 of file TRobustLineFitter.cxx.

38 : TLineFitter( name ), _a( 0. ), _b( 0. ), _det( 0. ) {}
TLineFitter(const std::string &name)
Constructor.
const std::string & name(void) const
returns name.

◆ ~TRobustLineFitter() [1/3]

TRobustLineFitter::~TRobustLineFitter ( )
virtual

Destructor.

Definition at line 40 of file TRobustLineFitter.cxx.

40{}

◆ TRobustLineFitter() [2/3]

TRobustLineFitter::TRobustLineFitter ( const std::string & name)

Constructor.

◆ ~TRobustLineFitter() [2/3]

virtual TRobustLineFitter::~TRobustLineFitter ( )
virtual

Destructor.

◆ TRobustLineFitter() [3/3]

TRobustLineFitter::TRobustLineFitter ( const std::string & name)

Constructor.

◆ ~TRobustLineFitter() [3/3]

virtual TRobustLineFitter::~TRobustLineFitter ( )
virtual

Destructor.

Member Function Documentation

◆ a() [1/3]

double TRobustLineFitter::a ( void ) const
inline

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

70{ return _a; }

◆ a() [2/3]

double TRobustLineFitter::a ( void ) const

◆ a() [3/3]

double TRobustLineFitter::a ( void ) const

◆ b() [1/3]

double TRobustLineFitter::b ( void ) const
inline

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

72{ return _b; }

◆ b() [2/3]

double TRobustLineFitter::b ( void ) const

◆ b() [3/3]

double TRobustLineFitter::b ( void ) const

◆ det() [1/3]

double TRobustLineFitter::det ( void ) const
inline

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

74{ return _det; }

◆ det() [2/3]

double TRobustLineFitter::det ( void ) const

◆ det() [3/3]

double TRobustLineFitter::det ( void ) const

◆ dump() [1/3]

void TRobustLineFitter::dump ( const std::string & message = std::string(""),
const std::string & prefix = std::string("") ) const

dumps debug information.

◆ dump() [2/3]

void TRobustLineFitter::dump ( const std::string & message = std::string(""),
const std::string & prefix = std::string("") ) const

dumps debug information.

◆ dump() [3/3]

void TRobustLineFitter::dump ( const std::string & message = std::string(""),
const std::string & prefix = std::string("") ) const

dumps debug information.

◆ fit() [1/3]

int TRobustLineFitter::fit ( TTrackBase & t) const
virtual

Reimplemented from TLineFitter.

Definition at line 42 of file TRobustLineFitter.cxx.

42 {
43 //...Initial guess...
44 int err = TLineFitter::fit( t );
45 if ( err ) return err;
46
47 //...Check # of hits...
48 const AList<TMLink>& links = t.links();
49 _n = links.length();
50 if ( _n < 3 ) return 0;
51
52 //...Standard deviation...
53 _a = TLineFitter::a();
54 _b = TLineFitter::b();
55 _det = TLineFitter::det();
56 double chisq = 0.;
57 for ( unsigned i = 0; i < _n; i++ )
58 {
59 const HepPoint3D& p = links[i]->position();
60 double tmp = p.y() - ( _a * p.x() + _b );
61 chisq += tmp * tmp;
62 }
63 double siga = sqrt( chisq / _det );
64
65 //...Decide iteration step...
66 double a1 = _a;
67 double f1 = rofunc( t, a1 );
68 double a2 = _a + copysign( 3.0 * siga, f1 );
69 double f2 = rofunc( t, a2 );
70
71 // if initial value f2 >f1, change the search direction
72 if ( f1 * f2 > 0. && fabs( f2 ) > fabs( f1 ) )
73 {
74 a2 = _a - copysign( 3.0 * siga, f1 );
75 f2 = rofunc( t, a2 );
76 }
77
78 int backwardSearch = 0;
79 while ( f1 * f2 > 0. )
80 {
81 _a = 2.0 * a2 - a1;
82 a1 = a2;
83 f1 = f2;
84 a2 = _a;
85 f2 = rofunc( t, a2 );
86
87 if ( f1 * f2 > 0. && ( fabs( f2 ) > fabs( f1 ) || fabs( f2 - f1 ) < 0.01 ) )
88 {
89 backwardSearch++;
90 if ( backwardSearch == 2 ) { break; }
91
92 double f = f2;
93 a2 = a1;
94 f2 = f1;
95 a1 = _a;
96 f1 = f;
97 }
98 }
99
100 if ( backwardSearch == 2 )
101 {
102 // for case of no zero cross
103 // search minimun fabs(f)
104
105 double siga1 = 0.01 * siga;
106 double a21( fabs( a2 - a1 ) );
107 while ( a21 > siga1 )
108 {
109 _a = 0.5 * ( a1 + a2 );
110 if ( _a == a1 || _a == a2 ) break;
111 double f = rofunc( t, _a );
112
113 if ( f * f1 < 0 )
114 {
115 f1 = f;
116 a1 = _a;
117 backwardSearch--;
118 break;
119 }
120
121 if ( fabs( f ) <= fabs( f1 ) && fabs( f ) <= fabs( f2 ) )
122 {
123 if ( fabs( f - f1 ) > fabs( f - f2 ) )
124 {
125 f1 = f;
126 a1 = _a;
127 }
128 else
129 {
130 f2 = f;
131 a2 = _a;
132 }
133 }
134 else if ( fabs( f ) <= fabs( f1 ) )
135 {
136 f1 = f;
137 a1 = _a;
138 }
139 else if ( fabs( f ) <= fabs( f2 ) )
140 {
141 f2 = f;
142 a2 = _a;
143 }
144 else
145 {
146 if ( fabs( f2 ) > fabs( f1 ) )
147 {
148 f1 = f;
149 a1 = _a;
150 }
151 else
152 {
153 f2 = f;
154 a2 = _a;
155 }
156 }
157 if ( fabs( a2 - a1 ) >= a21 ) break;
158 a21 = fabs( a2 - a1 );
159 }
160 }
161
162 if ( backwardSearch <= 1 )
163 {
164
165 // search zero cross
166 siga = 0.01 * siga;
167
168 double a21( fabs( a2 - a1 ) );
169 while ( a21 > siga )
170 {
171 _a = 0.5 * ( a1 + a2 );
172 if ( _a == a1 || _a == a2 ) break;
173 double f = rofunc( t, _a );
174 if ( f * f1 >= 0. )
175 {
176 f1 = f;
177 a1 = _a;
178 }
179 else
180 {
181 f2 = f;
182 a2 = _a;
183 }
184 if ( fabs( a2 - a1 ) >= a21 ) break;
185 a21 = fabs( a2 - a1 );
186 }
187 }
188
189 _det = _det / double( _n );
190
191 if ( t.objectType() == Line ) ( (TMLine&)t ).property( _a, _b, _det );
192 fitDone( t );
193 return 0;
194}
HepGeom::Point3D< double > HepPoint3D
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
TFile * f1
virtual int fit(TTrackBase &) const
void fitDone(TTrackBase &) const
sets the fitted flag. (Bad implementation)
Definition TMFitter.cxx:21
int t()
Definition t.c:1

Referenced by TBuilder::buildStereo(), TBuilderCurl::buildStereo(), TBuilder::initialLine2(), and TBuilder::searchLine().

◆ fit() [2/3]

virtual int TRobustLineFitter::fit ( TTrackBase & ) const
virtual

Reimplemented from TLineFitter.

◆ fit() [3/3]

virtual int TRobustLineFitter::fit ( TTrackBase & ) const
virtual

Reimplemented from TLineFitter.


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