Alignment of a TOP module.
More...
#include <ModuleAlignment.h>
|
| ModuleAlignment (PDFConstructor::EPDFOption opt=PDFConstructor::c_Rough) |
| Constructor.
|
|
void | setModuleID (int moduleID) |
| Sets module ID.
|
|
void | setSteps (double position, double angle, double time) |
| Sets steps for numerical calculation of derivatives.
|
|
void | setParameters (const std::vector< double > &parInit) |
| Sets initial values of parameters (overwrites current parameters!) Order is: translations in x, y, z, rotation angles around x, y, z, module T0.
|
|
void | fixParameter (const std::string &name) |
| Fixes parameter with its name given as argument.
|
|
void | releaseParameter (const std::string &name) |
| Release fixed parameter.
|
|
void | releaseAllParameters () |
| Release all fixed parameters.
|
|
int | iterate (TOPTrack &track, const Const::ChargedStable &hypothesis) |
| Run a single alignment iteration, on success update alignment parameters.
|
|
void | reset () |
| Reset the object.
|
|
int | getModuleID () const |
| Returns module ID.
|
|
const std::vector< std::string > & | getParameterNames () const |
| Returns alignment parameter names.
|
|
const std::vector< double > & | getParams () const |
| Returns alignment parameters.
|
|
std::vector< float > | getParameters () const |
| Returns alignment parameters.
|
|
std::vector< float > | getErrors () const |
| Returns errors on alignment parameters.
|
|
const TMatrixDSym & | getErrorMatrix () const |
| Returns error matrix of alignment parameters Order is: translations in x, y, z, rotation angles around x, y, z, module T0.
|
|
int | getNumTracks () const |
| Returns track counter.
|
|
int | getNumUsedTracks () const |
| Returns number of tracks used in current result.
|
|
bool | isValid () const |
| Checks if the results are valid.
|
|
int | getNumOfPhotons () const |
| Returns number of photons used for log likelihood calculation.
|
|
|
double | getLogL (const std::vector< double > &par, bool &ok) |
| Returns log likelihood for given parameters Note: it changes helix parameters of TOPTrack object (m_track)
|
|
bool | derivatives (std::vector< double > &first, TMatrixDSym &second) |
| Calculates numerically first and second derivatives of log likelihood against the parameters.
|
|
int | invertMatrixU () |
| Inverts matrix m_U using Cholesky decomposition.
|
|
Alignment of a TOP module.
Definition at line 30 of file ModuleAlignment.h.
◆ ModuleAlignment()
Constructor.
- Parameters
-
opt | PDF construction option |
Definition at line 25 of file ModuleAlignment.cc.
26 {
39 m_COV.ResizeTo(numPar, numPar);
40 m_U.ResizeTo(numPar, numPar);
42 }
TMatrixDSym m_U
matrix (neg.
TMatrixDSym m_COV
covariance matrix
std::vector< double > m_steps
step sizes
std::vector< bool > m_fixed
true if parameter is fixed
std::vector< std::string > m_parNames
parameter names
std::vector< double > m_par
current parameter values
void setSteps(double position, double angle, double time)
Sets steps for numerical calculation of derivatives.
std::vector< double > m_parInit
initial parameter values
PDFConstructor::EPDFOption m_opt
PDF option.
◆ derivatives()
bool derivatives |
( |
std::vector< double > & |
first, |
|
|
TMatrixDSym & |
second |
|
) |
| |
|
private |
Calculates numerically first and second derivatives of log likelihood against the parameters.
- Parameters
-
first | a vector of first derivatives [out] |
second | a matrix of second derivatives [out] |
- Returns
- status (true on success)
Definition at line 141 of file ModuleAlignment.cc.
142 {
143 bool ok = false;
145 if (not ok) return false;
146
148 for (size_t k = 0; k < par.size(); k++) {
150
153 if (not ok) return false;
154
157 if (not ok) return false;
158
159 first[k] = (fp - fm) / 2 /
m_steps[k];
160 second[k][k] = (fp - 2 * f0 + fm) / pow(
m_steps[k], 2);
161
163 }
164
165 for (size_t k = 0; k < par.size(); k++) {
167 for (size_t j = k + 1; j < par.size(); j++) {
169
173 if (not ok) return false;
174
177 if (not ok) return false;
178
182 if (not ok) return false;
183
186 if (not ok) return false;
187
188 second[j][k] = second[k][j] = (fpp - fmp - fpm + fmm) / 4 /
m_steps[k] /
m_steps[j];
189
191 }
193 }
194
195 return true;
196 }
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...
◆ fixParameter()
void fixParameter |
( |
const std::string & |
name | ) |
|
|
inline |
Fixes parameter with its name given as argument.
- Parameters
-
Definition at line 70 of file ModuleAlignment.h.
71 {
72 for (
unsigned i = 0; i <
m_parNames.size(); i++) {
75 return;
76 }
77 }
78 B2ERROR("TOP::ModuleAlignment::fixParameter: invalid parameter name '" << name << "'");
79 }
◆ getErrorMatrix()
const TMatrixDSym & getErrorMatrix |
( |
| ) |
const |
|
inline |
Returns error matrix of alignment parameters Order is: translations in x, y, z, rotation angles around x, y, z, module T0.
- Returns
- error matrix
Definition at line 155 of file ModuleAlignment.h.
◆ getErrors()
std::vector< float > getErrors |
( |
| ) |
const |
Returns errors on alignment parameters.
Order is: translations in x, y, z, rotation angles around x, y, z, module T0
- Returns
- errors in single precision
Definition at line 109 of file ModuleAlignment.cc.
110 {
111 std::vector<float> errors;
112 int numPar =
m_par.size();
113 for (int i = 0; i < numPar; i++) {
115 }
116 return errors;
117 }
double sqrt(double a)
sqrt for double
◆ getLogL()
double getLogL |
( |
const std::vector< double > & |
par, |
|
|
bool & |
ok |
|
) |
| |
|
private |
Returns log likelihood for given parameters Note: it changes helix parameters of TOPTrack object (m_track)
- Parameters
-
par | parameters |
ok | status [out] |
- Returns
- log likelihood
Definition at line 119 of file ModuleAlignment.cc.
120 {
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;
128
130 if (not pdfConstructor.isValid()) {
131 ok = false;
132 return 0;
133 }
134
135 auto LL = pdfConstructor.getLogL(par[6]);
137
138 return LL.logL;
139 }
int m_numPhotons
number of photons used for log likelihood calculation
Const::ChargedStable m_hypothesis
particle hypothesis
TOPTrack * m_track
track parameters at TOP
bool overrideTransformation(const ROOT::Math::Transform3D &transform)
Overrides transformation from local to nominal frame, which is by default obtained from DB.
◆ getModuleID()
int getModuleID |
( |
| ) |
const |
|
inline |
◆ getNumOfPhotons()
int getNumOfPhotons |
( |
| ) |
const |
|
inline |
Returns number of photons used for log likelihood calculation.
- Returns
- number of photons
Definition at line 179 of file ModuleAlignment.h.
◆ getNumTracks()
int getNumTracks |
( |
| ) |
const |
|
inline |
Returns track counter.
- Returns
- number of tracks
Definition at line 161 of file ModuleAlignment.h.
int m_numTracks
track counter
◆ getNumUsedTracks()
int getNumUsedTracks |
( |
| ) |
const |
|
inline |
Returns number of tracks used in current result.
- Returns
- number of tracks
Definition at line 167 of file ModuleAlignment.h.
int m_numUsedTracks
number of tracks used
◆ getParameterNames()
const std::vector< std::string > & getParameterNames |
( |
| ) |
const |
|
inline |
Returns alignment parameter names.
- Returns
- parameter names
Definition at line 127 of file ModuleAlignment.h.
◆ getParameters()
std::vector< float > getParameters |
( |
| ) |
const |
Returns alignment parameters.
Order is: translations in x, y, z, rotation angles around x, y, z, module T0
- Returns
- parameters in single precision
Definition at line 102 of file ModuleAlignment.cc.
103 {
104 std::vector<float> pars;
105 for (
auto par :
m_par) pars.push_back(par);
106 return pars;
107 }
◆ getParams()
const std::vector< double > & getParams |
( |
| ) |
const |
|
inline |
Returns alignment parameters.
Order is: translations in x, y, z, rotation angles around x, y, z, module T0
- Returns
- parameters in double precision
Definition at line 134 of file ModuleAlignment.h.
◆ invertMatrixU()
Inverts matrix m_U using Cholesky decomposition.
- Returns
- error status (0 = OK, > 0 matrix not pos. definite)
Definition at line 198 of file ModuleAlignment.cc.
199 {
200 int n = 0;
202 if (not fixed) n++;
203 }
204
205 TMatrixDSym A(n);
206 int ii = 0;
207 for (
int i = 0; i <
m_U.GetNrows(); i++) {
209 int kk = 0;
210 for (
int k = 0; k <
m_U.GetNrows(); k++) {
212 A[ii][kk] =
m_U[i][k];
213 kk++;
214 }
215 ii++;
216 }
217
218 TDecompChol chol(A);
219 if (not chol.Decompose()) return 1;
220 chol.Invert(A);
221
222 ii = 0;
223 for (
int i = 0; i <
m_U.GetNrows(); i++) {
225 int kk = 0;
226 for (
int k = 0; k <
m_U.GetNrows(); k++) {
228 m_COV[i][k] = A[ii][kk];
229 kk++;
230 }
231 ii++;
232 }
233
234 return 0;
235 }
◆ isValid()
Checks if the results are valid.
- Returns
- true if results valid
Definition at line 173 of file ModuleAlignment.h.
bool m_valid
validity of results
◆ iterate()
Run a single alignment iteration, on success update alignment parameters.
- Parameters
-
track | track parameters |
hypothesis | particle hypothesis |
- Returns
- error status (0 = OK, < 0 no track hit, > 0 matrix not positive definite)
Definition at line 56 of file ModuleAlignment.cc.
57 {
59 if (track.getModuleID() !=
m_moduleID)
return -2;
60
63
64 std::vector<double> first(
m_par.size(), 0);
65 TMatrixDSym second(
m_par.size());
67
70
72 if (ier != 0) return ier;
73
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];
78 }
79 if (fabs(dpar[i]) >
m_maxDpar[i])
return ier;
80 }
81
82 for (size_t i = 0; i < dpar.size(); i++) {
84 }
87
88 return 0;
89 }
bool derivatives(std::vector< double > &first, TMatrixDSym &second)
Calculates numerically first and second derivatives of log likelihood against the parameters.
int invertMatrixU()
Inverts matrix m_U using Cholesky decomposition.
std::vector< double > m_maxDpar
maximal parameter changes in one iteration
◆ releaseAllParameters()
void releaseAllParameters |
( |
| ) |
|
|
inline |
◆ releaseParameter()
void releaseParameter |
( |
const std::string & |
name | ) |
|
|
inline |
Release fixed parameter.
- Parameters
-
Definition at line 85 of file ModuleAlignment.h.
86 {
87 for (
unsigned i = 0; i <
m_parNames.size(); i++) {
90 return;
91 }
92 }
93 B2ERROR("TOP::ModuleAlignment::releaseParameter: invalid parameter name '" << name << "'");
94 }
◆ reset()
◆ setModuleID()
void setModuleID |
( |
int |
moduleID | ) |
|
|
inline |
◆ setParameters()
void setParameters |
( |
const std::vector< double > & |
parInit | ) |
|
|
inline |
Sets initial values of parameters (overwrites current parameters!) Order is: translations in x, y, z, rotation angles around x, y, z, module T0.
- Parameters
-
Definition at line 58 of file ModuleAlignment.h.
59 {
60 for (
size_t i = 0; i < std::min(parInit.size(),
m_parInit.size()); i++) {
62 }
64 }
◆ setSteps()
void setSteps |
( |
double |
position, |
|
|
double |
angle, |
|
|
double |
time |
|
) |
| |
Sets steps for numerical calculation of derivatives.
- Parameters
-
position | step size for translations [cm] |
angle | step size for rotations [radians] |
time | step size for module T0 [ns] |
Definition at line 44 of file ModuleAlignment.cc.
◆ m_COV
◆ m_fixed
std::vector<bool> m_fixed |
|
private |
◆ m_hypothesis
◆ m_maxDpar
std::vector<double> m_maxDpar |
|
private |
◆ m_moduleID
◆ m_numPhotons
number of photons used for log likelihood calculation
Definition at line 218 of file ModuleAlignment.h.
◆ m_numTracks
◆ m_numUsedTracks
◆ m_opt
◆ m_par
std::vector<double> m_par |
|
private |
◆ m_parInit
std::vector<double> m_parInit |
|
private |
◆ m_parNames
std::vector<std::string> m_parNames |
|
private |
◆ m_steps
std::vector<double> m_steps |
|
private |
◆ m_track
◆ m_U
◆ m_valid
The documentation for this class was generated from the following files: