ATLAS Offline Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
python.trfUtils.Fit Class Reference

Low-level fitting class. More...

Collaboration diagram for python.trfUtils.Fit:

Public Member Functions

def __init__ (self, **kwargs)
 
def fit (self)
 
def value (self, t)
 
def set_chi2 (self)
 
def chi2 (self)
 
def set_slope (self)
 
def slope (self)
 
def set_intersect (self)
 
def intersect (self)
 

Private Attributes

 _math
 

Static Private Attributes

 _model
 
 _x
 
 _y
 
 _xm
 
 _ym
 
 _ss
 
 _ss2
 
 _slope
 
 _intersect
 
 _chi2
 

Detailed Description

Low-level fitting class.

Definition at line 1375 of file trfUtils.py.

Constructor & Destructor Documentation

◆ __init__()

def python.trfUtils.Fit.__init__ (   self,
**  kwargs 
)

Definition at line 1387 of file trfUtils.py.

1387  def __init__(self, **kwargs):
1388  # extract parameters
1389  self._model = kwargs.get('model', 'linear')
1390  self._x = kwargs.get('x', None)
1391  self._y = kwargs.get('y', None)
1392  self._math = math()
1393 
1394  if not self._x or not self._y:
1395  msg.warning('input data not defined')
1396 
1397  if len(self._x) != len(self._y):
1398  msg.warning('input data (lists) have different lengths')
1399 
1400  # base calculations
1401  if self._model == 'linear':
1402  self._ss = self._math.sum_square_dev(self._x)
1403  self._ss2 = self._math.sum_dev(self._x, self._y)
1404  self.set_slope()
1405  self._xm = self._math.mean(self._x)
1406  self._ym = self._math.mean(self._y)
1407  self.set_intersect()
1408  self.set_chi2()
1409 
1410  else:
1411  msg.warning("\'{0}\' model is not implemented".format(self._model))
1412 

Member Function Documentation

◆ chi2()

def python.trfUtils.Fit.chi2 (   self)

Definition at line 1432 of file trfUtils.py.

1432  def chi2(self):
1433  #Return the chi2 value.
1434  return self._chi2
1435 

◆ fit()

def python.trfUtils.Fit.fit (   self)

Definition at line 1413 of file trfUtils.py.

1413  def fit(self):
1414  #Return fitting object.
1415  return self
1416 

◆ intersect()

def python.trfUtils.Fit.intersect (   self)

Definition at line 1454 of file trfUtils.py.

1454  def intersect(self):
1455  #Return the intersect value.
1456  return self._intersect
1457 
1458 

◆ set_chi2()

def python.trfUtils.Fit.set_chi2 (   self)

Definition at line 1421 of file trfUtils.py.

1421  def set_chi2(self):
1422  #Calculate and set the chi2 value.
1423  y_observed = self._y
1424  y_expected = []
1425  for x in self._x:
1426  y_expected.append(self.value(x))
1427  if y_observed and y_observed != [] and y_expected and y_expected != []:
1428  self._chi2 = self._math.chi2(y_observed, y_expected)
1429  else:
1430  self._chi2 = None
1431 

◆ set_intersect()

def python.trfUtils.Fit.set_intersect (   self)

Definition at line 1447 of file trfUtils.py.

1447  def set_intersect(self):
1448  #Calculate and set the intersect of the linear fit.
1449  if self._ym and self._slope and self._xm:
1450  self._intersect = self._ym - self._slope * self._xm
1451  else:
1452  self._intersect = None
1453 

◆ set_slope()

def python.trfUtils.Fit.set_slope (   self)

Definition at line 1436 of file trfUtils.py.

1436  def set_slope(self):
1437  #Calculate and set the slope of the linear fit.
1438  if self._ss2 and self._ss and self._ss != 0:
1439  self._slope = self._ss2 / self._ss
1440  else:
1441  self._slope = None
1442 

◆ slope()

def python.trfUtils.Fit.slope (   self)

Definition at line 1443 of file trfUtils.py.

1443  def slope(self):
1444  #Return the slope value.
1445  return self._slope
1446 

◆ value()

def python.trfUtils.Fit.value (   self,
  t 
)

Definition at line 1417 of file trfUtils.py.

1417  def value(self, t):
1418  #Return the value y(x=t) of a linear fit y(x) = slope * x + intersect.
1419  return self._slope * t + self._intersect
1420 

Member Data Documentation

◆ _chi2

python.trfUtils.Fit._chi2
staticprivate

Definition at line 1385 of file trfUtils.py.

◆ _intersect

python.trfUtils.Fit._intersect
staticprivate

Definition at line 1384 of file trfUtils.py.

◆ _math

python.trfUtils.Fit._math
private

Definition at line 1392 of file trfUtils.py.

◆ _model

python.trfUtils.Fit._model
staticprivate

Definition at line 1376 of file trfUtils.py.

◆ _slope

python.trfUtils.Fit._slope
staticprivate

Definition at line 1383 of file trfUtils.py.

◆ _ss

python.trfUtils.Fit._ss
staticprivate

Definition at line 1381 of file trfUtils.py.

◆ _ss2

python.trfUtils.Fit._ss2
staticprivate

Definition at line 1382 of file trfUtils.py.

◆ _x

python.trfUtils.Fit._x
staticprivate

Definition at line 1377 of file trfUtils.py.

◆ _xm

python.trfUtils.Fit._xm
staticprivate

Definition at line 1379 of file trfUtils.py.

◆ _y

python.trfUtils.Fit._y
staticprivate

Definition at line 1378 of file trfUtils.py.

◆ _ym

python.trfUtils.Fit._ym
staticprivate

Definition at line 1380 of file trfUtils.py.


The documentation for this class was generated from the following file:
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
vtune_athena.format
format
Definition: vtune_athena.py:14
athena.value
value
Definition: athena.py:122
chi2
double chi2(TH1 *h0, TH1 *h1)
Definition: comparitor.cxx:522
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
math
Amg::intersect
std::optional< double > intersect(const AmgVector(N)&posA, const AmgVector(N)&dirA, const AmgVector(N)&posB, const AmgVector(N)&dirB)
Calculates the closest approach of two lines.
Definition: GeoPrimitivesHelpers.h:302