File indexing completed on 2024-04-06 12:26:14
0001 #ifndef GEMSegment_MuonSegFit_h
0002 #define GEMSegment_MuonSegFit_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
0025
0026 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0027
0028 #include <Math/Functions.h>
0029 #include <Math/SVector.h>
0030 #include <Math/SMatrix.h>
0031
0032 #include <vector>
0033
0034 class MuonSegFit {
0035 public:
0036
0037
0038 typedef std::shared_ptr<TrackingRecHit> MuonRecHitPtr;
0039 typedef std::vector<MuonRecHitPtr> MuonRecHitContainer;
0040
0041 static const int MaxHits2 = 22;
0042
0043 typedef ROOT::Math::SMatrix<double, MaxHits2, MaxHits2, ROOT::Math::MatRepSym<double, MaxHits2> > SMatrixSym12;
0044
0045
0046 typedef ROOT::Math::SMatrix<double, MaxHits2, 4> SMatrix12by4;
0047
0048
0049 typedef ROOT::Math::SMatrix<double, 4> SMatrix4;
0050 typedef ROOT::Math::SMatrix<double, 4, 4, ROOT::Math::MatRepSym<double, 4> > SMatrixSym4;
0051
0052
0053 typedef ROOT::Math::SMatrix<double, 2, 2, ROOT::Math::MatRepSym<double, 2> > SMatrixSym2;
0054
0055
0056 typedef ROOT::Math::SVector<double, 4> SVector4;
0057
0058
0059
0060
0061
0062 MuonSegFit(MuonRecHitContainer hits)
0063 : hits_(hits), uslope_(.0), vslope_(.0), chi2_(.0), ndof_(0), scaleXError_(1.0), fitdone_(false) {}
0064
0065 virtual ~MuonSegFit() {}
0066
0067
0068 bool fit(void);
0069
0070 AlgebraicSymMatrix covarianceMatrix(void);
0071
0072
0073
0074 void setScaleXError(double factor) { scaleXError_ = factor; }
0075
0076
0077 float xfit(float z) const;
0078 float yfit(float z) const;
0079
0080
0081 float xdev(float x, float z) const;
0082 float ydev(float y, float z) const;
0083 float Rdev(float x, float y, float z) const;
0084
0085
0086 MuonRecHitContainer hits(void) const { return hits_; }
0087 double scaleXError(void) const { return scaleXError_; }
0088 size_t nhits(void) const { return hits_.size(); }
0089 double chi2(void) const { return chi2_; }
0090 int ndof(void) const { return ndof_; }
0091 LocalPoint intercept() const { return intercept_; }
0092 LocalVector localdir() const { return localdir_; }
0093 bool fitdone() const { return fitdone_; }
0094
0095 private:
0096
0097
0098 void fit2(void);
0099 void fitlsq(void);
0100 void setChi2(void);
0101
0102 protected:
0103
0104
0105
0106 void setOutFromIP(void);
0107
0108 SMatrix12by4 derivativeMatrix(void);
0109 SMatrixSym12 weightMatrix(void);
0110 AlgebraicSymMatrix flipErrors(const SMatrixSym4&);
0111
0112
0113
0114 MuonRecHitContainer hits_;
0115 float uslope_;
0116 float vslope_;
0117 LocalPoint intercept_;
0118 LocalVector localdir_;
0119 double chi2_;
0120 int ndof_;
0121 double scaleXError_;
0122 bool fitdone_;
0123 };
0124
0125 #endif