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

#include <PolygonBase.h>

Inheritance diagram for MuonCalib::PolygonBase:
Collaboration diagram for MuonCalib::PolygonBase:

Public Member Functions

 PolygonBase (const std::vector< double > &x)
 Constructor: the vector x contains the abscissae of the base points of the polygon. More...
 
double value (const int &k, const double &x) const
 get the value of the k-th base
More...
 

Private Member Functions

void init (const std::vector< double > &x)
 

Private Attributes

std::vector< double > m_x
 

Detailed Description

This class provides functions which allow the user to express a polygon as a linear combination of these functions.

Author
Olive.nosp@m.r.Ko.nosp@m.rtner.nosp@m.@CER.nosp@m.N.CH
Date
29.06.2006

Definition at line 42 of file PolygonBase.h.

Constructor & Destructor Documentation

◆ PolygonBase()

MuonCalib::PolygonBase::PolygonBase ( const std::vector< double > &  x)
inline

Constructor: the vector x contains the abscissae of the base points of the polygon.

x must contain the abscissae in increasing order.

Definition at line 46 of file PolygonBase.h.

Member Function Documentation

◆ init()

void PolygonBase::init ( const std::vector< double > &  x)
private

Definition at line 12 of file PolygonBase.cxx.

12  {
13 
15 // CHECK FOR CORRECT FILLING //
17 
18  for (unsigned int k=0; k<x.size()-1; k++) {
19  if (x[k]>=x[k+1]) {
20  throw std::runtime_error(Form("File: %s, Line: %d\nPolygonBase::init - Abscissae not in increasing order!", __FILE__, __LINE__));
21  }
22  }
23 
25 // TRANSFER THE INPUT DATA //
27 
28  m_x = x;
29 
30  return;
31 
32 }

◆ value()

double PolygonBase::value ( const int &  k,
const double &  x 
) const
virtual

get the value of the k-th base

function in x

Implements MuonCalib::BaseFunction.

Definition at line 40 of file PolygonBase.cxx.

40  {
41 
43 // CHECK THE BASE FUNCTION INDEX //
45 
46  if (k<0 || k>static_cast<int>(m_x.size()-1)) {
47  throw std::runtime_error(Form("File: %s, Line: %d\nPolygonBase::value - Illegal function index %i! Should be >0 and <%lu", __FILE__, __LINE__, k, m_x.size()));
48  }
49 
51 // CALCULATE THE VALUE OF THE BASE FUNCTION //
53 
54 // outside the domain of the polygon //
55  if (x<m_x[0] || x>m_x[m_x.size()-1]) {
56  return 0.0;
57  }
58 
59 // inside the domain of the polygon //
60  if (k==0 && x<m_x[0]) {
61  return 0.0;
62  }
63  if (k==0 && x<=m_x[1]) {
64  return (m_x[1]-x)/(m_x[1]-m_x[0]);
65  }
66  if (k==0 && x>m_x[1]) {
67  return 0.0;
68  }
69 
70  if (static_cast<unsigned int>(k)==m_x.size()-1 &&
71  x<=m_x[m_x.size()-2]) {
72  return 0.0;
73  }
74  if (static_cast<unsigned int>(k)==m_x.size()-1 &&
75  x<=m_x[m_x.size()-1]) {
76  return (x-m_x[k-1])/(m_x[k]-m_x[k-1]);
77  }
78  if (static_cast<unsigned int>(k)==m_x.size()-1 &&
79  x>m_x[m_x.size()-1]) {
80  return 0.0;
81  }
82 
83  if (x<m_x[k-1] || x>m_x[k+1]) {
84  return 0.0;
85  }
86 
87  if (x<m_x[k]) {
88  return (x-m_x[k-1])/(m_x[k]-m_x[k-1]);
89  }
90 
91  return (m_x[k+1]-x)/(m_x[k+1]-m_x[k]);
92 
93 }

Member Data Documentation

◆ m_x

std::vector<double> MuonCalib::PolygonBase::m_x
private

Definition at line 59 of file PolygonBase.h.


The documentation for this class was generated from the following files:
x
#define x
MuonCalib::PolygonBase::m_x
std::vector< double > m_x
Definition: PolygonBase.h:59
fitman.k
k
Definition: fitman.py:528