BOSS 7.1.1
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 "MdcGeom/Constants.h"
11#include "BField/BField.h"
12#include "TrkBase/TrkSimpTraj.h"
14#include "MdcGeom/BesAngle.h"
15#include "ProxyDict/IfdIntKey.h"
16#include "TrkBase/TrkRecoTrk.h"
17using std::endl;
18using std::ostream;
19
20// Construct from exchange parameters
22 TrkRecoTrk* trk,
23 PdtPid::PidType hypo,
24 const TrkHotList *hots) :
25 TrkSimpleRep(hots, trk, hypo),
26 _traj(inPar)
27{}
28
29
30// Construct from exchange parameters, no hits
32 PdtPid::PidType hypo, int nact, int nsv, int ndc, double chi2,
33 double stFndRng, double endFndRng) :
34 TrkSimpleRep(trk, hypo, nact, nsv, ndc, chi2, stFndRng, endFndRng),
35 _traj(inPar.params(), inPar.covariance())
36{}
37
38// copy ctor
40 TrkSimpleRep(old, trk, hypo), _traj(old._traj)
41{}
42
45
48{
49 TrkHelixRep* newRep = new TrkHelixRep(*this, theTrack, this->particleType());
50 newRep->setCurrent(fitCurrent());
51 return newRep;
52}
53
56{
57 TrkHelixRep* newRep = new TrkHelixRep(*this, parentTrack(), hypo);
58 newRep->setValid(fitValid());
59 newRep->setCurrent(fitCurrent()); // true for helices, anyway
60 return newRep;
61}
62
64TrkHelixRep::helix(double ) const
65{
66 HepVector outPar = _traj.parameters()->parameter();
68 return TrkExchangePar(outPar, _traj.parameters()->covariance());
69}
70
71void
72TrkHelixRep::print(ostream& ostr) const
73{
74 ostr << "TrkHelixRep "
75 << " q: "<<charge()
76 << " phi0: " << BesAngle(_traj.phi0()).rad()
77 << " om: "<<_traj.omega()
78 << " pt: "<<pt()
79 << " p: "<<momentum()
80 << " d0: " << _traj.d0()
81 << " z0: " << _traj.z0()
82 << " ct: " << _traj.tanDip()
83 << "parent track: "<<parentTrack()->id() << endl;
84}
85
86void
87TrkHelixRep::printAll(ostream& ostr) const
88{
89 print(ostr);
90}
91
94{
95 return _traj;
96}
97
98const TrkSimpTraj&
100{
101 return _traj;
102}
103
106{
107 return _traj;
108}
109
110const TrkDifTraj&
112{
113 return _traj;
114}
115
116//Returns arbitrary key, distinguishing this Rep from all other reps
117const IfdKey&
119{
120 static IfdIntKey _theKey(3133);
121 return _theKey;
122}
123
124
125bool
126TrkHelixRep::resid(const TrkHitOnTrk *h, double& residual, double& residErr,
127 bool exclude) const
128{
129 if (this != h->getParentRep() ) return false;
130 static HepVector derivs; double deltaChi;
131 TrkErrCode errCode = h->getFitStuff( derivs, deltaChi );
132 // TODO: add caching of derivatives here...
133 if (errCode.failure()) return false;
134 if (!exclude || !h->isActive()) {
135 HepSymMatrix c = _traj.parameters()->covariance().similarityT(derivs);
136 double tErr2 = c(1,1);
137 double rms = h->hitRms();
138 residual=h->residual();
139 double e2=rms*rms+(h->isActive()?-1:1)*tErr2;
140 if (e2<0) return false;
141 residErr=sqrt(e2);
142 } else {
143 assert(h->isActive());
144 // FIXME: never really checked this is really OK...
145 // FIXME: should compare to HelixRefiner...
146 HepSymMatrix w=_traj.parameters()->covariance();
147 int ier;
148 w.invert(ier);
149 if (ier!=0) return false;
150 HepVector p0 = _traj.parameters()->parameter();
151 HepVector p1 = w*p0;
152 p1 -= deltaChi*derivs;
153 for (unsigned i=0; i<p0.num_row(); ++i) for (unsigned j=0; j<i+1 ;++j) {
154 w.fast(i+1,j+1) -= derivs[i]*derivs[j];
155 }
156 w.invert(ier);
157 if (ier!=0) return false;
158 residual=h->residual()+h->hitRms()*dot(derivs,w*p1-p0);
159 residErr=h->hitRms()*sqrt(w(1,1)+1);
160 }
161 return true;
162}
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 rad() const
Definition BesAngle.h:118
HepVector & parameter()
Definition DifIndepPar.h:51
double omega() const
Definition HelixTraj.h:81
double d0() const
Definition HelixTraj.h:79
double phi0() const
double z0() const
Definition HelixTraj.h:82
double tanDip() const
Definition HelixTraj.h:83
PidType
Definition PdtPid.h:11
int failure() const
Definition TrkErrCode.h:61
void setValid(bool v)
bool fitValid() const
bool fitCurrent() const
void setCurrent(bool c)
virtual TrkDifTraj & traj()
const IfdKey & myKey() const
virtual bool resid(const TrkHitOnTrk *h, double &residual, double &residErr, bool exclude) const
virtual TrkHelixRep * clone(TrkRecoTrk *newTrack) const
virtual void printAll(std::ostream &ostr) const
virtual void print(std::ostream &ostr) 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)
double residual() const
double hitRms() const
Definition TrkHitOnTrk.h:89
const TrkRep * getParentRep() const
Definition TrkHitOnTrk.h:73
bool isActive() const
TrkErrCode getFitStuff(HepVector &derivs, double &deltaChi) const
HepSymMatrix & covariance()
Definition TrkParams.h:54
const TrkId & id() const
TrkRecoTrk * parentTrack()
Definition TrkRep.h:82
virtual PdtPid::PidType particleType() const
Definition TrkRep.cxx:308
TrkParams * parameters()
Definition TrkSimpTraj.h:80
virtual double pt(double fltL=0.) const
virtual int charge() const