ATLAS Offline Software
Loading...
Searching...
No Matches
TgcFit.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRIGL2MUONSA_TGCFIT_H
6#define TRIGL2MUONSA_TGCFIT_H
7
9
10#include "GaudiKernel/StatusCode.h"
13
14#include "TgcFitResult.h"
15
16namespace TrigL2MuonSA {
17
18/*
19 * Statistical routines and fit information (TGC points, statistics, etc.).
20 */
21class TgcFit: public AthAlgTool
22{
23 public:
30 /*
31 * A 2D point used in statistics and fits.
32 * X is always the Z-value of a digit and Y is either phi or eta.
33 */
34 struct Point
35 {
36 int nIdx;
38 double fX;
39 double fY;
40 bool bOutlier;
41 double fW;
42 double fChi2;
43
44 /*
45 * Default constructor.
46 */
47 Point() : nIdx(0), nStation(0), fX(0.0), fY(0.0), bOutlier(false), fW(0.0), fChi2(0.0)
48 {}
49 /*
50 * Constructor.
51 */
52 Point(int nIdx, int nStation, double fX, double fY, double fW = 1.0) :
53 nIdx(nIdx), nStation(nStation), fX(fX), fY(fY), bOutlier(false), fW(fW), fChi2(0.0)
54 {}
55 /*
56 * Add a constant to the coordinate.
57 */
58 void operator+=(double fD)
59 {
60 fX += fD;
61 fY += fD;
62 }
63 /*
64 * Add one point to another.
65 */
66 void operator+=(const Point& p)
67 {
68 fX += p.fX;
69 fY += p.fY;
70 }
71 /*
72 * Devide the coordiante by a constant.
73 */
74 void operator/=(double fD)
75 {
76 if (fD != 0.0)
77 {
78 fX /= fD;
79 fY /= fD;
80 }
81 }
82 };
83 /*
84 * A list of points.
85 */
86 typedef std::vector<Point> PointArray;
87
92 {
93 int n;
94 double fMean;
95 double fStd;
96 double fChi2;
97
102 n(0), fMean(0.0), fStd(0.0), fChi2(0.0)
103 {}
104
108 void clear()
109 {
110 n = 0;
111 fMean = fStd = fChi2 = 0.0;
112 }
113 };
114
115 /*
116 * A structure to hold linear fit statistics.
117 */
118 struct LinStats
119 {
120 int n;
121 double fIntercept;
122 double fSlope;
123 double fR2;
124 double fAdjR2;
125 double fChi2;
127
128 /*
129 * Default constructor.
130 */
132 n(0), fIntercept(0.0), fSlope(0.0), fR2(0.0), fAdjR2(0.0), fChi2(0.0),
133 fCov00(0.0), fCov01(0.0), fCov11(0.0)
134 {}
135 /*
136 * Clear statistics before a new fit.
137 */
138 void clear()
139 {
140 n = 0;
141 fIntercept = fSlope = fR2 = fAdjR2 = fChi2 = fCov00 = fCov01 = fCov11 = 0.0;
142 }
143 /*
144 * Calculate projected values given fit results.
145 * @parma fX The X value of the point to project.
146 * @return The projected Y value.
147 */
148 double eval(double fX) const;
149 };
150
151 public:
152
153 /*
154 * Default constuctor.
155 */
156 TgcFit(const std::string& type,
157 const std::string& name,
158 const IInterface* parent);
159
160 // not used
161 void setFitParameters(double CHI2_TEST,
162 unsigned MIN_WIRE_POINTS,
163 unsigned MIN_STRIP_POINTS);
164
165
166 /*
167 * Get the fit data for strip (phi) fit;
168 */
170 /*
171 * Get the fit data for wire (eta) fit;
172 */
173 const LinStats& getWireLinStats() const;
174 /*
175 * Fit a straight line throuh points. Ignore outliers.
176 * @param points The input list of data points.
177 * @param stats The statistics struct to fill with fit results.
178 */
179 void linReg(PointArray& points, LinStats& stats) const;
180 /*
181 * Calculate simple statistics for the Y values of a set of points.
182 * @param points The input list of data points.
183 * @param stats The statistics struct to fill with fit results.
184 */
185 void SimpleStatistics(PointArray& points, SimpleStats& stats) const;
186 /*
187 * Fit data to TGC. Calculate outliers and fit lines to strip and wire points.
188 */
189 Status runTgcMiddle(PointArray& stripPoints, PointArray& wirePoints, TgcFitResult& fitResult) const;
190 Status runTgcInner(PointArray& stripPoints, PointArray& wirePoints, TgcFitResult& fitResult) const;
191
192 protected:
195 double m_CHI2_TEST { 10.0 };
196 unsigned m_MIN_WIRE_POINTS { 4 };
197 unsigned m_MIN_STRIP_POINTS { 3 };
198
199 void printDebug(const std::string& str) const { ATH_MSG_DEBUG(str); };
200};
201
202}
203
204#endif
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const LinStats & getStripLinStats() const
void SimpleStatistics(PointArray &points, SimpleStats &stats) const
Definition TgcFit.cxx:54
TgcFit(const std::string &type, const std::string &name, const IInterface *parent)
Definition TgcFit.cxx:20
const LinStats & getWireLinStats() const
void linReg(PointArray &points, LinStats &stats) const
Definition TgcFit.cxx:114
unsigned m_MIN_WIRE_POINTS
Test for outliers: w * (value - mean)^2 > CHI2_TEST.
Definition TgcFit.h:196
std::vector< Point > PointArray
Definition TgcFit.h:86
void printDebug(const std::string &str) const
Definition TgcFit.h:199
Status runTgcMiddle(PointArray &stripPoints, PointArray &wirePoints, TgcFitResult &fitResult) const
Definition TgcFit.cxx:200
Status runTgcInner(PointArray &stripPoints, PointArray &wirePoints, TgcFitResult &fitResult) const
Definition TgcFit.cxx:318
size_t countUniqueStations(const TrigL2MuonSA::TgcFit::PointArray &) const
Definition TgcFit.cxx:188
unsigned m_MIN_STRIP_POINTS
Minimum number of strip points for linear fit.
Definition TgcFit.h:197
void setFitParameters(double CHI2_TEST, unsigned MIN_WIRE_POINTS, unsigned MIN_STRIP_POINTS)
Definition TgcFit.cxx:30
PointArray m_superPoints
List of wire (eta) super-points.
Definition TgcFit.h:193
double fIntercept
Intercept of the fit line.
Definition TgcFit.h:121
int n
Number of points.
Definition TgcFit.h:120
double fAdjR2
R-squared adjusted for small samples.
Definition TgcFit.h:124
double fChi2
Total Chi2.
Definition TgcFit.h:125
double fSlope
Slope of the fit line.
Definition TgcFit.h:122
double fR2
R-squared of the fit.
Definition TgcFit.h:123
double eval(double fX) const
Definition TgcFit.cxx:42
int nIdx
Index of point in original list of digits.
Definition TgcFit.h:36
void operator/=(double fD)
Definition TgcFit.h:74
Point(int nIdx, int nStation, double fX, double fY, double fW=1.0)
Definition TgcFit.h:52
double fY
Y coordinate.
Definition TgcFit.h:39
double fX
X coordinate.
Definition TgcFit.h:38
bool bOutlier
Indicates an outlier (excluded from all calculations).
Definition TgcFit.h:40
void operator+=(double fD)
Definition TgcFit.h:58
double fChi2
Chi2 contribution.
Definition TgcFit.h:42
int nStation
Index of station: 0-3 for TGC.
Definition TgcFit.h:37
void operator+=(const Point &p)
Definition TgcFit.h:66
A structure to hold simple statisitcs.
Definition TgcFit.h:92
double fChi2
Chi2 of all valid points.
Definition TgcFit.h:96
void clear()
Clear statistics before a new fit.
Definition TgcFit.h:108
int n
Number of valid points.
Definition TgcFit.h:93
double fStd
Standard deviation.
Definition TgcFit.h:95