CMS 3D CMS Logo

sistrip::LinearFit Class Reference

#include <DQM/SiStripCommissioningAnalysis/src/Utility.h>

List of all members.

Public Member Functions

void add (const float &value_x, const float &value_y, const float &error_y)
void add (const float &value_x, const float &value_y)
void fit (Params &fit_params)
 LinearFit ()
 ~LinearFit ()

Private Attributes

std::vector< float > e_
float ss_
float sx_
float sy_
std::vector< float > x_
std::vector< float > y_

Classes

class  Params


Detailed Description

Definition at line 11 of file Utility.h.


Constructor & Destructor Documentation

LinearFit::LinearFit (  ) 

Definition at line 5 of file Utility.cc.

00006   : x_(),
00007     y_(),
00008     e_(),
00009     ss_(0.),
00010     sx_(0.),
00011     sy_(0.) 
00012 {;}

sistrip::LinearFit::~LinearFit (  )  [inline]

Definition at line 17 of file Utility.h.

00017 {;}


Member Function Documentation

void LinearFit::add ( const float &  value_x,
const float &  value_y,
const float &  error_y 
)

Definition at line 30 of file Utility.cc.

References e_, funct::sqrt(), ss_, sx_, sy_, x_, and y_.

00032                                                {
00033   if ( e > 0. ) { 
00034     x_.push_back(x);
00035     y_.push_back(y);
00036     e_.push_back(e);
00037     float wt = 1. / sqrt(e); 
00038     ss_ += wt;
00039     sx_ += x*wt;
00040     sy_ += y*wt;
00041   } 
00042 }

void LinearFit::add ( const float &  value_x,
const float &  value_y 
)

Definition at line 16 of file Utility.cc.

References e, e_, funct::sqrt(), ss_, sx_, sy_, x_, and y_.

Referenced by OptoScanAlgorithm::analyse().

00017                                                {
00018   float e = 1.; // default
00019   x_.push_back(x);
00020   y_.push_back(y);
00021   e_.push_back(e);
00022   float wt = 1. / sqrt(e); 
00023   ss_ += wt;
00024   sx_ += x*wt;
00025   sy_ += y*wt;
00026 }

void LinearFit::fit ( Params fit_params  ) 

Definition at line 46 of file Utility.cc.

References sistrip::LinearFit::Params::a_, b, sistrip::LinearFit::Params::b_, e_, sistrip::LinearFit::Params::erra_, sistrip::LinearFit::Params::errb_, i, sistrip::LinearFit::Params::n_, s2, funct::sqrt(), ss_, sx_, sy_, t, x_, and y_.

Referenced by OptoScanAlgorithm::analyse().

00046                                            {
00047 
00048   float s2 = 0.;
00049   float b = 0;
00050   for ( uint16_t i = 0; i < x_.size(); i++ ) {
00051     float t = ( x_[i] - sx_/ss_ ) / e_[i]; 
00052     s2 += t*t;
00053     b += t * y_[i] / e_[i];
00054   }
00055   
00056   // Set parameters
00057   params.n_ = x_.size();
00058   params.b_ = b / s2;
00059   params.a_ = ( sy_ - sx_ * params.b_ ) / ss_;
00060   params.erra_ = sqrt( ( 1. + (sx_*sx_) / (ss_*s2) ) / ss_ );
00061   params.errb_ = sqrt( 1. / s2 );
00062   
00063   /*
00064     params.chi2_ = 0.;
00065     *q=1.0;
00066     if (mwt == 0) {
00067     for (i=1;i<=ndata;i++)
00068     *chi2 += SQR(y[i]-(*a)-(*b)*x[i]);
00069     sigdat=sqrt((*chi2)/(ndata-2));
00070     *sigb *= sigdat;
00071     */    
00072   
00073 }


Member Data Documentation

std::vector<float> sistrip::LinearFit::e_ [private]

Definition at line 48 of file Utility.h.

Referenced by add(), and fit().

float sistrip::LinearFit::ss_ [private]

Definition at line 49 of file Utility.h.

Referenced by add(), and fit().

float sistrip::LinearFit::sx_ [private]

Definition at line 50 of file Utility.h.

Referenced by add(), and fit().

float sistrip::LinearFit::sy_ [private]

Definition at line 51 of file Utility.h.

Referenced by add(), and fit().

std::vector<float> sistrip::LinearFit::x_ [private]

Definition at line 46 of file Utility.h.

Referenced by add(), and fit().

std::vector<float> sistrip::LinearFit::y_ [private]

Definition at line 47 of file Utility.h.

Referenced by add(), and fit().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:52:35 2009 for CMSSW by  doxygen 1.5.4