BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkCompTrk.cxx
Go to the documentation of this file.
1// #include "BaBar/BaBar.h"
2#include "TrkBase/TrkCompTrk.h"
3#include "TrkBase/HelixTraj.h"
4#include "TrkBase/NeutParams.h"
5#include "TrkBase/NeutTraj.h"
6#include "TrkBase/TrkMomCalculator.h"
7#include "TrkBase/TrkSimpTraj.h"
8#include <assert.h>
9#include <iostream>
10// #include "AbsEnv/AbsEnv.h"
11// #include "ProxyDict/Ifd.h"
12#include "MdcGeom/BesAngle.h"
13#include "MdcRecoUtil/BesPointErr.h"
14#include "MdcRecoUtil/BesVectorErr.h"
15#include "MdcRecoUtil/DifIndepPar.h"
16#include "MdcRecoUtil/DifPoint.h"
17#include "MdcRecoUtil/DifVector.h"
18#include "PatBField/BField.h"
19#include "ProxyDict/IfdStrKey.h"
20#include "TrkBase/TrkExchangePar.h"
21#include "TrkBase/TrkHelixUtils.h"
22#include "TrkBase/TrkPoca.h"
23using std::endl;
24using std::ostream;
25
27
28// Parameters Constructor
29//----------------------------------------------------------------------------
31 const HepMatrix& xpCov, int charge, double chisq, int nDof,
32 const BField* bf )
33 : _chisq( chisq ), _nDof( nDof ) {
34 //---------------------------------------------------------------------------
35 _bf = bf;
36 _charge = charge;
37 if ( _charge != 0 )
38 {
39 TrkExchangePar par1 = TrkHelixUtils::helixFromMomErr( pos, mom, xpCov, charge, bField() );
40 _traj.reset( new HelixTraj( par1.params(), par1.covariance() ) );
41 }
42 else
43 {
44 _traj.reset(
45 new NeutTraj( TrkHelixUtils::lineFromMomErr( pos, mom, xpCov, 1, bField() ) ) );
46 }
47}
48
49//-- Copy constructor
50//---------------------------------------------
52 : _bf( rhs._bf ), _chisq( rhs._chisq ), _nDof( rhs._nDof ) {
53 //---------------------------------------------
54 _traj.reset( (TrkSimpTraj*)rhs.traj().clone() );
55 _charge = rhs.charge();
56}
57
58//----------------------------------------------------------------------
60 //----------------------------------------------------------------------
61}
62
63//----------------------------------------------------------------------
65 //----------------------------------------------------------------------
66 if ( &right == this ) return *this;
67 _bf = right._bf;
68 _traj.reset( (TrkSimpTraj*)right.traj().clone() );
69 _chisq = right.chisq();
70 _nDof = right.nDof();
71 _charge = right.charge();
72 return *this;
73}
74
75//------------------------------------------------------------------------
76int TrkCompTrk::nDof() const {
77 //------------------------------------------------------------------------
78 return _nDof;
79}
80
81//------------------------------------------------------------------------
82double TrkCompTrk::chisq() const {
83 //------------------------------------------------------------------------
84 return _chisq;
85}
86
87//------------------------------------------------------------------------
88int TrkCompTrk::charge() const {
89 //------------------------------------------------------------------------
90 return _charge;
91}
92
93//------------------------------------------------------------------------
95 //------------------------------------------------------------------------
96 return *_traj;
97}
98
99//------------------------------------------------------------------------
100HepPoint3D TrkCompTrk::position( double fltL ) const {
101 //------------------------------------------------------------------------
102 return traj().position( fltL );
103}
104
105//------------------------------------------------------------------------
106Hep3Vector TrkCompTrk::direction( double fltL ) const {
107 //------------------------------------------------------------------------
108 return traj().direction( fltL );
109}
110
111Hep3Vector TrkCompTrk::momentum( double fltL ) const {
112 return TrkMomCalculator::vecMom( *_traj, bField(), fltL );
113}
114
116 // If getDFInfo is split up, use faster version - done JEA 020300
117 DifPoint posD;
118 DifVector dirD;
119 traj().getDFInfo2( fltL, posD, dirD );
120 HepMatrix err = posD.errorMatrix( posD.x.indepPar()->covariance() );
121 BesError symErr( 3 );
122 symErr.assign( err );
123 HepPoint3D point( posD.x.number(), posD.y.number(), posD.z.number() );
124 return BesPointErr( point, symErr );
125}
126
128 // If getDFInfo is split up, use faster version - done JEA 020300
129 DifPoint posD;
130 DifVector dirD;
131 traj().getDFInfo2( fltL, posD, dirD );
132 HepMatrix err = dirD.errorMatrix( dirD.x.indepPar()->covariance() );
133 BesError symErr( 3 );
134 symErr.assign( err );
135 Hep3Vector dir( dirD.x.number(), dirD.y.number(), dirD.z.number() );
136 return BesVectorErr( dir, symErr );
137}
138
140 return TrkMomCalculator::errMom( *_traj, bField(), fltL );
141}
142
143double TrkCompTrk::pt( double fltL ) const {
144 return TrkMomCalculator::ptMom( *_traj, bField(), fltL );
145 // This could probably be made more efficient.
146 // Hep3Vector pVec = momentum(fltL);
147 // return sqrt( pVec.x() * pVec.x() + pVec.y() * pVec.y() );
148}
149
150double TrkCompTrk::startValidRange() const { return traj().lowRange(); }
151
152double TrkCompTrk::endValidRange() const { return traj().hiRange(); }
153
154void TrkCompTrk::print( ostream& ostr ) const {
155 ostr << "Traj: ";
156 if ( _charge == -1 || _charge == 1 )
157 {
158 ostr << "Charged Particle -> Helix Trajectory" << endl;
159 HelixTraj& theTraj = (HelixTraj&)traj();
160 ostr << " phi0=" << BesAngle( theTraj.phi0() ).rad() << endl;
161 ostr << " d0=" << theTraj.d0() << endl;
162 ostr << " z0=" << theTraj.z0() << endl;
163 ostr << " omega=" << theTraj.omega() << endl;
164 ostr << " tanDip=" << theTraj.tanDip() << endl;
165 }
166 else
167 {
168 ostr << "Neutral Particle -> NeutTraj" << endl;
169 NeutTraj& theTraj = (NeutTraj&)traj();
170 ostr << " phi0=" << BesAngle( theTraj.params().phi0() ).rad() << endl;
171 ostr << " d0=" << theTraj.params().d0() << endl;
172 ostr << " z0=" << theTraj.params().z0() << endl;
173 ostr << " p=" << theTraj.params().p() << endl;
174 ostr << " tanDip=" << theTraj.params().tanDip() << endl;
175 }
176}
177
178void TrkCompTrk::printAll( ostream& ostr ) const { print( ostr ); }
179
180HepMatrix TrkCompTrk::posmomCov( double fltL ) const {
181 const BField& theField = bField();
182 return TrkMomCalculator::posmomCov( *_traj, theField, fltL );
183}
184
185void TrkCompTrk::getAllCovs( double fltL, HepSymMatrix& xxCov, HepSymMatrix& ppCov,
186 HepMatrix& xpCov ) const {
187 const BField& theField = bField();
188 TrkMomCalculator::getAllCovs( *_traj, theField, fltL, xxCov, ppCov, xpCov );
189}
190
191void TrkCompTrk::getAllWeights( double fltL, HepVector& pos, HepVector& mom,
192 HepSymMatrix& xxWeight, HepSymMatrix& ppWeight,
193 HepMatrix& xpWeight ) const {
194 const BField& theField = bField();
195 TrkMomCalculator::getAllWeights( *_traj, theField, fltL, pos, mom, xxWeight, ppWeight,
196 xpWeight );
197}
198
199void TrkCompTrk::getAllWeights( const HepPoint3D& pt, HepVector& pos, HepVector& mom,
200 HepSymMatrix& xxWeight, HepSymMatrix& ppWeight,
201 HepMatrix& xpWeight ) const {
202 double fltL = 0;
203 TrkPoca poca( traj(), fltL, pt );
204 fltL = poca.flt1();
205 getAllWeights( fltL, pos, mom, xxWeight, ppWeight, xpWeight );
206}
HepGeom::Point3D< double > HepPoint3D
HepSymMatrix errorMatrix(const HepSymMatrix &e) const
Definition DifVector.cxx:43
double phi0() const
virtual Trajectory * clone() const =0
virtual HepPoint3D position(double) const =0
virtual Hep3Vector direction(double) const =0
double chisq() const
double endValidRange() const
const TrkCompTrk & operator=(const TrkCompTrk &right)
double startValidRange() const
virtual ~TrkCompTrk()
virtual HepMatrix posmomCov(double fltL) const
BesVectorErr momentumErr(double fltL) const
BesVectorErr directionErr(double fltL) const
virtual void printAll(std::ostream &) const
virtual void getAllCovs(double fltL, HepSymMatrix &xxCov, HepSymMatrix &ppCov, HepMatrix &xpCov) const
double pt(double fltL=0.) const
Hep3Vector direction(double fltL) const
Hep3Vector momentum(double fltL=0.) const
virtual void getAllWeights(double fltL, HepVector &pos, HepVector &mom, HepSymMatrix &xxWeight, HepSymMatrix &ppWeight, HepMatrix &xpWeight) const
BesPointErr positionErr(double fltL) const
const TrkDifTraj & traj() const
TrkCompTrk(const BesPointErr &pos, const BesVectorErr &mom, const HepMatrix &xpCov, int charge, double chisq, int nDoF, const MdcPatRec::BField *bf)
virtual void print(std::ostream &) const
int charge() const
HepPoint3D position(double fltL) const
int nDof() const
virtual void getDFInfo2(double fltLen, DifPoint &pos, DifVector &direction) const
static NeutParams lineFromMomErr(const BesPointErr &vertex, const BesVectorErr &p, const HepMatrix &cxp, double sign, const BField &)
static TrkExchangePar helixFromMomErr(const BesPointErr &vertex, const BesVectorErr &p, const HepMatrix &cxp, double sign, const BField &)
static Hep3Vector vecMom(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen)
static double ptMom(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen)
static void getAllWeights(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen, HepVector &pos, HepVector &mom, HepSymMatrix &xxWeight, HepSymMatrix &ppWeight, HepMatrix &xpWeight)
static void getAllCovs(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen, HepSymMatrix &xxCov, HepSymMatrix &ppCov, HepMatrix &xpCov)
static HepMatrix posmomCov(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen)
static BesVectorErr errMom(const TrkSimpTraj &, const MdcPatRec::BField &, double fltlen)