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 ()
 default constructor, the number of fit parameters will be set to 5 More...
 
 BaseFunctionFitter (const unsigned nb_coefficients)
 constructor, the number of fit parameters is set to nb_coefficients More...
 
int number_of_coefficients () const
 get the number of fit parameters (coefficients) of the base functions to be fitted More...
 
const Amg::VectorXcoefficients () const
 get the coefficients determined by the fit to the sample points More...
 
void set_number_of_coefficients (const unsigned nb_coefficients)
 set the number of fit parameters (coefficients) of the base functions to nb_coefficients More...
 
void fit_parameters (const std::vector< SamplePoint > &sample_point, const unsigned int first_point, const unsigned int last_point, const 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 ()
 default initialization method More...
 
void init (const unsigned nb_coefficients)
 initialization method: the number of fit parameters (coefficients) is set to nb_coefficients More...
 

Private Attributes

unsigned int m_nb_coefficients {0}
 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.

Definition at line 39 of file BaseFunctionFitter.h.

Constructor & Destructor Documentation

◆ BaseFunctionFitter() [1/2]

MuonCalib::BaseFunctionFitter::BaseFunctionFitter ( )

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

Definition at line 10 of file BaseFunctionFitter.cxx.

10  {
11  init();
12  }

◆ BaseFunctionFitter() [2/2]

MuonCalib::BaseFunctionFitter::BaseFunctionFitter ( const unsigned  nb_coefficients)

constructor, the number of fit parameters is set to nb_coefficients

Definition at line 13 of file BaseFunctionFitter.cxx.

13  {
14  init(nb_coefficients);
15  }

Member Function Documentation

◆ coefficients()

const Amg::VectorX & MuonCalib::BaseFunctionFitter::coefficients ( ) const

get the coefficients determined by the fit to the sample points

Definition at line 30 of file BaseFunctionFitter.cxx.

30  {
31  return m_alpha;
32  }

◆ fit_parameters()

void MuonCalib::BaseFunctionFitter::fit_parameters ( const std::vector< SamplePoint > &  sample_point,
const unsigned int  first_point,
const unsigned int  last_point,
const 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 36 of file BaseFunctionFitter.cxx.

39  {
40  if (first_point<1 || first_point>sample_point.size()) {
41  THROW_EXCEPTION("BaseFunctionFitter::fit_parameters() - ERROR: Illegal first point "
42  <<first_point<<", must be >=1 and <="<<sample_point.size());
43  }
44  if (last_point<first_point || last_point>sample_point.size()) {
45  THROW_EXCEPTION("BaseFunctionFitter::fit_parameters() - ERROR: Illegal last point "<<last_point
46  <<", must be >="<<first_point<<" and <="<<sample_point.size());
47  }
48  // clear the objects //
50 
51  for (unsigned j=0; j<m_nb_coefficients; ++j) {
52  for (unsigned p=j; p<m_nb_coefficients; ++p) {
53  for (unsigned k=first_point-1; k<last_point; ++k) {
54  m_A.fillSymmetric(j,p,m_A(j,p)+base_function.value(j,sample_point[k].x1())
55  *base_function.value(p,sample_point[k].x1()) /
56  std::pow(sample_point[k].error(), 2));
57  }
58  }
59  for (unsigned k=first_point-1; k<last_point; k++) {
60  m_b[j] = m_b[j]+sample_point[k].x2()* base_function.value(j, sample_point[k].x1()) /
61  std::pow(sample_point[k].error(), 2);
62  }
63  }
64  // perform the minimization //
65  m_alpha = m_A.inverse()*m_b;
66  }

◆ init() [1/2]

void MuonCalib::BaseFunctionFitter::init ( )
private

default initialization method

Definition at line 16 of file BaseFunctionFitter.cxx.

16 { init(5); }

◆ init() [2/2]

void MuonCalib::BaseFunctionFitter::init ( const unsigned  nb_coefficients)
private

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

Definition at line 18 of file BaseFunctionFitter.cxx.

18  {
19  m_A = Amg::MatrixX(nb_coefficients,nb_coefficients);
20  m_A.setZero();
21  m_b = Amg::VectorX(nb_coefficients);
22  m_b.setZero();
23  m_alpha = Amg::VectorX(nb_coefficients);
24  m_alpha.setZero();
25  m_nb_coefficients = nb_coefficients;
26  }

◆ number_of_coefficients()

int MuonCalib::BaseFunctionFitter::number_of_coefficients ( ) const

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

Definition at line 27 of file BaseFunctionFitter.cxx.

27  {
28  return m_nb_coefficients;
29  }

◆ set_number_of_coefficients()

void MuonCalib::BaseFunctionFitter::set_number_of_coefficients ( const unsigned  nb_coefficients)

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

Definition at line 33 of file BaseFunctionFitter.cxx.

33  {
34  init(nb_coefficients);
35  }

Member Data Documentation

◆ m_A

Amg::MatrixX MuonCalib::BaseFunctionFitter::m_A {}
private

coefficient matrix for the fit

Definition at line 44 of file BaseFunctionFitter.h.

◆ m_alpha

Amg::VectorX MuonCalib::BaseFunctionFitter::m_alpha {}
private

coefficients of the base functions after the fit

Definition at line 45 of file BaseFunctionFitter.h.

◆ m_b

Amg::VectorX MuonCalib::BaseFunctionFitter::m_b {}
private

m_A*m_alpha = m_b;

Definition at line 46 of file BaseFunctionFitter.h.

◆ m_nb_coefficients

unsigned int MuonCalib::BaseFunctionFitter::m_nb_coefficients {0}
private

number of coefficients

Definition at line 43 of file BaseFunctionFitter.h.


The documentation for this class was generated from the following files:
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:216
Amg::VectorX
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Definition: EventPrimitives.h:30
Amg::MatrixX
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Definition: EventPrimitives.h:27
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
MuonCalib::BaseFunctionFitter::init
void init()
default initialization method
Definition: BaseFunctionFitter.cxx:16
MuonCalib::BaseFunctionFitter::m_A
Amg::MatrixX m_A
coefficient matrix for the fit
Definition: BaseFunctionFitter.h:44
MuonCalib::BaseFunctionFitter::m_alpha
Amg::VectorX m_alpha
coefficients of the base functions after the fit
Definition: BaseFunctionFitter.h:45
MuonCalib::BaseFunctionFitter::m_nb_coefficients
unsigned int m_nb_coefficients
number of coefficients
Definition: BaseFunctionFitter.h:43
MuonCalib::BaseFunctionFitter::m_b
Amg::VectorX m_b
m_A*m_alpha = m_b;
Definition: BaseFunctionFitter.h:46
get_generator_info.error
error
Definition: get_generator_info.py:40
pow
constexpr int pow(int base, int exp) noexcept
Definition: ap_fixedTest.cxx:15
fitman.k
k
Definition: fitman.py:528