// -*- mode: c++ -*- // // File pca.C generated by TPrincipal::MakeCode // on Tue May 19 20:27:15 2026 // ROOT version 6.41.01 // // This file contains the functions // // void X2P(Double_t *x, Double_t *p); // void P2X(Double_t *p, Double_t *x, Int_t nTest); // // The first for transforming original data x in // pattern space, to principal components p in // feature space. The second function is for the // inverse transformation, but using only nTest // of the principal components in the expansion // // See TPrincipal class documentation for more information // #include // needed for Double_t etc // // Static data variables // static Int_t gNVariables = 10; // Assignment of eigenvector matrix. // Elements are stored row-wise, that is // M[i][j] = e[i * nVariables + j] // where i and j are zero-based static Double_t gEigenVectors[] = { 0.092981, 0.0183025, -0.469673, 0.447794, 0.337217, 0.576659, 0.303622, 0.160821, -0.042452, 0.0616834, 0.300488, 0.173086, -0.0708037, 0.244314, -0.400902, 0.105924, -0.623148, 0.457597, -0.120792, 0.175512, 0.208504, -0.00193196, -0.189206, -0.393711, 0.708482, -0.275614, -0.247156, 0.322711, -0.085186, 0.123777, 0.101939, 0.171081, -0.2769, 0.390707, -0.127222, -0.732616, 0.382711, 0.161241, -0.0425628, 0.0618444, 0.291416, 0.18814, 0.474855, -0.276517, -0.10788, 0.176643, 0.534345, 0.452699, -0.119499, 0.173634, 0.131793, -0.880938, 0.15007, 0.180274, -0.0199821, -0.0784678, 0.0336452, 0.223039, -0.249119, -0.179066, 0.0399807, -0.169596, -0.637252, -0.56285, -0.435647, 0.0751499, 0.155583, -0.00185939, -0.161746, 0.0306869, 0.500682, -0.143895, -0.0635903, -0.0454421, -0.0563623, 0.000875005, 0.0283942, 0.00957304, 0.832746, -0.157991, 0.503213, -0.113272, 0.0614414, 0.0652156, 0.0288443, -0.0140081, -0.00186302, -0.568942, -0.190711, 0.604003, 0.489283, 0.258237, 0.00176374, -0.00720891, 0.0399618, 0.0187477, -0.016582, -0.236912, -0.377094, -0.70236}; // Assignment to eigen value vector. Zero-based. static Double_t gEigenValues[] = { 0.385574, 0.111974, 0.103131, 0.102198, 0.0999811, 0.0992024, 0.0979399, 1.16175e-16, 2.79523e-16, 4.23479e-16 }; // Assignment to mean value vector. Zero-based. static Double_t gMeanValues[] = { 4.99425, 8.0105, 2.017, 4.9975, 8.0189, 1.97633, 4.99577, 35.0103, 30.0145, 28.0382 }; // Assignment to sigma value vector. Zero-based. static Double_t gSigmaValues[] = { 0.992626, 2.82439, 1.99185, 0.995217, 2.79416, 2.00942, 0.999632, 5.1466, 5.04129, 4.64356 }; // // The function void X2P(Double_t *x, Double_t *p) // void X2P(Double_t *x, Double_t *p) { for (Int_t i = 0; i < gNVariables; i++) { p[i] = 0; for (Int_t j = 0; j < gNVariables; j++) p[i] += (x[j] - gMeanValues[j]) * gEigenVectors[j * gNVariables + i] / gSigmaValues[j]; } } // // The function void P2X(Double_t *p, Double_t *x, Int_t nTest) // void P2X(Double_t *p, Double_t *x, Int_t nTest) { for (Int_t i = 0; i < gNVariables; i++) { x[i] = gMeanValues[i]; for (Int_t j = 0; j < nTest; j++) x[i] += p[j] * gSigmaValues[i] * gEigenVectors[i * gNVariables + j]; } } // EOF for pca.C