BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkDifLineTraj.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkDifLineTraj.cxx,v 1.5 2007/12/07 07:06:34 zhangy Exp $
4//
5// Description:
6//
7// Environment:
8// Software developed for the BaBar Detector at the SLAC B-Factory.
9//
10// Author(s): Steve Schaffner
11//------------------------------------------------------------------------
12#include "TrkFitter/TrkDifLineTraj.h"
13#include <assert.h>
14#include <math.h>
15#include "MdcGeom/BesAngle.h"
16#include "TrkFitter/TrkDifLineTraj.h"
17#include "TrkBase/TrkExchangePar.h"
18#include "TrkBase/TrkVisitor.h"
19#include "MdcRecoUtil/DifNumber.h"
20#include "MdcRecoUtil/DifPoint.h"
21#include "MdcRecoUtil/DifVector.h"
22
23using CLHEP::Hep3Vector;
24
25TrkDifLineTraj::TrkDifLineTraj(const HepVector& pvec, const HepSymMatrix& pcov,
26 double lowlim, double hilim, const HepPoint3D& refpoint) :
27 TrkSimpTraj(pvec, pcov, lowlim,hilim,refpoint)
28{
29}
30
32 double lowlim, double hilim, const HepPoint3D& refpoint) :
33 TrkSimpTraj(HepVector(NLINPRM,1),HepSymMatrix(NLINPRM,1), lowlim,hilim,refpoint)
34{
35// the above constructor actually screws up z0 and tandip. I can't fix it in
36// the initializer, so I'll just overwrite the track here. Ugly and inefficient
37 HepVector subvect(NLINPRM,1);
38 HepSymMatrix submat(NLINPRM,1);
39 const HepSymMatrix covar = inpar.covariance();
40 subvect[d0Ind] = inpar.d0();
41 subvect[phi0Ind] = inpar.phi0();
42 subvect[z0Ind] = inpar.z0();
43 subvect[tanDipInd] = inpar.tanDip();
44
45 submat.fast(d0Ind+1,d0Ind+1) = covar.fast(TrkExchangePar::ex_d0+1,TrkExchangePar::ex_d0+1);
46 submat.fast(d0Ind+1,phi0Ind+1) = covar.fast(TrkExchangePar::ex_d0+1,TrkExchangePar::ex_phi0+1);
47 submat.fast(d0Ind+1,z0Ind+1) = covar.fast(TrkExchangePar::ex_d0+1,TrkExchangePar::ex_z0+1);
48 submat.fast(d0Ind+1,tanDipInd+1) = covar.fast(TrkExchangePar::ex_d0+1,TrkExchangePar::ex_tanDip+1);
49 submat.fast(phi0Ind+1,phi0Ind+1) = covar.fast(TrkExchangePar::ex_phi0+1,TrkExchangePar::ex_phi0+1);
50 submat.fast(phi0Ind+1,z0Ind+1) = covar.fast(TrkExchangePar::ex_phi0+1,TrkExchangePar::ex_z0+1);
51 submat.fast(phi0Ind+1,tanDipInd+1) = covar.fast(TrkExchangePar::ex_phi0+1,TrkExchangePar::ex_tanDip+1);
52 submat.fast(z0Ind+1,z0Ind+1) = covar.fast(TrkExchangePar::ex_z0+1,TrkExchangePar::ex_z0+1);
53 submat.fast(z0Ind+1,tanDipInd+1) = covar.fast(TrkExchangePar::ex_z0+1,TrkExchangePar::ex_tanDip+1);
55// reset the track
56 (*parameters()) = TrkParams(subvect,submat);
57}
58
60 : TrkSimpTraj(h.parameters()->parameter(), h.parameters()->covariance(),
61 h.lowRange(),h.hiRange(),h.referencePoint())
62{
63}
64
67{
68 return new TrkDifLineTraj(*this);
69}
70
73{
74 if( &h != this ){
76 _dtparams = *h.parameters();
78 }
79 return *this;
80}
81
83{
84}
85
86double
87TrkDifLineTraj::x( const double& f ) const
88{
89 return -d0() * sin(phi0()) + f * cos(phi0()) * cosDip() +
90 referencePoint().x();
91}
92
93double
94TrkDifLineTraj::y( const double& f ) const
95{
96 return d0() * cos(phi0()) + f * sin(phi0()) * cosDip() +
97 referencePoint().y();
98}
99
100double
101TrkDifLineTraj::z( const double& f ) const
102{
103 return z0() + f * tanDip() * cosDip() + referencePoint().z();
104}
105
108{
109 double cosd = cosDip();
110 double cp = cos(phi0());
111 double sp = sin(phi0());
112 return HepPoint3D(-d0()*sp + f*cp*cosd + referencePoint().x(),
113 d0()*cp + f*sp*cosd + referencePoint().y(),
114 z0() + f*tanDip()*cosd + referencePoint().z());
115}
116
117Hep3Vector
119{
120 double cdip = cosDip();
121 return Hep3Vector ( cos(phi0()) * cdip,
122 sin(phi0()) * cdip,
123 tanDip() * cdip);
124}
125
126Hep3Vector
128{
129 return Hep3Vector(0.0, 0.0, 0.0);
130}
131
132double
133TrkDifLineTraj::distTo1stError(double, double, int) const
134{
135 return 999.e4;
136}
137
138double
139TrkDifLineTraj::distTo2ndError(double, double, int) const
140{
141 return 999.e4;
142}
143
144void
145TrkDifLineTraj::getInfo(double fltLen, HepPoint3D& pos, Hep3Vector& dir,
146 Hep3Vector& delDir) const
147{
148 // This could be made much more efficient!!!!!!
149 pos = position(fltLen);
150 dir = direction(fltLen);
151 delDir = delDirect(fltLen);
152}
153
154void
155TrkDifLineTraj::getInfo( double fltLen, HepPoint3D& pos, Hep3Vector& dir ) const
156{
157 // This could be made much more efficient!!!!!
158 pos = position(fltLen);
159 dir = direction(fltLen);
160}
161
162void
164 DifVector& delDir) const
165{
166 //Provides difNum version of information for calculation of derivatives.
167
168 // Create difNumber versions of parameters
169 //enum index (phi0Index(), etc) is from TrkLineParams.hh
170 DifNumber phi0Df(phi0(), phi0Index()+1, nLinPrm());
171 DifNumber d0Df(d0(), d0Index()+1, nLinPrm());
172 DifNumber z0Df(z0(), z0Index()+1, nLinPrm());
173 DifNumber tanDipDf(tanDip(), tanDipIndex()+1, nLinPrm());
174 DifNumber zero(0.0, nLinPrm());
175 phi0Df.setIndepPar( parameters() );
176 d0Df.setIndepPar( parameters() );
177 z0Df.setIndepPar( parameters() );
178 tanDipDf.setIndepPar( parameters() );
180
181 DifNumber sphi0, cphi0;
182 phi0Df.cosAndSin(cphi0, sphi0);
183
184 DifNumber px(referencePoint().x());
185 DifNumber py(referencePoint().y());
186 DifNumber pz(referencePoint().z());
187
188 DifNumber cdip = 1. / sqrt(1. + tanDipDf*tanDipDf);
189 DifNumber xx = -d0Df * sphi0 + flt * cphi0 * cdip + px;
190 DifNumber yy = d0Df * cphi0 + flt * sphi0 * cdip + py;
191 DifNumber zz = z0Df + flt * tanDipDf * cdip + pz;
192
193 pos = DifPoint(xx, yy, zz);
194 dir = DifVector( cphi0 * cdip,
195 sphi0 * cdip,
196 tanDipDf * cdip);
197
198 delDir = DifVector(zero, zero, zero);
199}
200
201double
203{
204 return 0.;
205}
206
207double
209{
210 return BesAngle(parameters()->parameter()[phi0Index()]).rad();
211}
212
213HepMatrix
215{
216// This function computes the column matrix of derivatives for the change
217// in parameters for a change in the direction of a track at a point along
218// its flight, holding the momentum and position constant. The effects for
219// changes in 2 perpendicular directions (theta1 = dip and
220// theta2 = phi*cos(dip)) are uncorrelated.
221
222 HepMatrix ddflct(nLinPrm(),1);
223// Compute some common things
224 double cosd = cosDip();
225// Go through the parameters
226 switch (idirect) {
227 case theta1:
228 ddflct[tanDipIndex()][0] = 1.0/(cosd*cosd);
229 ddflct[d0Index()][0] = 0.0;
230 ddflct[phi0Index()][0] = 0.0;
231 ddflct[z0Index()][0] = -fltlen/cosd;;
232 break;
233 case theta2:
234 ddflct[tanDipIndex()][0] = 0;
235 ddflct[d0Index()][0] = -fltlen;
236 ddflct[phi0Index()][0] = 1.0/cosd;
237 ddflct[z0Index()][0] = -(tanDip()/cosd)*d0();
238 break;
239 }
240 return ddflct;
241}
242
243HepMatrix
245{
246// This function computes the column matrix of derivatives for the change
247// in parameters for a change in the position of a track at a point along
248// its flight, holding the momentum and direction constant. The effects for
249// changes in 2 perpendicular directions (theta1 = dip and
250// theta2 = phi*cos(dip)) are uncorrelated.
251
252 HepMatrix ddflct(nLinPrm(),1);
253// Compute some common things
254 double cosd = cosDip();
255// Go through the parameters
256 switch (idirect) {
257 case theta1:
258 ddflct[tanDipIndex()][0] = 0.0;
259 ddflct[d0Index()][0] = 0.0;
260 ddflct[phi0Index()][0] = 0.0;
261 ddflct[z0Index()][0] = 1.0/cosd;
262 break;
263 case theta2:
264 ddflct[tanDipIndex()][0] = 0;
265 ddflct[d0Index()][0] = 1.0;
266 ddflct[phi0Index()][0] = 0.0;
267 ddflct[z0Index()][0] = 0.0;
268 break;
269 }
270 return ddflct;
271}
272
273HepMatrix
275{
276// This function computes the column matrix of derrivatives for the change
277// in parameters from a (fractional) change in the track momentum,
278// holding the direction and position constant. The momentum change can
279// come from energy loss or bfield inhomogeneities. Line Trajs have no
280// geometric change from energy loss.
281
282 return HepMatrix(nLinPrm(),1, 0);
283}
284
285void
286TrkDifLineTraj::paramFunc(const HepPoint3D& oldpoint,const HepPoint3D& newpoint,
287 const HepVector& oldvec,const HepSymMatrix& oldcov,
288 HepVector& newvec,HepSymMatrix& newcov,
289 double fltlen)
290{
291// not yet implemented
292 std::cout<<"ErrMsg(fatal)" << "TrkDifLineTraj::paramFunc() is not implemented!" << std::endl;
293}
294
295void
296TrkDifLineTraj::invertParams(TrkParams* params, std::vector<bool>& flags) const
297{
298 // Inverts parameters and returns true if the parameter inversion
299 // requires a change in sign of elements in the covariance matrix
300 for (unsigned iparam = 0; iparam < NLINPRM; iparam++) {
301 switch ( iparam ) {
302 case d0Ind: // changes sign
303 case tanDipInd: // changes sign
304 params->parameter()[iparam] *= -1.0;
305 flags[iparam] = true;
306 break;
307 case phi0Ind: // changes by pi, but covariance matrix shouldn't change
308 params->parameter()[iparam] =
309 BesAngle(params->parameter()[iparam] + Constants::pi);
310 flags[iparam] = false;
311 break;
312 case z0Ind: // no change
313 flags[iparam] = false;
314 }
315 }
316 return;
317}
318
319void
321{
322// Visitor access--just use the TrkVisitor class member function
323 vis->trkVisitLineTraj(this);
324}
double sin(const BesAngle a)
double cos(const BesAngle a)
const DifNumber zero
************Class m_ypar INTEGER m_KeyWgt INTEGER m_KeyIHVP INTEGER m_KeyGPS INTEGER m_IsBeamPolarized INTEGER m_EvtGenInterface DOUBLE PRECISION m_Emin DOUBLE PRECISION m_sphot DOUBLE PRECISION m_Xenph DOUBLE PRECISION m_q2 DOUBLE PRECISION m_PolBeam2 DOUBLE PRECISION m_xErrPb *COMMON c_KK2f $ !CMS energy average $ !Spin Polarization vector first beam $ !Spin Polarization vector second beam $ !Beam energy spread[GeV] $ !minimum hadronization energy[GeV] $ !input parameters
Definition: KK2f.h:46
void cosAndSin(DifNumber &c, DifNumber &s) const
Trajectory & operator=(const Trajectory &)
Definition: Trajectory.cxx:86
virtual void getInfo(double fltLen, HepPoint3D &pos, Hep3Vector &dir) const
virtual void visitAccept(TrkVisitor *vis) const
virtual Hep3Vector direction(double fltLen) const
virtual double distTo1stError(double flt, double tol, int pathDir) const
TrkDifLineTraj(const HepVector &, const HepSymMatrix &, double lowlim=-99999., double hilim=99999., const HepPoint3D &refpoint=_theOrigin)
TrkDifLineTraj * clone() const
virtual Hep3Vector delDirect(double) const
double phi0() const
virtual void getDFInfo(double fltLen, DifPoint &, DifVector &dir, DifVector &delDir) const
void invertParams(TrkParams *params, std::vector< bool > &flags) const
virtual double distTo2ndError(double flt, double tol, int pathDir) const
HepMatrix derivDeflect(double fltlen, deflectDirection) const
TrkDifLineTraj & operator=(const TrkDifLineTraj &)
HepMatrix derivDisplace(double fltlen, deflectDirection) const
virtual double curvature(double fltLen) const
virtual HepPoint3D position(double fltLen) const
HepMatrix derivPFract(double fltlen) const
const HepPoint3D & referencePoint() const
virtual void trkVisitLineTraj(const TrkDifLineTraj *)=0
double y[1000]
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
double precision pisqo6 parameter(pi=3.14159265358979d0, pisq=pi *pi, pisqo6=pisq/6d0) double precision zip