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