BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkHelixRep.cxx
Go to the documentation of this file.
1// File and Version Information:
2// $Id: TrkHelixRep.cxx,v 1.4 2011/09/26 00:56:56 zhangy Exp $
3//
4// Description:
5// Implements helix track representation
6//
7// Author(s): Steve Schaffner
8//------------------------------------------------------------------------
9#include "TrkFitter/TrkHelixRep.h"
10#include "MdcGeom/BesAngle.h"
11#include "MdcGeom/Constants.h"
12#include "PatBField/BField.h"
13#include "ProxyDict/IfdIntKey.h"
14#include "TrkBase/TrkExchangePar.h"
15#include "TrkBase/TrkRecoTrk.h"
16#include "TrkBase/TrkSimpTraj.h"
17using std::endl;
18using std::ostream;
19
21
22// Construct from exchange parameters
24 const TrkHotList* hots )
25 : TrkSimpleRep( hots, trk, hypo ), _traj( inPar ) {}
26
27// Construct from exchange parameters, no hits
29 int nact, int nsv, int ndc, double chi2, double stFndRng,
30 double endFndRng )
31 : TrkSimpleRep( trk, hypo, nact, nsv, ndc, chi2, stFndRng, endFndRng )
32 , _traj( inPar.params(), inPar.covariance() ) {}
33
34// copy ctor
36 : TrkSimpleRep( old, trk, hypo ), _traj( old._traj ) {}
37
39
41 TrkHelixRep* newRep = new TrkHelixRep( *this, theTrack, this->particleType() );
42 newRep->setCurrent( fitCurrent() );
43 return newRep;
44}
45
47 TrkHelixRep* newRep = new TrkHelixRep( *this, parentTrack(), hypo );
48 newRep->setValid( fitValid() );
49 newRep->setCurrent( fitCurrent() ); // true for helices, anyway
50 return newRep;
51}
52
54 HepVector outPar = _traj.parameters()->parameter();
56 return TrkExchangePar( outPar, _traj.parameters()->covariance() );
57}
58
59void TrkHelixRep::print( ostream& ostr ) const {
60 ostr << "TrkHelixRep "
61 << " q: " << charge() << " phi0: " << BesAngle( _traj.phi0() ).rad()
62 << " om: " << _traj.omega() << " pt: " << pt() << " p: " << momentum()
63 << " d0: " << _traj.d0() << " z0: " << _traj.z0() << " ct: " << _traj.tanDip()
64 << "parent track: " << parentTrack()->id() << endl;
65}
66
67void TrkHelixRep::printAll( ostream& ostr ) const { print( ostr ); }
68
70
71const TrkSimpTraj& TrkHelixRep::simpTraj() const { return _traj; }
72
73TrkDifTraj& TrkHelixRep::traj() { return _traj; }
74
75const TrkDifTraj& TrkHelixRep::traj() const { return _traj; }
76
77// Returns arbitrary key, distinguishing this Rep from all other reps
78const IfdKey& TrkHelixRep::myKey() const {
79 static IfdIntKey _theKey( 3133 );
80 return _theKey;
81}
82
83bool TrkHelixRep::resid( const TrkHitOnTrk* h, double& residual, double& residErr,
84 bool exclude ) const {
85 if ( this != h->getParentRep() ) return false;
86 static HepVector derivs;
87 double deltaChi;
88 TrkErrCode errCode = h->getFitStuff( derivs, deltaChi );
89 // TODO: add caching of derivatives here...
90 if ( errCode.failure() ) return false;
91 if ( !exclude || !h->isActive() )
92 {
93 HepSymMatrix c = _traj.parameters()->covariance().similarityT( derivs );
94 double tErr2 = c( 1, 1 );
95 double rms = h->hitRms();
96 residual = h->residual();
97 double e2 = rms * rms + ( h->isActive() ? -1 : 1 ) * tErr2;
98 if ( e2 < 0 ) return false;
99 residErr = sqrt( e2 );
100 }
101 else
102 {
103 assert( h->isActive() );
104 // FIXME: never really checked this is really OK...
105 // FIXME: should compare to HelixRefiner...
106 HepSymMatrix w = _traj.parameters()->covariance();
107 int ier;
108 w.invert( ier );
109 if ( ier != 0 ) return false;
110 HepVector p0 = _traj.parameters()->parameter();
111 HepVector p1 = w * p0;
112 p1 -= deltaChi * derivs;
113 for ( unsigned i = 0; i < p0.num_row(); ++i )
114 for ( unsigned j = 0; j < i + 1; ++j )
115 { w.fast( i + 1, j + 1 ) -= derivs[i] * derivs[j]; }
116 w.invert( ier );
117 if ( ier != 0 ) return false;
118 residual = h->residual() + h->hitRms() * dot( derivs, w * p1 - p0 );
119 residErr = h->hitRms() * sqrt( w( 1, 1 ) + 1 );
120 }
121 return true;
122}
double p1[4]
**********INTEGER nmxhep !maximum number of particles DOUBLE PRECISION vhep INTEGER jdahep COMMON hepevt $ !serial number $ !number of particles $ !status code $ !particle ident KF $ !parent particles $ !childreen particles $ !four momentum
Double_t e2
double w
double phi0() const
void setValid(bool v)
virtual TrkDifTraj & traj()
virtual void print(std::ostream &ostr) const
const IfdKey & myKey() const
virtual bool resid(const TrkHitOnTrk *h, double &residual, double &residErr, bool exclude) const
virtual TrkHelixRep * clone(TrkRecoTrk *newTrack) const
virtual ~TrkHelixRep()
virtual TrkExchangePar helix(double fltLen) const
virtual TrkSimpTraj & simpTraj()
virtual TrkHelixRep * cloneNewHypo(PdtPid::PidType hypo)
TrkHelixRep(const TrkExchangePar &inPar, TrkRecoTrk *myTrack, PdtPid::PidType hypo, const TrkHotList *=0)
virtual void printAll(std::ostream &ostr) const
double residual() const
TrkErrCode getFitStuff(HepVector &derivs, double &deltaChi) const
const TrkId & id() const
virtual PdtPid::PidType particleType() const
Definition TrkRep.cxx:249
virtual double pt(double fltL=0.) const
virtual int charge() const
TrkSimpleRep(const TrkHotList *, TrkRecoTrk *, PdtPid::PidType)