CGEM BOSS 6.6.5.i
BESIII Offline Software System
Loading...
Searching...
No Matches
Lpar Class Reference

#include <Lpar.h>

+ Inheritance diagram for Lpar:

Public Member Functions

 Lpar ()
 
virtual ~Lpar ()
 
const Lparoperator= (const Lpar &)
 
void neg ()
 
void circle (double x1, double y1, double x2, double y2, double x3, double y3)
 
double kappa () const
 
double radius () const
 
HepVector center () const
 
double s (double x, double y) const
 
double d (double x, double y) const
 
double dr (double x, double y) const
 
double s (double r, int dir=0) const
 
double phi (double r, int dir=0) const
 
int sd (double r, double x, double y, double limit, double &s, double &d) const
 
HepVector Hpar (const HepPoint3D &pivot) const
 

Friends

class Lpav
 
class Lpar::Cpar
 
std::ostream & operator<< (std::ostream &o, Lpar &s)
 
int intersect (const Lpar &lp1, const Lpar &lp2, HepVector &v1, HepVector &v2)
 

Detailed Description

Constructor & Destructor Documentation

◆ Lpar()

Lpar::Lpar ( )
inline

Definition at line 164 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

164 {
165 m_alpha = 0;
166 m_beta = 1;
167 m_gamma = 0;
168 m_kappa = 0;
169 StatusCode scmgn = Gaudi::svcLocator()->service("MagneticFieldSvc",m_pmgnIMF);
170 if(scmgn!=StatusCode::SUCCESS) {
171 std::cout<< "Unable to open Magnetic field service"<<std::endl;
172 }
173}

◆ ~Lpar()

Lpar::~Lpar ( )
virtual

Definition at line 53 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

54{
55}

Member Function Documentation

◆ center()

HepVector Lpar::center ( ) const

Definition at line 229 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

232{
233#else
234{
235 HepVector v(3);
236#endif
237 v(1) = xc();
238 v(2) = yc();
239 v(3) = 0;
240 return(v);
241}
**********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

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), FTTrack::r_phiFit(), and FTWire::z().

◆ circle()

void Lpar::circle ( double x1,
double y1,
double x2,
double y2,
double x3,
double y3 )

Definition at line 78 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

79 {
80 double a;
81 double b;
82 double c;
83 double delta = (x1-x2)*(y1-y3) - (y1-y2)*(x1-x3);
84 if(delta==0) {
85 //
86 // three points are on a line.
87 //
88 m_kappa = 0;
89 double r12sq = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
90 if (r12sq>0) {
91 double r12 = sqrt(r12sq);
92 m_beta = -(x1-x2)/r12;
93 m_alpha = (y1-y2)/r12;
94 m_gamma = - (m_alpha*x1+m_beta*y1);
95 } else {
96 double r13sq = (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3);
97 if (r13sq>0) {
98 double r13 = sqrt(r13sq);
99 m_beta = -(x1-x3)/r13;
100 m_alpha = (y1-y3)/r13;
101 m_gamma = - (m_alpha*x3+m_beta*y3);
102 } else {
103 double r23sq = (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3);
104 if (r23sq>0) {
105 double r23 = sqrt(r23sq);
106 m_beta = -(x2-x3)/r23;
107 m_alpha = (y2-y3)/r23;
108 m_gamma = - (m_alpha*x3+m_beta*y3);
109 } else {
110 m_alpha = 1;
111 m_beta = 0;
112 m_gamma = 0;
113 }
114 }
115 }
116 } else {
117 double r1sq = x1 * x1 + y1 * y1;
118 double r2sq = x2 * x2 + y2 * y2;
119 double r3sq = x3 * x3 + y3 * y3;
120 a = 0.5 * ( (y1-y3)*(r1sq-r2sq) - (y1-y2)*(r1sq-r3sq)) / delta;
121 b = 0.5 * (- (x1-x3)*(r1sq-r2sq) + (x1-x2)*(r1sq-r3sq)) / delta;
122 double csq = (x1-a)*(x1-a) + (y1-b)*(y1-b);
123 c = sqrt(csq);
124 double csq2 = (x2-a)*(x2-a) + (y2-b)*(y2-b);
125 double csq3 = (x3-a)*(x3-a) + (y3-b)*(y3-b);
126 m_kappa = 1 / (2 * c);
127 m_alpha = - 2 * a * m_kappa;
128 m_beta = - 2 * b * m_kappa;
129 m_gamma = (a*a + b*b - c*c) * m_kappa;
130 }
131}

◆ d()

double Lpar::d ( double x,
double y ) const
inline

Definition at line 220 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

220 {
221 double dd = d0(x,y);
222 const double approx_limit = 0.2;
223 if(std::fabs(m_kappa*dd)>approx_limit) return -1;
224 return dd * ( 1 - m_kappa * dd );
225}

Referenced by Lpav::delta_chisq(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), FTTrack::r_phiReFit(), and sd().

◆ dr()

double Lpar::dr ( double x,
double y ) const
inline

Definition at line 227 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

227 {
228 double dx = xc() - x;
229 double dy = yc() - y;
230 double r = 0.5/std::fabs(m_kappa);
231 return std::fabs(std::sqrt(dx * dx + dy * dy) - r);
232}

◆ Hpar()

HepVector Lpar::Hpar ( const HepPoint3D & pivot) const
inline

Definition at line 280 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

280 {
281 HepVector a(5);
282 double m_bField = -10000*(m_pmgnIMF->getReferField());////zhangr 2012-09-06 for MagnField
283 //double m_bField = 10000*(m_pmgnIMF->getReferField());
284 double m_alpha = 10000. / 2.99792458 / m_bField;
285 double dd = d0(pivot.x(),pivot.y());
286 a(1) = dd * ( m_kappa * dd - 1 );
287 a(2) = (m_kappa>0) ? std::atan2(yc() - pivot.y(), xc() - pivot.x()) + M_PI
288 : std::atan2(pivot.y() - yc(), pivot.x() - xc()) - M_PI + 2*M_PI;
289 //a(3) = -2.0*BELLE_ALPHA*m_kappa;
290 a(3) = -2.0*m_alpha*m_kappa;
291 a(4) = 0;
292 a(5) = 0;
293 return a;
294}
#define M_PI
Definition TConstant.h:4
virtual double getReferField()=0

Referenced by FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), FTTrack::r_phiReFit(), and FTTrack::s_zFit().

◆ kappa()

double Lpar::kappa ( ) const
inline

Definition at line 73 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

73{ return m_kappa; }

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), s(), and s().

◆ neg()

void Lpar::neg ( )
inline

Definition at line 209 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

209 {
210 m_alpha = -m_alpha;
211 m_beta = -m_beta;
212 m_gamma = -m_gamma;
213 m_kappa = -m_kappa;
214}

Referenced by Lpav::calculate_lpar(), and Lpav::calculate_lpar3().

◆ operator=()

const Lpar & Lpar::operator= ( const Lpar & l)
inline

Definition at line 182 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

182 {
183 if (this != &l) {
184 m_alpha = l.m_alpha;
185 m_beta = l.m_beta;
186 m_gamma = l.m_gamma;
187 m_kappa = l.m_kappa;
188 }
189 return *this;
190}

Referenced by Lpav::operator=().

◆ phi()

double Lpar::phi ( double r,
int dir = 0 ) const

Definition at line 188 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

188 {
189 double x, y;
190 if (!xy(r,x,y, dir)) return -1;
191 double p = atan2(y,x);
192 if (p<0) p += (2*M_PI);
193 return p;
194}

Referenced by Lpav::extrapolate(), and sd().

◆ radius()

double Lpar::radius ( ) const
inline

Definition at line 74 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

74{ return 0.5/std::fabs(m_kappa);}

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), and FTWire::z().

◆ s() [1/2]

double Lpar::s ( double r,
int dir = 0 ) const

Definition at line 220 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

220 {
221 double d0 = da();
222 if (fabs(r)<fabs(d0)) return -1;
223 double b = fabs(kappa()) * sqrt((r*r-d0*d0)/(1 + 2 * kappa() * d0));
224 if (fabs(b)>1) return -1;
225 if(dir==0)return asin(b)/fabs(kappa());
226 return (M_PI-asin(b))/fabs(kappa());
227}

◆ s() [2/2]

double Lpar::s ( double x,
double y ) const

Definition at line 208 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

208 {
209 double xh, yh, xx, yy;
210 xhyh(x, y, xh, yh);
211 double fk = fabs(kappa());
212 if (fk==0) return 0;
213 yy = 2 * fk * ( alpha() * yh - beta() * xh);
214 xx = 2 * kappa() * ( alpha() * xh + beta() * yh ) + xi2();
215 double sp = atan2(yy, xx);
216 if (sp<0) sp += (2*M_PI);
217 return sp / 2 / fk;
218}

Referenced by FTTrack::s_zFit().

◆ sd()

int Lpar::sd ( double r,
double x,
double y,
double limit,
double & s,
double & d ) const
inline

Definition at line 261 of file TrackUtil/TrackUtil-00-00-12/TrackUtil/Lpar.h.

262 {
263 if ((x*yc()-y*xc())*m_kappa<0) return 0;
264 double dd = d0(x,y);
265 d = dd * ( 1 - m_kappa * dd );
266 double d_cross_limit = d*limit;
267 if (d_cross_limit < 0 || d_cross_limit > limit*limit) return 0;
268 double rc = std::sqrt(m_alpha*m_alpha+m_beta*m_beta)/(2*m_kappa);
269 double rho = 1./(-2*m_kappa);
270 double cosPhi = (rc*rc + rho*rho - r*r)/(-2*rc*rho);
271 double phi = std::acos(cosPhi);
272 s = std::fabs(rho)*phi;
273 d *= r/(std::fabs(rc)*std::sin(phi));
274 if (abs(d) > abs(limit)) return 0;
275 d_cross_limit = d*limit;
276 if (d_cross_limit > limit*limit) return 0;
277 return 1;
278}
double abs(const EvtComplex &c)
XmlRpcServer s
double d(double x, double y) const
double phi(double r, int dir=0) const

Referenced by FTSegment::update3D().

Friends And Related Symbol Documentation

◆ intersect

int intersect ( const Lpar & lp1,
const Lpar & lp2,
HepVector & v1,
HepVector & v2 )
friend

Definition at line 243 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

243 {
244 HepVector cen1(lp1.center());
245 HepVector cen2(lp2.center());
246 double dx = cen1(1)-cen2(1);
247 double dy = cen1(2)-cen2(2);
248 double dc = sqrt(dx*dx+dy*dy);
249 if(dc<fabs(0.5/lp1.kappa())+fabs(0.5/lp2.kappa())) {
250 double a1 = std::sqrt(lp1.alpha()) + std::sqrt(lp1.beta());
251 double a2 = std::sqrt(lp2.alpha()) + std::sqrt(lp2.beta());
252 double a3 = lp1.alpha()*lp2.alpha() + lp1.beta()*lp2.beta();
253 double det = lp1.alpha()*lp2.beta() - lp1.beta()*lp2.alpha();
254 if(fabs(det)>1e-12) {
255 double c1 = a2 * std::sqrt(lp1.kappa()) + a1 * std::sqrt(lp2.kappa()) -
256 2.0 * a3 * lp1.kappa() * lp2.kappa();
257 if(c1!=0) {
258 double cinv = 1.0 / c1;
259 double c2 = std::sqrt(a3) - 0.5 * (a1 + a2) - 2.0 * a3 *
260 (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
261 double c3 = a2 * std::sqrt(lp1.gamma()) + a1 * std::sqrt(lp2.gamma()) -
262 2.0 * a3 * lp1.gamma() * lp2.gamma();
263 double root = std::sqrt(c2) - 4.0 * c1 * c3;
264 if (root>=0) {
265 root = sqrt(root);
266 double rad2[2];
267 rad2[0] = 0.5 * cinv * (-c2 - root);
268 rad2[1] = 0.5 * cinv * (-c2 + root);
269 double ab1 = -(lp2.beta() * lp1.gamma() - lp1.beta() * lp2.gamma());
270 double ab2 = (lp2.alpha() * lp1.gamma() - lp1.alpha() * lp2.gamma());
271 double ac1 = -(lp2.beta() * lp1.kappa() - lp1.beta() * lp2.kappa());
272 double ac2 = (lp2.alpha() * lp1.kappa() - lp1.alpha() * lp2.kappa());
273 double dinv = 1.0 / det;
274 v1(1) = dinv * (ab1 + ac1 * rad2[0]);
275 v1(2) = dinv * (ab2 + ac2 * rad2[0]);
276 v1(3) = 0;
277 v2(1) = dinv * (ab1 + ac1 * rad2[1]);
278 v2(2) = dinv * (ab2 + ac2 * rad2[1]);
279 v2(3) = 0;
280 double d1 = lp1.d(v1(1),v1(2));
281 double d2 = lp2.d(v1(1),v1(2));
282 double d3 = lp1.d(v2(1),v2(2));
283 double d4 = lp2.d(v2(1),v2(2));
284 double r = sqrt(rad2[0]);
285 Lpar::Cpar cp1(lp1);
286 Lpar::Cpar cp2(lp2);
287 for(int j=0;j<2;j++) {
288 double s1,s2;
289 if(j==0) {
290 s1 = lp1.s(v1(1),v1(2));
291 s2 = lp2.s(v1(1),v1(2));
292 } else {
293 s1 = lp1.s(v2(1),v2(2));
294 s2 = lp2.s(v2(1),v2(2));
295 }
296 double phi1 = cp1.fi() + 2 * cp1.cu() * s1;
297 double phi2 = cp2.fi() + 2 * cp2.cu() * s2;
298 double f = (1 + 2 * cp1.cu() * cp1.da()) *
299 (1 + 2 * cp2.cu() * cp2.da()) * cos(cp1.fi()-cp2.fi());
300 f -= 2 * (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
301 double cosphi12 = f;
302 }
303 return 2;
304 }
305 }
306 }
307 }
308 return 0;
309}
double cos(const BesAngle a)
Definition BesAngle.h:213
std::string root
TCanvas * c1
Double_t phi2
Double_t phi1
int dc[18]
Definition EvtPycont.cc:42
double s(double x, double y) const

◆ Lpar::Cpar

friend class Lpar::Cpar
friend

◆ Lpav

friend class Lpav
friend

◆ operator<<

std::ostream & operator<< ( std::ostream & o,
Lpar & s )
friend

Definition at line 319 of file TrackUtil/TrackUtil-00-00-12/src/Lpar.cxx.

319 {
320 return o << " al=" << s.m_alpha << " be=" << s.m_beta
321 << " ka=" << s.m_kappa << " ga=" << s.m_gamma;
322}

The documentation for this class was generated from the following files: