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 AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors)
 
 CollinearFitAtTM2 (const TrajectoryMeasurement &tm)
 
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

◆ ResultMatrix

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

Definition at line 32 of file CollinearFitAtTM.h.

◆ ResultVector

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

Definition at line 31 of file CollinearFitAtTM.h.

Member Enumeration Documentation

◆ anonymous enum

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() [1/2]

CollinearFitAtTM2::CollinearFitAtTM2 ( const TrajectoryMeasurement tm)

Definition at line 4 of file CollinearFitAtTM.cc.

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 }

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

◆ CollinearFitAtTM2() [2/2]

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.

37  : valid_(false), chi2_(-1), ndof_(-1) {
38  //
39  // prepare fit
40  //
41  initJacobian();
42 
43  fit(fwdParameters, fwdCovariance, bwdParameters, bwdCovariance, hitPosition, hitErrors);
44 }

References fit(), and initJacobian().

Member Function Documentation

◆ chi2()

double CollinearFitAtTM2::chi2 ( void  ) const
inline

chi2

Definition at line 36 of file CollinearFitAtTM.h.

36 { return chi2_; }

References chi2_.

◆ covariance()

const ResultMatrix& CollinearFitAtTM2::covariance ( void  ) const
inline

covariance matrix of fitted parameters

Definition at line 42 of file CollinearFitAtTM.h.

42 { return covariance_; }

References covariance_.

◆ deltaP()

Measurement1D CollinearFitAtTM2::deltaP ( ) const

estimated deltaP (out-in) from fit parameters

Definition at line 126 of file CollinearFitAtTM.cc.

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 }

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

Referenced by GsfTrackProducerBase::computeModeAtTM().

◆ fit()

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.

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 }

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(), and trackingPlots.Iteration::modules().

◆ initJacobian()

void CollinearFitAtTM2::initJacobian ( )
private

initialise the jacobian

Definition at line 46 of file CollinearFitAtTM.cc.

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 }

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

Referenced by CollinearFitAtTM2().

◆ ndof()

int CollinearFitAtTM2::ndof ( void  ) const
inline

degrees of freedom

Definition at line 38 of file CollinearFitAtTM.h.

38 { return ndof_; }

References ndof_.

◆ parameters()

const ResultVector& CollinearFitAtTM2::parameters ( void  ) const
inline

vector of fitted parameters

Definition at line 40 of file CollinearFitAtTM.h.

40 { return parameters_; }

References parameters_.

◆ valid()

bool CollinearFitAtTM2::valid ( ) const
inline

status of the fit

Definition at line 34 of file CollinearFitAtTM.h.

34 { return valid_; }

References valid_.

Member Data Documentation

◆ chi2_

double CollinearFitAtTM2::chi2_
private

Definition at line 67 of file CollinearFitAtTM.h.

Referenced by chi2(), and fit().

◆ covariance_

ResultMatrix CollinearFitAtTM2::covariance_
private

Definition at line 66 of file CollinearFitAtTM.h.

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

◆ jacobian_

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

Definition at line 58 of file CollinearFitAtTM.h.

Referenced by fit(), and initJacobian().

◆ measurements_

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

Definition at line 59 of file CollinearFitAtTM.h.

Referenced by fit().

◆ ndof_

int CollinearFitAtTM2::ndof_
private

Definition at line 68 of file CollinearFitAtTM.h.

Referenced by fit(), and ndof().

◆ parameters_

ResultVector CollinearFitAtTM2::parameters_
private

◆ projectedMeasurements_

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

Definition at line 61 of file CollinearFitAtTM.h.

Referenced by fit().

◆ valid_

bool CollinearFitAtTM2::valid_
private

Definition at line 64 of file CollinearFitAtTM.h.

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

◆ weightMatrix_

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().

CollinearFitAtTM2::jacobian_
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
Definition: CollinearFitAtTM.h:58
Measurement1D
Definition: Measurement1D.h:11
CollinearFitAtTM2::fit
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.
Definition: CollinearFitAtTM.cc:61
mps_fire.i
i
Definition: mps_fire.py:428
CollinearFitAtTM2::ParDyDz
Definition: CollinearFitAtTM.h:21
CollinearFitAtTM2::parameters_
ResultVector parameters_
Definition: CollinearFitAtTM.h:65
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
LocalTrajectoryError::matrix
const AlgebraicSymMatrix55 & matrix() const
Definition: LocalTrajectoryError.h:60
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
CollinearFitAtTM2::ParQpIn
Definition: CollinearFitAtTM.h:21
CollinearFitAtTM2::ParQpOut
Definition: CollinearFitAtTM.h:21
TrajectoryMeasurement::backwardPredictedState
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
Definition: TrajectoryMeasurement.h:179
TrajectoryMeasurement::forwardPredictedState
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: TrajectoryMeasurement.h:177
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
CollinearFitAtTM2::valid_
bool valid_
Definition: CollinearFitAtTM.h:64
LocalTrajectoryParameters::vector
AlgebraicVector5 vector() const
Definition: LocalTrajectoryParameters.h:120
Point3DBase< float, LocalTag >
TrajectoryStateOnSurface::localParameters
const LocalTrajectoryParameters & localParameters() const
Definition: TrajectoryStateOnSurface.h:73
CollinearFitAtTM2::chi2_
double chi2_
Definition: CollinearFitAtTM.h:67
CollinearFitAtTM2::ParDxDz
Definition: CollinearFitAtTM.h:21
CollinearFitAtTM2::ndof_
int ndof_
Definition: CollinearFitAtTM.h:68
LocalError
Definition: LocalError.h:12
CollinearFitAtTM2::ParY
Definition: CollinearFitAtTM.h:21
AlgebraicVector5
ROOT::Math::SVector< double, 5 > AlgebraicVector5
Definition: AlgebraicROOTObjects.h:14
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
CollinearFitAtTM2::ParX
Definition: CollinearFitAtTM.h:21
CollinearFitAtTM2::covariance_
ResultMatrix covariance_
Definition: CollinearFitAtTM.h:66
CollinearFitAtTM2::projectedMeasurements_
ROOT::Math::SVector< double, 6 > projectedMeasurements_
Definition: CollinearFitAtTM.h:61
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
CollinearFitAtTM2::initJacobian
void initJacobian()
initialise the jacobian
Definition: CollinearFitAtTM.cc:46
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
CollinearFitAtTM2::measurements_
ROOT::Math::SVector< double, 12 > measurements_
Definition: CollinearFitAtTM.h:59
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
CollinearFitAtTM2::weightMatrix_
ROOT::Math::SMatrix< double, 12, 12, ROOT::Math::MatRepSym< double, 12 > > weightMatrix_
Definition: CollinearFitAtTM.h:60