BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
T3DLine.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------------
2// $Id: T3DLine.cxx,v 1.9 2010/03/31 09:58:59 liucy Exp $
3//-----------------------------------------------------------------------------
4// Filename : T3DLine.cc
5// Section : Tracking
6// Owner : Kenji Inami
7// Email : inami@bmail.kek.jp
8//-----------------------------------------------------------------------------
9// Description : A class to represent a 3D line in tracking.
10// See http://bsunsrv1.kek.jp/~yiwasaki/tracking/
11//-----------------------------------------------------------------------------
12
13#include "TrkReco/T3DLine.h"
14#include "TrkReco/T3DLineFitter.h"
15#include "TrkReco/TMDCWire.h"
16#include "TrkReco/TTrack.h"
17// #include "TrkReco/TMDCWire.h"
18
19const T3DLineFitter T3DLine::_fitter = T3DLineFitter( "T3DLine Default fitter" );
20
22 : TTrackBase()
23 , _dr( 0 )
24 , _phi0( 0 )
25 , _dz( 0 )
26 , _tanl( 0 )
27 , _chi2( 0 )
28 , _ndf( 0 )
29 , _Ea( SymMatrix( 4, 0 ) )
30 , _pivot( ORIGIN ) {
31
32 _cos_phi0 = 1;
33 _sin_phi0 = 0;
34
35 //...Set a default fitter...
36 fitter( &T3DLine::_fitter );
37
38 _fitted = false;
39 _fittedWithCathode = false;
40}
41
44 , _dr( a.helix().dr() )
45 , _phi0( a.helix().phi0() )
46 , _dz( a.helix().dz() )
47 , _tanl( a.helix().tanl() )
48 , _chi2( 0 )
49 , _ndf( 0 )
50 , _Ea( SymMatrix( 4, 0 ) )
51 , _pivot( a.helix().pivot() ) {
52
53 _cos_phi0 = cos( _phi0 );
54 _sin_phi0 = sin( _phi0 );
55
56 //...Set a default fitter...
57 fitter( &T3DLine::_fitter );
58
59 _fitted = false;
60 _fittedWithCathode = false;
61}
62
64
67 , _dr( a.dr() )
68 , _phi0( a.phi0() )
69 , _dz( a.dz() )
70 , _tanl( a.tanl() )
71 , _chi2( a.chi2() )
72 , _ndf( a.ndf() )
73 , _Ea( a.Ea() )
74 , _pivot( a.pivot() ) {
75
76 _cos_phi0 = cos( _phi0 );
77 _sin_phi0 = sin( _phi0 );
78
79 //...Set a default fitter...
80 fitter( &T3DLine::_fitter );
81
82 _fitted = false;
83 _fittedWithCathode = false;
84}
85
86double T3DLine::dr( void ) const { return _dr; }
87
88double T3DLine::phi0( void ) const { return _phi0; }
89
90double T3DLine::dz( void ) const { return _dz; }
91
92double T3DLine::tanl( void ) const { return _tanl; }
93
94double T3DLine::cosPhi0( void ) const { return _cos_phi0; }
95
96double T3DLine::sinPhi0( void ) const { return _sin_phi0; }
97
98const HepPoint3D& T3DLine::pivot( void ) const { return _pivot; }
99
100Vector T3DLine::a( void ) const {
101 Vector ta( 4 );
102 ta[0] = _dr;
103 ta[1] = _phi0;
104 ta[2] = _dz;
105 ta[3] = _tanl;
106 return ( ta );
107}
108
109const SymMatrix& T3DLine::Ea( void ) const { return ( _Ea ); }
110
111Helix T3DLine::helix( void ) const {
112 HepVector a( 5 );
113 a[0] = _dr;
114 a[1] = _phi0;
115 a[2] = 1e-10;
116 a[3] = _dz;
117 a[4] = _tanl;
118 Helix _helix( _pivot, a );
119 return _helix;
120}
121
122unsigned T3DLine::ndf( void ) const { return _ndf; }
123
124double T3DLine::chi2( void ) const { return _chi2; }
125
126double T3DLine::reducedchi2( void ) const {
127 if ( _ndf == 0 )
128 {
129 std::cout << "error at T3DLine::reducedchi2 ndf=0" << std::endl;
130 return 0;
131 }
132 return ( _chi2 / _ndf );
133}
134
135HepPoint3D T3DLine::x( double t ) const {
136 double tx = _pivot.x() + _dr * _cos_phi0 - t * _sin_phi0;
137 double ty = _pivot.y() + _dr * _sin_phi0 + t * _cos_phi0;
138 double tz = _pivot.z() + _dz + t * _tanl;
139 HepPoint3D p( tx, ty, tz );
140 return p;
141}
142
143HepPoint3D T3DLine::x0( void ) const {
144 double tx = _pivot.x() + _dr * _cos_phi0;
145 double ty = _pivot.y() + _dr * _sin_phi0;
146 double tz = _pivot.z() + _dz;
147 HepPoint3D p( tx, ty, tz );
148 return p;
149}
150HepVector3D T3DLine::k( void ) const {
151 HepPoint3D p( -_sin_phi0, _cos_phi0, _tanl );
152 return p;
153}
154
155const HepPoint3D& T3DLine::pivot( const HepPoint3D& newpivot ) {
156 double dr = ( _pivot.x() - newpivot.x() ) * _cos_phi0 +
157 ( _pivot.y() - newpivot.y() ) * _sin_phi0 + _dr;
158 double dz = _pivot.z() - newpivot.z() + _dz +
159 _tanl * ( ( _pivot.x() - newpivot.x() ) * _sin_phi0 +
160 ( newpivot.y() - _pivot.y() ) * _cos_phi0 );
161 _dr = dr;
162 _dz = dz;
163 _pivot = newpivot;
164 return _pivot;
165}
166
167void T3DLine::set( const HepPoint3D& t_pivot, double t_dr, double t_phi0, double t_dz,
168 double t_tanl ) {
169
170 _pivot = t_pivot;
171 _dr = t_dr;
172 _phi0 = t_phi0;
173 _dz = t_dz;
174 _tanl = t_tanl;
175 _cos_phi0 = cos( _phi0 );
176 _sin_phi0 = sin( _phi0 );
177}
178
180 _dr = ta[0];
181 _phi0 = ta[1];
182 _dz = ta[2];
183 _tanl = ta[3];
184 _cos_phi0 = cos( _phi0 );
185 _sin_phi0 = sin( _phi0 );
186 return ( ta );
187}
188
189const SymMatrix& T3DLine::Ea( const SymMatrix& tEa ) {
190 _Ea = tEa;
191 return ( _Ea );
192}
193
194int T3DLine::approach( TMLink& l, bool doSagCorrection ) const {
195
196 const TMDCWire& w = *l.wire();
197 HepPoint3D xw = w.xyPosition();
198 HepPoint3D wireBackwardPosition = w.backwardPosition();
199 HepVector3D v = w.direction();
200
201 HepPoint3D onWire, onTrack;
202
203 if ( approach_line( wireBackwardPosition, v, onWire, onTrack ) < 0 ) return ( -1 );
204
205 // onWire,onTrack filled
206
207 if ( !doSagCorrection )
208 {
209 l.positionOnWire( onWire );
210 l.positionOnTrack( onTrack );
211 return ( 0 ); // no sag correction
212 }
213 // Sag correction
214 // loop for sag correction
215 double onWire_y = onWire.y();
216 double onWire_z = onWire.z();
217
218 unsigned nTrial = 1;
219 while ( nTrial < 100 )
220 {
221 w.wirePosition( onWire_z, xw, wireBackwardPosition, (HepVector3D&)v );
222 if ( approach_line( wireBackwardPosition, v, onWire, onTrack ) < 0 ) return ( -1 );
223 if ( fabs( onWire_y - onWire.y() ) < 0.0001 ) break; // |dy|< 1 micron
224 onWire_y = onWire.y();
225 onWire_z = onWire.z();
226
227 nTrial++;
228 }
229
230 l.positionOnWire( onWire );
231 l.positionOnTrack( onTrack );
232 return ( nTrial );
233}
234
236 HepPoint3D& onTrack ) const {
237 // line = [w0] + s * [v] -> [onLine]
238 // trk = [x0] + t * [k] -> [onTrack]
239 // if [v]//[k] then return(-1) error
240
241 const HepVector3D k = this->k();
242 const double v_k = v.dot( k );
243 const double v_2 = v.mag2();
244 const double k_2 = k.mag2();
245 const double tk = v_k * v_k - v_2 * k_2;
246 if ( tk == 0 ) return ( -1 );
247
248 const HepPoint3D x0 = this->x0();
249 const HepPoint3D dx = x0 - w0;
250 const double t = dx.dot( v_2 * k - v_k * v ) / tk;
251 const double s = dx.dot( v_k * k - k_2 * v ) / tk;
252
253 onLine = w0 + s * v;
254 onTrack = x0 + t * k;
255 return ( 0 );
256}
257
258int T3DLine::approach_point( const HepPoint3D& p0, HepPoint3D& onTrack ) const {
259 // trk = [x0] + t * [k] -> [onTrack]
260 // if [v]//[k] then return(-1) error
261
262 const HepVector3D k = this->k();
263 const HepPoint3D x0 = this->x0();
264 const HepPoint3D dx = p0 - x0;
265 const double t = dx.dot( k ) / k.mag2();
266
267 onTrack = x0 + t * k;
268 return ( 0 );
269}
double w
XmlRpcServer s
const HepPoint3D ORIGIN
Constants.
Definition TMDCUtil.cxx:47
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition KarLud.h:35
HepGeom::Point3D< double > HepPoint3D
HepGeom::Vector3D< double > HepVector3D
A class to fit a TTrackBase object to a 3D line.
void set(const HepPoint3D &, double t_dr, double t_phi0, double t_dz, double t_tanl)
set track parameters,pivot
Definition T3DLine.cxx:167
double sinPhi0(void) const
Definition T3DLine.cxx:96
HepPoint3D x(double) const
returns position on 3D line
Definition T3DLine.cxx:135
double cosPhi0(void) const
Definition T3DLine.cxx:94
double dr(void) const
Track parameters.
Definition T3DLine.cxx:86
double phi0(void) const
Definition T3DLine.cxx:88
double reducedchi2(void) const
returns reduced-chi2
Definition T3DLine.cxx:126
int approach_point(const HepPoint3D &, HepPoint3D &onTrack) const
caluculate closest point between a point and this track
Definition T3DLine.cxx:258
HepPoint3D x0(void) const
returns 3D line component x(t)=x0 + t * k
Definition T3DLine.cxx:143
Helix helix(void) const
approximated helix class
Definition T3DLine.cxx:111
int approach(TMLink &, bool sagCorrection=true) const
Definition T3DLine.cxx:194
double tanl(void) const
Definition T3DLine.cxx:92
double dz(void) const
Definition T3DLine.cxx:90
double chi2(void) const
returns chi2.
Definition T3DLine.cxx:124
int approach_line(const HepPoint3D &, const HepVector3D &, HepPoint3D &onLine, HepPoint3D &onTrack) const
caluculate closest points between a line and this track
Definition T3DLine.cxx:235
HepVector3D k(void) const
Definition T3DLine.cxx:150
const HepPoint3D & pivot(void) const
pivot position
Definition T3DLine.cxx:98
const SymMatrix & Ea(void) const
returns error matrix
Definition T3DLine.cxx:109
unsigned ndf(void) const
returns NDF
Definition T3DLine.cxx:122
virtual ~T3DLine()
Destructor.
Definition T3DLine.cxx:63
Vector a(void) const
Definition T3DLine.cxx:100
T3DLine()
Constructors.
Definition T3DLine.cxx:21
const TMFitter *const fitter(void) const
returns a pointer to a default fitter.
TTrackBase()
Constructor.
A class to represent a track in tracking.
int t()
Definition t.c:1