CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
bak_TrkFitter-00-01-12/src/TrkBmSpotOnTrk.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkBmSpotOnTrk.cxx,v 1.1.1.1 2017/12/15 12:01:44 huangzhen Exp $
4//
5// Description:
6// Implementation of class to add beam spot to track fit.
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Authors: Steve Schaffner
12//------------------------------------------------------------------------
13#include <math.h>
14#include "CLHEP/Vector/ThreeVector.h"
15#include "CLHEP/Geometry/Point3D.h"
16#ifndef ENABLE_BACKWARDS_COMPATIBILITY
18#endif
19#include "TrkFitter/TrkBmSpotOnTrk.h"
20#include "TrkBase/TrkDifTraj.h"
21#include "TrkBase/TrkPoca.h"
22#include "TrkBase/TrkDifPoca.h"
23#include "TrkBase/TrkRep.h"
24using CLHEP::Hep3Vector;
25
26static HepPoint3D dum1(0,0,0),dum2(0,0,1);
27
28TrkBmSpotOnTrk::TrkBmSpotOnTrk(const HepPoint3D& ip, const HepSymMatrix& size)
29 : TrkHitOnTrk(0,0.5e-4),
30 _beamTraj(FindBeamTrajectory(ip,size)),
31 _ip(ip),
32 _size(size)
33{}
34
35// Effectively a copy constructor
37 : TrkHitOnTrk(hot,newRep,trkTraj),
38 _beamTraj(hot._beamTraj),
39 _ip(hot.ip()),
40 _size(hot._size)
41{}
42
43
45{ }
46
48TrkBmSpotOnTrk::clone(TrkRep *rep, const TrkDifTraj *trkTraj) const
49{
50 return new TrkBmSpotOnTrk(*this,rep,trkTraj);
51}
52
53
56{
57 TrkErrCode status=updatePoca(traj,x);
58 if (status.success()) {
59 assert(_poca!=0);
62 } else {
63#ifdef MDCPATREC_WARNING
64 std::cout<<"ErrMsg(warning) TrkBmSpotOnTrk::updateMeasurement failed" << std::endl;
65#endif
66 setHitResid(9999.9);
67 setHitRms(9999.9);
68 }
69 return status;
70}
71
74{
75 return TrkEnums::xyView;
76}
77
78const Trajectory*
80{
81 return &_beamTraj;
82}
83
84const HepPoint3D&
86{
87 return _ip;
88}
89
90
91//
92// GetRms
93//
94// Calculate RMS (hit width or resolution) based on local track
95// trajectory.
96//
97// We have to deal with the error ellipse carefully. To do
98// this, find the point along the linear trajectory in x and y
99// that minimizes the chi-squared, and then use doca/sqrt(chi2)
100// as the RMS.
101//
103{
104 //
105 // Get direction
106 //
107 const TrkDifTraj& trkTraj = getParentRep()->traj();
108 Hep3Vector trkDir = trkTraj.direction(fltLen());
109
110 //
111 // Get errors (assume no correlation)
112 //
113 double Mxx = 1.0/_size.fast(1,1);
114 double Myy = 1.0/_size.fast(2,2);
115
116 //
117 // Normalized track directions in x/y
118 //
119 double vx = trkDir[0];
120 double vy = trkDir[1];
121 double normxy = (vx*vx + vy*vy);
122 if (normxy <= 0) return 999.9;
123 normxy = sqrt(normxy);
124
125 vx /= normxy;
126 vy /= normxy;
127
128 //
129 // Solve for point of least chi2
130 //
131 double s = vx*vy*(Mxx-Myy)/(vx*vx*Mxx + vy*vy*Myy);
132
133 double dx = (-vy + s*vx);
134 double dy = (+vx + s*vy);
135
136 double chi2 = dx*dx*Mxx + dy*dy*Myy;
137
138 return chi2 <= 0 ? 0.0 : (1.0/sqrt(chi2));
139}
140
141
142//
143// FindBeamTrajectory
144//
145// Calculate a linear trajectory that corresponds to the
146// beam spot and error matrix
147//
148// The simplest way I have to understand this calculation
149// is to consider which (x,y) point is required to minimize
150// the chi2 at +/- one unit in z.
151//
152// The following simple calculation assumes x and y are uncorrelated.
153// This is to save CPU. It is straight forward to extend the
154// calculation to finite x/y correlation.
155//
157 const HepSymMatrix &error )
158{
159 int ifail;
160 HepSymMatrix cover(error.inverse(ifail));
161
162 if (ifail) {
163#ifdef MDCPATREC_FATAL
164 std::cout<<"ErrMsg(fatal) TrkLineTraj: "
165 <<"Error inverting beamspot error matrix" << std::endl;
166#endif
167 }
168 double dx = -cover.fast(3,1)/cover.fast(1,1);
169 double dy = -cover.fast(3,2)/cover.fast(2,2);
170
171 HepPoint3D p1 = point + Hep3Vector(-dx,-dy,-1);
172 HepPoint3D p2 = point + Hep3Vector(+dx,+dy,+1);
173
174 return TrkLineTraj( p1, p2 );
175}
Double_t x[10]
XmlRpcServer s
Definition: HelloServer.cpp:11
HepGeom::Point3D< double > HepPoint3D
static HepPoint3D dum2(0, 0, 1)
virtual Hep3Vector direction(double) const =0
virtual const TrkDifTraj & traj() const =0
TrkBmSpotOnTrk * clone(TrkRep *, const TrkDifTraj *t=0) const
static const TrkLineTraj FindBeamTrajectory(const HepPoint3D &point, const HepSymMatrix &error)
virtual TrkEnums::TrkViewInfo whatView() const
TrkBmSpotOnTrk(const HepPoint3D &ip, const HepSymMatrix &size)
TrkErrCode updatePoca(const TrkDifTraj *trkTraj, bool maintainAmbiguity)
friend class TrkBase::Functors::updateMeasurement