ATLAS Offline Software
Loading...
Searching...
No Matches
Fit2D.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef MUONLINEARSEGMENTMAKERUTILITIES_FIT2D_H
6#define MUONLINEARSEGMENTMAKERUTILITIES_FIT2D_H
7
8#include "GaudiKernel/MsgStream.h"
9#include <vector>
10#include <cstring>
11#include <string>
12
13namespace Muon
14{
15
28 class Fit2D
29 {
30 public:
34 struct Point
35 {
36 int nIdx;
37 double fX;
38 double fY;
39 double fW;
40 double fChi2;
41 bool bExclude;
42 const void* pData;
43
47 Point();
48
56 Point(int nIdx, double fX, double fY, double fW = 1.0, const void* pData = nullptr);
57 };
58
59 typedef std::vector<Point*> PointArray;
60
62 {
63 int n;
64 double fMean;
65 double fStd;
66 double fChi2;
67
69 void clear();
70 std::string toString() const;
71 };
72
76 struct LinStats
77 {
78 int n;
79 double fIntercept;
80 double fSlope;
81 double fCov[2][2];
82 double fChi2;
83
87 LinStats();
88
92 void clear();
93
100 void eval(double fX, double& fY, double& fYerr) const;
101
105 std::string toString() const;
106 };
107
111 Fit2D();
112
118 static void SimpleStatistics(const PointArray& points, SimpleStats& stats);
119
127 static void fitLine(PointArray& points, double fExclChi2, bool bDump, LinStats& stats);
128
136 static void fitPoint(PointArray& points, double fExclChi2, bool bDump, SimpleStats& stats);
137 };
138
140 nIdx(0), fX(0.0), fY(0.0), fW(1.0), fChi2(0.0), bExclude(false), pData(NULL)
141 {
142 }
143
144 inline Fit2D::Point::Point(int nIdx, double fX, double fY, double fW, const void* pData) :
145 nIdx(nIdx), fX(fX), fY(fY), fW(fW), fChi2(0.0), bExclude(false), pData(pData)
146 {
147 }
148
150 n(0),
151 fMean(0.0),
152 fStd(0.0),
153 fChi2(0.0)
154 {
155 }
156
158 {
159 n = 0;
160 fMean = fStd = fChi2 = 0.0;
161 }
162
164 n(0),
165 fIntercept(0.0),
166 fSlope(0.0),
167 fChi2(0.0)
168 {
169 memset(fCov, 0, sizeof(fCov));
170 }
171
173 {
174 n = 0;
175 fIntercept = fSlope = fChi2 = 0.0;
176 memset(fCov, 0, sizeof(fCov));
177 }
178
180 {
181 }
182
183}
184
185#endif //MUONLINEARSEGMENTMAKERUTILITIES_FIT2D_H
Fit2D()
Constructor.
Definition Fit2D.h:179
static void fitPoint(PointArray &points, double fExclChi2, bool bDump, SimpleStats &stats)
Estimate a new point from the given points.
Definition Fit2D.cxx:73
static void fitLine(PointArray &points, double fExclChi2, bool bDump, LinStats &stats)
Fit a straight line through the given points.
Definition Fit2D.cxx:132
static void SimpleStatistics(const PointArray &points, SimpleStats &stats)
Calculate simple statistics for the Y values of a set of points.
Definition Fit2D.cxx:43
std::vector< Point * > PointArray
A vector of points.
Definition Fit2D.h:59
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Point(double x_, double y_, double slope_)
Single point and slope to next point.
A structure to hold linear fit statistics.
Definition Fit2D.h:77
void eval(double fX, double &fY, double &fYerr) const
Evaluate a point along the fitted line.
Definition Fit2D.cxx:26
void clear()
Clear the statistics before a new fit.
Definition Fit2D.h:172
double fCov[2][2]
The parameter covariance matrix.
Definition Fit2D.h:81
int n
Number of points.
Definition Fit2D.h:78
LinStats()
Constructor.
Definition Fit2D.h:163
std::string toString() const
Get a string representation of the fit parameters.
Definition Fit2D.cxx:31
double fIntercept
Intercept of the fit line.
Definition Fit2D.h:79
double fChi2
Chi-squared of the fit.
Definition Fit2D.h:82
double fSlope
Slope of the fit line.
Definition Fit2D.h:80
bool bExclude
If set, exclude the point from all calculations.
Definition Fit2D.h:41
const void * pData
Any external data provided by the caller.
Definition Fit2D.h:42
double fW
Weight.
Definition Fit2D.h:39
Point()
Default constructor.
Definition Fit2D.h:139
double fX
The X coordinate.
Definition Fit2D.h:37
double fChi2
Contribution to the Chi2.
Definition Fit2D.h:40
int nIdx
Index of the point in the original list.
Definition Fit2D.h:36
double fY
The Y coordinate.
Definition Fit2D.h:38
std::string toString() const
Definition Fit2D.cxx:15