Lpav Class Reference

#include <Lpav.h>

Inheritance diagram for Lpav:

Lpar Lpar List of all members.

Public Member Functions

 Lpav ()
virtual ~Lpav ()
void calculate_average (void)
void calculate_average3 (void)
void calculate_average (double x, double y, double w=1)
void calculate_average3 (double x, double y, double w=1)
double calculate_lpar (void)
double calculate_lpar3 (void)
double fit ()
double fit (double x, double y, double w=1)
void clear ()
void add_point (double x, double y, double w=1)
void add_point_frac (double x, double y, double w, double f)
double nc () const
HepSymMatrix cov (int=0) const
HepSymMatrix cov_c (int=0) const
int extrapolate (double, double &, double &) const
double similarity (double, double) const
double delta_chisq (double x, double y, double w=1) const
double chisq () const
double prob () const
double chi_deg () const
const Lpavoperator= (const Lpav &)
const Lpavoperator= (const Lpar &)
const Lpavoperator+= (const Lpav &)
 Lpav ()
virtual ~Lpav ()
void calculate_average (void)
void calculate_average3 (void)
void calculate_average (double x, double y, double w=1)
void calculate_average3 (double x, double y, double w=1)
double calculate_lpar (void)
double calculate_lpar3 (void)
double fit ()
double fit (double x, double y, double w=1)
void clear ()
void add_point (double x, double y, double w=1)
void add_point_frac (double x, double y, double w, double f)
double nc () const
HepSymMatrix cov (int=0) const
HepSymMatrix cov_c (int=0) const
int extrapolate (double, double &, double &) const
double similarity (double, double) const
double delta_chisq (double x, double y, double w=1) const
double chisq () const
double prob () const
double chi_deg () const
const Lpavoperator= (const Lpav &)
const Lpavoperator= (const Lpar &)
const Lpavoperator+= (const Lpav &)
void neg ()
void neg ()
void circle (double x1, double y1, double x2, double y2, double x3, double y3)
void circle (double x1, double y1, double x2, double y2, double x3, double y3)
double kappa () const
double kappa () const
double radius () const
double radius () const
HepVector center () const
HepVector center () const
double s (double x, double y) const
double s (double r, int dir=0) const
double s (double x, double y) const
double s (double r, int dir=0) const
double d (double x, double y) const
double d (double x, double y) const
double dr (double x, double y) const
double dr (double x, double y) const
double phi (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
int sd (double r, double x, double y, double limit, double &s, double &d) const
HepVector Hpar (const HepPoint3D &pivot) const
HepVector Hpar (const HepPoint3D &pivot) const

Private Member Functions

 Lpav (const Lpav &)
bool operator== (const Lpav &) const
bool operator!= (const Lpav &) const
void add (double x, double y, double w=1, double a=0, double b=0)
void sub (double x, double y, double w=1, double a=0, double b=0)
void calculate_average_n (double xxav, double yyav, double xyav, double xrrav, double yrrav, double rrrrav)
double chisq (double chisq)
double nc (double nc)
double solve_lambda (void)
double solve_lambda3 (void)
 Lpav (const Lpav &)
bool operator== (const Lpav &) const
bool operator!= (const Lpav &) const
void add (double x, double y, double w=1, double a=0, double b=0)
void sub (double x, double y, double w=1, double a=0, double b=0)
void calculate_average_n (double xxav, double yyav, double xyav, double xrrav, double yrrav, double rrrrav)
double chisq (double chisq)
double nc (double nc)
double solve_lambda (void)
double solve_lambda3 (void)

Private Attributes

double m_wsum
double m_xsum
double m_ysum
double m_xxsum
double m_yysum
double m_xysum
double m_xrrsum
double m_yrrsum
double m_rrrrsum
double m_wsum_temp
double m_xav
double m_yav
double m_xyavp
double m_rscale
double m_xxavp
double m_yyavp
double m_xrravp
double m_yrravp
double m_rrrravp
double m_sinrot
double m_cosrot
double m_nc
double m_chisq

Friends

std::ostreamoperator<< (std::ostream &o, const Lpav &s)
Lpav operator+ (const Lpav &, const Lpav &)
std::ostreamoperator<< (std::ostream &o, const Lpav &s)
Lpav operator+ (const Lpav &, const Lpav &)
class Lpav
class Lpar::Cpar
std::ostreamoperator<< (std::ostream &o, Lpar &)
int intersect (const Lpar &, const Lpar &, HepVector &, HepVector &)
int intersect (const Lpar &, const Lpar &, HepVector &, HepVector &)

Classes

class  Singular
class  Singular
class  Singular_c
class  Singular_c

Detailed Description

Definition at line 33 of file Lpav.h.


Constructor & Destructor Documentation

Lpav::Lpav (  ) 

Definition at line 52 of file Lpav.cxx.

References clear().

00053 {
00054   clear();
00055 }

Lpav::~Lpav (  )  [virtual]

Definition at line 61 of file Lpav.cxx.

00062 {
00063 }

Lpav::Lpav ( const Lpav  )  [inline, private]

Definition at line 169 of file Lpav.h.

References m_chisq, m_cosrot, m_nc, m_rrrravp, m_rrrrsum, m_rscale, m_sinrot, m_wsum, m_wsum_temp, m_xav, m_xrravp, m_xrrsum, m_xsum, m_xxavp, m_xxsum, m_xyavp, m_xysum, m_yav, m_yrravp, m_yrrsum, m_ysum, m_yyavp, and m_yysum.

00169                                 : Lpar(lp) {
00170   m_wsum = lp.m_wsum;
00171   m_xsum = lp.m_xsum;
00172   m_ysum = lp.m_ysum;
00173   m_xxsum = lp.m_xxsum;
00174   m_yysum = lp.m_yysum;
00175   m_xysum = lp.m_xysum;
00176   m_xrrsum = lp.m_xrrsum;
00177   m_yrrsum = lp.m_yrrsum;
00178   m_rrrrsum = lp.m_rrrrsum;
00179   
00180   m_wsum_temp = lp. m_wsum_temp;
00181   m_xav = lp.m_xav;
00182   m_yav = lp.m_yav;
00183   m_xyavp = lp.m_xyavp;
00184   
00185   m_rscale = lp. m_rscale;
00186   m_xxavp = lp.m_xxavp;
00187   m_yyavp = lp.m_yyavp;
00188   m_xrravp = lp.m_xrravp;
00189   m_yrravp = lp.m_yrravp;
00190   m_rrrravp = lp.m_rrrravp;
00191   m_sinrot = lp.m_sinrot;
00192   m_cosrot = lp.m_cosrot;
00193   
00194   m_nc = lp. m_nc;
00195   m_chisq = lp.m_chisq;
00196   return;
00197 }

Lpav::Lpav (  ) 

virtual Lpav::~Lpav (  )  [virtual]

Lpav::Lpav ( const Lpav  )  [inline, private]


Member Function Documentation

void Lpav::add ( double  x,
double  y,
double  w = 1,
double  a = 0,
double  b = 0 
) [private]

void Lpav::add ( double  x,
double  y,
double  w = 1,
double  a = 0,
double  b = 0 
) [private]

Definition at line 562 of file Lpav.cxx.

References err_dis_inv().

00562                                                                  {
00563   register double wi = err_dis_inv(xi, yi, w, a, b);
00564   add(xi, yi, wi);
00565 }

void Lpav::add_point ( double  x,
double  y,
double  w = 1 
)

void Lpav::add_point ( double  x,
double  y,
double  w = 1 
)

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), TCurlFinder::fitWDD(), TBuilderCurl::fitWDD(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), and FTTrack::r_phiReFit().

void Lpav::add_point_frac ( double  x,
double  y,
double  w,
double  f 
)

void Lpav::add_point_frac ( double  x,
double  y,
double  w,
double  f 
)

Definition at line 583 of file Lpav.cxx.

References m_nc, m_rrrrsum, m_wsum, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yrrsum, and m_ysum.

00583                                                                   {
00584   register double wi = w * a;
00585   m_wsum += wi;
00586   m_xsum += wi * xi;
00587   m_ysum += wi * yi;
00588   m_xxsum += wi * xi * xi;
00589   m_yysum += wi * yi * yi;
00590   m_xysum += wi * xi * yi;
00591   register double rri = ( xi * xi + yi * yi );
00592   register double wrri = wi * rri;
00593   m_xrrsum += wrri * xi;
00594   m_yrrsum += wrri * yi;
00595   m_rrrrsum += wrri * rri;
00596   m_nc += a;
00597 }

void Lpav::calculate_average ( double  x,
double  y,
double  w = 1 
)

void Lpav::calculate_average ( void   ) 

void Lpav::calculate_average ( double  x,
double  y,
double  w = 1 
)

Definition at line 86 of file Lpav.cxx.

References calculate_average_n(), m_rrrrsum, m_wsum, m_wsum_temp, m_xav, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yav, m_yrrsum, m_ysum, and m_yysum.

00086                                                             {
00087   if(m_wsum<=0) return;
00088   m_wsum_temp = m_wsum + wi;
00089   double rri(xi * xi + yi * yi);
00090   double wrri(wi * rri);
00091   double wsum_inv(1/m_wsum_temp);
00092   m_xav = (m_xsum + wi * xi) * wsum_inv;
00093   m_yav = (m_ysum + wi * yi) * wsum_inv;
00094   
00095   double xxav((m_xxsum + wi * xi * xi) * wsum_inv);
00096   double yyav((m_yysum + wi * yi * yi) * wsum_inv);
00097   double xyav((m_xysum + wi * xi * yi) * wsum_inv);
00098   double xrrav((m_xrrsum + xi * wrri) * wsum_inv);
00099   double yrrav((m_yrrsum + yi * wrri) * wsum_inv);
00100   double rrrrav((m_rrrrsum + wrri * rri) * wsum_inv);
00101 
00102   calculate_average_n(xxav, yyav, xyav, xrrav, yrrav, rrrrav);
00103   
00104 }

void Lpav::calculate_average ( void   ) 

Definition at line 106 of file Lpav.cxx.

References calculate_average_n(), m_rrrrsum, m_wsum, m_wsum_temp, m_xav, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yav, m_yrrsum, m_ysum, and m_yysum.

Referenced by fit().

00106                                  {
00107   if(m_wsum<=0) return;
00108   m_wsum_temp = m_wsum;
00109   double wsum_inv(1/m_wsum_temp);
00110   m_xav = m_xsum * wsum_inv;
00111   m_yav = m_ysum * wsum_inv;
00112   
00113   double xxav(m_xxsum * wsum_inv);
00114   double yyav(m_yysum * wsum_inv);
00115   double xyav(m_xysum * wsum_inv);
00116   double xrrav(m_xrrsum * wsum_inv);
00117   double yrrav(m_yrrsum * wsum_inv);
00118   double rrrrav(m_rrrrsum * wsum_inv);
00119 
00120   calculate_average_n(xxav, yyav, xyav, xrrav, yrrav, rrrrav);
00121 }

void Lpav::calculate_average3 ( double  x,
double  y,
double  w = 1 
)

void Lpav::calculate_average3 ( void   ) 

void Lpav::calculate_average3 ( double  x,
double  y,
double  w = 1 
)

Definition at line 192 of file Lpav.cxx.

References m_cosrot, m_rrrravp, m_rrrrsum, m_rscale, m_sinrot, m_wsum, m_wsum_temp, m_xav, m_xrravp, m_xrrsum, m_xsum, m_xxavp, m_xxsum, m_xyavp, m_xysum, m_yav, m_yrravp, m_yrrsum, m_ysum, m_yyavp, and m_yysum.

00192                                                              {
00193   if(m_wsum<=0) return;
00194   m_wsum_temp = m_wsum + wi;
00195   double wsum_inv(1/m_wsum_temp);
00196   double rri(xi * xi + yi * yi);
00197   m_xav = (m_xsum + wi * xi) * wsum_inv;
00198   m_yav = (m_ysum + wi * yi) * wsum_inv;
00199 
00200   m_rscale = 1;
00201   m_cosrot = 1;
00202   m_sinrot = 0;
00203   m_xxavp = (m_xxsum + wi * xi * xi) * wsum_inv;
00204   m_xyavp = (m_xysum + wi * xi * yi) * wsum_inv;
00205   m_yyavp = (m_yysum + wi * yi * yi) * wsum_inv;
00206   double wrri(wi * rri);
00207   m_xrravp = (m_xrrsum + xi * wrri) * wsum_inv;
00208   m_yrravp = (m_yrrsum + yi * wrri) * wsum_inv;
00209   m_rrrravp = (m_rrrrsum + rri * wrri) * wsum_inv;
00210 }

void Lpav::calculate_average3 ( void   ) 

Definition at line 212 of file Lpav.cxx.

References m_cosrot, m_rrrravp, m_rrrrsum, m_rscale, m_sinrot, m_wsum, m_wsum_temp, m_xav, m_xrravp, m_xrrsum, m_xsum, m_xxavp, m_xxsum, m_xyavp, m_xysum, m_yav, m_yrravp, m_yrrsum, m_ysum, m_yyavp, and m_yysum.

Referenced by fit().

00212                                   {
00213   if(m_wsum<=0) return;
00214   m_wsum_temp = m_wsum;
00215   double wsum_inv(1/m_wsum_temp);
00216   m_xav = m_xsum * wsum_inv;
00217   m_yav = m_ysum * wsum_inv;
00218 
00219   m_rscale = 1;
00220   m_cosrot = 1;
00221   m_sinrot = 0;
00222   m_xxavp = m_xxsum * wsum_inv;
00223   m_xyavp = m_xysum * wsum_inv;
00224   m_yyavp = m_yysum * wsum_inv;
00225   m_xrravp = m_xrrsum * wsum_inv;
00226   m_yrravp = m_yrrsum * wsum_inv;
00227   m_rrrravp = m_rrrrsum * wsum_inv;
00228 }

void Lpav::calculate_average_n ( double  xxav,
double  yyav,
double  xyav,
double  xrrav,
double  yrrav,
double  rrrrav 
) [private]

void Lpav::calculate_average_n ( double  xxav,
double  yyav,
double  xyav,
double  xrrav,
double  yrrav,
double  rrrrav 
) [private]

Definition at line 123 of file Lpav.cxx.

References m_cosrot, m_rrrravp, m_rscale, m_sinrot, m_xav, m_xrravp, m_xxavp, m_xyavp, m_yav, m_yrravp, and m_yyavp.

Referenced by calculate_average().

00124                                                                             {
00125   double xxav_p = xxav - m_xav * m_xav;
00126   double yyav_p = yyav - m_yav * m_yav;
00127   double xyav_p = xyav - m_xav * m_yav;
00128   double rrav_p = xxav_p + yyav_p;
00129   
00130   double a = std::fabs(xxav_p - yyav_p);
00131   double b = 4 * xyav_p * xyav_p;
00132   double asqpb = a * a + b;
00133   double rasqpb = std::sqrt(asqpb);
00134   double splus = 1 + a / rasqpb;
00135   double sminus = b / (asqpb*splus);
00136   splus = std::sqrt(0.5*splus);
00137   sminus = std::sqrt(0.5*sminus);
00138 //C
00139 //C== First require : SIGN(C**2 - S**2) = SIGN(XXAV - YYAV)
00140 //C
00141   if ( xxav_p <= yyav_p ) {
00142     m_cosrot = sminus;
00143     m_sinrot = splus;
00144   } else {
00145     m_cosrot = splus;
00146     m_sinrot = sminus;
00147   }
00148 //C
00149 //C== Require : SIGN(S) = SIGN(XYAV)*SIGN(C) (Assuming SIGN(C) > 0)
00150 //C
00151   if (xyav_p < 0) m_sinrot = - m_sinrot;
00152 //*
00153 //* We now have the smallest angle that guarantees <X**2> > <Y**2>
00154 //*
00155 //*  To get the SIGN of the charge right, the new X-AXIS must point
00156 //*  outward from the orgin.  We are free to change signs of both
00157 //*  COSROT and SINROT simultaneously to accomplish this.
00158 //*
00159 //*  Choose SIGN of C wisely to be able to get the sign of the charge
00160 //*
00161   if ( m_cosrot*m_xav + m_sinrot*m_yav <= 0 ) {
00162     m_cosrot = - m_cosrot;
00163     m_sinrot = - m_sinrot;
00164   }
00165   m_rscale = std::sqrt(rrav_p);
00166   double cos2 = m_cosrot * m_cosrot;
00167   double sin2 = m_sinrot * m_sinrot;
00168   double cs2 = 2 * m_sinrot * m_cosrot;
00169   double rrav_p_inv(1/rrav_p);
00170   m_xxavp = (cos2 * xxav_p + cs2 * xyav_p + sin2 * yyav_p) * rrav_p_inv;
00171   m_yyavp = (cos2 * yyav_p - cs2 * xyav_p + sin2 * xxav_p) * rrav_p_inv;
00172   
00173   double xav2 = m_xav * m_xav;
00174   double yav2 = m_yav * m_yav;
00175   double xrrav_p = (xrrav - 2 * xxav * m_xav + xav2 * m_xav -
00176                     2 * xyav * m_yav + m_xav * yav2) - m_xav * rrav_p;
00177   double yrrav_p = (yrrav - 2 * yyav * m_yav + yav2 * m_yav -
00178                     2 * xyav * m_xav + m_yav * xav2) - m_yav * rrav_p;
00179   m_xrravp = (  m_cosrot * xrrav_p + m_sinrot * yrrav_p) * rrav_p_inv/m_rscale;
00180   m_yrravp = (- m_sinrot * xrrav_p + m_cosrot * yrrav_p) * rrav_p_inv/m_rscale;
00181   
00182   double rrav = xxav + yyav;
00183   double rrrrav_p = rrrrav
00184     - 2 * m_yav * yrrav - 2 * m_xav * xrrav
00185     + rrav * (xav2 + yav2)
00186     - 2 * m_xav * xrrav_p - xav2 * rrav_p 
00187     - 2 * m_yav * yrrav_p - yav2 * rrav_p;
00188   m_rrrravp = rrrrav_p * rrav_p_inv * rrav_p_inv;
00189   m_xyavp = 0;
00190 }

double Lpav::calculate_lpar ( void   ) 

double Lpav::calculate_lpar ( void   ) 

Definition at line 315 of file Lpav.cxx.

References lambda, Lpar::m_alpha, Lpar::m_beta, m_chisq, m_cosrot, Lpar::m_gamma, Lpar::m_kappa, m_rscale, m_sinrot, m_wsum_temp, m_xav, m_xrravp, m_xxavp, m_yav, m_yrravp, m_yyavp, Lpar::move(), Lpar::neg(), Lpar::rotate(), Lpar::scale(), and solve_lambda().

Referenced by fit().

00315                                 {
00316   double lambda = solve_lambda();
00317 // changed on Oct-13-93
00318 //  if (lambda<=0) return -1;
00319   if (lambda<0) return -1;
00320   double h11 = m_xxavp - lambda;
00321   double h22 = m_yyavp - lambda;
00322   if (h11==0.0) return -1;
00323   double h14 = m_xrravp;
00324   double h24 = m_yrravp;
00325   double h34 = 1 + 2 * lambda;
00326   double rootsq = (h14*h14/h11/h11) + 4 * h34;
00327   if ( std::fabs(h22) > std::fabs(h24) ) {
00328     if(h22==0.0) return -1;
00329     double ratio = h24/h22;
00330     rootsq += ratio * ratio ;
00331     m_kappa = 1/std::sqrt(rootsq);
00332     m_beta = - ratio * m_kappa;
00333   } else {
00334     if(h24==0.0) return -1;
00335     double ratio = h22 / h24;
00336     rootsq = 1 + ratio * ratio * rootsq;
00337     m_beta = 1 / std::sqrt(rootsq);
00338     m_beta = h24>0 ? -m_beta : m_beta;
00339     m_kappa = -ratio * m_beta;
00340   }
00341   m_alpha = - (h14/h11)*m_kappa;
00342   m_gamma = - h34 * m_kappa;
00343 //    if (lambda<0.0001) {
00344 //      cout << " lambda=" << lambda << " h34=" << h34
00345 //      << " rootsq=" << rootsq << " h22=" << h22
00346 //        << " h11=" << h11 << " h14=" << h14 << " h24=" << h24 <<
00347 //          " " << *this << endl;
00348 //    }
00349 //
00350 //C     TRANSFORM THESE INTO THE LAB COORDINATE SYSTEM
00351 //
00352 //C     FIRST GET KAPPA  AND GAMMA  BACK TO REAL DIMENSIONS
00353 //
00354   scale(m_rscale);
00355 //
00356 //C     NEXT ROTATE ALPHA  AND BETA
00357 //
00358   rotate(m_cosrot, -m_sinrot);
00359 //
00360 //C     THEN TRANSLATE BY (XAV,YAV)
00361 //
00362   move(-m_xav, -m_yav);
00363   if (m_yrravp < 0) neg();
00364   if (lambda>=0) m_chisq = lambda * m_wsum_temp * m_rscale * m_rscale;
00365   return lambda;
00366 }

double Lpav::calculate_lpar3 ( void   ) 

double Lpav::calculate_lpar3 ( void   ) 

Definition at line 368 of file Lpav.cxx.

References lambda, Lpar::m_alpha, Lpar::m_beta, m_chisq, Lpar::m_gamma, Lpar::m_kappa, m_rscale, m_wsum_temp, m_xav, m_xrravp, m_xxavp, m_xyavp, m_yav, m_yrravp, m_yyavp, Lpar::neg(), and solve_lambda3().

Referenced by fit().

00368                                  {
00369   double lambda = solve_lambda3();
00370 // changed on Oct-13-93
00371 //  if (lambda<=0) return -1;
00372   if (lambda<0) return -1;
00373   double h11 = m_xxavp - lambda;
00374   double h22 = m_yyavp - lambda;
00375   double h14 = m_xrravp;
00376   double h24 = m_yrravp;
00377   m_gamma = 0;
00378   double h12 = m_xyavp;
00379   double det = h11*h22-h12*h12;
00380   if (det!=0) {
00381     double r1 = (h14*h22-h24*h12)/(det);
00382     double r2 = (h24*h11-h14*h12)/(det);
00383     double kinvsq = r1*r1 + r2*r2;
00384     m_kappa = std::sqrt(1/kinvsq);
00385     if(h11!=0) m_alpha = -m_kappa * r1;
00386     else m_alpha = 1;
00387     if(h22!=0) m_beta = -m_kappa * r2;
00388     else m_beta = 1;
00389   } else {
00390     m_kappa = 0;
00391     if (h11!=0 && h22!=0) {
00392       m_beta = 1/std::sqrt(1+h12*h12/h11/h11);
00393       m_alpha = std::sqrt(1-m_beta*m_beta);
00394     } else if (h11!=0) {
00395       m_beta = 1;
00396       m_alpha = 0;
00397     } else {
00398       m_beta = 0;
00399       m_alpha = 1;
00400     }
00401   }
00402   if((m_alpha*m_xav + m_beta*m_yav) *
00403      (m_beta*m_xav - m_alpha*m_yav)<0) neg();
00404 //    if (std::fabs(m_alpha)<0.01 && std::fabs(m_beta)<0.01) {
00405 //      cout << " lambda=" << lambda << " " << *this << endl;
00406 //    }
00407   if (lambda>=0) m_chisq = lambda * m_wsum_temp * m_rscale * m_rscale;
00408   return lambda;
00409 }

HepVector Lpar::center (  )  const [inherited]

HepVector Lpar::center (  )  const [inherited]

Definition at line 228 of file Lpar.cxx.

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), TCurlFinder::fitWDD(), TBuilderCurl::fitWDD(), intersect(), FTTrack::r_phiFit(), FTWire::z(), and KalFitWire::z().

00231 {
00232 #else
00233 {
00234   HepVector v(3);
00235 #endif
00236   v(1) = xc();
00237   v(2) = yc();
00238   v(3) = 0;
00239   return(v);
00240 }

double Lpav::chi_deg (  )  const

double Lpav::chi_deg (  )  const

Definition at line 659 of file Lpav.cxx.

References m_chisq, and m_nc.

Referenced by operator+().

00659                            {
00660   if (m_nc<=3) return -1;
00661   else return m_chisq/(m_nc-3);
00662 }

double Lpav::chisq ( double  chisq  )  [inline, private]

Definition at line 93 of file Lpav.h.

References m_chisq.

00093 { m_chisq = chisq; return m_chisq; }

double Lpav::chisq (  )  const [inline]

Definition at line 59 of file Lpav.h.

References m_chisq.

00059 { return m_chisq; }

double Lpav::chisq ( double  chisq  )  [inline, private]

Definition at line 98 of file Lpav.h.

References m_chisq.

00098 { m_chisq = chisq; return m_chisq; }

double Lpav::chisq (  )  const [inline]

Definition at line 64 of file Lpav.h.

References m_chisq.

Referenced by FTFinder::makeTds(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), and FTTrack::r_phiReFit().

00064 { return m_chisq; }

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

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

Definition at line 77 of file Lpar.cxx.

References Lpar::m_alpha, Lpar::m_beta, Lpar::m_gamma, and Lpar::m_kappa.

00078                                         {
00079   double a;
00080   double b;
00081   double c;
00082   double delta = (x1-x2)*(y1-y3) - (y1-y2)*(x1-x3);
00083   if(delta==0) {
00084     //
00085     // three points are on a line.
00086     //
00087     m_kappa = 0;
00088     double r12sq = (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2);
00089     if (r12sq>0) {
00090       double r12 = sqrt(r12sq);
00091       m_beta = -(x1-x2)/r12;
00092       m_alpha = (y1-y2)/r12;
00093       m_gamma = - (m_alpha*x1+m_beta*y1);
00094     } else {
00095       double r13sq = (x1-x3)*(x1-x3) + (y1-y3)*(y1-y3);
00096       if (r13sq>0) {
00097         double r13 = sqrt(r13sq);
00098         m_beta = -(x1-x3)/r13;
00099         m_alpha = (y1-y3)/r13;
00100         m_gamma = - (m_alpha*x3+m_beta*y3);
00101       } else {
00102         double r23sq = (x2-x3)*(x2-x3) + (y2-y3)*(y2-y3);
00103         if (r23sq>0) {
00104           double r23 = sqrt(r23sq);
00105           m_beta = -(x2-x3)/r23;
00106           m_alpha = (y2-y3)/r23;
00107           m_gamma = - (m_alpha*x3+m_beta*y3);
00108         } else {
00109           m_alpha = 1;
00110           m_beta = 0;
00111           m_gamma = 0;
00112         }
00113       }
00114     }
00115   } else {
00116     double r1sq = x1 * x1 + y1 * y1;
00117     double r2sq = x2 * x2 + y2 * y2;
00118     double r3sq = x3 * x3 + y3 * y3;
00119     a = 0.5 * (  (y1-y3)*(r1sq-r2sq) - (y1-y2)*(r1sq-r3sq)) / delta;
00120     b = 0.5 * (- (x1-x3)*(r1sq-r2sq) + (x1-x2)*(r1sq-r3sq)) / delta;
00121     double csq = (x1-a)*(x1-a) + (y1-b)*(y1-b);
00122     c = sqrt(csq);
00123     double csq2 = (x2-a)*(x2-a) + (y2-b)*(y2-b);
00124     double csq3 = (x3-a)*(x3-a) + (y3-b)*(y3-b);
00125     m_kappa = 1 / (2 * c);
00126     m_alpha = - 2 * a * m_kappa;
00127     m_beta = - 2 * b * m_kappa;
00128     m_gamma = (a*a + b*b - c*c) * m_kappa;
00129   }
00130 }

void Lpav::clear (  )  [inline]

void Lpav::clear (  )  [inline]

Definition at line 199 of file Lpav.h.

References m_chisq, m_nc, m_rrrrsum, m_rscale, m_wsum, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yrrsum, m_ysum, and m_yysum.

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

00199                         {
00200   m_wsum = m_xsum = m_ysum = m_xxsum = m_yysum = m_xysum
00201     = m_xrrsum = m_yrrsum = m_rrrrsum  = m_rscale = m_nc = 0;
00202   m_chisq = -1;
00203 }

HepSymMatrix Lpav::cov ( int  = 0  )  const

HepSymMatrix Lpav::cov ( int  = 0  )  const

Definition at line 443 of file Lpav.cxx.

Referenced by extrapolate(), and similarity().

00446 {
00447 #else
00448 {
00449   HepSymMatrix vret(4);
00450 #endif
00451   vret(1,1) = m_xxsum;
00452   vret(2,1) = m_xysum;
00453   vret(2,2) = m_yysum;
00454   vret(3,1) = m_xsum;
00455   vret(3,2) = m_ysum;
00456   vret(3,3) = m_wsum;
00457   vret(4,1) = m_xrrsum;
00458   vret(4,2) = m_yrrsum;
00459   vret(4,3) = m_xxsum + m_yysum;
00460   vret(4,4) = m_rrrrsum;
00461   if(inv==0) {
00462 //    int i=vret.Inv();
00463     int i;
00464     vret.invert(i);
00465     if (i!=0) {
00466       std::cerr << "Lpav::cov:could not invert nc=" << m_nc << vret;
00467 #ifdef HAVE_EXCEPTION
00468       THROW(Lpav::cov,Singular);
00469 #endif
00470     }
00471   }
00472   return vret;
00473 }

HepSymMatrix Lpav::cov_c ( int  = 0  )  const

HepSymMatrix Lpav::cov_c ( int  = 0  )  const

Definition at line 475 of file Lpav.cxx.

00478 {
00479 #else
00480 {
00481   HepSymMatrix vret(3);
00482 #endif
00483 #ifdef HAVE_EXCEPTION
00484   try {
00485 #endif
00486     vret = cov(1).similarity(dldc());
00487 #ifdef HAVE_EXCEPTION
00488   }
00489   catch (Lpav::Singular) {
00490     THROW(Lpav::cov_c1,Singular_c);
00491   }
00492 #endif
00493   if(inv==0) {
00494 //    int i = vret.Inv();
00495     int i;
00496     vret.invert(i);
00497     if (i!=0) {
00498       std::cerr << "Lpav::cov_c:could not invert " << vret;
00499 #ifdef HAVE_EXCEPTION
00500       THROW(Lpav::cov_c2,Singular_c);
00501 #endif
00502     }
00503   }
00504   return vret;
00505 }

double Lpar::d ( double  x,
double  y 
) const [inline, inherited]

double Lpar::d ( double  x,
double  y 
) const [inline, inherited]

Definition at line 208 of file Lpar.h.

References Lpar::d0(), and Lpar::m_kappa.

Referenced by FTFinder::CorrectEvtTiming(), delta_chisq(), intersect(), operator+(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), and FTTrack::r_phiReFit().

00208                                               {
00209   double dd = d0(x,y);
00210   const double approx_limit = 0.2;
00211   if(std::fabs(m_kappa*dd)>approx_limit) return -1;
00212   return dd * ( 1 - m_kappa * dd );
00213 }

double Lpav::delta_chisq ( double  x,
double  y,
double  w = 1 
) const

double Lpav::delta_chisq ( double  x,
double  y,
double  w = 1 
) const

Definition at line 664 of file Lpav.cxx.

References Lpar::d(), Lpar::d0(), and similarity().

Referenced by operator+().

00664                                                            {
00665   double sim = similarity(x,y);
00666   if(sim<0) return -1;
00667   double d = d0(x,y);
00668   double delta = std::sqrt(d) * w / (1 + sim * w);
00669   return delta;
00670 }

double Lpar::dr ( double  x,
double  y 
) const [inline, inherited]

double Lpar::dr ( double  x,
double  y 
) const [inline, inherited]

Definition at line 215 of file Lpar.h.

References Lpar::m_kappa, Lpar::xc(), and Lpar::yc().

Referenced by Lpar::xhyh().

00215                                                {
00216   double dx = xc() - x;
00217   double dy = yc() - y;
00218   double r = 0.5/std::fabs(m_kappa);
00219   return std::fabs(std::sqrt(dx * dx + dy * dy) - r);
00220 }

int Lpav::extrapolate ( double  ,
double &  ,
double &   
) const

int Lpav::extrapolate ( double  ,
double &  ,
double &   
) const

Definition at line 507 of file Lpav.cxx.

References cov(), m_chisq, M_PI, v, Lpar::x(), Lpar::xy(), and Lpar::y().

00507                                                               {
00508   double x, y;
00509   if (m_chisq<0) return -1;
00510   if (xy(r, x, y)!=0) return -1;
00511   phi = std::atan2(y,x);
00512   if (phi<0) phi += (2*M_PI);
00513   HepVector v(4);
00514   v(1) = x;
00515   v(2) = y;
00516   v(3) = 1;
00517   v(4) = r * r;
00518 //  HepSymMatrix l = cov().similarityT(v);
00519 #ifdef HAVE_EXCEPTION
00520   try {
00521 #endif
00522 //     HepSymMatrix l = cov().similarity(v.T());
00523 //     //  cout << "delta d^2=" << l(1,1);
00524 //     if (l(1,1)>0) {
00525     double l = cov().similarity(v);
00526     if(l>0) {
00527       double ls = std::sqrt(l);
00528       dphi = ls / r;
00529       //    cout << " delta d=" << ls << " dphi=" << dphi;
00530     }
00531 #ifdef HAVE_EXCEPTION
00532   }
00533   catch (Lpav::Singular) {
00534     return -1;
00535   }
00536 #endif
00537 //  cout << endl;
00538   return 0;
00539 }

double Lpav::fit ( double  x,
double  y,
double  w = 1 
)

double Lpav::fit (  ) 

double Lpav::fit ( double  x,
double  y,
double  w = 1 
)

Definition at line 411 of file Lpav.cxx.

References calculate_average(), calculate_average3(), calculate_lpar(), calculate_lpar3(), m_chisq, m_nc, m_rscale, m_wsum_temp, and q.

00411                                              {
00412   if (m_nc<=3) return -1;
00413   m_chisq = -1;
00414   double q;
00415   if (m_nc<4) {
00416     calculate_average3(x,y,w);
00417     double q = calculate_lpar3();
00418     if (q>0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
00419   } else {
00420     calculate_average(x,y,w);
00421     q = calculate_lpar();
00422     if (q>0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
00423   }
00424   return m_chisq;
00425 }

double Lpav::fit (  ) 

Definition at line 427 of file Lpav.cxx.

References calculate_average(), calculate_average3(), calculate_lpar(), calculate_lpar3(), m_chisq, m_nc, m_rscale, m_wsum_temp, and q.

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), TCurlFinder::fitWDD(), TBuilderCurl::fitWDD(), FTTrack::r_phi2Fit(), FTTrack::r_phi3Fit(), FTTrack::r_phi4Fit(), FTTrack::r_phiFit(), and FTTrack::r_phiReFit().

00427                      {
00428   if (m_nc<=3) return -1;
00429   m_chisq = -1;
00430   double q;
00431   if (m_nc<4) {
00432     calculate_average3();
00433     q = calculate_lpar3();
00434     if (q>0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
00435   } else {
00436     calculate_average();
00437     q = calculate_lpar();
00438     if (q>0) m_chisq = q * m_wsum_temp * m_rscale * m_rscale;
00439   }
00440   return m_chisq;
00441 }

HepVector Lpar::Hpar ( const HepPoint3D pivot  )  const [inline, inherited]

HepVector Lpar::Hpar ( const HepPoint3D pivot  )  const [inline, inherited]

Definition at line 269 of file Lpar.h.

References Lpar::BELLE_ALPHA, Lpar::d0(), Lpar::m_kappa, M_PI, Lpar::xc(), and Lpar::yc().

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

00269                                                          {
00270   HepVector a(5);
00271   double dd = d0(pivot.x(),pivot.y());
00272   a(1) = dd * ( m_kappa * dd - 1 );
00273   a(2) = (m_kappa>0) ? std::atan2(yc() - pivot.y(), xc() - pivot.x()) + M_PI 
00274     : std::atan2(pivot.y() - yc(), pivot.x() - xc()) - M_PI;
00275   a(3) = -2.0*BELLE_ALPHA*m_kappa;
00276   a(4) = 0;
00277   a(5) = 0;
00278   return a;
00279 }

double Lpar::kappa ( void   )  const [inline, inherited]

Definition at line 73 of file Lpar.h.

References Lpar::m_kappa.

00073 { return m_kappa; }

double Lpar::kappa ( void   )  const [inline, inherited]

Definition at line 63 of file Lpar.h.

References Lpar::m_kappa.

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), TCurlFinder::fitWDD(), TBuilderCurl::fitWDD(), intersect(), Lpar::s(), and Lpar::xhyh().

00063 { return m_kappa; }

double Lpav::nc ( double  nc  )  [inline, private]

Definition at line 94 of file Lpav.h.

References m_nc.

00094 { m_nc = nc; return m_nc; }

double Lpav::nc (  )  const [inline]

Definition at line 53 of file Lpav.h.

References m_nc.

00053 { return m_nc; }

double Lpav::nc ( double  nc  )  [inline, private]

Definition at line 99 of file Lpav.h.

References m_nc.

00099 { m_nc = nc; return m_nc; }

double Lpav::nc (  )  const [inline]

Definition at line 58 of file Lpav.h.

References m_nc.

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

00058 { return m_nc; }

void Lpar::neg (  )  [inline, inherited]

void Lpar::neg (  )  [inline, inherited]

Definition at line 197 of file Lpar.h.

References Lpar::m_alpha, Lpar::m_beta, Lpar::m_gamma, and Lpar::m_kappa.

Referenced by calculate_lpar(), and calculate_lpar3().

00197                       {
00198   m_alpha = -m_alpha;
00199   m_beta = -m_beta;
00200   m_gamma = -m_gamma;
00201   m_kappa = -m_kappa;
00202 }

bool Lpav::operator!= ( const Lpav  )  const [private]

bool Lpav::operator!= ( const Lpav  )  const [private]

const Lpav& Lpav::operator+= ( const Lpav  ) 

const Lpav & Lpav::operator+= ( const Lpav  ) 

Definition at line 615 of file Lpav.cxx.

References m_nc, m_rrrrsum, m_wsum, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yrrsum, m_ysum, and m_yysum.

00615                                              {
00616   m_wsum += la1.m_wsum;
00617   m_xsum += la1.m_xsum;
00618   m_ysum += la1.m_ysum;
00619   m_xxsum += la1.m_xxsum;
00620   m_yysum += la1.m_yysum;
00621   m_xysum += la1.m_xysum;
00622   m_xrrsum += la1.m_xrrsum;
00623   m_yrrsum += la1.m_yrrsum;
00624   m_rrrrsum += la1.m_rrrrsum;
00625   m_nc += la1.m_nc;
00626   return *this;
00627 }

const Lpav& Lpav::operator= ( const Lpar  ) 

Reimplemented from Lpar.

const Lpav& Lpav::operator= ( const Lpav  )  [inline]

const Lpav& Lpav::operator= ( const Lpar  ) 

Reimplemented from Lpar.

const Lpav & Lpav::operator= ( const Lpav  )  [inline]

Definition at line 138 of file Lpav.h.

References m_chisq, m_cosrot, m_nc, m_rrrravp, m_rrrrsum, m_rscale, m_sinrot, m_wsum, m_wsum_temp, m_xav, m_xrravp, m_xrrsum, m_xsum, m_xxavp, m_xxsum, m_xyavp, m_xysum, m_yav, m_yrravp, m_yrrsum, m_ysum, m_yyavp, m_yysum, and Lpar::operator=().

00138                                                   {
00139   Lpar::operator=(lp);
00140   m_wsum = lp.m_wsum;
00141   m_xsum = lp.m_xsum;
00142   m_ysum = lp.m_ysum;
00143   m_xxsum = lp.m_xxsum;
00144   m_yysum = lp.m_yysum;
00145   m_xysum = lp.m_xysum;
00146   m_xrrsum = lp.m_xrrsum;
00147   m_yrrsum = lp.m_yrrsum;
00148   m_rrrrsum = lp.m_rrrrsum;
00149   
00150   m_wsum_temp = lp. m_wsum_temp;
00151   m_xav = lp.m_xav;
00152   m_yav = lp.m_yav;
00153   m_xyavp = lp.m_xyavp;
00154   
00155   m_rscale = lp. m_rscale;
00156   m_xxavp = lp.m_xxavp;
00157   m_yyavp = lp.m_yyavp;
00158   m_xrravp = lp.m_xrravp;
00159   m_yrravp = lp.m_yrravp;
00160   m_rrrravp = lp.m_rrrravp;
00161   m_sinrot = lp.m_sinrot;
00162   m_cosrot = lp.m_cosrot;
00163   
00164   m_nc = lp. m_nc;
00165   m_chisq = lp.m_chisq;
00166   return *this;
00167 }

bool Lpav::operator== ( const Lpav  )  const [private]

bool Lpav::operator== ( const Lpav  )  const [private]

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

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

Definition at line 187 of file Lpar.cxx.

References M_PI, Lpar::x(), Lpar::xy(), and Lpar::y().

Referenced by FTFinder::makeTds(), and Lpar::sd().

00187                                        {
00188   double x, y;
00189   if (!xy(r,x,y, dir)) return -1;
00190   double p = atan2(y,x);
00191   if (p<0) p += (2*M_PI);
00192   return p;
00193 }

double Lpav::prob (  )  const

double Lpav::prob (  )  const

Definition at line 650 of file Lpav.cxx.

References m_chisq, m_nc, and prob_().

Referenced by operator+().

00650                         {
00651   if (m_nc<=3) return 0;
00652   if (m_chisq<0) return 0;
00653   float c = m_chisq;
00654   int nci = (int)m_nc - 3;
00655   double p = (double) prob_(&c, &nci);
00656   return p;
00657 }

double Lpar::radius ( void   )  const [inline, inherited]

Definition at line 74 of file Lpar.h.

References Lpar::m_kappa.

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

double Lpar::radius ( void   )  const [inline, inherited]

Definition at line 64 of file Lpar.h.

References Lpar::m_kappa.

Referenced by TCircleFitter::fit(), TCircle::fitForCurl(), TCurlFinder::fitWDD(), TBuilderCurl::fitWDD(), FTWire::z(), and KalFitWire::z().

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

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

double Lpar::s ( double  x,
double  y 
) const [inherited]

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

Definition at line 219 of file Lpar.cxx.

References Lpar::d0(), Lpar::da(), Lpar::kappa(), and M_PI.

00219                                       {
00220   double d0 = da();
00221   if (fabs(r)<fabs(d0)) return -1;
00222   double b = fabs(kappa()) * sqrt((r*r-d0*d0)/(1 + 2 * kappa() * d0));
00223   if (fabs(b)>1) return -1;
00224   if(dir==0)return asin(b)/fabs(kappa());
00225   return (M_PI-asin(b))/fabs(kappa());
00226 }

double Lpar::s ( double  x,
double  y 
) const [inherited]

Definition at line 207 of file Lpar.cxx.

References Lpar::alpha(), Lpar::beta(), Lpar::kappa(), M_PI, Lpar::xhyh(), and Lpar::xi2().

Referenced by intersect(), and FTTrack::s_zFit().

00207                                        {
00208   double xh, yh, xx, yy;
00209   xhyh(x, y, xh, yh);
00210   double fk = fabs(kappa());
00211   if (fk==0) return 0;
00212   yy = 2 * fk * ( alpha() * yh - beta() * xh);
00213   xx = 2 * kappa() * ( alpha() * xh + beta() * yh ) + xi2();
00214   double sp = atan2(yy, xx);
00215   if (sp<0) sp += (2*M_PI);
00216   return sp / 2 / fk;
00217 }

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

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

Definition at line 249 of file Lpar.h.

References abs, Lpar::d0(), Lpar::m_alpha, Lpar::m_beta, Lpar::m_kappa, Lpar::phi(), sin(), Lpar::xc(), and Lpar::yc().

00250                                                                {
00251   if ((x*yc()-y*xc())*m_kappa<0) return 0;
00252   double dd = d0(x,y);
00253   d = dd * ( 1 - m_kappa * dd );
00254   double d_cross_limit = d*limit;
00255   if (d_cross_limit < 0 || d_cross_limit > limit*limit) return 0;
00256   
00257   double rc = std::sqrt(m_alpha*m_alpha+m_beta*m_beta)/(2*m_kappa);
00258   double rho = 1./(-2*m_kappa);
00259   double cosPhi = (rc*rc + rho*rho - r*r)/(-2*rc*rho);
00260   double phi = std::acos(cosPhi);
00261   s = std::fabs(rho)*phi;
00262   d *= r/(std::fabs(rc)*std::sin(phi));
00263   if (abs(d) > abs(limit)) return 0;
00264   d_cross_limit = d*limit;
00265   if (d_cross_limit > limit*limit) return 0;
00266   return 1;
00267 }

double Lpav::similarity ( double  ,
double   
) const

double Lpav::similarity ( double  ,
double   
) const

Definition at line 541 of file Lpav.cxx.

References cov(), m_nc, and v.

Referenced by delta_chisq(), and operator+().

00541                                                 {
00542   if (m_nc<=3) return -1;
00543   HepVector v(4);
00544   v(1) = x;
00545   v(2) = y;
00546   v(3) = 1;
00547   v(4) = x * x + y * y;
00548   double l;
00549 #ifdef HAVE_EXCEPTION
00550   try {
00551 #endif
00552     l = cov().similarity(v);
00553 #ifdef HAVE_EXCEPTION
00554   }
00555   catch (Lpav::Singular) {
00556     return -1;
00557   }
00558 #endif
00559   return l;
00560 }

double Lpav::solve_lambda ( void   )  [private]

double Lpav::solve_lambda ( void   )  [private]

Definition at line 256 of file Lpav.cxx.

References lambda, m_rrrravp, m_rscale, m_wsum_temp, m_xrravp, m_xxavp, m_yrravp, and m_yyavp.

Referenced by calculate_lpar().

00256                               {
00257   if (m_rscale<=0) return -1;
00258   double xrrxrr = m_xrravp * m_xrravp;
00259   double yrryrr = m_yrravp * m_yrravp;
00260   double rrrrm1 = m_rrrravp - 1;
00261   double xxyy = m_xxavp * m_yyavp;
00262 
00263   double c0 =       rrrrm1 * xxyy - xrrxrr * m_yyavp - yrryrr * m_xxavp;
00264   double c1 =     - rrrrm1        + xrrxrr        + yrryrr        - 4 * xxyy;
00265   double c2 =   4 + rrrrm1                                        - 4 * xxyy;
00266   double c4 = - 4;  
00267 //
00268 //C     COEFFICIENTS OF THE DERIVATIVE - USED IN NEWTON-RAPHSON ITERATIONS
00269 //
00270   double c2d = 2 * c2;
00271   double c4d = 4 * c4;
00272 //
00273   double lambda = 0;
00274   
00275   double chiscl = m_wsum_temp * m_rscale * m_rscale;
00276   double dlamax = 0.001 / chiscl;
00277   const int ntry = 5;
00278   int itry = 0;
00279   double dlambda = dlamax;
00280   while ( itry<ntry && std::fabs(dlambda) >= dlamax) {
00281     double cpoly = c0 + lambda * ( c1 + lambda *
00282                                    ( c2 + lambda * lambda * c4));
00283     double dcpoly = c1 + lambda * ( c2d + lambda * lambda * c4d);
00284     dlambda = - cpoly / dcpoly;
00285     lambda += dlambda;
00286     itry ++;
00287   }
00288   lambda = lambda<0 ? 0 : lambda;
00289   return lambda;
00290 }

double Lpav::solve_lambda3 ( void   )  [private]

double Lpav::solve_lambda3 ( void   )  [private]

Definition at line 292 of file Lpav.cxx.

References m_rrrravp, m_rscale, m_xrravp, m_xxavp, m_xyavp, m_yrravp, and m_yyavp.

Referenced by calculate_lpar3().

00292                                {
00293   if (m_rscale<=0) return -1;
00294   double xrrxrr = m_xrravp * m_xrravp;
00295   double yrryrr = m_yrravp * m_yrravp;
00296   double rrrrm1 = m_rrrravp - 1;
00297   double xxyy = m_xxavp * m_yyavp;
00298 
00299   double a = m_rrrravp;
00300   double b = xrrxrr + yrryrr - m_rrrravp * (m_xxavp + m_yyavp);
00301   double c = m_rrrravp * m_xxavp * m_yyavp
00302     - m_yyavp * xrrxrr - m_xxavp * yrryrr
00303     + 2 * m_xyavp * m_xrravp * m_yrravp - m_rrrravp * m_xyavp * m_xyavp;
00304   if (c>=0 && b<=0) {
00305     return (-b-std::sqrt(b*b-4*a*c))/2/a;
00306   } else if (c>=0 && b>0) {
00307     std::cerr << " returning " <<-1<<std::endl; 
00308     return -1;
00309   } else if (c<0) {
00310     return (-b+std::sqrt(b*b-4*a*c))/2/a;
00311   }
00312   return -1;
00313 }

void Lpav::sub ( double  x,
double  y,
double  w = 1,
double  a = 0,
double  b = 0 
) [private]

void Lpav::sub ( double  x,
double  y,
double  w = 1,
double  a = 0,
double  b = 0 
) [private]

Definition at line 599 of file Lpav.cxx.

References err_dis_inv(), m_nc, m_rrrrsum, m_wsum, m_xrrsum, m_xsum, m_xxsum, m_xysum, m_yrrsum, and m_ysum.

00599                                                                  {
00600   register double wi = err_dis_inv(xi, yi, w, a, b);
00601   m_wsum -= wi;
00602   m_xsum -= wi * xi;
00603   m_ysum -= wi * yi;
00604   m_xxsum -= wi * xi * xi;
00605   m_yysum -= wi * yi * yi;
00606   m_xysum -= wi * xi * yi;
00607   register double rri = ( xi * xi + yi * yi );
00608   register double wrri = wi * rri;
00609   m_xrrsum -= wrri * xi;
00610   m_yrrsum -= wrri * yi;
00611   m_rrrrsum -= wrri * rri;
00612   m_nc -= 1;
00613 }


Friends And Related Function Documentation

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

Definition at line 242 of file Lpar.cxx.

00242                                                                           {
00243   HepVector cen1(lp1.center());
00244   HepVector cen2(lp2.center());
00245   double dx = cen1(1)-cen2(1);
00246   double dy = cen1(2)-cen2(2);
00247   double dc = sqrt(dx*dx+dy*dy);
00248   if(dc<fabs(0.5/lp1.kappa())+fabs(0.5/lp2.kappa())) {
00249     double a1 = std::sqrt(lp1.alpha()) + std::sqrt(lp1.beta());
00250     double a2 = std::sqrt(lp2.alpha()) + std::sqrt(lp2.beta());
00251     double a3 = lp1.alpha()*lp2.alpha() + lp1.beta()*lp2.beta();
00252     double det = lp1.alpha()*lp2.beta() - lp1.beta()*lp2.alpha();
00253     if(fabs(det)>1e-12) {
00254       double c1 = a2 * std::sqrt(lp1.kappa()) + a1 * std::sqrt(lp2.kappa()) -
00255         2.0 * a3 * lp1.kappa() * lp2.kappa();
00256       if(c1!=0) {
00257         double cinv = 1.0 / c1;
00258         double c2 = std::sqrt(a3) - 0.5 * (a1 + a2) - 2.0 * a3 *
00259           (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
00260         double c3 = a2 * std::sqrt(lp1.gamma()) + a1 * std::sqrt(lp2.gamma()) -
00261           2.0 * a3 * lp1.gamma() * lp2.gamma();
00262         double root = std::sqrt(c2) - 4.0 * c1 * c3;
00263         if (root>=0) {
00264           root = sqrt(root);
00265           double rad2[2];
00266           rad2[0] = 0.5 * cinv * (-c2 - root);
00267           rad2[1] = 0.5 * cinv * (-c2 + root);
00268           double ab1 = -(lp2.beta() * lp1.gamma() - lp1.beta() * lp2.gamma());
00269           double ab2 = (lp2.alpha() * lp1.gamma() - lp1.alpha() * lp2.gamma());
00270           double ac1 = -(lp2.beta() * lp1.kappa() - lp1.beta() * lp2.kappa());
00271           double ac2 = (lp2.alpha() * lp1.kappa() - lp1.alpha() * lp2.kappa());
00272           double dinv = 1.0 / det;
00273           v1(1) = dinv * (ab1 + ac1 * rad2[0]);
00274           v1(2) = dinv * (ab2 + ac2 * rad2[0]);
00275           v1(3) = 0;
00276           v2(1) = dinv * (ab1 + ac1 * rad2[1]);
00277           v2(2) = dinv * (ab2 + ac2 * rad2[1]);
00278           v2(3) = 0;
00279           double d1 = lp1.d(v1(1),v1(2));
00280           double d2 = lp2.d(v1(1),v1(2));
00281           double d3 = lp1.d(v2(1),v2(2));
00282           double d4 = lp2.d(v2(1),v2(2));
00283           double r = sqrt(rad2[0]);
00284           Lpar::Cpar cp1(lp1);
00285           Lpar::Cpar cp2(lp2);
00286           for(int j=0;j<2;j++) {
00287             double s1,s2;
00288             if(j==0) {
00289               s1 = lp1.s(v1(1),v1(2));
00290               s2 = lp2.s(v1(1),v1(2));
00291             } else {
00292               s1 = lp1.s(v2(1),v2(2));
00293               s2 = lp2.s(v2(1),v2(2));
00294             }
00295             double phi1 = cp1.fi() + 2 * cp1.cu() * s1;
00296             double phi2 = cp2.fi() + 2 * cp2.cu() * s2;
00297             double f = (1 + 2 * cp1.cu() * cp1.da()) *
00298               (1 + 2 * cp2.cu() * cp2.da()) * cos(cp1.fi()-cp2.fi());
00299             f -= 2 * (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
00300             double cosphi12 = f;
00301           }
00302           return 2;
00303         }
00304       }
00305     }
00306   }
00307   return 0;
00308 }

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

Definition at line 242 of file Lpar.cxx.

00242                                                                           {
00243   HepVector cen1(lp1.center());
00244   HepVector cen2(lp2.center());
00245   double dx = cen1(1)-cen2(1);
00246   double dy = cen1(2)-cen2(2);
00247   double dc = sqrt(dx*dx+dy*dy);
00248   if(dc<fabs(0.5/lp1.kappa())+fabs(0.5/lp2.kappa())) {
00249     double a1 = std::sqrt(lp1.alpha()) + std::sqrt(lp1.beta());
00250     double a2 = std::sqrt(lp2.alpha()) + std::sqrt(lp2.beta());
00251     double a3 = lp1.alpha()*lp2.alpha() + lp1.beta()*lp2.beta();
00252     double det = lp1.alpha()*lp2.beta() - lp1.beta()*lp2.alpha();
00253     if(fabs(det)>1e-12) {
00254       double c1 = a2 * std::sqrt(lp1.kappa()) + a1 * std::sqrt(lp2.kappa()) -
00255         2.0 * a3 * lp1.kappa() * lp2.kappa();
00256       if(c1!=0) {
00257         double cinv = 1.0 / c1;
00258         double c2 = std::sqrt(a3) - 0.5 * (a1 + a2) - 2.0 * a3 *
00259           (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
00260         double c3 = a2 * std::sqrt(lp1.gamma()) + a1 * std::sqrt(lp2.gamma()) -
00261           2.0 * a3 * lp1.gamma() * lp2.gamma();
00262         double root = std::sqrt(c2) - 4.0 * c1 * c3;
00263         if (root>=0) {
00264           root = sqrt(root);
00265           double rad2[2];
00266           rad2[0] = 0.5 * cinv * (-c2 - root);
00267           rad2[1] = 0.5 * cinv * (-c2 + root);
00268           double ab1 = -(lp2.beta() * lp1.gamma() - lp1.beta() * lp2.gamma());
00269           double ab2 = (lp2.alpha() * lp1.gamma() - lp1.alpha() * lp2.gamma());
00270           double ac1 = -(lp2.beta() * lp1.kappa() - lp1.beta() * lp2.kappa());
00271           double ac2 = (lp2.alpha() * lp1.kappa() - lp1.alpha() * lp2.kappa());
00272           double dinv = 1.0 / det;
00273           v1(1) = dinv * (ab1 + ac1 * rad2[0]);
00274           v1(2) = dinv * (ab2 + ac2 * rad2[0]);
00275           v1(3) = 0;
00276           v2(1) = dinv * (ab1 + ac1 * rad2[1]);
00277           v2(2) = dinv * (ab2 + ac2 * rad2[1]);
00278           v2(3) = 0;
00279           double d1 = lp1.d(v1(1),v1(2));
00280           double d2 = lp2.d(v1(1),v1(2));
00281           double d3 = lp1.d(v2(1),v2(2));
00282           double d4 = lp2.d(v2(1),v2(2));
00283           double r = sqrt(rad2[0]);
00284           Lpar::Cpar cp1(lp1);
00285           Lpar::Cpar cp2(lp2);
00286           for(int j=0;j<2;j++) {
00287             double s1,s2;
00288             if(j==0) {
00289               s1 = lp1.s(v1(1),v1(2));
00290               s2 = lp2.s(v1(1),v1(2));
00291             } else {
00292               s1 = lp1.s(v2(1),v2(2));
00293               s2 = lp2.s(v2(1),v2(2));
00294             }
00295             double phi1 = cp1.fi() + 2 * cp1.cu() * s1;
00296             double phi2 = cp2.fi() + 2 * cp2.cu() * s2;
00297             double f = (1 + 2 * cp1.cu() * cp1.da()) *
00298               (1 + 2 * cp2.cu() * cp2.da()) * cos(cp1.fi()-cp2.fi());
00299             f -= 2 * (lp1.gamma() * lp2.kappa() + lp2.gamma() * lp1.kappa());
00300             double cosphi12 = f;
00301           }
00302           return 2;
00303         }
00304       }
00305     }
00306   }
00307   return 0;
00308 }

Lpar::Cpar [friend, inherited]

Definition at line 105 of file Lpar.h.

Lpav [friend, inherited]

Definition at line 78 of file Lpar.h.

Lpav operator+ ( const Lpav la1,
const Lpav la2 
) [friend]

Definition at line 629 of file Lpav.cxx.

00632 {
00633 #else
00634 {
00635   Lpav la;
00636 #endif
00637   la.m_wsum = la1.m_wsum + la2.m_wsum;
00638   la.m_xsum = la1.m_xsum + la2.m_xsum;
00639   la.m_ysum = la1.m_ysum + la2.m_ysum;
00640   la.m_xxsum = la1.m_xxsum + la2.m_xxsum;
00641   la.m_yysum = la1.m_yysum + la2.m_yysum;
00642   la.m_xysum = la1.m_xysum + la2.m_xysum;
00643   la.m_xrrsum = la1.m_xrrsum + la2.m_xrrsum;
00644   la.m_yrrsum = la1.m_yrrsum + la2.m_yrrsum;
00645   la.m_rrrrsum = la1.m_rrrrsum + la2.m_rrrrsum;
00646   la.m_nc = la1.m_nc + la2.m_nc;
00647   return la;
00648 }

Lpav operator+ ( const Lpav la1,
const Lpav la2 
) [friend]

Definition at line 629 of file Lpav.cxx.

00632 {
00633 #else
00634 {
00635   Lpav la;
00636 #endif
00637   la.m_wsum = la1.m_wsum + la2.m_wsum;
00638   la.m_xsum = la1.m_xsum + la2.m_xsum;
00639   la.m_ysum = la1.m_ysum + la2.m_ysum;
00640   la.m_xxsum = la1.m_xxsum + la2.m_xxsum;
00641   la.m_yysum = la1.m_yysum + la2.m_yysum;
00642   la.m_xysum = la1.m_xysum + la2.m_xysum;
00643   la.m_xrrsum = la1.m_xrrsum + la2.m_xrrsum;
00644   la.m_yrrsum = la1.m_yrrsum + la2.m_yrrsum;
00645   la.m_rrrrsum = la1.m_rrrrsum + la2.m_rrrrsum;
00646   la.m_nc = la1.m_nc + la2.m_nc;
00647   return la;
00648 }

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

Definition at line 318 of file Lpar.cxx.

00318                                                {
00319   return o << " al=" << s.m_alpha << " be=" << s.m_beta
00320            << " ka=" << s.m_kappa << " ga=" << s.m_gamma;
00321 }

std::ostream& operator<< ( std::ostream o,
const Lpav s 
) [friend]

Definition at line 240 of file Lpav.cxx.

00240                                                      {
00241 //  o << "wsum=" << a.m_wsum << " xsum=" << a.m_xsum << " ysum=" << a.m_ysum 
00242 //  << " xxsum=" << a.m_xxsum << " xysum=" << a.m_xysum
00243 //  << " yysum=" << a.m_yysum 
00244 //  << " xrrsum=" << a.m_xrrsum << " yrrsum=" << a.m_yrrsum
00245 //  << " rrrrsum=" << a.m_rrrrsum;
00246 //  o << " rscale=" << a.m_rscale
00247 //  << " xxavp=" << a.m_xxavp << " yyavp=" << a.m_yyavp
00248 //  << " xrravp=" << a.m_xrravp << " yrravp=" << a.m_yrravp
00249 //  << " rrrravp=" << a.m_rrrravp << " cosrot=" << a.m_cosrot
00250 //  << " sinrot=" << a.m_sinrot
00251 //  << endl;
00252   o << " nc=" << a.m_nc << " chisq=" << a.m_chisq << " " << (Lpar&) a;
00253   return o;
00254 }

std::ostream& operator<< ( std::ostream o,
const Lpav s 
) [friend]

Definition at line 240 of file Lpav.cxx.

00240                                                      {
00241 //  o << "wsum=" << a.m_wsum << " xsum=" << a.m_xsum << " ysum=" << a.m_ysum 
00242 //  << " xxsum=" << a.m_xxsum << " xysum=" << a.m_xysum
00243 //  << " yysum=" << a.m_yysum 
00244 //  << " xrrsum=" << a.m_xrrsum << " yrrsum=" << a.m_yrrsum
00245 //  << " rrrrsum=" << a.m_rrrrsum;
00246 //  o << " rscale=" << a.m_rscale
00247 //  << " xxavp=" << a.m_xxavp << " yyavp=" << a.m_yyavp
00248 //  << " xrravp=" << a.m_xrravp << " yrravp=" << a.m_yrravp
00249 //  << " rrrravp=" << a.m_rrrravp << " cosrot=" << a.m_cosrot
00250 //  << " sinrot=" << a.m_sinrot
00251 //  << endl;
00252   o << " nc=" << a.m_nc << " chisq=" << a.m_chisq << " " << (Lpar&) a;
00253   return o;
00254 }


Member Data Documentation

double Lpav::m_chisq [private]

Definition at line 131 of file Lpav.h.

Referenced by calculate_lpar(), calculate_lpar3(), chi_deg(), chisq(), clear(), extrapolate(), fit(), Lpav(), operator+(), operator<<(), operator=(), and prob().

double Lpav::m_cosrot [private]

Definition at line 128 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), Lpav(), and operator=().

double Lpav::m_nc [private]

Definition at line 130 of file Lpav.h.

Referenced by add_point_frac(), chi_deg(), clear(), fit(), Lpav(), nc(), operator+(), operator+=(), operator<<(), operator=(), prob(), similarity(), and sub().

double Lpav::m_rrrravp [private]

Definition at line 126 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_rrrrsum [private]

Definition at line 114 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_rscale [private]

Definition at line 121 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), clear(), fit(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_sinrot [private]

Definition at line 127 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), Lpav(), and operator=().

double Lpav::m_wsum [private]

Definition at line 106 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_wsum_temp [private]

Definition at line 116 of file Lpav.h.

Referenced by calculate_average(), calculate_average3(), calculate_lpar(), calculate_lpar3(), fit(), Lpav(), operator=(), and solve_lambda().

double Lpav::m_xav [private]

Definition at line 117 of file Lpav.h.

Referenced by calculate_average(), calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), and operator=().

double Lpav::m_xrravp [private]

Definition at line 124 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_xrrsum [private]

Definition at line 112 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_xsum [private]

Definition at line 107 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_xxavp [private]

Definition at line 122 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_xxsum [private]

Definition at line 109 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_xyavp [private]

Definition at line 119 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar3(), Lpav(), operator=(), and solve_lambda3().

double Lpav::m_xysum [private]

Definition at line 111 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_yav [private]

Definition at line 118 of file Lpav.h.

Referenced by calculate_average(), calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), and operator=().

double Lpav::m_yrravp [private]

Definition at line 125 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_yrrsum [private]

Definition at line 113 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_ysum [private]

Definition at line 108 of file Lpav.h.

Referenced by add_point_frac(), calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), operator=(), and sub().

double Lpav::m_yyavp [private]

Definition at line 123 of file Lpav.h.

Referenced by calculate_average3(), calculate_average_n(), calculate_lpar(), calculate_lpar3(), Lpav(), operator=(), solve_lambda(), and solve_lambda3().

double Lpav::m_yysum [private]

Definition at line 110 of file Lpav.h.

Referenced by calculate_average(), calculate_average3(), clear(), Lpav(), operator+(), operator+=(), and operator=().


Generated on Tue Nov 29 23:20:03 2016 for BOSS_7.0.2 by  doxygen 1.4.7