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()) {
450 if (numberAlignments) {
452 unsigned alignmentParameter = 0;
453 int firstAlignmentRow = 0;
454 int firstAlignment2Row = 0;
455 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
456 if ((**m).alignmentParameter()) {
457 if ((**m).alignmentParameter() > alignmentParameter) {
458 if (!firstAlignmentRow)
459 firstAlignmentRow =
row;
461 if ((**m).alignmentParameter2()) {
462 if (!firstAlignment2Row)
463 firstAlignment2Row =
row;
466 if (!(**m).numberDoF())
468 if (!(**m).isAlignment()) {
469 row += (**m).numberDoF();
474 (**m).alignmentAngle(), (**m).alignmentOffset());
479 (**m).firstParameter(numberParameters);
480 numberParameters += 2;
481 alignmentParameter =
parameters->numberAlignments();
482 (**m).alignmentParameter(alignmentParameter);
483 (**m).lastParameter(numberParameters, afterCalo);
494 parameters->numberParameters(numberParameters);
503 if (2 * measurements.size() >
mxmeas)
505 if (numberParameters >
mxparam)
509 if (numberEnergyDeposits > 1)
516 for (
m = measurements.begin();
m != measurements.end(); ++
m) {
517 if (!(**m).isPositionMeasurement() || (**m).numberDoF() > 1)
519 if (!(**m).numberDoF()) {
520 for (
int i = 0;
i != numberParameters; ++
i)
526 for (
int i = 0;
i != numberParameters; ++
i)
534 for (
int param = 0; param < numberParameters; ++param) {