~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/common_cpp/Recon/Kalman/KalmanTrackFit.cc

merging in changes in merge branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
      for (unsigned int i = 0; i < state.GetDimension(); ++i) {
43
43
        converter << "(" << vec(i, 0) << " +/- " << sqrt(cov(i, i)) << "), ";
44
44
      }
45
 
      converter << 1.0/vec(vec.GetNrows()-1, 0);
46
45
      converter << "\n";
47
46
    } else {
48
47
      converter << "NO DATA\n";
54
53
  std::string print_track(const Track& track, const char* name) {
55
54
    unsigned int num = track.GetLength();
56
55
    std::ostringstream converter("");
57
 
    if (name)
58
 
      converter << "Printing " << name << "\n";
59
 
    else
60
 
      converter << "TRACK:\n";
 
56
    if (name) {
 
57
      converter << "Printing " << name << " (" << num << ")\n";
 
58
    } else {
 
59
      converter << "Printing Track (" << num << ")\n";
 
60
    }
61
61
 
62
62
    for (unsigned int i = 0; i < num; ++i) {
63
63
      State state = track[i];
75
75
    }
76
76
    TMatrixD vector = st1._vector - st2._vector;
77
77
    TMatrixD covariance = st1._covariance + st2._covariance;
78
 
//    TMatrixD covariance = st1._covariance + st2._covariance;
79
78
 
80
79
    State residual(vector, covariance, st1._position);
81
80
    residual.SetId(st1._id);
195
194
 
196
195
        _smoothed[i].SetVector(vec);
197
196
        _smoothed[i].SetCovariance(cov);
198
 
 
199
 
        Kalman::State measured = _measurement->Measure(_smoothed[i]);
200
197
      }
201
198
    }
202
199
  }
309
306
    for (unsigned int i = 0; i < track.GetLength(); ++i) {
310
307
      if (_data[i]) {
311
308
        State measured = _measurement->Measure(track[i]);
312
 
 
313
 
        TMatrixD vector = _data[i]._vector - measured._vector;
314
 
        TMatrixD covariance = _measurement->GetMeasurementNoise() - measured._covariance;
315
 
 
316
 
        State chisq(vector, covariance, measured._position);
317
 
        chi_squared += CalculateChiSquaredUpdate(chisq);
 
309
        State chisq = CalculateResidual(measured, _data[i]);
 
310
        double update = CalculateChiSquaredUpdate(chisq);
 
311
        chi_squared += update;
318
312
      }
319
313
    }
320
314
 
325
319
    int no_parameters = GetDimension();
326
320
    int no_measurements = 0;
327
321
    for (unsigned int i = 0; i < _data.GetLength(); ++i) {
328
 
      if (_data[i]) no_measurements += GetMeasurementDimension();
 
322
      if (_data[i].HasValue()) {
 
323
        no_measurements += GetMeasurementDimension();
 
324
      }
329
325
    }
330
 
    return (no_measurements - no_parameters) - 1;
331
 
//    return (no_measurements - no_parameters);
 
326
    return (no_measurements - no_parameters);
332
327
  }
333
328
 
334
329
  State TrackFit::CalculateCleanedState(unsigned int i) const {