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