24 #include "StThinPlateSpline.h"
28 StThinPlateSpline::StThinPlateSpline(Int_t nMeasurements)
30 mX =
new TMatrixT<double>(nMeasurements, 1);
31 mY =
new TMatrixT<double>(nMeasurements, 1);
32 mW =
new TMatrixT<double>(nMeasurements, 1);
33 mA =
new TMatrixT<double>(3, 1);
36 StThinPlateSpline::StThinPlateSpline(Int_t nMeasurements, Double_t *X, Double_t *Y, Double_t *W, Double_t *A)
38 mX =
new TMatrixT<double>(nMeasurements, 1, X);
39 mY =
new TMatrixT<double>(nMeasurements, 1, Y);
40 mW =
new TMatrixT<double>(nMeasurements, 1, W);
41 mA =
new TMatrixT<double>(3, 1, A);
44 StThinPlateSpline::StThinPlateSpline(Int_t nMeasurements, Float_t *X, Float_t *Y, Float_t *W, Float_t *A)
46 mX =
new TMatrixT<double>(nMeasurements, 1);
47 mY =
new TMatrixT<double>(nMeasurements, 1);
48 mW =
new TMatrixT<double>(nMeasurements, 1);
49 mA =
new TMatrixT<double>(3, 1);
50 for (
int j = 0; j < 3; j++)
52 for (
int j = 0; j < nMeasurements; j++)
54 for (
int j = 0; j < nMeasurements; j++)
56 for (
int j = 0; j < nMeasurements; j++)
60 StThinPlateSpline::~StThinPlateSpline()
68 void StThinPlateSpline::fit(Int_t nMeasurements, Double_t *xMeasurement, Double_t *yMeasurement, Double_t *zMeasurement, Double_t lambda)
70 TMatrixT<double> P(nMeasurements, 3);
71 TMatrixT<double> One(nMeasurements, 1);
74 mX->Use(nMeasurements, 1, xMeasurement);
75 mY->Use(nMeasurements, 1, yMeasurement);
81 TMatrixT<double> K(nMeasurements, nMeasurements);
82 for (
int i = 0; i < nMeasurements; i++)
83 for (
int j = 0; j < nMeasurements; j++) {
84 double r2 = pow((*mX)[i][0] - (*mX)[j][0], 2) + pow((*mY)[i][0] - (*mY)[j][0], 2);
89 TMatrixT<double> I(nMeasurements, nMeasurements);
93 TMatrixT<double> L(nMeasurements + 3, nMeasurements + 3);
95 L.SetSub(0, nMeasurements, P);
96 L.SetSub(nMeasurements, 0, P.Transpose(P));
99 TMatrixT<double> V(nMeasurements, 1, zMeasurement);
100 TMatrixT<double> Y(nMeasurements + 3, 1);
104 TMatrixT<double> WA(Y);
109 mW->ResizeTo(nMeasurements, 1);
110 *mW = WA.GetSub(0, nMeasurements - 1, 0, 0);
111 *mA = WA.GetSub(nMeasurements, nMeasurements + 2, 0, 0);
117 Double_t StThinPlateSpline::ur(Double_t r2)
const
119 if (r2 == 0)
return 0;
126 z_ = (*mA)[0][0] + (*mA)[1][0] * x + (*mA)[2][0] * y;
127 for (
int i = 0; i < mW->GetNrows(); i++) {
128 double r2 = pow(x - (*mX)[i][0], 2) + pow(y - (*mY)[i][0], 2);
129 z_ += (*mW)[i][0] * ur(r2);
Double_t z(Double_t x, Double_t y) const
calculate z on the profile at (x,y)
void fit(Int_t nMeasurements, Double_t *xMeasurement, Double_t *yMeasurement, Double_t *zMeasurement, Double_t lambda=0)
fit measurements on a profile with tps to get mX, mY, mW, mA matrix