CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

CollinearFitAtTM Class Reference

#include <CollinearFitAtTM.h>

List of all members.

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 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.
bool fit (const TrajectoryMeasurement &tm, ResultVector &parameters, ResultMatrix &covariance, double &chi2)
 Fit for one TM. Return value "true" for success.

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 i, j, jacobian_, ParQpIn, and ParQpOut.

{
  //
  // Jacobian
  //
  for ( int i=0; i<12; ++i ) {
    for ( int j=0; j<6; ++j )  jacobian_(i,j) = 0;
  }
  for ( int i=1; i<5; ++i ) {
    jacobian_(i,ParQpOut+i) = jacobian_(i+5,ParQpOut+i) = 1;
  }
  jacobian_(0,ParQpIn) = 1.;
  jacobian_(5,ParQpOut) = 1.;
}

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 20 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 PFGsfHelper::PFGsfHelper().

{
  //
  // check input
  //
  if ( !tm.forwardPredictedState().isValid() ||
       !tm.backwardPredictedState().isValid() ||
       !tm.updatedState().isValid() ) {
    edm::LogWarning("CollinearFitAtTM") << "Invalid state in TrajectoryMeasurement";
    return false;
  }
  //
  // prepare fit
  //
  AlgebraicVector5 fwdPar = tm.forwardPredictedState().localParameters().vector();
  AlgebraicSymMatrix55 fwdCov = tm.forwardPredictedState().localError().matrix();
  AlgebraicVector5 bwdPar = tm.backwardPredictedState().localParameters().vector();
  AlgebraicSymMatrix55 bwdCov = tm.backwardPredictedState().localError().matrix();

  LocalPoint hitPos(0.,0.,0.);
  LocalError hitErr(-1.,-1.,-1.);
  if ( tm.recHit()->isValid() ) {
    hitPos = tm.recHit()->localPosition();
    hitErr = tm.recHit()->localPositionError();
  }

  return fit(fwdPar,fwdCov,bwdPar,bwdCov,
             hitPos,hitErr,
             parameters,covariance,chi2);
}
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 55 of file CollinearFitAtTM.cc.

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

{

  if ( hitErr.xx()>0 )
    jacobian_(10,ParX) = jacobian_(11,ParY) = 1;
  else
    jacobian_(10,ParX) = jacobian_(11,ParY) = 0;

  for ( int i=0; i<12; ++i ) {
    for ( int j=0; j<12; ++j )  weightMatrix_(i,j) = 0;
  }

  for ( int i=0; i<5; ++i )  measurements_(i) = fwdParameters(i);
  weightMatrix_.Place_at(fwdCovariance,0,0);
  for ( int i=0; i<5; ++i )  measurements_(i+5) = bwdParameters(i);
  weightMatrix_.Place_at(bwdCovariance,5,5);
  if ( hitErr.xx()>0 ) {
    measurements_(10) = hitPos.x();
    measurements_(11) = hitPos.y();
    weightMatrix_(10,10) = hitErr.xx();
    weightMatrix_(10,11) = weightMatrix_(11,10) = hitErr.xy();
    weightMatrix_(11,11) = hitErr.yy();
  }
  else {
    measurements_(10) = measurements_(11) = 0.;
    weightMatrix_(10,10) = weightMatrix_(11,11) = 1.;
    weightMatrix_(10,11) = weightMatrix_(11,10) = 0.;
  }
  //
  // invert covariance matrix
  //
  if ( !weightMatrix_.Invert() ) {
    edm::LogWarning("CollinearFitAtTM") << "Inversion of input covariance matrix failed";
    return false;
  }

  //
  projectedMeasurements_ = ROOT::Math::Transpose(jacobian_)*(weightMatrix_*measurements_);
  //
  // Fitted parameters and covariance matrix
  // 
  covariance = ROOT::Math::SimilarityT(jacobian_,weightMatrix_);
  if ( !covariance.Invert() ) {
    edm::LogWarning("CollinearFitAtTM") << "Inversion of resulting weight matrix failed";
    return false;
  }

  parameters = covariance*projectedMeasurements_;

  //
  // chi2
  //
  chi2 = ROOT::Math::Similarity(measurements_,weightMatrix_) -
    ROOT::Math::Similarity(projectedMeasurements_,covariance);

  return true;
}

Member Data Documentation

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

Definition at line 41 of file CollinearFitAtTM.h.

Referenced by CollinearFitAtTM(), and fit().

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

Definition at line 42 of file CollinearFitAtTM.h.

Referenced by fit().

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

Definition at line 44 of file CollinearFitAtTM.h.

Referenced by fit().

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

Definition at line 43 of file CollinearFitAtTM.h.

Referenced by fit().