_HADES_CLASS_DESCRIPTION This class is responsible for the Kalman filter. The Kalman filter is started via the Bool_t fitTrack(const TObjArray &hits, const TVectorD &iniStateVec, const TMatrixD &iniCovMat) function. It needs a series of measurement points (an array of class HKalMdcHit) and initial estimations for the track state and covariance matrix as input. It will then make an estimation for the initial track state based on the measurement hits and fill the covariance matrix with large values. The function will return a boolean to indicate whether problems (high chi^2 or unrealistic track parameters) were encountered during track fitting. Track propagation will be done with the Runge-Kutta method. After the Kalman filter is done, a measurement site may be eliminated from the calculation with the function excludeSite(Int_t iSite) Several options for the Kalman filter may be set: setNumIterations(Int_t kalRuns) Number of iterations. After each iteration the Kalman filter will use the result of the previous iteration as starting value. Default is 1. setDirection(Bool_t dir) Propagation direction (kIterForward, kIterBackward). Direction will switch after each iteration. Default is forward direction. setSmoothing(Bool_t smooth) Smooth or don't smooth track states after filter. Smoothing attempts to improve the filtered track states by using the results of all subsequent as well. Default is on. setRotation(Kalman::kalRotateOptions rotate) kNoRot: No coordinate transformation. Not recommended for high track angles (> 30°). kVarRot (default): Tilt the coordinate system along the initial track direction to avoid large values for the track state parameters tx or ty. setDoEnerLoss(Bool_t dedx) setDoMultScat(Bool_t ms) Include energy or multiple scattering in the Kalman filter. Default is on. setConstField(Bool_t constField) setFieldVector(const TVector3 &B) Tells the Kalman filter to use a constant magnetic field instead of the field map. Field vector must be in Tesla. Default is off. setFilterMethod(Kalman::filtMethod type) Changes which formulation of the Kalman equations to use. The formulations differ in speed and numerical stability. See the description of the functions named filter... for details. Notation: a: track state vector m: measurement vector r: residual of the measurement vector and the predicted measurement f(a): propagation function: Propagate track state a to the next detector. h(a): projection function that calculates a measurement vector from track state v F: Jacobian of f(a) H: Jacobian of h(a) C: covariance matrix of the track state Q: covariance matrix of the process noise V: covariance matrix of the measurement errors
virtual | ~HKalIFilt() |
void | TObject::AbstractMethod(const char* method) const |
virtual void | TObject::AppendPad(Option_t* option = "") |
virtual void | TObject::Browse(TBrowser* b) |
virtual Bool_t | calcMeasVecFromState(TVectorD& projMeasVec, const HKalTrackSite *const site, Kalman::kalFilterTypes stateType, Kalman::coordSys sys) const |
virtual Bool_t | checkCovMat(const TMatrixD& fCov) const |
static TClass* | Class() |
virtual const char* | TObject::ClassName() const |
virtual void | TObject::Clear(Option_t* = "") |
virtual TObject* | TObject::Clone(const char* newname = "") const |
virtual Int_t | TObject::Compare(const TObject* obj) const |
virtual void | TObject::Copy(TObject& object) const |
virtual void | TObject::Delete(Option_t* option = "")MENU |
virtual Int_t | TObject::DistancetoPrimitive(Int_t px, Int_t py) |
virtual void | TObject::Draw(Option_t* option = "") |
virtual void | TObject::DrawClass() constMENU |
virtual TObject* | TObject::DrawClone(Option_t* option = "") constMENU |
virtual void | TObject::Dump() constMENU |
virtual void | TObject::Error(const char* method, const char* msgfmt) const |
virtual Bool_t | excludeSite(Int_t iSite) |
virtual void | TObject::Execute(const char* method, const char* params, Int_t* error = 0) |
virtual void | TObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0) |
virtual void | TObject::ExecuteEvent(Int_t event, Int_t px, Int_t py) |
virtual void | TObject::Fatal(const char* method, const char* msgfmt) const |
virtual Bool_t | filter(Int_t iSite) |
virtual TObject* | TObject::FindObject(const char* name) const |
virtual TObject* | TObject::FindObject(const TObject* obj) const |
virtual Bool_t | fitTrack(const TObjArray& hits, const TVectorD& iniStateVec, const TMatrixD& iniCovMat, Int_t pId) |
virtual Double_t | getBetaInput() const |
virtual Double_t | getChi2() const |
virtual void | getCovErrs(Int_t& nSymErrs, Int_t& nPosDefErrs) const |
virtual Double_t | getDafChi2Cut() const |
virtual const Double_t* | getDafT() const |
virtual Bool_t | getDirection() const |
virtual Bool_t | getDoDaf() const |
virtual Bool_t | getDoEnerLoss() const |
virtual Bool_t | getDoMultScat() const |
virtual Bool_t | getDoSmooth() const |
virtual Option_t* | TObject::GetDrawOption() const |
static Long_t | TObject::GetDtorOnly() |
virtual Double_t | getFieldIntegral() const |
virtual const TObjArray& | getFieldTrack() const |
virtual Int_t | getFilterMethod() const |
virtual const TMatrixD& | getHitErrMat(HKalTrackSite *const site) const |
virtual Int_t | getHitType() const |
virtual const TVectorD& | getHitVec(HKalTrackSite *const site) const |
virtual const char* | TObject::GetIconName() const |
virtual const TVectorD& | getIniStateVec() const |
virtual Bool_t | getLastTrackAccepted() const |
virtual Int_t | getMeasDim() const |
virtual void | getMetaPos(Double_t& x, Double_t& y, Double_t& z) const |
virtual const char* | TObject::GetName() const |
virtual Int_t | getNdafs() const |
virtual Double_t | getNdf() const |
virtual Int_t | getNhits() const |
virtual Int_t | getNiter() const |
virtual Int_t | getNmaxSites() const |
virtual Int_t | getNsites() const |
virtual char* | TObject::GetObjectInfo(Int_t px, Int_t py) const |
static Bool_t | TObject::GetObjectStat() |
virtual Option_t* | TObject::GetOption() const |
virtual Int_t | getPid() const |
virtual const TObjArray& | getPointsTrack() const |
virtual Bool_t | getPrintErr() const |
virtual Bool_t | getPrintWarn() const |
virtual Int_t | getRotation() const |
virtual HKalTrackSite* | getSite(UInt_t site) const |
virtual Int_t | getStateDim(Kalman::coordSys coord = kSecCoord) const |
virtual const char* | TObject::GetTitle() const |
virtual Double_t | getTrackLength() const |
virtual Int_t | getTrackNum() const |
virtual const HKalRungeKutta* | getTrackPropagator() const |
virtual UInt_t | TObject::GetUniqueID() const |
virtual void | getVertexPos(Double_t& x, Double_t& y, Double_t& z) const |
virtual Bool_t | TObject::HandleTimer(TTimer* timer) |
virtual ULong_t | TObject::Hash() const |
virtual void | TObject::Info(const char* method, const char* msgfmt) const |
virtual Bool_t | TObject::InheritsFrom(const char* classname) const |
virtual Bool_t | TObject::InheritsFrom(const TClass* cl) const |
virtual void | TObject::Inspect() constMENU |
void | TObject::InvertBit(UInt_t f) |
virtual TClass* | IsA() const |
virtual Bool_t | TObject::IsEqual(const TObject* obj) const |
virtual Bool_t | TObject::IsFolder() const |
Bool_t | TObject::IsOnHeap() const |
virtual Bool_t | TObject::IsSortable() const |
Bool_t | TObject::IsZombie() const |
virtual void | TObject::ls(Option_t* option = "") const |
void | TObject::MayNotUse(const char* method) const |
virtual Bool_t | TObject::Notify() |
void | TObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const |
static void | TObject::operator delete(void* ptr) |
static void | TObject::operator delete(void* ptr, void* vp) |
static void | TObject::operator delete[](void* ptr) |
static void | TObject::operator delete[](void* ptr, void* vp) |
void* | TObject::operator new(size_t sz) |
void* | TObject::operator new(size_t sz, void* vp) |
void* | TObject::operator new[](size_t sz) |
void* | TObject::operator new[](size_t sz, void* vp) |
TObject& | TObject::operator=(const TObject& rhs) |
virtual void | TObject::Paint(Option_t* option = "") |
virtual void | TObject::Pop() |
virtual void | TObject::Print(Option_t* option = "") const |
virtual Bool_t | propagate(Int_t iFromSite, Int_t iToSite) |
virtual Bool_t | propagateToPlane(TVectorD& svTo, const TVectorD& svFrom, const HKalMdcMeasLayer& measLayFrom, const HKalMdcMeasLayer& measLayTo, Int_t pid, Bool_t dir) |
virtual Int_t | TObject::Read(const char* name) |
virtual void | TObject::RecursiveRemove(TObject* obj) |
void | TObject::ResetBit(UInt_t f) |
virtual Bool_t | runFilter(Int_t fromSite, Int_t toSite) |
virtual void | TObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU |
virtual void | TObject::SavePrimitive(ostream& out, Option_t* option = "") |
virtual void | setBetaInput(Double_t b) |
void | TObject::SetBit(UInt_t f) |
void | TObject::SetBit(UInt_t f, Bool_t set) |
virtual void | setConstField(Bool_t constField) |
virtual void | setDafPars(Double_t chi2cut, const Double_t* T, Int_t n) |
virtual void | setDirection(Bool_t dir) |
virtual void | setDoEnerLoss(Bool_t dedx) |
virtual void | setDoMultScat(Bool_t ms) |
virtual void | TObject::SetDrawOption(Option_t* option = "")MENU |
static void | TObject::SetDtorOnly(void* obj) |
virtual void | setFieldMap(HMdcTrackGField* fMap, Double_t fpol) |
virtual void | setFieldVector(const TVector3& B) |
virtual void | setFillPointsArrays(Bool_t fill) |
virtual void | setFilterMethod(Kalman::filtMethod type) |
virtual void | setHitType(Kalman::kalHitTypes hType) |
virtual void | setNumIterations(Int_t kalRuns) |
static void | TObject::SetObjectStat(Bool_t stat) |
virtual void | setPrintErrors(Bool_t print) |
virtual void | setPrintWarnings(Bool_t print) |
virtual void | setRotation(Kalman::kalRotateOptions rotate) |
virtual void | setRotationAngles(Double_t rotXAngle, Double_t rotYAngle) |
virtual void | setRungeKuttaParams(Float_t initialStpSize, Float_t stpSizeDec, Float_t stpSizeInc, Float_t maxStpSize, Float_t minStpSize, Float_t minPrec, Float_t maxPrec, Int_t maxNumStps, Int_t maxNumStpsPCA, Float_t maxDst, Double_t minLngthCalcQ) |
virtual void | setSmoothing(Bool_t smooth) |
virtual void | TObject::SetUniqueID(UInt_t uid) |
virtual void | ShowMembers(TMemberInspector&) |
virtual Bool_t | smooth() |
virtual void | sortHits() |
virtual void | Streamer(TBuffer&) |
void | StreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b) |
virtual void | TObject::SysError(const char* method, const char* msgfmt) const |
Bool_t | TObject::TestBit(UInt_t f) const |
Int_t | TObject::TestBits(UInt_t f) const |
virtual Bool_t | traceToMeta(const TVector3& metaHit, const TVector3& metaNormVec) |
virtual Bool_t | traceToVertex() |
virtual void | transformFromSectorToTrack() |
virtual void | transformFromTrackToSector() |
virtual void | updateSites(const TObjArray& hits) |
virtual void | TObject::UseCurrentStyle() |
virtual void | TObject::Warning(const char* method, const char* msgfmt) const |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) |
virtual Int_t | TObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const |
virtual Bool_t | calcProjector(Int_t iSite) const |
virtual Bool_t | checkSitePreFilter(Int_t iSite) const |
virtual void | TObject::DoError(int level, const char* location, const char* fmt, va_list va) const |
virtual void | filterConventional(Int_t iSite) |
virtual void | filterJoseph(Int_t iSite) |
virtual void | filterSequential(Int_t iSite) |
virtual void | filterSwerling(Int_t iSite) |
virtual void | filterUD(Int_t iSite) |
virtual Kalman::coordSys | getFilterInCoordSys() const |
virtual TRotation* | getRotMat() const |
void | TObject::MakeZombie() |
virtual void | newTrack(const TObjArray& hits, const TVectorD& iniSv, const TMatrixD& iniCovMat, Int_t pid) |
virtual void | propagateCovConv(Int_t iFromSite, Int_t iToSite) |
virtual void | propagateCovUD(Int_t iFromSite, Int_t iToSite) |
virtual Bool_t | propagateTrack(Int_t iFromSite, Int_t iToSite) |
virtual void | setChi2(Double_t c) |
virtual void | setNHitsInTrack(Int_t n) |
virtual void | setNSites(Int_t n) |
virtual void | setTrackChi2(Double_t c) |
virtual void | setTrackLength(Double_t l) |
virtual void | setTrackLengthAtLastMdc(Double_t l) |
virtual void | updateChi2Filter(Int_t iSite) |
enum TObject::EStatusBits { | kCanDelete | |
kMustCleanup | ||
kObjInCanvas | ||
kIsReferenced | ||
kHasUUID | ||
kCannotPick | ||
kNoContextMenu | ||
kInvalidObject | ||
}; | ||
enum TObject::[unnamed] { | kIsOnHeap | |
kNotDeleted | ||
kZombie | ||
kBitMask | ||
kSingleKey | ||
kOverwrite | ||
kWriteDelete | ||
}; |
Bool_t | bDoDEDX | Energy loss. |
Bool_t | bDoMS | Multiple scattering. |
Bool_t | bDoSmooth | ! Do smoothing. |
Bool_t | bFillPointArrays | == kTRUE if point arrays should be filled |
Bool_t | bPrintErr | ! Print error messages. |
Bool_t | bPrintWarn | ! Print warning messages. |
Bool_t | bTrackAccepted | Track filtering done without errors. |
Double_t | betaInput | Beta value used for initial particle hypothesis. |
Double_t | chi2 | chi2 of track. Will be -1 if fit failed. |
Bool_t | direction | Propagation direction: kIterForward/kIterBackward |
TObjArray | fieldTrack | Field from Runge-Kutta stepping at Points along trajectory stored |
Int_t | filtType | Switch between alternate formulations of the Kalman equations. |
Int_t | hitType | Wire or segment hits. |
TVectorD | iniStateVec | Estimation of the track state vector at the first measurement site. |
Int_t | nCondErrs | Number of times when a matrix was ill-conditioned for inversion. Only filled if kalDebug > 0. |
Int_t | nCovPosDefErrs | Number of times the covariance matrix was not positive definite. Only filled if kalDebug > 0. |
Int_t | nCovSymErrs | Number of symmetry breaking in the covariance matrix. Only filled if kalDebug > 0. |
Int_t | nHitsInTrack | Number of sites in current track. |
Int_t | nKalRuns | Number of Kalman filter iterations. |
Int_t | nMaxSites | Maximum number of sites that can be stored. |
Int_t | nSites | Number of measurement sites in track. |
TRotation* | pRotMat | ! Rotation matrix for possible coordinate tilting. |
TVector3* | pTransVec | ! Translation vector for possible coordinate transformations. |
Int_t | pid | Geant particle id. |
TObjArray | pointsTrack | Points from Runge-Kutta stepping along trajectory stored |
TVector3 | posMeta | ! Position information at meta detector. |
TVector3 | posVertex | ! Position information at vertex. |
Int_t | rotCoords | Option to tilt coordinate system for track fitting. |
HKalTrackSite** | sites | ! Array of MDC track sites. |
TVectorD | svMeta | ! Track state at META detector. |
TVectorD | svVertex | ! Track state at vertex. |
Double_t | trackLength | Track length from target. |
Double_t | trackLengthAtLastMdc | Track length from target to last MDC. |
Int_t | trackNum | Number of tracks fitted. |
HKalRungeKutta | trackPropagator | ! The object that realizes the track propagation. |
Checks for potential issues when site with index iSite is filtered.
Filter a site using the conventional formulation of the Kalman filter equations. C_k = (I - K_k * H_k) * C^{k-1}_k K_k = C^{k-1}_k * H^T_k * (V_k + H_k * C^{k-1}_k * H^T_k)^-1 These are simpler equations compared to the Joseph or Swerling forumations. Only one inversion of a matrix with the dimension of the measurement vector is neccessary. However, the updated covariance matrix may not be positive definite due to numerical computing problems.
This filter method uses the Joseph stabilized update of the covariance matrix. K_k = C^k-1_k * H^T * (V_k + H_k * C^k-1_k * H_k^T)^-1 C^k = (I - K_k * H) * C^k-1_k * (I - K_k * H)^T + K_k * V_k * K_k^T This method is numerically more stable than the conventional or Swerling formulations of the Kalman equations. It guarantees that the updated covariance matrix is positive definite if the covariance from the prediction step and the measurement noise covariance are also positive definite.
Swerling calculation of covariance matrix for filtered state and the Kalman gain matrix. C_k = [ (C^k-1_k)^-1 + H^T_k * (V_k)^-1 * H_k ]^-1 K_k = C_k * H^T_k * (V_k)^-1 This form requires two inversions of matrices with the dimension of the state vector and one inversion of a matrix with the dimension of the measurement vector. It can be more efficient if the dimension of the state vector is small.
Update of the covariance matrix and state vector for the filter step using the U-D filter. A UD decomposition of the covariance matrix is used and only the U and D matrices are propagated. This method increases the numerical precision of the Kalman filter. It cannot be used together with the annealing filter. Literature: Optimal State Estimation: Kalman, H infinity and Nonlinear Approaches Chapter 6.4: U-D filtering Dan Simon Kalman Filtering: Theory and Practice using MATLAB, 3rd edition Chapter 6.5: Square Root and UD Filters Mohinder S. Grewal, Angus P. Andrews G. J. Bierman, Factorization Methods for Discrete Sequential Estimation, Academic Press, New York 1977
Propagate the covariance matrix between measurement sites. Must not be called before propagateTrack(). When applying the UD filter use propagateCovUD() function instead. iFromSite: index of measurement site to start propagation from. iToSite: index of measurement site to propagate to (will be modified).
Update of the covariance matrix' U and D factors after the prediction step. iFromSite: index of measurement site to start propagation from. iToSite: index of measurement site to propagate to (will be modified). Only the matrix upper triangular U with the elements of D on its diagonal are stored in the site. Literature: Kalman Filtering: Theory and Practice using MATLAB, 3rd edition Chapter 6.5: Square Root and UD Filters Mohinder S. Grewal, Angus P. Andrews and Catherine L. Thornton, Triangular covariance factorizations for Kalman filtering, Ph.D. thesis, University of California at Los Angeles, 1976
Reset data members to fit a new track. Input: hits: the array with the measurement hits. Elements must be of class HKalMdcHit. iniStateVec: initial track state that the filter will use. iniCovMat: initial covariance matrix that the filter will use. pId: Geant particle id. momGeant: Geant momentum that will be written in the output tree. Ignore if this is not simulation data.
Implements the projection function h(a) that calculates a measurement vector from a track state. Output: projMeasVec: The calculated measurement vector. Input: site: Pointer to current site of the track. stateType: Which state (predicted, filtered, smoothed) to project on a measurement vector. sys: Coordinate system to use (sector or virtual layer coordinates)
Covariance matrices must be positive definite, i.e. symmetric and all its eigenvalues are real and positive. Returns true if this is the case.
Exclude a site from the measurement. Requires that prediction, filtering and smoothing has been done before. If smoothing has been disabled it will be done in this function. iSite: index in sites array of the site to exclude
Runs the Kalman filter over a set of measurement hits. Returns false if the Kalman filter encountered problems during track fitting or the chi^2 is too high. Input: hits: the array with the measurement hits. Elements must be of class HKalMdcHit. iniStateVec: initial track state that the filter will use. iniCovMat: initial covariance matrix that the filter will use. pId: Geant particle id. momGeant: Geant momentum that will be written in the output tree. Ignore if this is not simulation data.
Propagates the track to the next measurement site and update covariance matrices. iFromSite: index of measurement site to start propagation from. iToSite: index of measurement site to propagate to.
Propagates the track from the last fitted MDC position till track intersection with META plane (is defined by META-hit and normal vector to rod's plane. Should only be called after having filtered all sites. Input: metaHit: metaNormVec:
Transform all sites using the inverse rotation matrix stored in the Kalman system. This will transform the sites back to sector coordinates after a call of transformFromSectorToTrack() and if the rotation matrix has not been modified in the meantime.
Replace sites of the Kalman system with new hits. hits: array with new measurement hits. Must be of class HKalMdcHit.
Returns the measurement error of site. Input: site: measurement site.
Returns the measurement vector of measurement site. Input: site: measurement site.
Returns number degrees of freedom, i.e. number of experimental points minus number of parameters that are estimated.
Set options for the Kalman filter. kalRotateOptions: Tilt coordinate system. There are (approximately) three options: 1. kNoRot: Don't tilt the coordinate system. 2. kVarRot: Tilt the coordinate system so that the z-axis will always point in the initial track direction. Assuming track curvature is not large this ensures that the track state parameters tx = tan(p_x / p_z) and ty = tan(p_y / p_z) remain small. Angles close to 90° would result in large values for tx and ty due to the tangens and poor results for the Kalman filter.
Set the rotation matrix. rotXangle: rotation angle around x axis in radians. rotYangle: rotation angle around y axis in radians.
{ nSymErrs = nCovSymErrs; nPosDefErrs = nCovPosDefErrs; }
{ return getSite(0)->getStateDim(coord); }
{ bFillPointArrays = fill; trackPropagator.setFillPointsArrays(fill); }