test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions | Private Attributes
heppy::Davismt2 Class Reference

#include <Davismt2.h>

Public Member Functions

 Davismt2 ()
 
double get_mt2 ()
 
void mt2_bisect ()
 
void mt2_massless ()
 
void print ()
 
void set_mn (double mn)
 
void set_momenta (double *pa0, double *pb0, double *pmiss0)
 
void set_verbose (int vlevel)
 
virtual ~Davismt2 ()
 

Public Attributes

int nevt
 

Static Public Attributes

static const float ABSOLUTE_PRECISION = 0.0
 
static const float MIN_MASS = 0.1
 
static const float RELATIVE_PRECISION = 0.00001
 
static const float SCANSTEP = 0.1
 
static const float ZERO_MASS = 0.0
 

Private Member Functions

int find_high (double &Deltasq_high)
 
int nsols (double Dsq)
 
int nsols_massless (double Dsq)
 
int scan_high (double &Deltasq_high)
 
int signchange_n (long double t1, long double t2, long double t3, long double t4, long double t5)
 
int signchange_p (long double t1, long double t2, long double t3, long double t4, long double t5)
 

Private Attributes

double a1
 
double a2
 
double b1
 
double b2
 
double c1
 
double c2
 
double d1
 
double d11
 
double d2
 
double d20
 
double d21
 
double e1
 
double e11
 
double e2
 
double e20
 
double e21
 
double Ea
 
double Easq
 
double Eb
 
double Ebsq
 
double f1
 
double f10
 
double f12
 
double f2
 
double f20
 
double f21
 
double f22
 
double ma
 
double masq
 
double mb
 
double mbsq
 
double mn
 
double mn_unscale
 
double mnsq
 
bool momenta_set
 
double mt2_b
 
double pax
 
double pay
 
double pbx
 
double pby
 
double pmissx
 
double pmissxsq
 
double pmissy
 
double pmissysq
 
double precision
 
double scale
 
bool solved
 
int verbose
 

Detailed Description

Definition at line 12 of file Davismt2.h.

Constructor & Destructor Documentation

heppy::Davismt2::Davismt2 ( )

Definition at line 51 of file Davismt2.cc.

References pileupReCalc_HLTpaths::scale.

51  {
52  solved = false;
53  momenta_set = false;
54  mt2_b = 0.;
55  scale = 1.;
56  verbose = 1;
57 }
double mt2_b
Definition: Davismt2.h:37
double scale
Definition: Davismt2.h:63
bool momenta_set
Definition: Davismt2.h:36
heppy::Davismt2::~Davismt2 ( )
virtual

Definition at line 59 of file Davismt2.cc.

59 {}

Member Function Documentation

int heppy::Davismt2::find_high ( double &  Deltasq_high)
private

Definition at line 495 of file Davismt2.cc.

References alignmentValidation::c1, reco::e1, reco::e2, and validate-o2o-wbm::f2.

495  {
496  double x0,y0;
497  x0 = (c1*d1-b1*e1)/(b1*b1-a1*c1);
498  y0 = (a1*e1-b1*d1)/(b1*b1-a1*c1);
499  double Deltasq_low = (mn + ma)*(mn + ma) - mnsq;
500  do
501  {
502  double Deltasq_mid = (Deltasq_high + Deltasq_low)/2.;
503  int nsols_mid = nsols(Deltasq_mid);
504  if ( nsols_mid == 2 )
505  {
506  Deltasq_high = Deltasq_mid;
507  return 1;
508  }
509  else if (nsols_mid == 4)
510  {
511  Deltasq_high = Deltasq_mid;
512  continue;
513  }
514  else if (nsols_mid ==0)
515  {
516  d1 = -pax*(Deltasq_mid-masq)/(2*Easq);
517  e1 = -pay*(Deltasq_mid-masq)/(2*Easq);
518  d2 = -pmissx + pbx*(Deltasq_mid - mbsq)/(2*Ebsq)
519  + pbx*(pbx*pmissx+pby*pmissy)/(Ebsq);
520  e2 = -pmissy + pby*(Deltasq_mid - mbsq)/(2*Ebsq)
521  + pby*(pbx*pmissx+pby*pmissy)/(Ebsq);
522  f2 = pmissx*pmissx+pmissy*pmissy-((Deltasq_mid-mbsq)/(2*Eb)+
523  (pbx*pmissx+pby*pmissy)/Eb)*((Deltasq_mid-mbsq)/(2*Eb)+
524  (pbx*pmissx+pby*pmissy)/Eb)+mnsq;
525 // Does the larger ellipse contain the smaller one?
526  double dis = a2*x0*x0 + 2*b2*x0*y0 + c2*y0*y0 + 2*d2*x0 + 2*e2*y0 + f2;
527  if (dis < 0) Deltasq_high = Deltasq_mid;
528  else Deltasq_low = Deltasq_mid;
529  }
530 
531  } while ( Deltasq_high - Deltasq_low > 0.001);
532  return 0;
533 }
double Ebsq
Definition: Davismt2.h:55
double pax
Definition: Davismt2.h:48
double pmissy
Definition: Davismt2.h:49
double Easq
Definition: Davismt2.h:54
int nsols(double Dsq)
Definition: Davismt2.cc:560
double pay
Definition: Davismt2.h:48
double mbsq
Definition: Davismt2.h:55
double pby
Definition: Davismt2.h:50
double pmissx
Definition: Davismt2.h:49
double masq
Definition: Davismt2.h:54
double pbx
Definition: Davismt2.h:50
double mnsq
Definition: Davismt2.h:57
double heppy::Davismt2::get_mt2 ( )

Definition at line 61 of file Davismt2.cc.

References gather_cfg::cout, and pileupReCalc_HLTpaths::scale.

61  {
62  if (!momenta_set)
63  {
64  cout << "Davismt2::get_mt2() ==> Please set momenta first!" << endl;
65  return 0;
66  }
67 
68  if (!solved) mt2_bisect();
69  return mt2_b*scale;
70 }
double mt2_b
Definition: Davismt2.h:37
tuple cout
Definition: gather_cfg.py:145
double scale
Definition: Davismt2.h:63
void mt2_bisect()
Definition: Davismt2.cc:347
bool momenta_set
Definition: Davismt2.h:36
void heppy::Davismt2::mt2_bisect ( )

Definition at line 347 of file Davismt2.cc.

References alignmentValidation::c1, gather_cfg::cout, reco::e1, reco::e2, validate-o2o-wbm::f2, nevt, and mathSSE::sqrt().

347  {
348 
349  solved = true;
350  cout.precision(11);
351 
352 //if masses are very small, use code for massless case.
353  if(masq < MIN_MASS && mbsq < MIN_MASS){
354  mt2_massless();
355  return;
356  }
357 
358 
359  double Deltasq0;
360  Deltasq0 = ma*(ma + 2*mn); //The minimum mass square to have two ellipses
361 
362 // find the coefficients for the two quadratic equations when Deltasq=Deltasq0.
363 
364  a1 = 1-pax*pax/(Easq);
365  b1 = -pax*pay/(Easq);
366  c1 = 1-pay*pay/(Easq);
367  d1 = -pax*(Deltasq0-masq)/(2*Easq);
368  e1 = -pay*(Deltasq0-masq)/(2*Easq);
369  a2 = 1-pbx*pbx/(Ebsq);
370  b2 = -pbx*pby/(Ebsq);
371  c2 = 1-pby*pby/(Ebsq);
372  d2 = -pmissx+pbx*(Deltasq0-mbsq)/(2*Ebsq)+pbx*(pbx*pmissx+pby*pmissy)/(Ebsq);
373  e2 = -pmissy+pby*(Deltasq0-mbsq)/(2*Ebsq)+pby*(pbx*pmissx+pby*pmissy)/(Ebsq);
374  f2 = pmissx*pmissx+pmissy*pmissy-((Deltasq0-mbsq)/(2*Eb)+
375  (pbx*pmissx+pby*pmissy)/Eb)*((Deltasq0-mbsq)/(2*Eb)+
376  (pbx*pmissx+pby*pmissy)/Eb)+mnsq;
377 
378 // find the center of the smaller ellipse
379  double x0,y0;
380  x0 = (c1*d1-b1*e1)/(b1*b1-a1*c1);
381  y0 = (a1*e1-b1*d1)/(b1*b1-a1*c1);
382 
383 
384 // Does the larger ellipse contain the smaller one?
385  double dis=a2*x0*x0+2*b2*x0*y0+c2*y0*y0+2*d2*x0+2*e2*y0+f2;
386 
387  if(dis<=0.01)
388  {
389  mt2_b = (double) sqrt(mnsq+Deltasq0);
390  return;
391  }
392 
393 
394 /* find the coefficients for the two quadratic equations */
395 /* coefficients for quadratic terms do not change */
396 /* coefficients for linear and constant terms are polynomials of */
397 /* delta=(Deltasq-m7sq)/(2 E7sq) */
398  d11 = -pax;
399  e11 = -pay;
400  f10 = mnsq;
401  f12 = -Easq;
402  d21 = (Easq*pbx)/Ebsq;
403  d20 = ((masq - mbsq)*pbx)/(2.*Ebsq) - pmissx +
404  (pbx*(pbx*pmissx + pby*pmissy))/Ebsq;
405  e21 = (Easq*pby)/Ebsq;
406  e20 = ((masq - mbsq)*pby)/(2.*Ebsq) - pmissy +
407  (pby*(pbx*pmissx + pby*pmissy))/Ebsq;
408  f22 = -Easq*Easq/Ebsq;
409  f21 = (-2*Easq*((masq - mbsq)/(2.*Eb) + (pbx*pmissx + pby*pmissy)/Eb))/Eb;
410  f20 = mnsq + pmissx*pmissx + pmissy*pmissy -
411  ((masq - mbsq)/(2.*Eb) + (pbx*pmissx + pby*pmissy)/Eb)
412  *((masq - mbsq)/(2.*Eb) + (pbx*pmissx + pby*pmissy)/Eb);
413 
414 //Estimate upper bound of mT2
415 //when Deltasq > Deltasq_high1, the larger encloses the center of the smaller
416  double p2x0,p2y0;
417  double Deltasq_high1;
418  p2x0 = pmissx-x0;
419  p2y0 = pmissy-y0;
420  Deltasq_high1 = 2*Eb*sqrt(p2x0*p2x0+p2y0*p2y0+mnsq)-2*pbx*p2x0-2*pby*p2y0+mbsq;
421 
422 //Another estimate, if both ellipses enclose the origin, Deltasq > mT2
423 
424  double Deltasq_high2, Deltasq_high21, Deltasq_high22;
425  Deltasq_high21 = 2*Eb*sqrt(pmissx*pmissx+pmissy*pmissy+mnsq)-2*pbx*pmissx-2*pby*pmissy+mbsq;
426  Deltasq_high22 = 2*Ea*mn+masq;
427 
428  if ( Deltasq_high21 < Deltasq_high22 ) Deltasq_high2 = Deltasq_high22;
429  else Deltasq_high2 = Deltasq_high21;
430 
431 //pick the smaller upper bound
432  double Deltasq_high;
433  if(Deltasq_high1 < Deltasq_high2) Deltasq_high = Deltasq_high1;
434  else Deltasq_high = Deltasq_high2;
435 
436 
437  double Deltasq_low; //lower bound
438  Deltasq_low = Deltasq0;
439 
440 //number of solutions at Deltasq_low should not be larger than zero
441  if( nsols(Deltasq_low) > 0 )
442  {
443 //cout << "Davismt2::mt2_bisect() ==> nsolutions(Deltasq_low) > 0"<<endl;
444  mt2_b = (double) sqrt(mnsq+Deltasq0);
445  return;
446  }
447 
448  int nsols_high, nsols_low;
449 
450  nsols_low = nsols(Deltasq_low);
451  int foundhigh;
452 
453 
454 //if nsols_high=nsols_low, we missed the region where the two ellipse overlap
455 //if nsols_high=4, also need a scan because we may find the wrong tangent point.
456 
457  nsols_high = nsols(Deltasq_high);
458 
459  if(nsols_high == nsols_low || nsols_high == 4)
460  {
461  //foundhigh = scan_high(Deltasq_high);
462  foundhigh = find_high(Deltasq_high);
463  if(foundhigh == 0)
464  {
465  if(verbose > 0) cout << "Davismt2::mt2_bisect() ==> Deltasq_high not found at event " << nevt << endl;
466  mt2_b = sqrt( Deltasq_low + mnsq );
467  return;
468  }
469 
470  }
471 
472  while(sqrt(Deltasq_high+mnsq) - sqrt(Deltasq_low+mnsq) > precision)
473  {
474  double Deltasq_mid,nsols_mid;
475  //bisect
476  Deltasq_mid = (Deltasq_high+Deltasq_low)/2.;
477  nsols_mid = nsols(Deltasq_mid);
478  // if nsols_mid = 4, rescan for Deltasq_high
479  if ( nsols_mid == 4 )
480  {
481  Deltasq_high = Deltasq_mid;
482  //scan_high(Deltasq_high);
483  find_high(Deltasq_high);
484  continue;
485  }
486 
487 
488  if(nsols_mid != nsols_low) Deltasq_high = Deltasq_mid;
489  if(nsols_mid == nsols_low) Deltasq_low = Deltasq_mid;
490  }
491  mt2_b = (double) sqrt( mnsq + Deltasq_high);
492  return;
493 }
int find_high(double &Deltasq_high)
Definition: Davismt2.cc:495
double Ebsq
Definition: Davismt2.h:55
double pax
Definition: Davismt2.h:48
double pmissy
Definition: Davismt2.h:49
double f20
Definition: Davismt2.h:61
double f12
Definition: Davismt2.h:61
void mt2_massless()
Definition: Davismt2.cc:154
double Easq
Definition: Davismt2.h:54
int nsols(double Dsq)
Definition: Davismt2.cc:560
double e21
Definition: Davismt2.h:61
double d20
Definition: Davismt2.h:61
double precision
Definition: Davismt2.h:64
T sqrt(T t)
Definition: SSEVec.h:18
static const float MIN_MASS
Definition: Davismt2.h:17
double pay
Definition: Davismt2.h:48
double mbsq
Definition: Davismt2.h:55
double f21
Definition: Davismt2.h:61
double e11
Definition: Davismt2.h:61
double pby
Definition: Davismt2.h:50
double d11
Definition: Davismt2.h:61
double pmissx
Definition: Davismt2.h:49
double mt2_b
Definition: Davismt2.h:37
double masq
Definition: Davismt2.h:54
double f10
Definition: Davismt2.h:61
double d21
Definition: Davismt2.h:61
tuple cout
Definition: gather_cfg.py:145
double pbx
Definition: Davismt2.h:50
double e20
Definition: Davismt2.h:61
double f22
Definition: Davismt2.h:61
double mnsq
Definition: Davismt2.h:57
void heppy::Davismt2::mt2_massless ( )

Definition at line 154 of file Davismt2.cc.

References EnergyCorrector::c, funct::cos(), gather_cfg::cout, ResonanceBuilder::mass, nevt, alignCSCRings::s, funct::sin(), mathSSE::sqrt(), and theta().

154  {
155 
156 //rotate so that pay = 0
157  double theta,s,c;
158  theta = atan(pay/pax);
159  s = sin(theta);
160  c = cos(theta);
161 
162  double pxtemp,pytemp;
163  Easq = pax*pax+pay*pay;
164  Ebsq = pbx*pbx+pby*pby;
165  Ea = sqrt(Easq);
166  Eb = sqrt(Ebsq);
167 
168  pxtemp = pax*c+pay*s;
169  pax = pxtemp;
170  pay = 0;
171  pxtemp = pbx*c+pby*s;
172  pytemp = -s*pbx+c*pby;
173  pbx = pxtemp;
174  pby = pytemp;
175  pxtemp = pmissx*c+pmissy*s;
176  pytemp = -s*pmissx+c*pmissy;
177  pmissx = pxtemp;
178  pmissy = pytemp;
179 
180  a2 = 1-pbx*pbx/(Ebsq);
181  b2 = -pbx*pby/(Ebsq);
182  c2 = 1-pby*pby/(Ebsq);
183 
184  d21 = (Easq*pbx)/Ebsq;
185  d20 = - pmissx + (pbx*(pbx*pmissx + pby*pmissy))/Ebsq;
186  e21 = (Easq*pby)/Ebsq;
187  e20 = - pmissy + (pby*(pbx*pmissx + pby*pmissy))/Ebsq;
188  f22 = -(Easq*Easq/Ebsq);
189  f21 = -2*Easq*(pbx*pmissx + pby*pmissy)/Ebsq;
191 
192  double Deltasq0 = 0;
193  double Deltasq_low, Deltasq_high;
194  int nsols_high, nsols_low;
195 
196  Deltasq_low = Deltasq0 + precision;
197  nsols_low = nsols_massless(Deltasq_low);
198 
199  if(nsols_low > 1)
200  {
201  mt2_b = (double) sqrt(Deltasq0+mnsq);
202  return;
203  }
204 
205 /*
206  if( nsols_massless(Deltasq_high) > 0 )
207  {
208  mt2_b = (double) sqrt(mnsq+Deltasq0);
209  return;
210  }*/
211 
212 //look for when both parablos contain origin
213  double Deltasq_high1, Deltasq_high2;
214  Deltasq_high1 = 2*Eb*sqrt(pmissx*pmissx+pmissy*pmissy+mnsq)-2*pbx*pmissx-2*pby*pmissy;
215  Deltasq_high2 = 2*Ea*mn;
216 
217  if(Deltasq_high1 < Deltasq_high2) Deltasq_high = Deltasq_high2;
218  else Deltasq_high = Deltasq_high1;
219 
220  nsols_high=nsols_massless(Deltasq_high);
221 
222  int foundhigh;
223  if (nsols_high == nsols_low)
224  {
225 
226 
227  foundhigh=0;
228 
229  double minmass, maxmass;
230  minmass = mn ;
231  maxmass = sqrt(mnsq + Deltasq_high);
232  for(double mass = minmass + SCANSTEP; mass < maxmass; mass += SCANSTEP)
233  {
234  Deltasq_high = mass*mass - mnsq;
235 
236  nsols_high = nsols_massless(Deltasq_high);
237  if(nsols_high>0)
238  {
239  foundhigh=1;
240  Deltasq_low = (mass-SCANSTEP)*(mass-SCANSTEP) - mnsq;
241  break;
242  }
243  }
244  if(foundhigh==0)
245  {
246 
247  if(verbose > 0) cout << "Davismt2::mt2_massless() ==> Deltasq_high not found at event " << nevt <<endl;
248 
249 
250  mt2_b = (double)sqrt(Deltasq_low+mnsq);
251  return;
252  }
253  }
254 
255  if(nsols_high == nsols_low)
256  {
257  if(verbose > 0) cout << "Davismt2::mt2_massless() ==> error: nsols_low=nsols_high=" << nsols_high << endl;
258  if(verbose > 0) cout << "Davismt2::mt2_massless() ==> Deltasq_high=" << Deltasq_high << endl;
259  if(verbose > 0) cout << "Davismt2::mt2_massless() ==> Deltasq_low= "<< Deltasq_low << endl;
260 
261  mt2_b = sqrt(mnsq + Deltasq_low);
262  return;
263  }
264  double minmass, maxmass;
265  minmass = sqrt(Deltasq_low+mnsq);
266  maxmass = sqrt(Deltasq_high+mnsq);
267  while(maxmass - minmass > precision)
268  {
269  double Delta_mid, midmass, nsols_mid;
270  midmass = (minmass+maxmass)/2.;
271  Delta_mid = midmass * midmass - mnsq;
272  nsols_mid = nsols_massless(Delta_mid);
273  if(nsols_mid != nsols_low) maxmass = midmass;
274  if(nsols_mid == nsols_low) minmass = midmass;
275  }
276  mt2_b = minmass;
277  return;
278 }
double pmissxsq
Definition: Davismt2.h:56
double Ebsq
Definition: Davismt2.h:55
double pax
Definition: Davismt2.h:48
double pmissy
Definition: Davismt2.h:49
double f20
Definition: Davismt2.h:61
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
double Easq
Definition: Davismt2.h:54
double e21
Definition: Davismt2.h:61
int nsols_massless(double Dsq)
Definition: Davismt2.cc:280
double d20
Definition: Davismt2.h:61
double precision
Definition: Davismt2.h:64
T sqrt(T t)
Definition: SSEVec.h:18
double pay
Definition: Davismt2.h:48
double f21
Definition: Davismt2.h:61
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
static const float SCANSTEP
Definition: Davismt2.h:19
double pby
Definition: Davismt2.h:50
double pmissysq
Definition: Davismt2.h:56
double pmissx
Definition: Davismt2.h:49
double mt2_b
Definition: Davismt2.h:37
double d21
Definition: Davismt2.h:61
tuple cout
Definition: gather_cfg.py:145
double pbx
Definition: Davismt2.h:50
double e20
Definition: Davismt2.h:61
double f22
Definition: Davismt2.h:61
double mnsq
Definition: Davismt2.h:57
int heppy::Davismt2::nsols ( double  Dsq)
private

Definition at line 560 of file Davismt2.cc.

References alignmentValidation::c1, delta, reco::e1, reco::e2, validate-o2o-wbm::f1, validate-o2o-wbm::f2, and reco::t2.

560  {
561  double delta = (Dsq-masq)/(2*Easq);
562 
563 //calculate coefficients for the two quadratic equations
564  d1 = d11*delta;
565  e1 = e11*delta;
566  f1 = f12*delta*delta+f10;
567  d2 = d21*delta+d20;
568  e2 = e21*delta+e20;
569  f2 = f22*delta*delta+f21*delta+f20;
570 
571 //obtain the coefficients for the 4th order equation
572 //devided by Ea^n to make the variable dimensionless
573  long double A4, A3, A2, A1, A0;
574 
575  A4 =
576  -4*a2*b1*b2*c1 + 4*a1*b2*b2*c1 +a2*a2*c1*c1 +
577  4*a2*b1*b1*c2 - 4*a1*b1*b2*c2 - 2*a1*a2*c1*c2 +
578  a1*a1*c2*c2;
579 
580  A3 =
581  (-4*a2*b2*c1*d1 + 8*a2*b1*c2*d1 - 4*a1*b2*c2*d1 - 4*a2*b1*c1*d2 +
582  8*a1*b2*c1*d2 - 4*a1*b1*c2*d2 - 8*a2*b1*b2*e1 + 8*a1*b2*b2*e1 +
583  4*a2*a2*c1*e1 - 4*a1*a2*c2*e1 + 8*a2*b1*b1*e2 - 8*a1*b1*b2*e2 -
584  4*a1*a2*c1*e2 + 4*a1*a1*c2*e2)/Ea;
585 
586 
587  A2 =
588  (4*a2*c2*d1*d1 - 4*a2*c1*d1*d2 - 4*a1*c2*d1*d2 + 4*a1*c1*d2*d2 -
589  8*a2*b2*d1*e1 - 8*a2*b1*d2*e1 + 16*a1*b2*d2*e1 +
590  4*a2*a2*e1*e1 + 16*a2*b1*d1*e2 - 8*a1*b2*d1*e2 -
591  8*a1*b1*d2*e2 - 8*a1*a2*e1*e2 + 4*a1*a1*e2*e2 - 4*a2*b1*b2*f1 +
592  4*a1*b2*b2*f1 + 2*a2*a2*c1*f1 - 2*a1*a2*c2*f1 +
593  4*a2*b1*b1*f2 - 4*a1*b1*b2*f2 - 2*a1*a2*c1*f2 + 2*a1*a1*c2*f2)/Easq;
594 
595  A1 =
596  (-8*a2*d1*d2*e1 + 8*a1*d2*d2*e1 + 8*a2*d1*d1*e2 - 8*a1*d1*d2*e2 -
597  4*a2*b2*d1*f1 - 4*a2*b1*d2*f1 + 8*a1*b2*d2*f1 + 4*a2*a2*e1*f1 -
598  4*a1*a2*e2*f1 + 8*a2*b1*d1*f2 - 4*a1*b2*d1*f2 - 4*a1*b1*d2*f2 -
599  4*a1*a2*e1*f2 + 4*a1*a1*e2*f2)/(Easq*Ea);
600 
601  A0 =
602  (-4*a2*d1*d2*f1 + 4*a1*d2*d2*f1 + a2*a2*f1*f1 +
603  4*a2*d1*d1*f2 - 4*a1*d1*d2*f2 - 2*a1*a2*f1*f2 +
604  a1*a1*f2*f2)/(Easq*Easq);
605 
606  long double A3sq;
607  /*
608  long double A0sq, A1sq, A2sq, A3sq, A4sq;
609  A0sq = A0*A0;
610  A1sq = A1*A1;
611  A2sq = A2*A2;
612  A4sq = A4*A4;
613  */
614  A3sq = A3*A3;
615 
616  long double B3, B2, B1, B0;
617  B3 = 4*A4;
618  B2 = 3*A3;
619  B1 = 2*A2;
620  B0 = A1;
621 
622  long double C2, C1, C0;
623  C2 = -(A2/2 - 3*A3sq/(16*A4));
624  C1 = -(3*A1/4. -A2*A3/(8*A4));
625  C0 = -A0 + A1*A3/(16*A4);
626 
627  long double D1, D0;
628  D1 = -B1 - (B3*C1*C1/C2 - B3*C0 -B2*C1)/C2;
629  D0 = -B0 - B3 *C0 *C1/(C2*C2)+ B2*C0/C2;
630 
631  long double E0;
632  E0 = -C0 - C2*D0*D0/(D1*D1) + C1*D0/D1;
633 
634  long double t1,t2,t3,t4,t5;
635 //find the coefficients for the leading term in the Sturm sequence
636  t1 = A4;
637  t2 = A4;
638  t3 = C2;
639  t4 = D1;
640  t5 = E0;
641 
642 
643 //The number of solutions depends on diffence of number of sign changes for x->Inf and x->-Inf
644  int nsol;
645  nsol = signchange_n(t1,t2,t3,t4,t5) - signchange_p(t1,t2,t3,t4,t5);
646 
647 //Cannot have negative number of solutions, must be roundoff effect
648  if (nsol < 0) nsol = 0;
649 
650  return nsol;
651 
652 }
dbl * delta
Definition: mlp_gen.cc:36
double f20
Definition: Davismt2.h:61
Divides< arg, void > D0
Definition: Factorize.h:143
double f12
Definition: Davismt2.h:61
double Easq
Definition: Davismt2.h:54
double e21
Definition: Davismt2.h:61
double d20
Definition: Davismt2.h:61
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
double f21
Definition: Davismt2.h:61
Divides< A, C > D1
Definition: Factorize.h:144
int signchange_n(long double t1, long double t2, long double t3, long double t4, long double t5)
Definition: Davismt2.cc:655
double e11
Definition: Davismt2.h:61
double d11
Definition: Davismt2.h:61
double masq
Definition: Davismt2.h:54
double f10
Definition: Davismt2.h:61
double d21
Definition: Davismt2.h:61
double e20
Definition: Davismt2.h:61
int signchange_p(long double t1, long double t2, long double t3, long double t4, long double t5)
Definition: Davismt2.cc:666
double f22
Definition: Davismt2.h:61
int heppy::Davismt2::nsols_massless ( double  Dsq)
private

Definition at line 280 of file Davismt2.cc.

References a, b, delta, reco::e1, reco::e2, validate-o2o-wbm::f1, validate-o2o-wbm::f2, and reco::t2.

280  {
281  double delta;
282  delta = Dsq/(2*Easq);
283  d1 = d11*delta;
284  e1 = e11*delta;
285  f1 = f12*delta*delta+f10;
286  d2 = d21*delta+d20;
287  e2 = e21*delta+e20;
288  f2 = f22*delta*delta+f21*delta+f20;
289 
290  double a,b;
291  if (pax > 0) a = Ea/Dsq;
292  else a = -Ea/Dsq;
293  if (pax > 0) b = -Dsq/(4*Ea)+mnsq*Ea/Dsq;
294  else b = Dsq/(4*Ea)-mnsq*Ea/Dsq;
295 
296  double A4,A3,A2,A1,A0;
297 
298  A4 = a*a*a2;
299  A3 = 2*a*b2/Ea;
300  A2 = (2*a*a2*b+c2+2*a*d2)/(Easq);
301  A1 = (2*b*b2+2*e2)/(Easq*Ea);
302  A0 = (a2*b*b+2*b*d2+f2)/(Easq*Easq);
303 
304  long double A3sq;
305  A3sq = A3*A3;
306  /*
307  long double A0sq, A1sq, A2sq, A3sq, A4sq;
308  A0sq = A0*A0;
309  A1sq = A1*A1;
310  A2sq = A2*A2;
311  A3sq = A3*A3;
312  A4sq = A4*A4;
313  */
314 
315  long double B3, B2, B1, B0;
316  B3 = 4*A4;
317  B2 = 3*A3;
318  B1 = 2*A2;
319  B0 = A1;
320  long double C2, C1, C0;
321  C2 = -(A2/2 - 3*A3sq/(16*A4));
322  C1 = -(3*A1/4. -A2*A3/(8*A4));
323  C0 = -A0 + A1*A3/(16*A4);
324  long double D1, D0;
325  D1 = -B1 - (B3*C1*C1/C2 - B3*C0 -B2*C1)/C2;
326  D0 = -B0 - B3 *C0 *C1/(C2*C2)+ B2*C0/C2;
327 
328  long double E0;
329  E0 = -C0 - C2*D0*D0/(D1*D1) + C1*D0/D1;
330 
331  long double t1,t2,t3,t4,t5;
332 
333 //find the coefficients for the leading term in the Sturm sequence
334  t1 = A4;
335  t2 = A4;
336  t3 = C2;
337  t4 = D1;
338  t5 = E0;
339 
340  int nsol;
341  nsol = signchange_n(t1,t2,t3,t4,t5)-signchange_p(t1,t2,t3,t4,t5);
342  if( nsol < 0 ) nsol=0;
343 
344  return nsol;
345 }
dbl * delta
Definition: mlp_gen.cc:36
double pax
Definition: Davismt2.h:48
double f20
Definition: Davismt2.h:61
Divides< arg, void > D0
Definition: Factorize.h:143
double f12
Definition: Davismt2.h:61
double Easq
Definition: Davismt2.h:54
double e21
Definition: Davismt2.h:61
double d20
Definition: Davismt2.h:61
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
double f21
Definition: Davismt2.h:61
Divides< A, C > D1
Definition: Factorize.h:144
int signchange_n(long double t1, long double t2, long double t3, long double t4, long double t5)
Definition: Davismt2.cc:655
double e11
Definition: Davismt2.h:61
double b
Definition: hdecay.h:120
double d11
Definition: Davismt2.h:61
double a
Definition: hdecay.h:121
double f10
Definition: Davismt2.h:61
double d21
Definition: Davismt2.h:61
double e20
Definition: Davismt2.h:61
int signchange_p(long double t1, long double t2, long double t3, long double t4, long double t5)
Definition: Davismt2.cc:666
double f22
Definition: Davismt2.h:61
double mnsq
Definition: Davismt2.h:57
void heppy::Davismt2::print ( void  )

Definition at line 146 of file Davismt2.cc.

References gather_cfg::cout, and pileupReCalc_HLTpaths::scale.

146  {
147  cout << " Davismt2::print() ==> pax = " << pax*scale << "; pay = " << pay*scale << "; ma = " << ma*scale <<";"<< endl;
148  cout << " Davismt2::print() ==> pbx = " << pbx*scale << "; pby = " << pby*scale << "; mb = " << mb*scale <<";"<< endl;
149  cout << " Davismt2::print() ==> pmissx = " << pmissx*scale << "; pmissy = " << pmissy*scale <<";"<< endl;
150  cout << " Davismt2::print() ==> mn = " << mn_unscale<<";" << endl;
151 }
double pax
Definition: Davismt2.h:48
double pmissy
Definition: Davismt2.h:49
double mn_unscale
Definition: Davismt2.h:51
double pay
Definition: Davismt2.h:48
double pby
Definition: Davismt2.h:50
double pmissx
Definition: Davismt2.h:49
tuple cout
Definition: gather_cfg.py:145
double pbx
Definition: Davismt2.h:50
double scale
Definition: Davismt2.h:63
int heppy::Davismt2::scan_high ( double &  Deltasq_high)
private

Definition at line 535 of file Davismt2.cc.

References gather_cfg::cout, ResonanceBuilder::mass, nevt, and mathSSE::sqrt().

535  {
536  int foundhigh = 0 ;
537  int nsols_high;
538 
539 
540  // double Deltasq_low;
541  double tempmass, maxmass;
542  tempmass = mn + ma;
543  maxmass = sqrt(mnsq + Deltasq_high);
544  if (nevt == 32334) cout << "Davismt2::scan_high() ==> Deltasq_high = " << Deltasq_high << endl; // ???
545  for(double mass = tempmass + SCANSTEP; mass < maxmass; mass += SCANSTEP)
546  {
547  Deltasq_high = mass*mass - mnsq;
548  nsols_high = nsols(Deltasq_high);
549 
550  if( nsols_high > 0)
551  {
552  // Deltasq_low = (mass-SCANSTEP)*(mass-SCANSTEP) - mnsq;
553  foundhigh = 1;
554  break;
555  }
556  }
557  return foundhigh;
558 }
int nsols(double Dsq)
Definition: Davismt2.cc:560
T sqrt(T t)
Definition: SSEVec.h:18
static const float SCANSTEP
Definition: Davismt2.h:19
tuple cout
Definition: gather_cfg.py:145
double mnsq
Definition: Davismt2.h:57
void heppy::Davismt2::set_mn ( double  mn)

Definition at line 139 of file Davismt2.cc.

References pileupReCalc_HLTpaths::scale.

139  {
140  solved = false; //reset solved tag when mn is changed.
141  mn_unscale = fabs(mn0); //mass cannot be negative
142  mn = mn_unscale/scale;
143  mnsq = mn*mn;
144 }
double mn_unscale
Definition: Davismt2.h:51
double scale
Definition: Davismt2.h:63
double mnsq
Definition: Davismt2.h:57
void heppy::Davismt2::set_momenta ( double *  pa0,
double *  pb0,
double *  pmiss0 
)

Definition at line 72 of file Davismt2.cc.

References pileupReCalc_HLTpaths::scale, mathSSE::sqrt(), and groupFilesInBlocks::temp.

72  {
73  solved = false; //reset solved tag when momenta are changed.
74  momenta_set = true;
75 
76  ma = fabs(pa0[0]); // mass cannot be negative
77 
78  if (ma < ZERO_MASS) ma = ZERO_MASS;
79 
80  pax = pa0[1];
81  pay = pa0[2];
82  masq = ma*ma;
83  Easq = masq+pax*pax+pay*pay;
84  Ea = sqrt(Easq);
85 
86  mb = fabs(pb0[0]);
87 
88  if (mb < ZERO_MASS) mb = ZERO_MASS;
89 
90  pbx = pb0[1];
91  pby = pb0[2];
92  mbsq = mb*mb;
93  Ebsq = mbsq+pbx*pbx+pby*pby;
94  Eb = sqrt(Ebsq);
95 
96  pmissx = pmiss0[1]; pmissy = pmiss0[2];
99 
100 // set ma>= mb
101  if(masq < mbsq)
102  {
103  double temp;
104  temp = pax; pax = pbx; pbx = temp;
105  temp = pay; pay = pby; pby = temp;
106  temp = Ea; Ea = Eb; Eb = temp;
107  temp = Easq; Easq = Ebsq; Ebsq = temp;
108  temp = masq; masq = mbsq; mbsq = temp;
109  temp = ma; ma = mb; mb = temp;
110  }
111 //normalize max{Ea, Eb} to 100
112  if (Ea > Eb) scale = Ea/100.;
113  else scale = Eb/100.;
114 
115  if (sqrt(pmissxsq+pmissysq)/100 > scale) scale = sqrt(pmissxsq+pmissysq)/100;
116  //scale = 1;
117  double scalesq = scale * scale;
118  ma = ma/scale;
119  mb = mb/scale;
120  masq = masq/scalesq;
121  mbsq = mbsq/scalesq;
122  pax = pax/scale; pay = pay/scale;
123  pbx = pbx/scale; pby = pby/scale;
124  Ea = Ea/scale; Eb = Eb/scale;
125 
126  Easq = Easq/scalesq;
127  Ebsq = Ebsq/scalesq;
128  pmissx = pmissx/scale;
129  pmissy = pmissy/scale;
130  pmissxsq = pmissxsq/scalesq;
131  pmissysq = pmissysq/scalesq;
132  mn = mn_unscale/scale;
133  mnsq = mn*mn;
134 
136  else precision = 100.*RELATIVE_PRECISION;
137 }
double pmissxsq
Definition: Davismt2.h:56
double Ebsq
Definition: Davismt2.h:55
double pax
Definition: Davismt2.h:48
double pmissy
Definition: Davismt2.h:49
double mn_unscale
Definition: Davismt2.h:51
double Easq
Definition: Davismt2.h:54
double precision
Definition: Davismt2.h:64
T sqrt(T t)
Definition: SSEVec.h:18
double pay
Definition: Davismt2.h:48
double mbsq
Definition: Davismt2.h:55
static const float ABSOLUTE_PRECISION
Definition: Davismt2.h:16
double pby
Definition: Davismt2.h:50
static const float RELATIVE_PRECISION
Definition: Davismt2.h:15
double pmissysq
Definition: Davismt2.h:56
static const float ZERO_MASS
Definition: Davismt2.h:18
double pmissx
Definition: Davismt2.h:49
double masq
Definition: Davismt2.h:54
double pbx
Definition: Davismt2.h:50
double scale
Definition: Davismt2.h:63
double mnsq
Definition: Davismt2.h:57
bool momenta_set
Definition: Davismt2.h:36
void heppy::Davismt2::set_verbose ( int  vlevel)
inline

Definition at line 27 of file Davismt2.h.

27 {verbose = vlevel;};
int heppy::Davismt2::signchange_n ( long double  t1,
long double  t2,
long double  t3,
long double  t4,
long double  t5 
)
private

Definition at line 655 of file Davismt2.cc.

655  {
656  int nsc;
657  nsc=0;
658  if(t1*t2>0) nsc++;
659  if(t2*t3>0) nsc++;
660  if(t3*t4>0) nsc++;
661  if(t4*t5>0) nsc++;
662  return nsc;
663 }
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
int heppy::Davismt2::signchange_p ( long double  t1,
long double  t2,
long double  t3,
long double  t4,
long double  t5 
)
private

Definition at line 666 of file Davismt2.cc.

666  {
667  int nsc;
668  nsc=0;
669  if(t1*t2<0) nsc++;
670  if(t2*t3<0) nsc++;
671  if(t3*t4<0) nsc++;
672  if(t4*t5<0) nsc++;
673  return nsc;
674 }
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16

Member Data Documentation

double heppy::Davismt2::a1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::a2
private

Definition at line 60 of file Davismt2.h.

const float heppy::Davismt2::ABSOLUTE_PRECISION = 0.0
static

Definition at line 16 of file Davismt2.h.

double heppy::Davismt2::b1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::b2
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::c1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::c2
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::d1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::d11
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::d2
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::d20
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::d21
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::e1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::e11
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::e2
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::e20
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::e21
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::Ea
private

Definition at line 48 of file Davismt2.h.

double heppy::Davismt2::Easq
private

Definition at line 54 of file Davismt2.h.

double heppy::Davismt2::Eb
private

Definition at line 50 of file Davismt2.h.

double heppy::Davismt2::Ebsq
private

Definition at line 55 of file Davismt2.h.

double heppy::Davismt2::f1
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::f10
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::f12
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::f2
private

Definition at line 60 of file Davismt2.h.

double heppy::Davismt2::f20
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::f21
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::f22
private

Definition at line 61 of file Davismt2.h.

double heppy::Davismt2::ma
private

Definition at line 48 of file Davismt2.h.

double heppy::Davismt2::masq
private

Definition at line 54 of file Davismt2.h.

double heppy::Davismt2::mb
private

Definition at line 50 of file Davismt2.h.

double heppy::Davismt2::mbsq
private

Definition at line 55 of file Davismt2.h.

const float heppy::Davismt2::MIN_MASS = 0.1
static

Definition at line 17 of file Davismt2.h.

double heppy::Davismt2::mn
private

Definition at line 51 of file Davismt2.h.

double heppy::Davismt2::mn_unscale
private

Definition at line 51 of file Davismt2.h.

double heppy::Davismt2::mnsq
private

Definition at line 57 of file Davismt2.h.

bool heppy::Davismt2::momenta_set
private

Definition at line 36 of file Davismt2.h.

double heppy::Davismt2::mt2_b
private

Definition at line 37 of file Davismt2.h.

int heppy::Davismt2::nevt

Definition at line 30 of file Davismt2.h.

double heppy::Davismt2::pax
private

Definition at line 48 of file Davismt2.h.

double heppy::Davismt2::pay
private

Definition at line 48 of file Davismt2.h.

double heppy::Davismt2::pbx
private

Definition at line 50 of file Davismt2.h.

double heppy::Davismt2::pby
private

Definition at line 50 of file Davismt2.h.

double heppy::Davismt2::pmissx
private

Definition at line 49 of file Davismt2.h.

double heppy::Davismt2::pmissxsq
private

Definition at line 56 of file Davismt2.h.

double heppy::Davismt2::pmissy
private

Definition at line 49 of file Davismt2.h.

double heppy::Davismt2::pmissysq
private

Definition at line 56 of file Davismt2.h.

double heppy::Davismt2::precision
private

Definition at line 64 of file Davismt2.h.

const float heppy::Davismt2::RELATIVE_PRECISION = 0.00001
static

Definition at line 15 of file Davismt2.h.

double heppy::Davismt2::scale
private
const float heppy::Davismt2::SCANSTEP = 0.1
static

Definition at line 19 of file Davismt2.h.

bool heppy::Davismt2::solved
private

Definition at line 35 of file Davismt2.h.

int heppy::Davismt2::verbose
private
const float heppy::Davismt2::ZERO_MASS = 0.0
static

Definition at line 18 of file Davismt2.h.