Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:33

0001 #ifndef CollinearFitAtTM2_h_
0002 #define CollinearFitAtTM2_h_
0003 
0004 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0005 #include "DataFormats/GeometryCommonDetAlgo/interface/Measurement1D.h"
0006 #include "DataFormats/Math/interface/Vector.h"
0007 #include "DataFormats/Math/interface/Error.h"
0008 
0009 // #include "Workspace/TrajectoryMeasurementFits/interface/RandomVector.h"
0010 
0011 /** Constrained fit at a TrajectoryMeasurement assuming collinearity 
0012  *  of incoming / outgoing momenta. The result of the fit is a vector
0013  *  of 6 variables: the first five correspond to local trajectory
0014  *  parameters for the incoming momentum, the 6th is the estimated 
0015  *  remaining energy fraction (p_out / p_in). The NDF are 6 (4)
0016  *  for a valid (invalid) RecHit. **/
0017 
0018 class CollinearFitAtTM2 {
0019 public:
0020   /// parameter indices in the result vector / covariance matrix
0021   enum { ParQpIn = 0, ParQpOut, ParDxDz, ParDyDz, ParX, ParY };
0022 
0023   CollinearFitAtTM2(const TrajectoryMeasurement& tm);
0024   CollinearFitAtTM2(const AlgebraicVector5& fwdParameters,
0025                     const AlgebraicSymMatrix55& fwdCovariance,
0026                     const AlgebraicVector5& bwdParameters,
0027                     const AlgebraicSymMatrix55& bwdCovariance,
0028                     const LocalPoint& hitPosition,
0029                     const LocalError& hitErrors);
0030 
0031   typedef ROOT::Math::SVector<double, 6> ResultVector;
0032   typedef ROOT::Math::SMatrix<double, 6, 6, ROOT::Math::MatRepSym<double, 6> > ResultMatrix;
0033   /// status of the fit
0034   bool valid() const { return valid_; }
0035   /// chi2
0036   double chi2() const { return chi2_; }
0037   /// degrees of freedom
0038   int ndof() const { return ndof_; }
0039   /// vector of fitted parameters
0040   const ResultVector& parameters() const { return parameters_; }
0041   /// covariance matrix of fitted parameters
0042   const ResultMatrix& covariance() const { return covariance_; }
0043   /// estimated deltaP (out-in) from fit parameters
0044   Measurement1D deltaP() const;
0045 
0046 private:
0047   /// initialise the jacobian
0048   void initJacobian();
0049   /// Perform the fit. Return value "true" for success.
0050   bool fit(const AlgebraicVector5& fwdParameters,
0051            const AlgebraicSymMatrix55& fwdCovariance,
0052            const AlgebraicVector5& bwdParameters,
0053            const AlgebraicSymMatrix55& bwdCovariance,
0054            const LocalPoint& hitPosition,
0055            const LocalError& hitErrors);
0056 
0057 private:
0058   ROOT::Math::SMatrix<double, 12, 6> jacobian_;
0059   ROOT::Math::SVector<double, 12> measurements_;
0060   ROOT::Math::SMatrix<double, 12, 12, ROOT::Math::MatRepSym<double, 12> > weightMatrix_;
0061   ROOT::Math::SVector<double, 6> projectedMeasurements_;
0062   //   RandomVector randomGenerator;
0063 
0064   bool valid_;
0065   ResultVector parameters_;
0066   ResultMatrix covariance_;
0067   double chi2_;
0068   int ndof_;
0069 };
0070 
0071 #endif