CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  :
5  valid_(false),chi2_(-1),ndof_(-1) {
6  //
7  // check input
8  //
9  if ( !tm.forwardPredictedState().isValid() ||
11  !tm.updatedState().isValid() ) {
12  edm::LogWarning("CollinearFitAtTM2") << "Invalid state in TrajectoryMeasurement";
13  return;
14  }
15  //
16  // prepare fit
17  //
18  initJacobian();
23 
24  LocalPoint hitPos(0.,0.,0.);
25  LocalError hitErr(-1.,-1.,-1.);
26  if ( tm.recHit()->isValid() ) {
27  hitPos = tm.recHit()->localPosition();
28  hitErr = tm.recHit()->localPositionError();
29  }
30 
31  fit(fwdPar,fwdCov,bwdPar,bwdCov,hitPos,hitErr);
32 }
ConstRecHitPointer const & recHit() const
const LocalTrajectoryParameters & localParameters() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
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 &quot;true&quot; for success.
AlgebraicVector5 vector() const
const AlgebraicSymMatrix55 & matrix() const
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
ROOT::Math::SVector< double, 5 > AlgebraicVector5
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 34 of file CollinearFitAtTM.cc.

References fit(), and initJacobian().

39  :
40  valid_(false),chi2_(-1),ndof_(-1) {
41  //
42  // prepare fit
43  //
44  initJacobian();
45 
46  fit(fwdParameters,fwdCovariance,bwdParameters,bwdCovariance,hitPosition,hitErrors);
47 }
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 &quot;true&quot; 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_.

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

estimated deltaP (out-in) from fit parameters

Definition at line 131 of file CollinearFitAtTM.cc.

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

Referenced by GsfTrackProducerBase::computeModeAtTM().

131  {
132  //
133  // check validity
134  //
135  if ( !valid_ ) return Measurement1D();
136  //
137  // deltaP = 1/qpout - 1/qpin ; uncertainty from linear error propagation
138  //
139  double qpIn = parameters_(0);
140  double sig2In = covariance_(0,0);
141  double qpOut = parameters_(1);
142  double sig2Out = covariance_(1,1);
143  double corrInOut = covariance_(0,1);
144  double pIn = 1./fabs(qpIn);
145  double pOut = 1./fabs(qpOut);
146  double sig2DeltaP = pIn/qpIn*pIn/qpIn*sig2In - 2*pIn/qpIn*pOut/qpOut*corrInOut +
147  pOut/qpOut*pOut/qpOut*sig2Out;
148 
149  return Measurement1D(pOut-pIn,sig2DeltaP?sqrt(sig2DeltaP):0.);
150 }
ResultVector parameters_
T sqrt(T t)
Definition: SSEVec.h:48
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 66 of file CollinearFitAtTM.cc.

References chi2_, covariance_, i, 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().

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

initialise the jacobian

Definition at line 50 of file CollinearFitAtTM.cc.

References i, j, jacobian_, ParQpIn, and ParQpOut.

Referenced by CollinearFitAtTM2().

51 {
52  //
53  // Jacobian
54  //
55  for ( int i=0; i<12; ++i ) {
56  for ( int j=0; j<6; ++j ) jacobian_(i,j) = 0;
57  }
58  for ( int i=1; i<5; ++i ) {
60  }
61  jacobian_(0,ParQpIn) = 1.;
62  jacobian_(5,ParQpOut) = 1.;
63 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
ROOT::Math::SMatrix< double, 12, 6 > jacobian_
int CollinearFitAtTM2::ndof ( ) 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 66 of file CollinearFitAtTM.h.

Referenced by chi2(), and fit().

ResultMatrix CollinearFitAtTM2::covariance_
private

Definition at line 65 of file CollinearFitAtTM.h.

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

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

Definition at line 57 of file CollinearFitAtTM.h.

Referenced by fit(), and initJacobian().

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

Definition at line 58 of file CollinearFitAtTM.h.

Referenced by fit().

int CollinearFitAtTM2::ndof_
private

Definition at line 67 of file CollinearFitAtTM.h.

Referenced by fit(), and ndof().

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

Definition at line 60 of file CollinearFitAtTM.h.

Referenced by fit().

bool CollinearFitAtTM2::valid_
private

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

Referenced by fit().