BOSS 7.1.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 : [email protected]
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"
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),_phi0(0),_dz(0),_tanl(0),
24 _chi2(0),_ndf(0),_Ea(SymMatrix(4,0)),
25 _pivot(ORIGIN){
26
27 _cos_phi0 = 1;
28 _sin_phi0 = 0;
29
30 //...Set a default fitter...
31 fitter(& T3DLine::_fitter);
32
33 _fitted = false;
34 _fittedWithCathode = false;
35}
36
38 : TTrackBase((TTrackBase &) a),
39 _dr(a.helix().dr()),
40 _phi0(a.helix().phi0()),
41 _dz(a.helix().dz()),
42 _tanl(a.helix().tanl()),
43 _chi2(0),_ndf(0),_Ea(SymMatrix(4,0)),
44 _pivot(a.helix().pivot()){
45
46 _cos_phi0 = cos(_phi0);
47 _sin_phi0 = sin(_phi0);
48
49 //...Set a default fitter...
50 fitter(& T3DLine::_fitter);
51
52 _fitted = false;
53 _fittedWithCathode = false;
54}
55
57}
58
60 : TTrackBase((TTrackBase &) a),
61 _dr(a.dr()),
62 _phi0(a.phi0()),
63 _dz(a.dz()),
64 _tanl(a.tanl()),
65 _chi2(a.chi2()),_ndf(a.ndf()),
66 _Ea(a.Ea()),
67 _pivot(a.pivot()){
68
69 _cos_phi0 = cos(_phi0);
70 _sin_phi0 = sin(_phi0);
71
72 //...Set a default fitter...
73 fitter(& T3DLine::_fitter);
74
75 _fitted = false;
76 _fittedWithCathode = false;
77}
78
79double T3DLine::dr(void) const{
80 return _dr;
81}
82
83double T3DLine::phi0(void) const{
84 return _phi0;
85}
86
87double T3DLine::dz(void) const{
88 return _dz;
89}
90
91double T3DLine::tanl(void) const{
92 return _tanl;
93}
94
95double T3DLine::cosPhi0(void) const{
96 return _cos_phi0;
97}
98
99double T3DLine::sinPhi0(void) const{
100 return _sin_phi0;
101}
102
103const HepPoint3D& T3DLine::pivot(void) const{
104 return _pivot;
105}
106
107Vector T3DLine::a(void) const{
108 Vector ta(4);
109 ta[0] = _dr;
110 ta[1] = _phi0;
111 ta[2] = _dz;
112 ta[3] = _tanl;
113 return(ta);
114}
115
116const SymMatrix& T3DLine::Ea(void) const{
117 return(_Ea);
118}
119
121 HepVector a(5);
122 a[0]=_dr;a[1]=_phi0;a[2]=1e-10;a[3]=_dz;a[4]=_tanl;
123 Helix _helix(_pivot,a);
124 return _helix;
125}
126
127unsigned T3DLine::ndf(void) const{
128 return _ndf;
129}
130
131double T3DLine::chi2(void) const{
132 return _chi2;
133}
134
135double T3DLine::reducedchi2(void) const{
136 if(_ndf==0){
137 std::cout<<"error at T3DLine::reducedchi2 ndf=0"<<std::endl;
138 return 0;
139 }
140 return (_chi2/_ndf);
141}
142
143HepPoint3D T3DLine::x(double t) const{
144 double tx= _pivot.x() + _dr * _cos_phi0 - t * _sin_phi0;
145 double ty= _pivot.y() + _dr * _sin_phi0 + t * _cos_phi0;
146 double tz= _pivot.z() + _dz + t * _tanl;
147 HepPoint3D p(tx,ty,tz);
148 return p;
149}
150
152 double tx= _pivot.x() + _dr * _cos_phi0;
153 double ty= _pivot.y() + _dr * _sin_phi0;
154 double tz= _pivot.z() + _dz;
155 HepPoint3D p(tx,ty,tz);
156 return p;
157}
159 HepPoint3D p(-_sin_phi0,_cos_phi0,_tanl);
160 return p;
161}
162
163const HepPoint3D& T3DLine::pivot(const HepPoint3D& newpivot){
164 double dr=(_pivot.x()-newpivot.x())*_cos_phi0
165 +(_pivot.y()-newpivot.y())*_sin_phi0 + _dr;
166 double dz=_pivot.z()-newpivot.z()+_dz
167 +_tanl*((_pivot.x()-newpivot.x())*_sin_phi0
168 +(newpivot.y()-_pivot.y())*_cos_phi0);
169 _dr=dr;
170 _dz=dz;
171 _pivot=newpivot;
172 return _pivot;
173}
174
175void T3DLine::set(const HepPoint3D& t_pivot,
176 double t_dr,double t_phi0,double t_dz,double t_tanl){
177
178 _pivot = t_pivot;
179 _dr = t_dr;
180 _phi0 = t_phi0;
181 _dz = t_dz;
182 _tanl = t_tanl;
183 _cos_phi0 = cos(_phi0);
184 _sin_phi0 = sin(_phi0);
185}
186
188 _dr = ta[0];
189 _phi0 = ta[1];
190 _dz = ta[2];
191 _tanl = ta[3];
192 _cos_phi0 = cos(_phi0);
193 _sin_phi0 = sin(_phi0);
194 return(ta);
195}
196
197const SymMatrix& T3DLine::Ea(const SymMatrix& tEa){
198 _Ea = tEa;
199 return(_Ea);
200}
201
202int T3DLine::approach(TMLink& l,bool doSagCorrection) const{
203
204 const TMDCWire& w=*l.wire();
205 HepPoint3D xw = w.xyPosition();
206 HepPoint3D wireBackwardPosition = w.backwardPosition();
207 HepVector3D v = w.direction();
208
209 HepPoint3D onWire,onTrack;
210
211 if(approach_line(wireBackwardPosition,v,onWire,onTrack)<0)
212 return(-1);
213
214 // onWire,onTrack filled
215
216 if(!doSagCorrection){
217 l.positionOnWire(onWire);
218 l.positionOnTrack(onTrack);
219 return(0); // no sag correction
220 }
221 // Sag correction
222 // loop for sag correction
223 double onWire_y = onWire.y();
224 double onWire_z = onWire.z();
225
226 unsigned nTrial = 1;
227 while(nTrial<100){
228 w.wirePosition(onWire_z,xw,wireBackwardPosition,(HepVector3D&)v);
229 if(approach_line(wireBackwardPosition,v,onWire,onTrack)<0)
230 return(-1);
231 if(fabs(onWire_y - onWire.y())<0.0001) break; // |dy|< 1 micron
232 onWire_y = onWire.y();
233 onWire_z = onWire.z();
234
235 nTrial++;
236 }
237
238 l.positionOnWire(onWire);
239 l.positionOnTrack(onTrack);
240 return(nTrial);
241}
242
244 HepPoint3D& onLine,HepPoint3D& onTrack) const{
245 // line = [w0] + s * [v] -> [onLine]
246 // trk = [x0] + t * [k] -> [onTrack]
247 // if [v]//[k] then return(-1) error
248
249 const HepVector3D k = this->k();
250 const double v_k = v.dot(k);
251 const double v_2 = v.mag2();
252 const double k_2 = k.mag2();
253 const double tk = v_k*v_k - v_2*k_2;
254 if(tk==0) return(-1);
255
256 const HepPoint3D x0 = this->x0();
257 const HepPoint3D dx = x0 - w0;
258 const double t = dx.dot( v_2 * k - v_k * v)/tk;
259 const double s = dx.dot( v_k * k - k_2 * v)/tk;
260
261 onLine = w0 + s * v;
262 onTrack = x0 + t * k;
263 return(0);
264}
265
266int T3DLine::approach_point(const HepPoint3D& p0,HepPoint3D& onTrack) const{
267 // trk = [x0] + t * [k] -> [onTrack]
268 // if [v]//[k] then return(-1) error
269
270 const HepVector3D k = this->k();
271 const HepPoint3D x0 = this->x0();
272 const HepPoint3D dx = p0 - x0;
273 const double t = dx.dot(k)/k.mag2();
274
275 onTrack = x0 + t * k;
276 return(0);
277}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
double w
XmlRpcServer s
Definition: HelloServer.cpp:11
**********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
const HepPoint3D ORIGIN
Constants.
Definition: TMDCUtil.cxx:47
TTree * t
Definition: binning.cxx:23
A class to fit a TTrackBase object to a 3D line.
Definition: T3DLineFitter.h:41
A class to represent a track in tracking.
Definition: T3DLine.h:50
void set(const HepPoint3D &, double t_dr, double t_phi0, double t_dz, double t_tanl)
set track parameters,pivot
Definition: T3DLine.cxx:175
double sinPhi0(void) const
Definition: T3DLine.cxx:99
HepPoint3D x(double) const
returns position on 3D line
Definition: T3DLine.cxx:143
double cosPhi0(void) const
Definition: T3DLine.cxx:95
double dr(void) const
Track parameters.
Definition: T3DLine.cxx:79
double phi0(void) const
Definition: T3DLine.cxx:83
double reducedchi2(void) const
returns reduced-chi2
Definition: T3DLine.cxx:135
int approach_point(const HepPoint3D &, HepPoint3D &onTrack) const
caluculate closest point between a point and this track
Definition: T3DLine.cxx:266
HepPoint3D x0(void) const
returns 3D line component x(t)=x0 + t * k
Definition: T3DLine.cxx:151
Helix helix(void) const
approximated helix class
Definition: T3DLine.cxx:120
int approach(TMLink &, bool sagCorrection=true) const
calculates the closest approach to a wire in real space. Results are stored in TMLink....
Definition: T3DLine.cxx:202
double tanl(void) const
Definition: T3DLine.cxx:91
double dz(void) const
Definition: T3DLine.cxx:87
double chi2(void) const
returns chi2.
Definition: T3DLine.cxx:131
int approach_line(const HepPoint3D &, const HepVector3D &, HepPoint3D &onLine, HepPoint3D &onTrack) const
caluculate closest points between a line and this track
Definition: T3DLine.cxx:243
HepVector3D k(void) const
Definition: T3DLine.cxx:158
const HepPoint3D & pivot(void) const
pivot position
Definition: T3DLine.cxx:103
const SymMatrix & Ea(void) const
returns error matrix
Definition: T3DLine.cxx:116
unsigned ndf(void) const
returns NDF
Definition: T3DLine.cxx:127
virtual ~T3DLine()
Destructor.
Definition: T3DLine.cxx:56
Vector a(void) const
Definition: T3DLine.cxx:107
T3DLine()
Constructors.
Definition: T3DLine.cxx:21
A class to represent a wire in MDC.
Definition: TMDCWire.h:55
A virtual class for a track class in tracking.
Definition: TTrackBase.h:46
bool _fittedWithCathode
Definition: TTrackBase.h:163
bool _fitted
Definition: TTrackBase.h:162
const TMFitter *const fitter(void) const
returns a pointer to a default fitter.
Definition: TTrackBase.h:255
A class to represent a track in tracking.
Definition: TTrack.h:129