56 namespace mt2bl_bisect
66 double mt2bl::get_mt2bl()
70 cout <<
" Please set momenta first!" << endl;
74 if (!solved) mt2bl_bisect();
78 void mt2bl::set_momenta(
double *pl,
double *pb1,
double *pb2,
double* pmiss)
82 set_momenta(pl[0], pl[1], pl[2], pl[3],
83 pb1[0], pb1[1], pb1[2], pb1[3],
84 pb2[0], pb2[1], pb2[2], pb2[3],
90 void mt2bl::set_momenta(
double El,
double plx,
double ply,
double plz,
91 double Eb1,
double pb1x,
double pb1y,
double pb1z,
92 double Eb2,
double pb2x,
double pb2y,
double pb2z,
93 double pmissx,
double pmissy)
102 Easq = (El+Eb1)*(El+Eb1) - (plz+pb1z)*(plz+pb1z);
104 masq = max(0., Easq - pax*pax - pay*pay);
110 Ebsq = Eb2*Eb2 - pb2z*pb2z;
112 mbsq = max(0., Ebsq - pbx*pbx - pby*pby);
115 this->pmissx = pmissx;
116 this->pmissy = pmissy;
118 pmissxsq = pmissx*pmissx;
119 pmissysq = pmissy*pmissy;
126 if(ma + mn1 < mb + mn2)
129 temp = pax; pax = pbx; pbx = temp;
130 temp = pay; pay = pby; pby = temp;
131 temp = Ea; Ea = Eb; Eb = temp;
132 temp = Easq; Easq = Ebsq; Ebsq = temp;
133 temp = masq; masq = mbsq; mbsq = temp;
134 temp = ma; ma = mb; mb = temp;
135 temp = mn1; mn1 = mn2; mn2 = temp;
160 void mt2bl::mt2bl_bisect()
167 double Deltasq0 = ma*(ma + 2*mn1);
168 double Delta2sq0 = Deltasq0 + mn1sq - mn2sq;
172 a1 = 1-pax*pax/(Easq);
173 b1 = -pax*pay/(Easq);
174 c1 = 1-pay*pay/(Easq);
175 d1 = -pax*(Deltasq0-masq)/(2*Easq);
176 e1 = -pay*(Deltasq0-masq)/(2*Easq);
177 a2 = 1-pbx*pbx/(Ebsq);
178 b2 = -pbx*pby/(Ebsq);
179 c2 = 1-pby*pby/(Ebsq);
180 d2 = -pmissx+pbx*(Delta2sq0-mbsq)/(2*Ebsq)+pbx*(pbx*pmissx+pby*pmissy)/(Ebsq);
181 e2 = -pmissy+pby*(Delta2sq0-mbsq)/(2*Ebsq)+pby*(pbx*pmissx+pby*pmissy)/(Ebsq);
182 f2 = pmissx*pmissx+pmissy*pmissy-((Delta2sq0-mbsq)/(2*Eb)+
183 (pbx*pmissx+pby*pmissy)/Eb)*((Delta2sq0-mbsq)/(2*Eb)+
184 (pbx*pmissx+pby*pmissy)/Eb)+mn2sq;
193 x0 = (c1*d1-b1*e1)/(b1*b1-a1*c1);
194 y0 = (a1*e1-b1*d1)/(b1*b1-a1*c1);
198 double dis=a2*x0*x0+2*b2*x0*y0+c2*y0*y0+2*d2*x0+2*e2*y0+f2;
202 mt2bl_b = (double) sqrt(mn1sq+Deltasq0);
217 d20 = -a2*pmissx - b2*pmissy;
219 e20 = -c2*pmissy - b2*pmissx;
221 f21 = -2.*(pmissx*pbx+pmissy*pby);
222 f20 = a2*pmissxsq + 2.*b2*pmissx*pmissy + c2*pmissysq + mn2sq;
227 double Deltasq_high1;
230 Deltasq_high1 = 2*Eb*sqrt(p2x0*p2x0+p2y0*p2y0+mn2sq)-2*pbx*p2x0-2*pby*p2y0+mbsq + mn2sq - mn1sq;
234 double Deltasq_high2, Deltasq_high21, Deltasq_high22;
235 Deltasq_high21 = 2*Eb*sqrt(pmissx*pmissx+pmissy*pmissy+mn2sq)-2*pbx*pmissx-2*pby*pmissy+mbsq + mn2sq - mn1sq;
236 Deltasq_high22 = 2*Ea*mn1+masq;
238 if ( Deltasq_high21 < Deltasq_high22 ) Deltasq_high2 = Deltasq_high22;
239 else Deltasq_high2 = Deltasq_high21;
243 if(Deltasq_high1 < Deltasq_high2) Deltasq_high = Deltasq_high1;
244 else Deltasq_high = Deltasq_high2;
247 Deltasq_low = Deltasq0;
250 if( nsols(Deltasq_low) > 0 )
253 mt2bl_b = (double) sqrt(mn1sq+Deltasq0);
257 int nsols_high, nsols_low;
259 nsols_low = nsols(Deltasq_low);
266 nsols_high = nsols(Deltasq_high);
268 if(nsols_high == nsols_low || nsols_high == 4)
270 foundhigh = scan_high(Deltasq_high);
274 cout <<
"Deltasq_high not found, output ma+mn1" << endl;
282 mt2bl_b = sqrt( Deltasq_low + mn1sq );
288 while(sqrt(Deltasq_high+mn1sq) - sqrt(Deltasq_low+mn1sq) > precision)
290 double Deltasq_mid,nsols_mid;
292 Deltasq_mid = (Deltasq_high+Deltasq_low)/2.;
293 nsols_mid = nsols(Deltasq_mid);
295 if ( nsols_mid == 4 )
297 Deltasq_high = Deltasq_mid;
299 find_high(Deltasq_high);
304 if(nsols_mid != nsols_low) Deltasq_high = Deltasq_mid;
305 if(nsols_mid == nsols_low) Deltasq_low = Deltasq_mid;
307 mt2bl_b = (double) sqrt( mn1sq + Deltasq_high);
313 int mt2bl::find_high(
double & Deltasq_high)
316 x0 = (c1*d1-b1*e1)/(b1*b1-a1*c1);
317 y0 = (a1*e1-b1*d1)/(b1*b1-a1*c1);
318 double Deltasq_low = ma*(ma + 2*mn1);
321 double Deltasq_mid = (Deltasq_high + Deltasq_low)/2.;
322 int nsols_mid = nsols(Deltasq_mid);
323 if ( nsols_mid == 2 )
325 Deltasq_high = Deltasq_mid;
328 else if (nsols_mid == 4)
330 Deltasq_high = Deltasq_mid;
333 else if (nsols_mid ==0)
335 d1 = -pax*(Deltasq_mid-masq)/(2*Easq);
336 e1 = -pay*(Deltasq_mid-masq)/(2*Easq);
337 d2 = -pmissx + pbx*(Deltasq_mid - mbsq - mn2sq + mn1sq )/(2*Ebsq)
338 + pbx*(pbx*pmissx+pby*pmissy)/(Ebsq);
339 e2 = -pmissy + pby*(Deltasq_mid - mbsq - mn2sq + mn1sq)/(2*Ebsq)
340 + pby*(pbx*pmissx+pby*pmissy)/(Ebsq);
341 f2 = pmissx*pmissx+pmissy*pmissy-((Deltasq_mid-mbsq- mn2sq + mn1sq)/(2*Eb)+
342 (pbx*pmissx+pby*pmissy)/Eb)*((Deltasq_mid-mbsq- mn2sq + mn1sq)/(2*Eb)+
343 (pbx*pmissx+pby*pmissy)/Eb)+mn2sq;
345 double dis = a2*x0*x0 + 2*b2*x0*y0 + c2*y0*y0 + 2*d2*x0 + 2*e2*y0 + f2;
346 if (dis < 0) Deltasq_high = Deltasq_mid;
347 else Deltasq_low = Deltasq_mid;
351 }
while ( Deltasq_high - Deltasq_low > 0.001);
356 int mt2bl::scan_high(
double & Deltasq_high)
363 double tempmass, maxmass;
365 maxmass = sqrt(mn1sq + Deltasq_high);
367 for(
double mass = tempmass + scan_step; mass < maxmass; mass += scan_step)
369 Deltasq_high = mass*mass - mn1sq;
370 nsols_high = nsols(Deltasq_high);
374 Deltasq_low = (mass-scan_step)*(mass-scan_step) - mn1sq;
384 int mt2bl::nsols(
double Dsq)
386 double delta = (Dsq-masq)/(2*Easq);
387 double delta2 = (Dsq-mbsq - mn2sq + mn1sq )/(2*Ebsq);
393 f1 = f12*delta*delta+f10;
396 f2 = f22*delta2*delta2+f21*delta2+f20;
400 long double A4, A3, A2, A1, A0;
403 -4*a2*b1*b2*c1 + 4*a1*b2*b2*c1 +a2*a2*c1*c1 +
404 4*a2*b1*b1*c2 - 4*a1*b1*b2*c2 - 2*a1*a2*c1*c2 +
408 (-4*a2*b2*c1*d1 + 8*a2*b1*c2*d1 - 4*a1*b2*c2*d1 - 4*a2*b1*c1*d2 +
409 8*a1*b2*c1*d2 - 4*a1*b1*c2*d2 - 8*a2*b1*b2*e1 + 8*a1*b2*b2*e1 +
410 4*a2*a2*c1*e1 - 4*a1*a2*c2*e1 + 8*a2*b1*b1*e2 - 8*a1*b1*b2*e2 -
411 4*a1*a2*c1*e2 + 4*a1*a1*c2*e2)/Ea;
415 (4*a2*c2*d1*d1 - 4*a2*c1*d1*d2 - 4*a1*c2*d1*d2 + 4*a1*c1*d2*d2 -
416 8*a2*b2*d1*e1 - 8*a2*b1*d2*e1 + 16*a1*b2*d2*e1 +
417 4*a2*a2*e1*e1 + 16*a2*b1*d1*e2 - 8*a1*b2*d1*e2 -
418 8*a1*b1*d2*e2 - 8*a1*a2*e1*e2 + 4*a1*a1*e2*e2 - 4*a2*b1*b2*f1 +
419 4*a1*b2*b2*f1 + 2*a2*a2*c1*f1 - 2*a1*a2*c2*f1 +
420 4*a2*b1*b1*f2 - 4*a1*b1*b2*f2 - 2*a1*a2*c1*f2 + 2*a1*a1*c2*f2)/Easq;
423 (-8*a2*d1*d2*e1 + 8*a1*d2*d2*e1 + 8*a2*d1*d1*e2 - 8*a1*d1*d2*e2 -
424 4*a2*b2*d1*f1 - 4*a2*b1*d2*f1 + 8*a1*b2*d2*f1 + 4*a2*a2*e1*f1 -
425 4*a1*a2*e2*f1 + 8*a2*b1*d1*f2 - 4*a1*b2*d1*f2 - 4*a1*b1*d2*f2 -
426 4*a1*a2*e1*f2 + 4*a1*a1*e2*f2)/(Easq*Ea);
429 (-4*a2*d1*d2*f1 + 4*a1*d2*d2*f1 + a2*a2*f1*f1 +
430 4*a2*d1*d1*f2 - 4*a1*d1*d2*f2 - 2*a1*a2*f1*f2 +
431 a1*a1*f2*f2)/(Easq*Easq);
433 long double A0sq, A1sq, A2sq, A3sq, A4sq;
440 long double B3, B2, B1, B0;
446 long double C2, C1, C0;
447 C2 = -(A2/2 - 3*A3sq/(16*A4));
448 C1 = -(3*A1/4. -A2*A3/(8*A4));
449 C0 = -A0 + A1*A3/(16*A4);
452 D1 = -B1 - (B3*C1*C1/C2 - B3*C0 -B2*C1)/C2;
453 D0 = -B0 - B3 *C0 *C1/(C2*C2)+ B2*C0/C2;
456 E0 = -C0 - C2*D0*D0/(D1*D1) + C1*D0/D1;
458 long double t1,t2,t3,t4,t5;
469 nsol = signchange_n(t1,t2,t3,t4,t5) - signchange_p(t1,t2,t3,t4,t5);
472 if (nsol < 0) nsol = 0;
478 inline int mt2bl::signchange_n(
long double t1,
long double t2,
long double t3,
long double t4,
long double t5)
488 inline int mt2bl::signchange_p(
long double t1,
long double t2,
long double t3,
long double t4,
long double t5)
#define RELATIVE_PRECISION
#define ABSOLUTE_PRECISION