CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
CollinearFitAtTM2 Class Reference

#include <CollinearFitAtTM.h>

Public Types

enum  {
  ParQpIn = 0, ParQpOut, ParDxDz, ParDyDz,
  ParX, ParY
}
 parameter indices in the result vector / covariance matrix More...
 
typedef ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > ResultMatrix
 
typedef ROOT::Math::SVector< double, 6 > ResultVector
 

Public Member Functions

double chi2 () const
 chi2 More...
 
 CollinearFitAtTM2 (const TrajectoryMeasurement &tm)
 
 CollinearFitAtTM2 (const AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors)
 
const ResultMatrixcovariance () const
 covariance matrix of fitted parameters More...
 
Measurement1D deltaP () const
 estimated deltaP (out-in) from fit parameters More...
 
int ndof () const
 degrees of freedom More...
 
const ResultVectorparameters () const
 vector of fitted parameters More...
 
bool valid () const
 status of the fit More...
 

Private Member Functions

bool fit (const AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors)
 Perform the fit. Return value "true" for success. More...
 
void initJacobian ()
 initialise the jacobian More...
 

Private Attributes

double chi2_
 
ResultMatrix covariance_
 
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
 
ROOT::Math::SVector< double, 12 > measurements_
 
int ndof_
 
ResultVector parameters_
 
ROOT::Math::SVector< double, 6 > projectedMeasurements_
 
bool valid_
 
ROOT::Math::SMatrix< double, 12, 12, ROOT::Math::MatRepSym< double, 12 > > weightMatrix_
 

Detailed Description

Constrained fit at a TrajectoryMeasurement assuming collinearity of incoming / outgoing momenta. The result of the fit is a vector of 6 variables: the first five correspond to local trajectory parameters for the incoming momentum, the 6th is the estimated remaining energy fraction (p_out / p_in). The NDF are 6 (4) for a valid (invalid) RecHit.

Definition at line 18 of file CollinearFitAtTM.h.

Member Typedef Documentation

typedef ROOT::Math::SMatrix<double, 6, 6, ROOT::Math::MatRepSym<double, 6> > CollinearFitAtTM2::ResultMatrix

Definition at line 32 of file CollinearFitAtTM.h.

typedef ROOT::Math::SVector<double, 6> CollinearFitAtTM2::ResultVector

Definition at line 31 of file CollinearFitAtTM.h.

Member Enumeration Documentation

anonymous enum

parameter indices in the result vector / covariance matrix

Enumerator
ParQpIn 
ParQpOut 
ParDxDz 
ParDyDz 
ParX 
ParY 

Definition at line 21 of file CollinearFitAtTM.h.

Constructor & Destructor Documentation

CollinearFitAtTM2::CollinearFitAtTM2 ( const TrajectoryMeasurement tm)

Definition at line 4 of file CollinearFitAtTM.cc.

References TrajectoryMeasurement::backwardPredictedState(), fit(), TrajectoryMeasurement::forwardPredictedState(), initJacobian(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), TrajectoryMeasurement::recHit(), TrajectoryMeasurement::updatedState(), and LocalTrajectoryParameters::vector().

4  : valid_(false), chi2_(-1), ndof_(-1) {
5  //
6  // check input
7  //
9  edm::LogWarning("CollinearFitAtTM2") << "Invalid state in TrajectoryMeasurement";
10  return;
11  }
12  //
13  // prepare fit
14  //
15  initJacobian();
20 
21  LocalPoint hitPos(0., 0., 0.);
22  LocalError hitErr(-1., -1., -1.);
23  if (tm.recHit()->isValid()) {
24  hitPos = tm.recHit()->localPosition();
25  hitErr = tm.recHit()->localPositionError();
26  }
27 
28  fit(fwdPar, fwdCov, bwdPar, bwdCov, hitPos, hitErr);
29 }
ConstRecHitPointer const & recHit() const
const LocalTrajectoryParameters & localParameters() const
bool fit(const AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors)
Perform the fit. Return value "true" for success.
AlgebraicVector5 vector() const
ROOT::Math::SVector< double, 5 > AlgebraicVector5
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
void initJacobian()
initialise the jacobian
TrajectoryStateOnSurface const & updatedState() const
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
CollinearFitAtTM2::CollinearFitAtTM2 ( const AlgebraicVector5 fwdParameters,
const AlgebraicSymMatrix55 fwdCovariance,
const AlgebraicVector5 bwdParameters,
const AlgebraicSymMatrix55 bwdCovariance,
const LocalPoint hitPosition,
const LocalError hitErrors 
)

Definition at line 31 of file CollinearFitAtTM.cc.

References fit(), and initJacobian().

37  : valid_(false), chi2_(-1), ndof_(-1) {
38  //
39  // prepare fit
40  //
41  initJacobian();
42 
43  fit(fwdParameters, fwdCovariance, bwdParameters, bwdCovariance, hitPosition, hitErrors);
44 }
bool fit(const AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors)
Perform the fit. Return value "true" for success.
void initJacobian()
initialise the jacobian

Member Function Documentation

double CollinearFitAtTM2::chi2 ( void  ) const
inline

chi2

Definition at line 36 of file CollinearFitAtTM.h.

References chi2_.

36 { return chi2_; }
const ResultMatrix& CollinearFitAtTM2::covariance ( void  ) const
inline

covariance matrix of fitted parameters

Definition at line 42 of file CollinearFitAtTM.h.

References covariance_, deltaP(), fit(), and initJacobian().

42 { return covariance_; }
ResultMatrix covariance_
Measurement1D CollinearFitAtTM2::deltaP ( ) const

estimated deltaP (out-in) from fit parameters

Definition at line 126 of file CollinearFitAtTM.cc.

References covariance_, parameters_, mathSSE::sqrt(), and valid_.

Referenced by GsfTrackProducerBase::computeModeAtTM(), and covariance().

126  {
127  //
128  // check validity
129  //
130  if (!valid_)
131  return Measurement1D();
132  //
133  // deltaP = 1/qpout - 1/qpin ; uncertainty from linear error propagation
134  //
135  double qpIn = parameters_(0);
136  double sig2In = covariance_(0, 0);
137  double qpOut = parameters_(1);
138  double sig2Out = covariance_(1, 1);
139  double corrInOut = covariance_(0, 1);
140  double pIn = 1. / fabs(qpIn);
141  double pOut = 1. / fabs(qpOut);
142  double sig2DeltaP = pIn / qpIn * pIn / qpIn * sig2In - 2 * pIn / qpIn * pOut / qpOut * corrInOut +
143  pOut / qpOut * pOut / qpOut * sig2Out;
144 
145  return Measurement1D(pOut - pIn, sig2DeltaP ? sqrt(sig2DeltaP) : 0.);
146 }
ResultVector parameters_
T sqrt(T t)
Definition: SSEVec.h:19
ResultMatrix covariance_
bool CollinearFitAtTM2::fit ( const AlgebraicVector5 fwdParameters,
const AlgebraicSymMatrix55 fwdCovariance,
const AlgebraicVector5 bwdParameters,
const AlgebraicSymMatrix55 bwdCovariance,
const LocalPoint hitPosition,
const LocalError hitErrors 
)
private

Perform the fit. Return value "true" for success.

Definition at line 61 of file CollinearFitAtTM.cc.

References chi2_, covariance_, mps_fire::i, dqmiolumiharvest::j, jacobian_, measurements_, ndof_, parameters_, ParX, ParY, projectedMeasurements_, valid_, weightMatrix_, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), LocalError::xy(), PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by CollinearFitAtTM2(), covariance(), and trackingPlots.Iteration::modules().

66  {
67  if (hitErr.xx() > 0)
68  jacobian_(10, ParX) = jacobian_(11, ParY) = 1;
69  else
70  jacobian_(10, ParX) = jacobian_(11, ParY) = 0;
71 
72  for (int i = 0; i < 12; ++i) {
73  for (int j = 0; j < 12; ++j)
74  weightMatrix_(i, j) = 0;
75  }
76 
77  for (int i = 0; i < 5; ++i)
78  measurements_(i) = fwdParameters(i);
79  weightMatrix_.Place_at(fwdCovariance, 0, 0);
80  for (int i = 0; i < 5; ++i)
81  measurements_(i + 5) = bwdParameters(i);
82  weightMatrix_.Place_at(bwdCovariance, 5, 5);
83  if (hitErr.xx() > 0) {
84  measurements_(10) = hitPos.x();
85  measurements_(11) = hitPos.y();
86  weightMatrix_(10, 10) = hitErr.xx();
87  weightMatrix_(10, 11) = weightMatrix_(11, 10) = hitErr.xy();
88  weightMatrix_(11, 11) = hitErr.yy();
89  } else {
90  measurements_(10) = measurements_(11) = 0.;
91  weightMatrix_(10, 10) = weightMatrix_(11, 11) = 1.;
92  weightMatrix_(10, 11) = weightMatrix_(11, 10) = 0.;
93  }
94  //
95  // invert covariance matrix
96  //
97  if (!weightMatrix_.Invert()) {
98  edm::LogWarning("CollinearFitAtTM2") << "Inversion of input covariance matrix failed";
99  return false;
100  }
101 
102  //
103  projectedMeasurements_ = ROOT::Math::Transpose(jacobian_) * (weightMatrix_ * measurements_);
104  //
105  // Fitted parameters and covariance matrix
106  //
107  covariance_ = ROOT::Math::SimilarityT(jacobian_, weightMatrix_);
108  if (!covariance_.Invert()) {
109  edm::LogWarning("CollinearFitAtTM2") << "Inversion of resulting weight matrix failed";
110  return false;
111  }
112 
114 
115  //
116  // chi2
117  //
118  chi2_ = ROOT::Math::Similarity(measurements_, weightMatrix_) -
119  ROOT::Math::Similarity(projectedMeasurements_, covariance_);
120  ndof_ = hitErr.xx() > 0 ? 6 : 4;
121 
122  valid_ = true;
123  return true;
124 }
ROOT::Math::SMatrix< double, 12, 12, ROOT::Math::MatRepSym< double, 12 > > weightMatrix_
ResultVector parameters_
ResultMatrix covariance_
ROOT::Math::SVector< double, 6 > projectedMeasurements_
ROOT::Math::SVector< double, 12 > measurements_
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
void CollinearFitAtTM2::initJacobian ( )
private

initialise the jacobian

Definition at line 46 of file CollinearFitAtTM.cc.

References mps_fire::i, dqmiolumiharvest::j, jacobian_, ParQpIn, and ParQpOut.

Referenced by CollinearFitAtTM2(), and covariance().

46  {
47  //
48  // Jacobian
49  //
50  for (int i = 0; i < 12; ++i) {
51  for (int j = 0; j < 6; ++j)
52  jacobian_(i, j) = 0;
53  }
54  for (int i = 1; i < 5; ++i) {
55  jacobian_(i, ParQpOut + i) = jacobian_(i + 5, ParQpOut + i) = 1;
56  }
57  jacobian_(0, ParQpIn) = 1.;
58  jacobian_(5, ParQpOut) = 1.;
59 }
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
int CollinearFitAtTM2::ndof ( void  ) const
inline

degrees of freedom

Definition at line 38 of file CollinearFitAtTM.h.

References ndof_.

38 { return ndof_; }
const ResultVector& CollinearFitAtTM2::parameters ( void  ) const
inline

vector of fitted parameters

Definition at line 40 of file CollinearFitAtTM.h.

References parameters_.

40 { return parameters_; }
ResultVector parameters_
bool CollinearFitAtTM2::valid ( ) const
inline

status of the fit

Definition at line 34 of file CollinearFitAtTM.h.

References valid_.

34 { return valid_; }

Member Data Documentation

double CollinearFitAtTM2::chi2_
private

Definition at line 67 of file CollinearFitAtTM.h.

Referenced by chi2(), and fit().

ResultMatrix CollinearFitAtTM2::covariance_
private

Definition at line 66 of file CollinearFitAtTM.h.

Referenced by covariance(), deltaP(), and fit().

ROOT::Math::SMatrix<double, 12, 6> CollinearFitAtTM2::jacobian_
private

Definition at line 58 of file CollinearFitAtTM.h.

Referenced by fit(), and initJacobian().

ROOT::Math::SVector<double, 12> CollinearFitAtTM2::measurements_
private

Definition at line 59 of file CollinearFitAtTM.h.

Referenced by fit().

int CollinearFitAtTM2::ndof_
private

Definition at line 68 of file CollinearFitAtTM.h.

Referenced by fit(), and ndof().

ResultVector CollinearFitAtTM2::parameters_
private
ROOT::Math::SVector<double, 6> CollinearFitAtTM2::projectedMeasurements_
private

Definition at line 61 of file CollinearFitAtTM.h.

Referenced by fit().

bool CollinearFitAtTM2::valid_
private

Definition at line 64 of file CollinearFitAtTM.h.

Referenced by deltaP(), fit(), and valid().

ROOT::Math::SMatrix<double, 12, 12, ROOT::Math::MatRepSym<double, 12> > CollinearFitAtTM2::weightMatrix_
private

Definition at line 60 of file CollinearFitAtTM.h.

Referenced by fit().