BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkSimpTraj.cxx
Go to the documentation of this file.
1
2//--------------------------------------------------------------------------
3// File and Version Information:
4// $Id: TrkSimpTraj.cxx,v 1.2 2005/07/18 02:56:08 zhangy Exp $
5//
6// Description:
7//
8//
9// Environment:
10// Software developed for the BaBar Detector at the SLAC B-Factory.
11//
12// Author(s): Steve Schaffner
13//
14//------------------------------------------------------------------------
15
16// #include "BaBar/BaBar.h"
17#include "TrkBase/TrkSimpTraj.h"
18#include "CLHEP/Matrix/SymMatrix.h"
19#include "MdcGeom/BesAngle.h"
20#include "MdcGeom/Constants.h"
21#include "TrkBase/TrkParams.h"
22#include "TrkBase/TrkPocaXY.h"
23// #include "ErrLogger/ErrLog.h"
24using std::ostream;
25
26// statics
27HepPoint3D TrkSimpTraj::_theOrigin( 0.0, 0.0, 0.0 );
28// Constructors
29//----------------------------------------------------------------------------
30TrkSimpTraj::TrkSimpTraj( const HepVector& params, const HepSymMatrix& cov,
31 const double lowlim, const double hilim, const HepPoint3D& refpoint )
32 : //----------------------------------------------------------------------------
33 TrkDifTraj( lowlim, hilim )
34 , _dtparams( params, cov )
35 , _refpoint( refpoint ) {
36 ;
37}
38
39TrkSimpTraj::TrkSimpTraj( const TrkParams& params, const double lowlim, const double hilim,
40 const HepPoint3D& refpoint )
41 : //----------------------------------------------------------------------------
42 TrkDifTraj( lowlim, hilim )
43 , _dtparams( params )
44 , _refpoint( refpoint ) {
45 ;
46}
47
48//----------------------------------------------------------------------------
50 : //----------------------------------------------------------------------------
51 TrkDifTraj( other.lowRange(), other.hiRange() )
52 , _dtparams( other._dtparams )
53 , _refpoint( other._refpoint ) {}
54
55//----------------------------------------------------------------------------
57//----------------------------------------------------------------------------
58{}
59
60//----------------------------------------------------------------------------
61const TrkSimpTraj* TrkSimpTraj::localTrajectory( double fltLen, double& localFlt ) const {
62 //----------------------------------------------------------------------------
63 localFlt = fltLen;
64 return this;
65}
66
67//
68// The following is the only useful function which can be implemented at this level
69//
70//----------------------------------------------------------------------------
71void TrkSimpTraj::changePoint( const HepPoint3D& newpoint, double& fltlen ) {
72 //----------------------------------------------------------------------------
73 if ( newpoint != _refpoint )
74 {
75 // find POCA to the new point
76 TrkPocaXY endpoca( *this, fltlen, newpoint );
77 if ( endpoca.status().failure() )
78 {
79 std::cout << "ErrMsg(error)"
80 << "poca failure changing reference point" << std::endl;
81 return;
82 }
83 else
84 {
85 // update flight length
86 fltlen = endpoca.flt1();
87 // make a symmatrix from the covariance: temporary kludge
88 int nrow = parameters()->covariance().num_row();
89 HepSymMatrix cov( nrow );
90 for ( int irow = 0; irow < nrow; irow++ )
91 for ( int icol = 0; icol <= irow; icol++ )
92 cov.fast( irow + 1, icol + 1 ) =
93 parameters()->covariance().fast( irow + 1, icol + 1 );
94 // Get the translation function
96 // Use it on the SimpTraj parameters
97 pfunc( _refpoint, newpoint, parameters()->parameter(), cov, _dtparams.parameter(), cov,
98 fltlen );
99 // put back the covariance
100 _dtparams.covariance() = cov;
101 _refpoint = newpoint;
102 // update the flight range to correspond to the same range in space as before
103 double newrange[2];
104 newrange[0] = lowRange() - fltlen;
105 newrange[1] = hiRange() - fltlen;
106 setFlightRange( newrange );
107 }
108 }
109 return;
110}
111//----------------------------------------------------------------------------
112void TrkSimpTraj::printAll( ostream& os ) const {
113 //----------------------------------------------------------------------------
114 os << "Simple ";
116 os << "SimpTraj parameter vector = " << _dtparams.parameter();
117 os << " and covariance matrix = " << _dtparams.covariance();
118}
119//----------------------------------------------------------------------------
120void TrkSimpTraj::print( ostream& os ) const {
121 //----------------------------------------------------------------------------
122 os << "Simple ";
123 Trajectory::print( os );
124}
125// Inversion. This changes the flightrange from A->B to (-B)->(-A), as well
126// adjusting the parameters so that the same arc in space is described (just
127// going the opposite direction). This is now implemented fully generically.
129 // Invert parameters
130 std::vector<bool> flags( parameters()->nPar(), false );
131 invertParams( parameters(), flags );
132 // loop over parameters and invert covariance matrix
133 for ( int iparam = 0; iparam < parameters()->nPar(); iparam++ )
134 {
135 bool iinvert = flags[iparam];
136 // do covariance cross-terms too
137 for ( int jparam = iparam + 1; jparam < parameters()->nPar(); jparam++ )
138 {
139 bool jinvert = flags[jparam];
140 if ( ( iinvert && !jinvert ) || ( !iinvert && jinvert ) )
141 {
142 // cross-terms change sign
143 parameters()->covariance()[iparam][jparam] *= -1.0;
144 }
145 }
146 }
147 // invert the flightlength
148 double range[2];
149 range[0] = -hiRange();
150 range[1] = -lowRange();
152 // done
153 return *this;
154}
155
156bool TrkSimpTraj::operator==( const TrkSimpTraj& x ) const {
157 if ( lowRange() != x.lowRange() || hiRange() != x.hiRange() ) return false;
158 const HepVector& m = _dtparams.parameter();
159 unsigned int mp = m.num_row();
160 const HepVector& n = x._dtparams.parameter();
161 unsigned int np = n.num_row();
162 if ( np != mp ) return false;
163 for ( unsigned i = 0; i < np; ++i )
164 {
165 if ( m[i] != n[i] ) return false;
166 }
167 return _refpoint == x._refpoint;
168}
HepGeom::Point3D< double > HepPoint3D
const Int_t n
double mp
void(* TranslateParams)(const HepPoint3D &oldpoint, const HepPoint3D &newpoint, const HepVector &oldpar, const HepSymMatrix &oldcov, HepVector &newpar, HepSymMatrix &newcov, double fltlen)
virtual void print(std::ostream &os) const
virtual void setFlightRange(double newrange[2])
virtual void printAll(std::ostream &os) const
TrkDifTraj(const double lowlim=-99999., const double hilim=99999.)
virtual TranslateParams paramFunction() const =0
TrkSimpTraj(const HepVector &params, const HepSymMatrix &cov, const double startRange=-99999., const double endRange=99999., const HepPoint3D &refpoint=_theOrigin)
TrkSimpTraj & invert()
bool operator==(const TrkSimpTraj &) const
void changePoint(const HepPoint3D &newpoint, double &fltlen)
virtual void print(std::ostream &os) const
virtual void printAll(std::ostream &os) const
virtual ~TrkSimpTraj()
virtual const TrkSimpTraj * localTrajectory(double fltLen, double &localFlt) const
virtual void invertParams(TrkParams *newparams, std::vector< bool > &flags) const =0