ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
MuonCalib::BaseFunctionFitter Class Reference

#include <BaseFunctionFitter.h>

Collaboration diagram for MuonCalib::BaseFunctionFitter:

Public Member Functions

 BaseFunctionFitter (void)
 default constructor, the number of fit parameters will be set to 5 More...
 
 BaseFunctionFitter (const int &nb_coefficients)
 constructor, the number of fit parameters is set to nb_coefficients More...
 
int number_of_coefficients (void) const
 get the number of fit parameters (coefficients) of the base functions to be fitted More...
 
Amg::VectorX coefficients (void) const
 get the coefficients determined by the fit to the sample points More...
 
void set_number_of_coefficients (const int &nb_coefficients)
 set the number of fit parameters (coefficients) of the base functions to nb_coefficients More...
 
bool fit_parameters (const std::vector< SamplePoint > &sample_point, const unsigned int &first_point, const unsigned int &last_point, BaseFunction *base_function)
 perform a fit of the base functions (base_function) to the sample points as given in "sample_point" starting at the sample point first_point and stopping at the point last_point, 1 <= first_point < last_point <= size of the sample_point vector; the method returns true, if the fit failed More...
 

Private Member Functions

void init (void)
 default initialization method More...
 
void init (const int &nb_coefficients)
 initialization method: the number of fit parameters (coefficients) is set to nb_coefficients More...
 

Private Attributes

int m_nb_coefficients
 number of coefficients More...
 
Amg::MatrixX m_A
 coefficient matrix for the fit More...
 
Amg::VectorX m_alpha
 coefficients of the base functions after the fit More...
 
Amg::VectorX m_b
 m_A*m_alpha = m_b; More...
 

Detailed Description

This class performs a fit of a linear combination of base functions to a set of sample points.

Author
Olive.nosp@m.r.Ko.nosp@m.rtner.nosp@m.@cer.nosp@m.n.ch
Date
05.04.2005

Definition at line 47 of file BaseFunctionFitter.h.

Constructor & Destructor Documentation

◆ BaseFunctionFitter() [1/2]

MuonCalib::BaseFunctionFitter::BaseFunctionFitter ( void  )
inline

default constructor, the number of fit parameters will be set to 5

Definition at line 65 of file BaseFunctionFitter.h.

65  {
66  init();
67  }

◆ BaseFunctionFitter() [2/2]

MuonCalib::BaseFunctionFitter::BaseFunctionFitter ( const int &  nb_coefficients)
inline

constructor, the number of fit parameters is set to nb_coefficients

Definition at line 69 of file BaseFunctionFitter.h.

69  {
70  init(nb_coefficients);
71  }

Member Function Documentation

◆ coefficients()

Amg::VectorX MuonCalib::BaseFunctionFitter::coefficients ( void  ) const
inline

get the coefficients determined by the fit to the sample points

◆ fit_parameters()

bool MuonCalib::BaseFunctionFitter::fit_parameters ( const std::vector< SamplePoint > &  sample_point,
const unsigned int &  first_point,
const unsigned int &  last_point,
BaseFunction base_function 
)

perform a fit of the base functions (base_function) to the sample points as given in "sample_point" starting at the sample point first_point and stopping at the point last_point, 1 <= first_point < last_point <= size of the sample_point vector; the method returns true, if the fit failed

Definition at line 18 of file BaseFunctionFitter.cxx.

22  {
23 
25 // CHECKS //
27 
28  if (first_point<1 || first_point>sample_point.size()) {
29  throw std::runtime_error(Form("File: %s, Line: %d\nBaseFunctionFitter::fit_parameters() - ERROR: Illegal first point %d, must be >=1 and <=%lu", __FILE__, __LINE__, first_point, sample_point.size()));
30  }
31  if (last_point<first_point || last_point>sample_point.size()) {
32  throw std::runtime_error(Form("File: %s, Line: %d\nBaseFunctionFitter::fit_parameters() - ERROR: Illegal last point %d, must be >=%d and <=%lu", __FILE__, __LINE__, last_point, first_point, sample_point.size()));
33  }
34 
36 // IF ALL CHECK ARE PASSED, FILL THE MINIMIZATION OBJECTS //
38 
39 // clear the objects //
41 
42  for (int j=0; j<m_nb_coefficients; j++) {
43  for (int p=j; p<m_nb_coefficients; p++) {
44 
45  for (unsigned int k=first_point-1; k<last_point; k++) {
46  m_A.fillSymmetric(j,p,m_A(j,p)+base_function->value(j,sample_point[k].x1())
47  *base_function->value(p,sample_point[k].x1())/
48  std::pow(sample_point[k].error(), 2));
49 
50  }
51 
52  }
53 
54  for (unsigned int k=first_point-1; k<last_point; k++) {
55  m_b[j] = m_b[j]+sample_point[k].x2()*
56  base_function->value(j,
57  sample_point[k].x1())/
58  std::pow(sample_point[k].error(), 2);
59  }
60 
61  }
62 
63 // perform the minimization //
64  Amg::MatrixX aInv = m_A.inverse();
65  m_alpha = aInv*m_b;
66 
67  return false;
68 
69 }

◆ init() [1/2]

void MuonCalib::BaseFunctionFitter::init ( const int &  nb_coefficients)
inlineprivate

initialization method: the number of fit parameters (coefficients) is set to nb_coefficients

◆ init() [2/2]

void MuonCalib::BaseFunctionFitter::init ( void  )
inlineprivate

default initialization method

◆ number_of_coefficients()

int MuonCalib::BaseFunctionFitter::number_of_coefficients ( void  ) const
inline

get the number of fit parameters (coefficients) of the base functions to be fitted

◆ set_number_of_coefficients()

void MuonCalib::BaseFunctionFitter::set_number_of_coefficients ( const int &  nb_coefficients)
inline

set the number of fit parameters (coefficients) of the base functions to nb_coefficients

Member Data Documentation

◆ m_A

Amg::MatrixX MuonCalib::BaseFunctionFitter::m_A
private

coefficient matrix for the fit

Definition at line 52 of file BaseFunctionFitter.h.

◆ m_alpha

Amg::VectorX MuonCalib::BaseFunctionFitter::m_alpha
private

coefficients of the base functions after the fit

Definition at line 53 of file BaseFunctionFitter.h.

◆ m_b

Amg::VectorX MuonCalib::BaseFunctionFitter::m_b
private

m_A*m_alpha = m_b;

Definition at line 54 of file BaseFunctionFitter.h.

◆ m_nb_coefficients

int MuonCalib::BaseFunctionFitter::m_nb_coefficients
private

number of coefficients

Definition at line 51 of file BaseFunctionFitter.h.


The documentation for this class was generated from the following files:
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:29
MuonCalib::BaseFunctionFitter::m_nb_coefficients
int m_nb_coefficients
number of coefficients
Definition: BaseFunctionFitter.h:51
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
MuonCalib::BaseFunctionFitter::m_A
Amg::MatrixX m_A
coefficient matrix for the fit
Definition: BaseFunctionFitter.h:52
MuonCalib::BaseFunctionFitter::m_alpha
Amg::VectorX m_alpha
coefficients of the base functions after the fit
Definition: BaseFunctionFitter.h:53
MuonCalib::BaseFunctionFitter::m_b
Amg::VectorX m_b
m_A*m_alpha = m_b;
Definition: BaseFunctionFitter.h:54
get_generator_info.error
error
Definition: get_generator_info.py:40
MuonCalib::BaseFunctionFitter::init
void init(void)
default initialization method
fitman.k
k
Definition: fitman.py:528