38Lpar::Cpar::Cpar(
const Lpar&l) {
40 if (l.alpha() !=0 && l.beta() !=0)
41 m_fi = atan2(l.alpha(), -l.beta());
43 if(m_fi<0) m_fi+=2*
M_PI;
44 m_da = 2 * l.gamma()/ (1 + sqrt (1 + 4 * l.
kappa() * l.gamma()));
79 double x3,
double y3) {
83 double delta = (x1-x2)*(y1-y3) - (y1-y2)*(x1-x3);
89 double r12sq = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
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);
96 double r13sq = (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3);
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);
103 double r23sq = (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3);
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);
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);
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;
133HepMatrix Lpar::dldc() const
134#ifdef BELLE_OPTIMIZED_RETURN
145 vret(1,1) = 2*cp.da()*
s;
146 vret(1,2) = -2*cp.da()*c;
147 vret(1,3) = cp.da()*cp.da();
153 vret(3,1) = 2*cp.cu()*
s;
154 vret(3,2) = -2*cp.cu()*c;
160bool Lpar::xy(
double r,
double &x,
double &y,
int dir)
const {
161 double t_kr2g = kr2g(r);
162 double t_xi2 = xi2();
163 double ro = r * r * t_xi2 - t_kr2g * t_kr2g;
164 if ( ro < 0 )
return false;
165 double rs = sqrt(ro);
167 x = (- m_alpha * t_kr2g - m_beta * rs) / t_xi2;
168 y = (- m_beta * t_kr2g + m_alpha * rs) / t_xi2;
170 x = (- m_alpha * t_kr2g + m_beta * rs) / t_xi2;
171 y = (- m_beta * t_kr2g - m_alpha * rs) / t_xi2;
176double Lpar::x(
double r)
const {
182double Lpar::y(
double r)
const {
190 if (!xy(r,
x,y, dir))
return -1;
191 double p = atan2(y,
x);
192 if (p<0) p += (2*
M_PI);
196void Lpar::xhyh(
double x,
double y,
double &xh,
double &yh)
const {
197 double ddm =
dr(x, y);
203 double kdp1 = 1 + 2 *
kappa() * ddm;
204 xh =
x - ddm * ( 2 *
kappa() *
x + alpha())/kdp1;
205 yh = y - ddm * ( 2 *
kappa() * y + beta())/kdp1;
209 double xh, yh, xx, yy;
211 double fk = fabs(
kappa());
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);
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());
230#ifdef BELLE_OPTIMIZED_RETURN
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);
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()) -
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;
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]);
277 v2(1) = dinv * (ab1 + ac1 * rad2[1]);
278 v2(2) = dinv * (ab2 + ac2 * rad2[1]);
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]);
287 for(
int j=0;j<2;j++) {
290 s1 = lp1.
s(v1(1),v1(2));
291 s2 = lp2.
s(v1(1),v1(2));
293 s1 = lp1.
s(v2(1),v2(2));
294 s2 = lp2.
s(v2(1),v2(2));
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());
320 return o <<
" al=" <<
s.m_alpha <<
" be=" <<
s.m_beta
321 <<
" ka=" <<
s.m_kappa <<
" ga=" <<
s.m_gamma;
double sin(const BesAngle a)
double cos(const BesAngle a)
**********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
double dr(double x, double y) const
friend std::ostream & operator<<(std::ostream &o, Lpar &)
double d(double x, double y) const
friend int intersect(const Lpar &, const Lpar &, HepVector &, HepVector &)
void circle(double x1, double y1, double x2, double y2, double x3, double y3)
double s(double x, double y) const
double phi(double r, int dir=0) const