CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Private Attributes
CollinearFitAtTM 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

 CollinearFitAtTM ()
 
bool fit (const TrajectoryMeasurement &tm, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
 Fit for one TM. Return value "true" for success. More...
 
bool fit (const AlgebraicVector5 &fwdParameters, const AlgebraicSymMatrix55 &fwdCovariance, const AlgebraicVector5 &bwdParameters, const AlgebraicSymMatrix55 &bwdCovariance, const LocalPoint &hitPosition, const LocalError &hitErrors, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
 Fit with explicit input parameters. Return value "true" for success. More...
 

Private Attributes

ROOT::Math::SMatrix< double, 12, 6 > jacobian_
 
ROOT::Math::SVector< double, 12 > measurements_
 
ROOT::Math::SVector< double, 6 > projectedMeasurements_
 
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 17 of file CollinearFitAtTM.h.

Member Typedef Documentation

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

Definition at line 25 of file CollinearFitAtTM.h.

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

Definition at line 24 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 20 of file CollinearFitAtTM.h.

Constructor & Destructor Documentation

CollinearFitAtTM::CollinearFitAtTM ( )

Definition at line 4 of file CollinearFitAtTM.cc.

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

4  {
5  //
6  // Jacobian
7  //
8  for (int i = 0; i < 12; ++i) {
9  for (int j = 0; j < 6; ++j)
10  jacobian_(i, j) = 0;
11  }
12  for (int i = 1; i < 5; ++i) {
13  jacobian_(i, ParQpOut + i) = jacobian_(i + 5, ParQpOut + i) = 1;
14  }
15  jacobian_(0, ParQpIn) = 1.;
16  jacobian_(5, ParQpOut) = 1.;
17 }
ROOT::Math::SMatrix< double, 12, 6 > jacobian_

Member Function Documentation

bool CollinearFitAtTM::fit ( const TrajectoryMeasurement tm,
ResultVector parameters,
ResultMatrix covariance,
double &  chi2 
)

Fit for one TM. Return value "true" for success.

Definition at line 19 of file CollinearFitAtTM.cc.

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

Referenced by trackingPlots.Iteration::modules(), and PFGsfHelper::PFGsfHelper().

22  {
23  //
24  // check input
25  //
27  edm::LogWarning("CollinearFitAtTM") << "Invalid state in TrajectoryMeasurement";
28  return false;
29  }
30  //
31  // prepare fit
32  //
37 
38  LocalPoint hitPos(0., 0., 0.);
39  LocalError hitErr(-1., -1., -1.);
40  if (tm.recHit()->isValid()) {
41  hitPos = tm.recHit()->localPosition();
42  hitErr = tm.recHit()->localPositionError();
43  }
44 
45  return fit(fwdPar, fwdCov, bwdPar, bwdCov, hitPos, hitErr, parameters, covariance, chi2);
46 }
ConstRecHitPointer const & recHit() const
const LocalTrajectoryParameters & localParameters() const
bool fit(const TrajectoryMeasurement &tm, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
Fit for one TM. Return value &quot;true&quot; 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
TrajectoryStateOnSurface const & updatedState() const
Log< level::Warning, false > LogWarning
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)
bool CollinearFitAtTM::fit ( const AlgebraicVector5 fwdParameters,
const AlgebraicSymMatrix55 fwdCovariance,
const AlgebraicVector5 bwdParameters,
const AlgebraicSymMatrix55 bwdCovariance,
const LocalPoint hitPosition,
const LocalError hitErrors,
ResultVector parameters,
ResultMatrix covariance,
double &  chi2 
)

Fit with explicit input parameters. Return value "true" for success.

Definition at line 48 of file CollinearFitAtTM.cc.

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

Referenced by trackingPlots.Iteration::modules().

56  {
57  if (hitErr.xx() > 0)
58  jacobian_(10, ParX) = jacobian_(11, ParY) = 1;
59  else
60  jacobian_(10, ParX) = jacobian_(11, ParY) = 0;
61 
62  for (int i = 0; i < 12; ++i) {
63  for (int j = 0; j < 12; ++j)
64  weightMatrix_(i, j) = 0;
65  }
66 
67  for (int i = 0; i < 5; ++i)
68  measurements_(i) = fwdParameters(i);
69  weightMatrix_.Place_at(fwdCovariance, 0, 0);
70  for (int i = 0; i < 5; ++i)
71  measurements_(i + 5) = bwdParameters(i);
72  weightMatrix_.Place_at(bwdCovariance, 5, 5);
73  if (hitErr.xx() > 0) {
74  measurements_(10) = hitPos.x();
75  measurements_(11) = hitPos.y();
76  weightMatrix_(10, 10) = hitErr.xx();
77  weightMatrix_(10, 11) = weightMatrix_(11, 10) = hitErr.xy();
78  weightMatrix_(11, 11) = hitErr.yy();
79  } else {
80  measurements_(10) = measurements_(11) = 0.;
81  weightMatrix_(10, 10) = weightMatrix_(11, 11) = 1.;
82  weightMatrix_(10, 11) = weightMatrix_(11, 10) = 0.;
83  }
84  //
85  // invert covariance matrix
86  //
87  if (!weightMatrix_.Invert()) {
88  edm::LogWarning("CollinearFitAtTM") << "Inversion of input covariance matrix failed";
89  return false;
90  }
91 
92  //
93  projectedMeasurements_ = ROOT::Math::Transpose(jacobian_) * (weightMatrix_ * measurements_);
94  //
95  // Fitted parameters and covariance matrix
96  //
97  covariance = ROOT::Math::SimilarityT(jacobian_, weightMatrix_);
98  if (!covariance.Invert()) {
99  edm::LogWarning("CollinearFitAtTM") << "Inversion of resulting weight matrix failed";
100  return false;
101  }
102 
103  parameters = covariance * projectedMeasurements_;
104 
105  //
106  // chi2
107  //
108  chi2 =
109  ROOT::Math::Similarity(measurements_, weightMatrix_) - ROOT::Math::Similarity(projectedMeasurements_, covariance);
110 
111  return true;
112 }
ROOT::Math::SVector< double, 6 > projectedMeasurements_
ROOT::Math::SMatrix< double, 12, 12, ROOT::Math::MatRepSym< double, 12 > > weightMatrix_
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
ROOT::Math::SVector< double, 12 > measurements_
Log< level::Warning, false > LogWarning

Member Data Documentation

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

Definition at line 40 of file CollinearFitAtTM.h.

Referenced by CollinearFitAtTM(), and fit().

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

Definition at line 41 of file CollinearFitAtTM.h.

Referenced by fit().

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

Definition at line 43 of file CollinearFitAtTM.h.

Referenced by fit().

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

Definition at line 42 of file CollinearFitAtTM.h.

Referenced by fit().