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

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

#include <T3DLineFitter.h>

Inheritance diagram for T3DLineFitter:

Public Member Functions

 T3DLineFitter (const std::string &name)
 Constructor.
 T3DLineFitter (const std::string &name, bool m_sag, int m_prop, bool m_tof)
virtual ~T3DLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
virtual int fit (TTrackBase &) const
virtual int fit (TTrackBase &, float t0Offset) const
void sag (bool)
void propagation (int)
void tof (bool)
 T3DLineFitter (const std::string &name)
 Constructor.
 T3DLineFitter (const std::string &name, bool m_sag, int m_prop, bool m_tof)
virtual ~T3DLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
virtual int fit (TTrackBase &) const
virtual int fit (TTrackBase &, float t0Offset) const
void sag (bool)
void propagation (int)
void tof (bool)
 T3DLineFitter (const std::string &name)
 Constructor.
 T3DLineFitter (const std::string &name, bool m_sag, int m_prop, bool m_tof)
virtual ~T3DLineFitter ()
 Destructor.
void dump (const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
 dumps debug information.
virtual int fit (TTrackBase &) const
virtual int fit (TTrackBase &, float t0Offset) const
void sag (bool)
void propagation (int)
void tof (bool)
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 3D line.

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

Constructor & Destructor Documentation

◆ T3DLineFitter() [1/6]

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

Constructor.

Definition at line 76 of file T3DLineFitter.cxx.

77 : TMFitter( name ), _sag( false ), _propagation( 0 ), _tof( true ) {}
const std::string & name(void) const
returns name.
TMFitter(const std::string &name)
Constructor.
Definition TMFitter.cxx:17

◆ T3DLineFitter() [2/6]

T3DLineFitter::T3DLineFitter ( const std::string & name,
bool m_sag,
int m_prop,
bool m_tof )

Definition at line 79 of file T3DLineFitter.cxx.

80 : TMFitter( name ), _sag( m_sag ), _propagation( m_prop ), _tof( m_tof ) {}
NTuple::Array< double > m_tof

◆ ~T3DLineFitter() [1/3]

T3DLineFitter::~T3DLineFitter ( )
virtual

Destructor.

Definition at line 82 of file T3DLineFitter.cxx.

82{}

◆ T3DLineFitter() [3/6]

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

Constructor.

◆ T3DLineFitter() [4/6]

T3DLineFitter::T3DLineFitter ( const std::string & name,
bool m_sag,
int m_prop,
bool m_tof )

◆ ~T3DLineFitter() [2/3]

virtual T3DLineFitter::~T3DLineFitter ( )
virtual

Destructor.

◆ T3DLineFitter() [5/6]

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

Constructor.

◆ T3DLineFitter() [6/6]

T3DLineFitter::T3DLineFitter ( const std::string & name,
bool m_sag,
int m_prop,
bool m_tof )

◆ ~T3DLineFitter() [3/3]

virtual T3DLineFitter::~T3DLineFitter ( )
virtual

Destructor.

Member Function Documentation

◆ dump() [1/3]

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

dumps debug information.

◆ dump() [2/3]

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

dumps debug information.

◆ dump() [3/3]

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

dumps debug information.

◆ fit() [1/6]

int T3DLineFitter::fit ( TTrackBase & tb) const
virtual

Implements TMFitter.

Definition at line 193 of file T3DLineFitter.cxx.

193{ return fit( tb, 0 ); }
virtual int fit(TTrackBase &) const

Referenced by fit().

◆ fit() [2/6]

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

Implements TMFitter.

◆ fit() [3/6]

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

Implements TMFitter.

◆ fit() [4/6]

int T3DLineFitter::fit ( TTrackBase & tb,
float t0Offset ) const
virtual

Definition at line 195 of file T3DLineFitter.cxx.

195 {
196
197 // std::cout<<"T3DLineFitter::fit start"<<std::endl;
198
199 //...Type check...
200 if ( tb.objectType() != Line3D ) return TFitUnavailable;
201 T3DLine& t = (T3DLine&)tb;
202
203 //...Already fitted ?...
204 if ( t.fitted() ) return TFitAlreadyFitted;
205
206 //...Count # of hits...
207 AList<TMLink> cores = t.cores();
208 unsigned nCores = cores.length();
209 unsigned nStereoCores = NStereoHits( cores );
210
211 //...Check # of hits...
212 bool flag2D = false;
213 if ( ( nStereoCores == 0 ) && ( nCores > 3 ) ) flag2D = true;
214 else if ( ( nStereoCores < 2 ) || ( nCores - nStereoCores < 3 ) ) return TFitErrorFewHits;
215
216 //...Move pivot to ORIGIN...
217 const HepPoint3D pivot_bak = t.pivot();
218 t.pivot( ORIGIN );
219
220 //...Setup...
221 Vector a( 4 ), da( 4 );
222 a = t.a();
223 Vector dxda( 4 );
224 Vector dyda( 4 );
225 Vector dzda( 4 );
226 Vector dDda( 4 );
227 Vector dchi2da( 4 );
228 SymMatrix d2chi2d2a( 4, 0 );
229 static const SymMatrix zero4( 4, 0 );
230 double chi2;
231 double chi2Old = DBL_MAX;
232 double factor = 1.0;
233 int err = 0;
234 SymMatrix e( 2, 0 );
235 Vector f( 2 );
236
237 //...Fitting loop...
238 unsigned nTrial = 0;
239 while ( nTrial < 100 )
240 {
241
242 //...Set up...
243 chi2 = 0;
244 for ( unsigned j = 0; j < 4; j++ ) dchi2da[j] = 0;
245 d2chi2d2a = zero4;
246
247 //...Loop with hits...
248 unsigned i = 0;
249 while ( TMLink* l = cores[i++] )
250 {
251 const TMDCWireHit& h = *l->hit();
252
253 //...Cal. closest points...
254 t.approach( *l, _sag );
255 const HepPoint3D& onTrack = l->positionOnTrack();
256 const HepPoint3D& onWire = l->positionOnWire();
257 unsigned leftRight = WireHitRight;
258 if ( onWire.cross( onTrack ).z() < 0. ) leftRight = WireHitLeft;
259
260 //...Obtain drift distance and its error...
261 double distance;
262 double eDistance;
263 drift( t, *l, t0Offset, distance, eDistance );
264 l->drift( distance, 0 );
265 l->drift( distance, 1 );
266 l->dDrift( eDistance, 0 );
267 l->dDrift( eDistance, 1 );
268 double eDistance2 = eDistance * eDistance;
269 // cout<<"distance: "<< distance << " eDistance: " << eDistance << endl;
270
271 //...Residual...
272 HepVector3D v = onTrack - onWire;
273 double vmag = v.mag();
274 double dDistance = vmag - distance;
275
276 HepVector3D vw;
277 //...dxda...
278 this->dxda( *l, t, dxda, dyda, dzda, vw );
279
280 //...Chi2 related...
281 dDda = ( vmag > 0. ) ? ( ( v.x() * ( 1. - vw.x() * vw.x() ) - v.y() * vw.x() * vw.y() -
282 v.z() * vw.x() * vw.z() ) *
283 dxda +
284 ( v.y() * ( 1. - vw.y() * vw.y() ) - v.z() * vw.y() * vw.z() -
285 v.x() * vw.y() * vw.x() ) *
286 dyda +
287 ( v.z() * ( 1. - vw.z() * vw.z() ) - v.x() * vw.z() * vw.x() -
288 v.y() * vw.z() * vw.y() ) *
289 dzda ) /
290 vmag
291 : Vector( 4, 0 );
292 if ( vmag <= 0.0 )
293 {
294 std::cout << " in fit " << onTrack << ", " << onWire;
295 h.dump();
296 }
297 dchi2da += ( dDistance / eDistance2 ) * dDda;
298 d2chi2d2a += vT_times_v( dDda ) / eDistance2;
299 double pChi2 = dDistance * dDistance / eDistance2;
300 chi2 += pChi2;
301
302 //...Store results...
303 l->update( onTrack, onWire, leftRight, pChi2 );
304 }
305
306 //...Check condition...
307 double change = chi2Old - chi2;
308
309 if ( fabs( change ) < 1.0e-5 ) break;
310 if ( change < 0. )
311 {
312 a += factor * da; // recover
313 factor *= 0.1;
314 }
315 else
316 {
317 chi2Old = chi2;
318 if ( flag2D )
319 {
320 f = dchi2da.sub( 1, 2 );
321 e = d2chi2d2a.sub( 1, 2 );
322 f = solve( e, f );
323 da[0] = f[0];
324 da[1] = f[1];
325 da[2] = 0;
326 da[3] = 0;
327 }
328 else
329 {
330 //...Cal. helix parameters for next loop...
331 da = solve( d2chi2d2a, dchi2da );
332 }
333 }
334 a -= factor * da;
335 t.a( a );
336 ++nTrial;
337 }
338
339 //...Cal. error matrix...
340 SymMatrix Ea( 4, 0 );
341 unsigned dim;
342 if ( flag2D )
343 {
344 dim = 2;
345 SymMatrix Eb( 3, 0 ), Ec( 3, 0 );
346 Eb = d2chi2d2a.sub( 1, 3 );
347 Ec = Eb.inverse( err );
348 Ea[0][0] = Ec[0][0];
349 Ea[0][1] = Ec[0][1];
350 Ea[0][2] = Ec[0][2];
351 Ea[1][1] = Ec[1][1];
352 Ea[1][2] = Ec[1][2];
353 Ea[2][2] = Ec[2][2];
354 }
355 else
356 {
357 dim = 4;
358 Ea = d2chi2d2a.inverse( err );
359 }
360
361 //...Store information...
362 if ( !err )
363 {
364 t.a( a );
365 t.Ea( Ea );
366 t._fitted = true;
367 if ( flag2D ) err = T3DLine2DFit;
368 }
369 else { err = TFitFailed; }
370
371 t._ndf = nCores - dim;
372 t._chi2 = chi2;
373
374 //...Recover pivot...
375 t.pivot( pivot_bak );
376
377 return err;
378}
HepGeom::Point3D< double > HepPoint3D
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
const HepPoint3D ORIGIN
Constants.
Definition TMDCUtil.cxx:47
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
HepGeom::Vector3D< double > HepVector3D
#define T3DLine2DFit
void dump(const std::string &message=std::string(""), const std::string &prefix=std::string("")) const
dumps debug information.
virtual unsigned objectType(void) const
returns object type.
int t()
Definition t.c:1

◆ fit() [5/6]

virtual int T3DLineFitter::fit ( TTrackBase & ,
float t0Offset ) const
virtual

◆ fit() [6/6]

virtual int T3DLineFitter::fit ( TTrackBase & ,
float t0Offset ) const
virtual

◆ propagation() [1/3]

void T3DLineFitter::propagation ( int _in)

Definition at line 85 of file T3DLineFitter.cxx.

85{ _propagation = _in; }

◆ propagation() [2/3]

void T3DLineFitter::propagation ( int )

◆ propagation() [3/3]

void T3DLineFitter::propagation ( int )

◆ sag() [1/3]

void T3DLineFitter::sag ( bool _in)

Definition at line 84 of file T3DLineFitter.cxx.

84{ _sag = _in; }

◆ sag() [2/3]

void T3DLineFitter::sag ( bool )

◆ sag() [3/3]

void T3DLineFitter::sag ( bool )

◆ tof() [1/3]

void T3DLineFitter::tof ( bool _in)

Definition at line 86 of file T3DLineFitter.cxx.

86{ _tof = _in; }

◆ tof() [2/3]

void T3DLineFitter::tof ( bool )

◆ tof() [3/3]

void T3DLineFitter::tof ( bool )

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