32 #include "GaudiKernel/SystemOfUnits.h"
44 m_constrainedAlignmentEffects(constrainedAlignmentEffects),
45 m_largePhiWeight(10000.),
46 m_matrixFromCLHEP(
false),
47 m_measurements(
nullptr),
49 m_numberDriftCircles(0),
51 m_parameters(
nullptr),
54 m_perigeeWeight(
nullptr),
64 log <<
" col " <<
col <<
" unexpected first nonzero DM element " <<
i
69 log <<
" col " <<
col <<
" first nonzero DM element is zero! " << j
75 log <<
" col " <<
col <<
" unexpected last nonzero DM element " <<
i
83 std::cout <<
" unexpected :chiSquaredChange " << std::endl;
112 weight.selfadjointView<0x2>();
131 covariance(4,
row) *= d4;
132 covariance(
row, 4) = covariance(4,
row);
134 covariance(4, 4) *= d4;
141 covariance(5,
row) *= d5;
142 covariance(
row, 5) = covariance(5,
row);
144 covariance(5, 5) *= d5;
152 for (
int i = 0;
i != 5; ++
i) {
153 for (
int j = 0; j != 5; ++j) {
169 std::cout <<
"DerivativeMatrix: rows * columns " <<
m_rowsDM <<
" * "
177 std::vector<FitMeasurement*> alignmentfm;
179 bool singleRow =
true;
185 (!(**m).numberDoF() || (**m).isAlignment())) {
186 if ((**m).isAlignment())
187 alignmentfm.push_back(*
m);
193 fm = alignmentfm.back();
194 alignmentfm.pop_back();
199 std::cout << std::endl << std::setiosflags(std::ios::fixed);
201 std::cout <<
"measurement";
203 std::cout <<
"scatterer ";
205 std::cout <<
"energyDepos";
207 std::cout <<
"alignment ";
217 std::cout <<
" row " << std::setw(3) <<
row <<
" col 0 ";
222 std::cout << std::endl
223 << std::setiosflags(std::ios::fixed) <<
" row "
224 << std::setw(3) <<
row <<
" col 0 ";
227 if (col < firstCol || col > lastCol)
233 std::cout << std::setiosflags(std::ios::scientific)
234 << std::setbase(10) <<
"<" << std::setw(10)
238 std::cout << std::setiosflags(std::ios::scientific) << std::setbase(10)
243 std::cout << std::endl
244 << std::setiosflags(std::ios::fixed)
245 <<
" col " << std::setw(3) <<
col + 1
249 std::cout << std::endl;
253 std::cout << std::endl
254 <<
"WeightMatrix: symmetric with rank " <<
m_columnsDM;
257 std::cout << std::endl
258 << std::setiosflags(std::ios::fixed) <<
" row " << std::setw(3)
261 std::cout << std::setiosflags(std::ios::scientific) << std::setbase(10)
265 std::cout << std::endl
266 << std::setiosflags(std::ios::fixed) <<
" col "
267 << std::setw(3) <<
col + 1 <<
" ";
270 std::cout << std::endl;
311 m_residuals = std::vector<double>(2 * measurements.size(), 0.);
313 bool haveMeasurement =
false;
314 bool haveVertex =
false;
315 int numberAlignments = 0;
316 int numberEnergyDeposits = 0;
317 int numberParameters = 5;
318 int numberScatterers = 0;
324 if ((**m).isVertex()) {
332 if ((**m).is2Dimensional()) {
341 for (;
m != measurements.end(); ++
m) {
342 if (!(**m).numberDoF())
346 if ((**m).isAlignment())
350 if (!haveMeasurement) {
351 if ((**m).isPositionMeasurement()) {
352 haveMeasurement =
true;
353 for (
int i = 0;
i < numberParameters; ++
i)
356 }
else if (!haveVertex && (**m).isScatterer()) {
370 if ((**m).isEnergyDeposit()) {
383 ++numberEnergyDeposits;
387 if ((**m).isScatterer())
394 if ((**m).is2Dimensional()) {
401 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
402 if (!(**m).isAlignment())
410 if ((**m).is2Dimensional()) {
417 parameters->numberAlignments(numberAlignments);
418 parameters->numberScatterers(numberScatterers);
419 bool afterCalo =
false;
422 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
423 if ((**m).numberDoF()) {
424 if ((**m).isEnergyDeposit()) {
427 }
else if ((**m).isScatterer()) {
431 parameters->addScatterer((**m).scattererPhi(), (**m).scattererTheta());
434 }
else if ((**m).isAlignment()) {
452 if (numberAlignments) {
454 unsigned alignmentParameter = 0;
455 int firstAlignmentRow = 0;
456 int firstAlignment2Row = 0;
457 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
458 if ((**m).alignmentParameter()) {
459 if ((**m).alignmentParameter() > alignmentParameter) {
460 if (!firstAlignmentRow)
461 firstAlignmentRow =
row;
463 if ((**m).alignmentParameter2()) {
464 if (!firstAlignment2Row)
465 firstAlignment2Row =
row;
468 if (!(**m).numberDoF())
470 if (!(**m).isAlignment()) {
471 row += (**m).numberDoF();
476 (**m).alignmentAngle(), (**m).alignmentOffset());
481 (**m).firstParameter(numberParameters);
482 numberParameters += 2;
483 alignmentParameter =
parameters->numberAlignments();
484 (**m).alignmentParameter(alignmentParameter);
485 (**m).lastParameter(numberParameters, afterCalo);
496 parameters->numberParameters(numberParameters);
505 if (2 * measurements.size() >
mxmeas)
507 if (numberParameters >
mxparam)
511 if (numberEnergyDeposits > 1)
518 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
519 if (!(**m).isPositionMeasurement() || (**m).numberDoF() > 1)
521 if (!(**m).numberDoF()) {
522 for (
int i = 0;
i != numberParameters; ++
i)
528 for (
int i = 0;
i != numberParameters; ++
i)
536 for (
int param = 0; param < numberParameters; ++param) {
593 weight = fitMatrixDerivativeT * fitMatrixDerivativeT.transpose();
594 weightedDifference = fitMatrixDerivativeT * residuals;
606 weight.colPivHouseholderQr().solve(weightedDifference);