Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:48

0001 #ifndef L1Trigger_TrackFindingTMTT_KalmanState_h
0002 #define L1Trigger_TrackFindingTMTT_KalmanState_h
0003 
0004 #include "L1Trigger/TrackFindingTMTT/interface/Stub.h"
0005 #include "L1Trigger/TrackFindingTMTT/interface/KFbase.h"
0006 #include <TMatrixD.h>
0007 #include <TVectorD.h>
0008 
0009 #include <map>
0010 
0011 ///=== Represents helix state & last associated stub.
0012 ///=== All variable names & equations come from Fruhwirth KF paper
0013 ///=== http://dx.doi.org/10.1016/0168-9002%2887%2990887-4
0014 
0015 namespace tmtt {
0016 
0017   class KFbase;
0018   class KalmanState;
0019   class Stub;
0020   class Settings;
0021 
0022   class KalmanState {
0023   public:
0024     KalmanState(const Settings *settings,
0025                 const L1track3D &candidate,
0026                 unsigned nSkipped,
0027                 int kLayer,
0028                 const KalmanState *last_state,
0029                 const TVectorD &vecX,
0030                 const TMatrixD &matC,
0031                 const TMatrixD &matK,
0032                 const TMatrixD &matV,
0033                 Stub *stub,
0034                 double chi2rphi,
0035                 double chi2rz);
0036 
0037     const Settings *settings() const { return settings_; }
0038     // KF layer where next stub to extend this state should be sought.
0039     unsigned nextLayer() const { return (1 + kLayer_); }
0040     // KF layer of last added stub. (-1 if no stubs yet).
0041     int layer() const { return kLayer_; }
0042     bool barrel() const { return barrel_; }
0043     unsigned nSkippedLayers() const { return nSkipped_; }
0044     // Hit coordinates.
0045     double r() const { return r_; }
0046     double z() const { return z_; }
0047     const KalmanState *last_state() const { return last_state_; }
0048     // Helix parameters (1/2R, phi relative to sector, z0, tanLambda)
0049     const TVectorD &vectorX() const { return vecX_; }
0050     // Covariance matrix on helix params.
0051     const TMatrixD &matrixC() const { return matC_; }
0052     // Kalman Gain matrix
0053     const TMatrixD &matrixK() const { return matK_; }
0054     // Hit position covariance matrix.
0055     const TMatrixD &matrixV() const { return matV_; }
0056     // Last added stub
0057     Stub *stub() const { return stub_; }
0058     // Track used to seed KF.
0059     const L1track3D &candidate() const { return l1track3D_; }
0060 
0061     double chi2() const { return chi2rphi_ + chi2rz_; }
0062     double chi2scaled() const { return chi2rphi_ / kalmanChi2RphiScale_ + chi2rz_; }  // Improves electron performance.
0063     double chi2rphi() const { return chi2rphi_; }
0064     double chi2rz() const { return chi2rz_; }
0065     unsigned nStubLayers() const { return n_stubs_; }
0066     unsigned int hitPattern() const { return hitPattern_; }  // Bit-encoded KF layers the fitted track has stubs in.
0067 
0068     bool good(const TP *tp) const;
0069     double reducedChi2() const;
0070     const KalmanState *last_update_state() const;
0071     std::vector<Stub *> stubs() const;
0072 
0073     void setChi2(double chi2rphi, double chi2rz) {
0074       chi2rphi_ = chi2rphi;
0075       chi2rz_ = chi2rz;
0076     }
0077 
0078   private:
0079     const Settings *settings_;
0080     int kLayer_;
0081     double r_;
0082     double z_;
0083     const KalmanState *last_state_;
0084     TVectorD vecX_;
0085     TMatrixD matC_;
0086     TMatrixD matK_;
0087     TMatrixD matV_;
0088     Stub *stub_;
0089     double chi2rphi_;
0090     double chi2rz_;
0091     unsigned int kalmanChi2RphiScale_;
0092     unsigned n_stubs_;
0093     bool barrel_;
0094     unsigned nSkipped_;
0095     L1track3D l1track3D_;
0096     unsigned int hitPattern_;
0097   };
0098 
0099 }  // namespace tmtt
0100 
0101 #endif