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) {