9#include <top/reconstruction_cpp/ModuleAlignment.h>
10#include <Math/RotationX.h>
11#include <Math/RotationY.h>
12#include <Math/RotationZ.h>
13#include <Math/Translation3D.h>
14#include <Math/Transform3D.h>
15#include <TDecompChol.h>
39 m_COV.ResizeTo(numPar, numPar);
40 m_U.ResizeTo(numPar, numPar);
59 if (track.getModuleID() !=
m_moduleID)
return -2;
64 std::vector<double> first(
m_par.size(), 0);
65 TMatrixDSym second(
m_par.size());
72 if (ier != 0)
return ier;
74 std::vector<double> dpar(
m_par.size(), 0);
75 for (
size_t i = 0; i < dpar.size(); i++) {
76 for (
size_t k = 0; k < dpar.size(); k++) {
77 dpar[i] +=
m_COV[i][k] * first[k];
79 if (fabs(dpar[i]) >
m_maxDpar[i])
return ier;
82 for (
size_t i = 0; i < dpar.size(); i++) {
104 std::vector<float> pars;
105 for (
auto par :
m_par) pars.push_back(par);
111 std::vector<float> errors;
112 int numPar =
m_par.size();
113 for (
int i = 0; i < numPar; i++) {
121 ROOT::Math::Translation3D t(par[0], par[1], par[2]);
122 ROOT::Math::RotationX Rx(par[3]);
123 ROOT::Math::RotationY Ry(par[4]);
124 ROOT::Math::RotationZ Rz(par[5]);
125 ROOT::Math::Transform3D T(Rz * Ry * Rx, t);
127 if (not ok)
return 0;
130 if (not pdfConstructor.
isValid()) {
135 auto LL = pdfConstructor.
getLogL(par[6]);
145 if (not ok)
return false;
148 for (
size_t k = 0; k < par.size(); k++) {
153 if (not ok)
return false;
157 if (not ok)
return false;
159 first[k] = (fp - fm) / 2 /
m_steps[k];
160 second[k][k] = (fp - 2 * f0 + fm) / pow(
m_steps[k], 2);
165 for (
size_t k = 0; k < par.size(); k++) {
167 for (
size_t j = k + 1; j < par.size(); j++) {
173 if (not ok)
return false;
177 if (not ok)
return false;
182 if (not ok)
return false;
186 if (not ok)
return false;
188 second[j][k] = second[k][j] = (fpp - fmp - fpm + fmm) / 4 /
m_steps[k] /
m_steps[j];
207 for (
int i = 0; i <
m_U.GetNrows(); i++) {
210 for (
int k = 0; k <
m_U.GetNrows(); k++) {
212 A[ii][kk] =
m_U[i][k];
219 if (not chol.Decompose())
return 1;
223 for (
int i = 0; i <
m_U.GetNrows(); i++) {
226 for (
int k = 0; k <
m_U.GetNrows(); k++) {
228 m_COV[i][k] = A[ii][kk];
Provides a type-safe way to pass members of the chargedStableSet set.
int m_numUsedTracks
number of tracks used
TMatrixDSym m_U
matrix (neg.
bool derivatives(std::vector< double > &first, TMatrixDSym &second)
Calculates numerically first and second derivatives of log likelihood against the parameters.
TMatrixDSym m_COV
covariance matrix
std::vector< double > m_steps
step sizes
int m_numPhotons
number of photons used for log likelihood calculation
std::vector< bool > m_fixed
true if parameter is fixed
int m_numTracks
track counter
std::vector< std::string > m_parNames
parameter names
std::vector< float > getParameters() const
Returns alignment parameters.
std::vector< double > m_par
current parameter values
double getLogL(const std::vector< double > &par, bool &ok)
Returns log likelihood for given parameters Note: it changes helix parameters of TOPTrack object (m_t...
Const::ChargedStable m_hypothesis
particle hypothesis
bool m_valid
validity of results
void setSteps(double position, double angle, double time)
Sets steps for numerical calculation of derivatives.
int iterate(TOPTrack &track, const Const::ChargedStable &hypothesis)
Run a single alignment iteration, on success update alignment parameters.
std::vector< double > m_parInit
initial parameter values
int invertMatrixU()
Inverts matrix m_U using Cholesky decomposition.
std::vector< double > m_maxDpar
maximal parameter changes in one iteration
std::vector< float > getErrors() const
Returns errors on alignment parameters.
void reset()
Reset the object.
ModuleAlignment(PDFConstructor::EPDFOption opt=PDFConstructor::c_Rough)
Constructor.
TOPTrack * m_track
track parameters at TOP
PDFConstructor::EPDFOption m_opt
PDF option.
PDF construction and log likelihood determination for a given track and particle hypothesis.
LogL getLogL() const
Returns extended log likelihood (using the default time window)
bool isValid() const
Checks the object status.
EPDFOption
Signal PDF construction options.
Reconstructed track at TOP.
bool overrideTransformation(const ROOT::Math::Transform3D &transform)
Overrides transformation from local to nominal frame, which is by default obtained from DB.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.