6 #include "gsl/gsl_statistics.h"
7 #include "gsl/gsl_fit.h"
21 const std::string&
name,
31 unsigned MIN_WIRE_POINTS,
32 unsigned MIN_STRIP_POINTS)
34 m_CHI2_TEST = CHI2_TEST;
35 m_MIN_WIRE_POINTS = MIN_WIRE_POINTS;
36 m_MIN_STRIP_POINTS = MIN_STRIP_POINTS;
47 gsl_fit_linear_est(fX, fIntercept, fSlope, fCov00, fCov01, fCov11, &fY, &fYerr);
56 double *
y =
new double[
points.size()];
57 double *
w =
new double[
points.size()];
82 double fMaxChi2 = 0.0;
84 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
91 if (fMaxChi2 <
points[iPt].fChi2)
93 fMaxChi2 =
points[iPt].fChi2;
100 <<
" n=" <<
stats.n <<
" Mean=" <<
stats.fMean
101 <<
" Std=" <<
stats.fStd <<
" Chi2=" <<
stats.fChi2);
103 if (iPtMax == -1 || fMaxChi2 < m_CHI2_TEST)
105 points[iPtMax].bOutlier =
true;
116 double *
x =
new double[
points.size()];
117 double *
y =
new double[
points.size()];
118 double *
w =
new double[
points.size()];
144 <<
", N=" <<
stats.n <<
", Chi2=" <<
stats.fChi2);
146 double fMaxChi2 = 0.0;
148 for (
unsigned iPt = 0; iPt <
points.size(); iPt++)
150 if (!
points[iPt].bOutlier)
154 if (fMaxChi2 <
points[iPt].fChi2)
156 fMaxChi2 =
points[iPt].fChi2;
161 if (iPtMax == -1 || fMaxChi2 < m_CHI2_TEST ||
stats.n <= 2)
163 points[iPtMax].bOutlier =
true;
180 <<
", chi2=" <<
Pt.fChi2);
189 std::vector<int> Stations;
190 Stations.reserve(
array.size());
193 Stations.push_back(wirePt.nStation);
195 std::sort(Stations.begin(), Stations.end());
196 Stations.erase( std::unique( Stations.begin(), Stations.end() ), Stations.end() );
197 return Stations.size();
204 ATH_MSG_DEBUG(
"TrigL2MuonSA::TgcFit::runTgcMiddle stripPoints=" << stripPoints.size()
205 <<
" wirePoints=" << wirePoints.size());
210 if (stripPoints.empty() || wirePoints.empty())
216 const int wireStationsCount = countUniqueStations(wirePoints);
217 const int stripStationsCount = countUniqueStations(stripPoints);
220 if (wireStationsCount == 1 || wirePoints.size() < m_MIN_WIRE_POINTS)
223 printDebug(
"runTgcMiddle: Wires fit point");
225 SimpleStatistics(wirePoints,
stats);
230 printDebug(
"runTgcMiddle: Strips fit point");
231 SimpleStatistics(stripPoints,
stats);
239 printDebug(
"runTgcMiddle: Wires fit line");
240 linReg(wirePoints, wireStats);
241 if (stripStationsCount == 1 || stripPoints.size() < m_MIN_STRIP_POINTS)
243 printDebug(
"runTgcMiddle: Strips fit point");
245 SimpleStatistics(stripPoints,
stats);
252 printDebug(
"runTgcMiddle: Strips fit line");
253 linReg(stripPoints, stripStats);
261 double lowZ = 30000.0, highZ = 0.0;
262 int iLow = -1, iHigh = -1;
263 for (
unsigned iPt = 0; iPt < wirePoints.size(); iPt++)
265 if (!wirePoints[iPt].bOutlier)
267 if (lowZ > std::abs(wirePoints[iPt].fX))
269 lowZ = std::abs(wirePoints[iPt].fX);
272 if (highZ < std::abs(wirePoints[iPt].fX))
274 highZ = std::abs(wirePoints[iPt].fX);
279 if (iLow > -1 && iLow < (
int)wirePoints.size()) lowZ = wirePoints[iLow].fX;
280 if (iHigh > -1 && iHigh < (
int)wirePoints.size()) highZ = wirePoints[iHigh].fX;
282 double phi = stripStats.
eval(lowZ);
287 phi = stripStats.
eval(highZ);
293 <<
",phi=" <<
p1.phi() <<
",perp=" <<
p1.perp() <<
",z=" <<
p1.z());
297 <<
",phi=" <<
p2.phi() <<
",perp=" <<
p2.perp() <<
",z=" <<
p2.z());
329 ATH_MSG_DEBUG(
"runTgcInner: stripPoints.size()=" << stripPoints.size()
330 <<
", wirePoints.size()=" << wirePoints.size());
332 if (stripPoints.size() > 1 && wirePoints.size() > 1)
335 printDebug(
"runTgcInner: Wires fit point");
336 SimpleStatistics(wirePoints, wireStats);
338 printDebug(
"runTgcInner: Strips fit point");
339 SimpleStatistics(stripPoints, stripStats);
342 double phi = stripStats.
fMean;
348 <<
",phi=" <<
p.phi() <<
",perp=" <<
p.perp() <<
",z=" <<
p.z());
350 tgcFitResult.
tgcInn[0] =
p.eta();
351 tgcFitResult.
tgcInn[1] =
p.phi();
352 tgcFitResult.
tgcInn[2] =
p.perp();
353 tgcFitResult.
tgcInn[3] =
p.z();