BOSS 7.1.2
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
 
- 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
 
- 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
 

Additional Inherited Members

- Protected Member Functions inherited from TMFitter
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 TRobustLineFitter.h.

Constructor & Destructor Documentation

◆ TRobustLineFitter()

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

Constructor.

Definition at line 37 of file TRobustLineFitter.cxx.

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

◆ ~TRobustLineFitter()

TRobustLineFitter::~TRobustLineFitter ( )
virtual

Destructor.

Definition at line 41 of file TRobustLineFitter.cxx.

41 {
42}

Member Function Documentation

◆ a()

double TRobustLineFitter::a ( void ) const
inline

Definition at line 72 of file TRobustLineFitter.h.

72 {
73 return _a;
74}

◆ b()

double TRobustLineFitter::b ( void ) const
inline

Definition at line 78 of file TRobustLineFitter.h.

78 {
79 return _b;
80}

◆ det()

double TRobustLineFitter::det ( void ) const
inline

Definition at line 84 of file TRobustLineFitter.h.

84 {
85 return _det;
86}

◆ dump()

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

dumps debug information.

◆ fit()

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

Reimplemented from TLineFitter.

Definition at line 45 of file TRobustLineFitter.cxx.

45 {
46 //...Initial guess...
47 int err = TLineFitter::fit(t);
48 if (err) return err;
49
50 //...Check # of hits...
51 const AList<TMLink> & links = t.links();
52 _n = links.length();
53 if (_n < 3) return 0;
54
55 //...Standard deviation...
56 _a = TLineFitter::a();
57 _b = TLineFitter::b();
58 _det = TLineFitter::det();
59 double chisq = 0.;
60 for (unsigned i = 0; i < _n; i++) {
61 const HepPoint3D & p = links[i]->position();
62 double tmp = p.y() - (_a * p.x() + _b);
63 chisq += tmp * tmp;
64 }
65 double siga = sqrt(chisq / _det);
66
67 //...Decide iteration step...
68 double a1 = _a;
69 double f1 = rofunc(t, a1);
70 double a2 = _a + copysign(3.0 * siga, f1);
71 double f2 = rofunc(t, a2);
72
73 // if initial value f2 >f1, change the search direction
74 if( f1 * f2 > 0. && fabs(f2) > fabs(f1) ){
75 a2 = _a - copysign(3.0 * siga, f1);
76 f2 = rofunc(t, a2);
77 }
78
79 int backwardSearch=0;
80 while (f1 * f2 > 0. ) {
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 backwardSearch++;
89 if(backwardSearch==2){
90 break;
91 }
92
93 double f=f2;
94 a2 = a1;
95 f2 = f1;
96 a1 = _a;
97 f1 = f;
98 }
99 }
100
101 if(backwardSearch==2){
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 _a = 0.5 * (a1 + a2);
109 if (_a == a1 || _a == a2) break;
110 double f = rofunc(t, _a);
111
112 if( f * f1 <0 ){
113 f1=f;
114 a1=_a;
115 backwardSearch--;
116 break;
117 }
118
119 if ( fabs(f) <= fabs(f1) && fabs(f) <= fabs(f2)) {
120 if( fabs(f-f1) > fabs(f-f2) ){
121 f1 = f;
122 a1 = _a;
123 }else{
124 f2 = f;
125 a2 = _a;
126 }
127 }else if( fabs(f) <= fabs(f1) ){
128 f1 = f;
129 a1 = _a;
130 }else if ( fabs(f) <= fabs(f2) ){
131 f2 = f;
132 a2 = _a;
133 }else{
134 if( fabs(f2) > fabs(f1) ){
135 f1=f;
136 a1 = _a;
137 }else{
138 f2 = f;
139 a2 = _a;
140 }
141 }
142 if (fabs(a2-a1) >= a21) break;
143 a21 = fabs(a2-a1);
144 }
145 }
146
147 if(backwardSearch<=1){
148
149 //search zero cross
150 siga = 0.01 * siga;
151
152 double a21(fabs(a2-a1));
153 while (a21 > siga) {
154 _a = 0.5 * (a1 + a2);
155 if (_a == a1 || _a == a2) break;
156 double f = rofunc(t, _a);
157 if (f * f1 >= 0.) {
158 f1 = f;
159 a1 = _a;
160 }
161 else {
162 f2 = f;
163 a2 = _a;
164 }
165 if (fabs(a2-a1) >= a21) break;
166 a21 = fabs(a2-a1);
167 }
168 }
169
170 _det = _det / double(_n);
171
172 if (t.objectType() == Line)
173 ((TMLine &) t).property(_a, _b, _det);
174 fitDone(t);
175 return 0;
176}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
TFile * f1
#define Line
Definition TTrackBase.h:29
TTree * t
Definition binning.cxx:23
double a(void) const
Definition TLineFitter.h:67
virtual int fit(TTrackBase &) const
double b(void) const
Definition TLineFitter.h:73
double det(void) const
Definition TLineFitter.h:79
void fitDone(TTrackBase &) const
sets the fitted flag. (Bad implementation)
Definition TMFitter.cxx:24
A class to represent a track in tracking.
Definition TMLine.h:40

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


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