ATLAS Offline Software
Loading...
Searching...
No Matches
RtFromPoints.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8#include "GaudiKernel/MsgStream.h"
11
15
18
23
26
29
31
32
33using namespace MuonCalib;
34
35
36
37CalibFunc::ParVec RtFromPoints::legendreFit(const std::vector<SamplePoint>& dataPoints,
38 const unsigned order) {
39 const auto [minT, maxT] = interval(dataPoints);
40
41 CalibFunc::ParVec pars{minT, maxT};
42 BaseFunctionFitter fitter{order};
43 LegendrePolynomial legendre{};
44 fitter.fit_parameters(normalizeDomain(dataPoints), 1, dataPoints.size(), legendre);
45 for (unsigned k = 0; k < fitter.coefficients().size(); k++) {
46 pars.emplace_back(fitter.coefficients()[k]);
47 }
48 return pars;
49}
50
51CalibFunc::ParVec RtFromPoints::chebyFit(const std::vector<SamplePoint>& dataPoints,
52 const unsigned order) {
53
54 const auto [minT, maxT] = interval(dataPoints);
55 CalibFunc::ParVec pars{minT, maxT};
56 BaseFunctionFitter fitter{order};
57 ChebyshevPolynomial chebyshev{}; // Chebyshev polynomial
58
59
60 fitter.fit_parameters(normalizeDomain(dataPoints), 1, dataPoints.size(), chebyshev);
61 for (unsigned k = 0; k < fitter.coefficients().size(); k++) {
62 pars.emplace_back(fitter.coefficients()[k]);
63 }
64 return pars;
65}
66CalibFunc::ParVec RtFromPoints::simplePolyFit(const std::vector<SamplePoint>& dataPoints,
67 const unsigned order) {
68 const auto [minT, maxT] = interval(dataPoints);
69 CalibFunc::ParVec pars{minT, maxT};
70 BaseFunctionFitter fitter{order};
71 SimplePolynomial simplePoly{};
72 fitter.fit_parameters(normalizeDomain(dataPoints), 1, dataPoints.size(), simplePoly);
73 for (unsigned k = 0; k < fitter.coefficients().size(); k++) {
74 pars.emplace_back(fitter.coefficients()[k]);
75 }
76 return pars;
77
78}
79std::unique_ptr<IRtRelation> RtFromPoints::getRtChebyshev(const std::vector<SamplePoint> &dataPoints, const unsigned order) {
80 return std::make_unique<RtChebyshev>(chebyFit(dataPoints, order));
81} // end RtFromPoints::getRtChebyshev
82std::unique_ptr<ITrRelation> RtFromPoints::getTrChebyshev(const std::vector<SamplePoint>& dataPoints, const unsigned order) {
83 return std::make_unique<TrChebyshev>(chebyFit(dataPoints, order));
84}
85std::unique_ptr<IRtResolution> RtFromPoints::getResoChebyshev(const std::vector<SamplePoint>& dataPoints, const unsigned order){
86 return std::make_unique<RtResolutionChebyshev>(chebyFit(dataPoints, order));
87}
88std::unique_ptr<IRtResolution> RtFromPoints::getResoChebyshev(const std::vector<SamplePoint>& dataPoints, const IRtRelationPtr rtRelPtr,
89 const double relUnc, const unsigned order) {
90 std::vector<double> chebyCoeff = chebyFit(resoFromRadius(dataPoints, relUnc), order);
91 chebyCoeff.erase(chebyCoeff.begin(), chebyCoeff.begin() +2);
92 return std::make_unique<RadiusResolutionChebyshev>(chebyCoeff, rtRelPtr);
93}
94
95std::unique_ptr<IRtRelation> RtFromPoints::getRtLegendre(const std::vector<SamplePoint>& dataPoints, const unsigned order) {
96 return std::make_unique<RtLegendre>(legendreFit(dataPoints, order));
97}
98std::unique_ptr<ITrRelation> RtFromPoints::getTrLegendre(const std::vector<SamplePoint>& dataPoints, const unsigned order) {
99 return std::make_unique<TrLegendre>(legendreFit(dataPoints, order));
100}
101std::unique_ptr<IRtRelation> RtFromPoints::getRtSimplePoly(const std::vector<SamplePoint>& dataPoints, const unsigned order) {
102 return std::make_unique<RtSimplePolynomial>(simplePolyFit(dataPoints, order));
103}
104std::unique_ptr<ITrRelation> RtFromPoints::getTrSimplePoly(const std::vector<SamplePoint>& dataPoints, const unsigned order) {
105 return std::make_unique<TrSimplePolynomial>(simplePolyFit(dataPoints, order));
106}
107//*****************************************************************************
108
109//::::::::::::::::::::::::::::::::
110//:: METHOD getRtRelationLookUp ::
111//::::::::::::::::::::::::::::::::
112std::unique_ptr<IRtRelation> RtFromPoints::getRtRelationLookUp(const std::vector<SamplePoint> &dataPoints) {
113 // create spline rt relation
114 CalibFunc ::ParVec pars(2 * dataPoints.size());
115 for (unsigned i = 0; i < dataPoints.size(); i++) {
116 pars[2 * i] = dataPoints[i].x1();
117 pars[2 * i + 1] = dataPoints[i].x2();
118 }
119 RtSpline rt(pars);
120
121 // variables
122 unsigned nb_points(100); // number of (r, t) points
123 double bin_width((rt.tUpper() - rt.tLower()) / static_cast<double>(nb_points - 1)); // step size
124 std::vector<double> rt_param(nb_points + 2); // r-t parameters
125
127 // CREATE AN RtRelationLookUp OBJECT WITH THE CORRECT PARAMETERS //
129 rt_param[0] = rt.tLower();
130 rt_param[1] = bin_width;
131 for (unsigned k = 0; k < nb_points; k++) { rt_param[k + 2] = rt.radius(rt.tLower() + k * bin_width); }
132 return std::make_unique<RtRelationLookUp>(rt_param);
133}
This class performs a fit of a linear combination of base functions to a set of sample points.
std::vector< double > ParVec
Definition CalibFunc.h:35
This class class provides a Chebyshev polynomial of order k.
This class provides a legendre polynomial of order k.
static std::unique_ptr< ITrRelation > getTrLegendre(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of t(r) data points into a t(r) relation expressed as a series of legendre polynomial...
static std::unique_ptr< IRtRelation > getRtChebyshev(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of r-t data points into a r(t) relation expressed as a series of chebychev polynomial...
static std::unique_ptr< ITrRelation > getTrChebyshev(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of r-t data points into a t(r) relation expressed as a series of chebychev polynomial...
static std::unique_ptr< IRtRelation > getRtSimplePoly(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of r(t) data points into a r(t) relation expressed as a series of elementary monomoni...
static std::unique_ptr< IRtResolution > getResoChebyshev(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of reso - t into a reso(t) relation expressed as a series of chebychev polynomials.
static std::unique_ptr< IRtRelation > getRtLegendre(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of r-t data points into a r(t) relation expressed as a series of legendre polynomials...
static CalibFunc::ParVec legendreFit(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Executes the fit of Legendre polynomials to the data points.
static CalibFunc::ParVec chebyFit(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Executes the fit of chebychev polynomials to the data points.
static std::unique_ptr< IRtRelation > getRtRelationLookUp(const std::vector< SamplePoint > &sample_points)
static std::unique_ptr< ITrRelation > getTrSimplePoly(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Converts a list of t(r) data points into a t(r) relation expressed as a series of elementary monomoni...
static CalibFunc::ParVec simplePolyFit(const std::vector< SamplePoint > &dataPoints, const unsigned order)
Exectues the fit of simple monomials to the data points.
This class contains the implementation of an r(t) relationship parameterized as support points to a c...
Definition RtSpline.h:34
virtual double tLower() const override final
get the lower drift-time bound
Definition RtSpline.cxx:58
virtual double tUpper() const override final
get the upper drift-time bound
Definition RtSpline.cxx:60
virtual double radius(double t) const override final
get the radius corresponding to the drift time t; 0 or 14.6 is returned if t is outside the range
Definition RtSpline.cxx:45
This class provides the simple polynomials x^k (k=0, 1, ...) as base functions for fits.
singleton-like access to IMessageSvc via open function and helper
CscCalcPed - algorithm that finds the Cathode Strip Chamber pedestals from an RDO.
std::pair< double, double > interval(const std::vector< SamplePoint > &points)
Returns the interval covered by the sample points.
GeoModel::TransientConstSharedPtr< IRtRelation > IRtRelationPtr
Definition IRtRelation.h:17
std::vector< SamplePoint > resoFromRadius(const std::vector< SamplePoint > &points, const double uncert)
Creates a new vector of sample points where the x2 coordinate becomes the x1 coordinate and the resol...
std::vector< SamplePoint > normalizeDomain(const std::vector< SamplePoint > &dataPoints)
Normalizes the domain of the samples points to the interval -1 to 1.