67 #include "cetlib_except/exception.h"
80 KHit(
const std::shared_ptr<const Surface>& psurf);
83 KHit(
const std::shared_ptr<const Surface>& psurf,
189 virtual std::ostream&
Print(std::ostream& out,
bool doTitle =
true)
const;
234 :
KHitBase(psurf), fMvec(mvec), fMerr(merr), fChisq(0.)
268 if (getMeasSurface()->isEqual(*fPredSurf)) {
273 ok = subpredict(tre, fPvec, fPerr, fH);
312 ok = subpredict(treprop, fPvec, fPerr, hmatrix);
318 fH = prod(hmatrix, prop_matrix);
326 fRvec = fMvec - fPvec;
327 fRerr = fMerr + fPerr;
336 fChisq = inner_prod(fRvec, prod(fRinv, fRvec));
365 if (!getPredSurface()->isEqual(*tre.
getSurface()))
366 throw cet::exception(
"KHit") <<
"Track surface not the same as prediction surface.\n";
370 TrackVector::size_type
size = tvec.size();
376 temp = prod(trans(fH), fRinv);
377 gain = prod(terr, temp);
385 TrackMatrix fact = ublas::identity_matrix<TrackVector::value_type>(
size);
386 fact -= prod(gain, fH);
389 TrackError errtemp2s = ublas::symmetric_adaptor<TrackMatrix>(errtemp2);
392 TrackError errtemp4s = ublas::symmetric_adaptor<TrackMatrix>(errtemp4);
406 if (doTitle) out <<
"KHit<" <<
N <<
">:\n";
414 out <<
" Measurement vector:\n"
416 for (
unsigned int i = 0; i < fMvec.size(); ++i) {
417 if (i != 0) out <<
", ";
424 out <<
" Diagonal measurement errors:\n"
426 for (
unsigned int i = 0; i < fMerr.size1(); ++i) {
427 if (i != 0) out <<
", ";
428 double err = fMerr(i, i);
429 err = (err >= 0. ? std::sqrt(err) : -std::sqrt(-err));
436 if (fMerr.size1() > 1) {
437 out <<
" Measurement correlation matrix:";
438 for (
unsigned int i = 0; i < fMerr.size1(); ++i) {
443 for (
unsigned int j = 0; j <= i; ++j) {
444 if (j != 0) out <<
", ";
448 double eiijj = fMerr(i, i) * fMerr(j, j);
449 double eij = fMerr(i, j);
463 out <<
" Prediction vector:\n"
465 for (
unsigned int i = 0; i < fPvec.size(); ++i) {
466 if (i != 0) out <<
", ";
473 out <<
" Diagonal prediction errors:\n"
475 for (
unsigned int i = 0; i < fPerr.size1(); ++i) {
476 if (i != 0) out <<
", ";
477 double err = fPerr(i, i);
478 err = (err >= 0. ? std::sqrt(err) : -std::sqrt(-err));
485 if (fPerr.size1() > 1) {
486 out <<
" Prediction correlation matrix:";
487 for (
unsigned int i = 0; i < fPerr.size1(); ++i) {
492 for (
unsigned int j = 0; j <= i; ++j) {
493 if (j != 0) out <<
", ";
497 double eiijj = fPerr(i, i) * fPerr(j, j);
498 double eij = fPerr(i, j);
512 out <<
" Residual vector:\n"
514 for (
unsigned int i = 0; i < fRvec.size(); ++i) {
515 if (i != 0) out <<
", ";
522 out <<
" Diagonal residual errors:\n"
524 for (
unsigned int i = 0; i < fRerr.size1(); ++i) {
525 if (i != 0) out <<
", ";
526 double err = fRerr(i, i);
527 err = (err >= 0. ? std::sqrt(err) : -std::sqrt(-err));
534 if (fRerr.size1() > 1) {
535 out <<
" Residual correlation matrix:";
536 for (
unsigned int i = 0; i < fRerr.size1(); ++i) {
541 for (
unsigned int j = 0; j <= i; ++j) {
542 if (j != 0) out <<
", ";
546 double eiijj = fRerr(i, i) * fRerr(j, j);
547 double eij = fRerr(i, j);
561 out <<
" Incremental chisquare = " << fChisq <<
"\n";
bool predict(const KETrack &tre, const Propagator &prop, const KTrack *ref=0) const
Prediction method (return false if fail).
ublas::symmetric_matrix< double, ublas::lower, ublas::row_major, ublas::bounded_array< double, N *(N+1)/2 > > type
const TrackError & getError() const
Track error matrix.
virtual bool subpredict(const KETrack &tre, typename KVector< N >::type &pvec, typename KSymMatrix< N >::type &perr, typename KHMatrix< N >::type &hmatrix) const =0
Calculate prediction function (return via arguments).
const std::shared_ptr< const Surface > & getSurface() const
Surface.
void update(KETrack &tre) const
Update track method.
KSymMatrix< 5 >::type TrackError
Track error matrix, dimension 5x5.
void setVector(const TrackVector &vec)
Set state vector.
const KSymMatrix< N >::type & getMeasError() const
Measurement error matrix.
EResult err(const char *call)
std::size_t size(FixedBins< T, C > const &) noexcept
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
const KHMatrix< N >::type & getH() const
Kalman H-matrix.
const KVector< N >::type & getResVector() const
Residual vector.
virtual std::ostream & Print(std::ostream &out, bool doTitle=true) const
Printout.
void setError(const TrackError &err)
Set error matrix.
const KVector< N >::type & getPredVector() const
Prediction vector.
const KSymMatrix< N >::type & getPredError() const
Prediction matrix.
KVector< N >::type fPvec
Prediction vector.
KHit()
Default constructor.
KMatrix< N, 5 >::type type
KVector< N >::type fMvec
Measurement vector.
KVector< N >::type fRvec
Residual vector.
void setMeasVector(const typename KVector< N >::type &mvec)
Set measurement vector.
const KSymMatrix< N >::type & getResError() const
Residual error matrix.
ublas::vector< double, ublas::bounded_array< double, N > > type
bool syminvert(ublas::symmetric_matrix< T, TRI, L, A > &m)
KHMatrix< N >::type fH
Kalman H-matrix.
const KSymMatrix< N >::type & getResInvError() const
Residual inv. error matrix.
double getChisq() const
Incremental chisquare.
std::optional< double > err_prop(KETrack &tre, const std::shared_ptr< const Surface > &psurf, PropDirection dir, bool doDedx, KTrack *ref=0, TrackMatrix *prop_matrix=0) const
Propagate with error, but without noise.
KSymMatrix< N >::type fRinv
Residual inverse error matrix.
Base class for Kalman filter track propagator.
KVector< 5 >::type TrackVector
Track state vector, dimension 5.
void setMeasError(const typename KSymMatrix< N >::type &merr)
Set measurement error.
const TrackVector & getVector() const
Track state vector.
KSymMatrix< N >::type fRerr
Residual error matrix.
const KVector< N >::type & getMeasVector() const
Measurement vector.
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
KMatrix< 5, 5 >::type TrackMatrix
General 5x5 matrix.
process_name largeant stream1 can override from command line with o or output physics producers generator N
KSymMatrix< N >::type fPerr
Prediction error matrix.
KMatrix< 5, N >::type type
virtual ~KHit()
Destructor.
KSymMatrix< N >::type fMerr
Measurement error matrix.
Base class for Kalman filter measurement.
double fChisq
Incremental chisquare.