ATLAS Offline Software
Control
PerformanceMonitoring
PerfMonComps
src
LinFitSglPass.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
// //
7
// Header file for class LinFitSglPass //
8
// //
9
// Description: Little helper class for single-pass linear //
10
// fits of data points. //
11
// //
12
// Author: Thomas H. Kittelmann (Thomas.Kittelmann@cern.ch) //
13
// Initial version: February 2011 //
14
// //
16
17
#ifndef LINFITSGLPASS_H
18
#define LINFITSGLPASS_H
19
20
namespace
PerfMon
{
21
22
class
LinFitSglPass
{
23
public
:
24
25
LinFitSglPass
();
26
~LinFitSglPass
(){}
27
28
void
addPoint
(
const
double
&,
const
double
&);
29
void
getFit
(
double
&
offset
,
double
&
slope
)
const
;
//Fitted line parametrised as: y(x) = offset + x*slope
30
void
reset
();
31
unsigned
nPoints
()
const
{
return
m_n
; }
32
double
slope
()
const
;
33
private
:
34
unsigned
m_n
;
35
double
m_sumx
;
36
double
m_sumy
;
37
double
m_sumxy
;
38
double
m_sumxx
;
39
};
40
42
// Implementation //
44
45
inline
LinFitSglPass::LinFitSglPass
()
46
: m_n(0),m_sumx(0),m_sumy(0),m_sumxy(0),m_sumxx(0)
47
{
48
}
49
50
inline
void
LinFitSglPass::reset
()
51
{
52
m_n
=0;
53
m_sumx
=
m_sumy
=
m_sumxy
=
m_sumxx
=0;
54
}
55
56
inline
void
LinFitSglPass::addPoint
(
const
double
&
x
,
const
double
&
y
)
57
{
58
++
m_n
;
59
m_sumx
+=
x
;
60
m_sumy
+=
y
;
61
m_sumxy
+=
x
*
y
;
62
m_sumxx
+=
x
*
x
;
63
}
64
65
inline
void
LinFitSglPass::getFit
(
double
&
offset
,
double
&slope)
const
66
{
67
if
(
m_n
<2) {
68
offset
=
slope
=0;
69
}
else
{
70
slope
= (
m_sumxy
*
m_n
-
m_sumx
*
m_sumy
)/(
m_sumxx
*
m_n
-
m_sumx
*
m_sumx
);
71
offset
= (
m_sumy
-
slope
*
m_sumx
)/
m_n
;
72
}
73
}
74
75
inline
double
LinFitSglPass::slope
()
const
76
{
77
double
offset
,
slope
;
78
getFit
(
offset
,
slope
);
79
return
slope
;
80
}
81
82
}
//> namespace PerfMon
83
84
#endif
PerfMon::LinFitSglPass
Definition:
LinFitSglPass.h:22
PerfMon::LinFitSglPass::addPoint
void addPoint(const double &, const double &)
Definition:
LinFitSglPass.h:56
PerfMon::LinFitSglPass::m_sumxy
double m_sumxy
Definition:
LinFitSglPass.h:37
x
#define x
PerfMon::LinFitSglPass::m_n
unsigned m_n
Definition:
LinFitSglPass.h:34
PerfMon::LinFitSglPass::m_sumy
double m_sumy
Definition:
LinFitSglPass.h:36
PerfMon
Definition:
LinFitSglPass.h:20
PerfMon::LinFitSglPass::m_sumx
double m_sumx
Definition:
LinFitSglPass.h:35
PerfMon::LinFitSglPass::m_sumxx
double m_sumxx
Definition:
LinFitSglPass.h:38
PerfMon::LinFitSglPass::nPoints
unsigned nPoints() const
Definition:
LinFitSglPass.h:31
y
#define y
PerfMon::LinFitSglPass::LinFitSglPass
LinFitSglPass()
Definition:
LinFitSglPass.h:45
PerfMon::LinFitSglPass::getFit
void getFit(double &offset, double &slope) const
Definition:
LinFitSglPass.h:65
PerfMon::LinFitSglPass::slope
double slope() const
Definition:
LinFitSglPass.h:75
convertTimingResiduals.offset
offset
Definition:
convertTimingResiduals.py:71
PerfMon::LinFitSglPass::reset
void reset()
Definition:
LinFitSglPass.h:50
PerfMon::LinFitSglPass::~LinFitSglPass
~LinFitSglPass()
Definition:
LinFitSglPass.h:26
Generated on Thu Nov 7 2024 21:20:12 for ATLAS Offline Software by
1.8.18