CMS 3D CMS Logo

ReferenceTrajectory Class Reference

#include <Alignment/ReferenceTrajectories/interface/ReferenceTrajectory.h>

Inheritance diagram for ReferenceTrajectory:

ReferenceTrajectoryBase ReferenceCounted BzeroReferenceTrajectory

List of all members.

Public Types

typedef
SurfaceSideDefinition::SurfaceSide 
SurfaceSide

Public Member Functions

virtual ReferenceTrajectoryclone () const
 ReferenceTrajectory (const TrajectoryStateOnSurface &referenceTsos, const TransientTrackingRecHit::ConstRecHitContainer &recHits, bool hitsAreReverse, const MagneticField *magField, MaterialEffects materialEffects=combined, PropagationDirection propDir=alongMomentum, double mass=0.10565836)
 Constructor with Tsos at first hit (in physical order) and list of hits [if (hitsAreReverse) ==> order of hits is in opposite direction compared to the flight of particle, but note that ReferenceTrajectory::recHits() returns the hits always in order of flight], the material effects to be considered and a particle mass, the magnetic field of the event is needed for propagations etc.
virtual ~ReferenceTrajectory ()

Protected Member Functions

virtual void addMaterialEffectsCov (const std::vector< AlgebraicMatrix > &allJacobians, const std::vector< AlgebraicMatrix > &allProjections, const std::vector< AlgebraicSymMatrix > &allCurvChanges, const std::vector< AlgebraicSymMatrix > &allDeltaParaCovs)
 internal method to add material effects to measurments covariance matrix
virtual bool construct (const TrajectoryStateOnSurface &referenceTsos, const TransientTrackingRecHit::ConstRecHitContainer &recHits, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField)
 internal method to calculate members
MaterialEffectsUpdatorcreateUpdator (MaterialEffects materialEffects, double mass) const
 internal method to get apropriate updator
virtual void fillDerivatives (const AlgebraicMatrix &projection, const AlgebraicMatrix &fullJacobian, unsigned int iRow)
 internal method to fill derivatives for hit iRow/2
virtual void fillMeasurementAndError (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr, unsigned int iRow, const TrajectoryStateOnSurface &updatedTsos)
 internal method to fill measurement and error matrix for hit iRow/2
virtual void fillTrajectoryPositions (const AlgebraicMatrix &projection, const AlgebraicVector &mixedLocalParams, unsigned int iRow)
 internal method to fill the trajectory positions for hit iRow/2
virtual bool propagate (const BoundPlane &previousSurface, const TrajectoryStateOnSurface &previousTsos, const BoundPlane &newSurface, TrajectoryStateOnSurface &newTsos, AlgebraicMatrix &newJacobian, const PropagationDirection propDir, const MagneticField *magField) const
 internal method to calculate jacobian
 ReferenceTrajectory (unsigned int nPar=0, unsigned int nHits=0)
const SurfaceSide surfaceSide (const PropagationDirection dir) const


Detailed Description

Definition at line 42 of file ReferenceTrajectory.h.


Member Typedef Documentation

typedef SurfaceSideDefinition::SurfaceSide ReferenceTrajectory::SurfaceSide

Definition at line 47 of file ReferenceTrajectory.h.


Constructor & Destructor Documentation

ReferenceTrajectory::ReferenceTrajectory ( const TrajectoryStateOnSurface referenceTsos,
const TransientTrackingRecHit::ConstRecHitContainer recHits,
bool  hitsAreReverse,
const MagneticField magField,
MaterialEffects  materialEffects = combined,
PropagationDirection  propDir = alongMomentum,
double  mass = 0.10565836 
)

Constructor with Tsos at first hit (in physical order) and list of hits [if (hitsAreReverse) ==> order of hits is in opposite direction compared to the flight of particle, but note that ReferenceTrajectory::recHits() returns the hits always in order of flight], the material effects to be considered and a particle mass, the magnetic field of the event is needed for propagations etc.

Definition at line 33 of file ReferenceTrajectory.cc.

References construct(), it, TrajectoryStateOnSurface::localParameters(), LocalTrajectoryParameters::mixedFormatVector(), ReferenceTrajectoryBase::theParameters, and ReferenceTrajectoryBase::theValidityFlag.

Referenced by clone().

00040   : ReferenceTrajectoryBase( refTsos.localParameters().mixedFormatVector().kSize,
00041                              numberOfUsedRecHits(recHits) )
00042 {
00043   // no check against magField == 0
00044 
00045   theParameters = asHepVector<5>( refTsos.localParameters().mixedFormatVector() );
00046 
00047   if (hitsAreReverse) {
00048     TransientTrackingRecHit::ConstRecHitContainer fwdRecHits;
00049     fwdRecHits.reserve(recHits.size());
00050     for (TransientTrackingRecHit::ConstRecHitContainer::const_reverse_iterator it=recHits.rbegin();
00051          it != recHits.rend(); ++it) {
00052       fwdRecHits.push_back(*it);
00053     }
00054     theValidityFlag = this->construct(refTsos, fwdRecHits, mass, materialEffects, propDir, magField);
00055   } else {
00056     theValidityFlag = this->construct(refTsos, recHits, mass, materialEffects, propDir, magField);
00057   }
00058 }

virtual ReferenceTrajectory::~ReferenceTrajectory (  )  [inline, virtual]

Definition at line 63 of file ReferenceTrajectory.h.

00063 {}

ReferenceTrajectory::ReferenceTrajectory ( unsigned int  nPar = 0,
unsigned int  nHits = 0 
) [protected]

Definition at line 63 of file ReferenceTrajectory.cc.

00064   : ReferenceTrajectoryBase( nPar, nHits )
00065 {}


Member Function Documentation

void ReferenceTrajectory::addMaterialEffectsCov ( const std::vector< AlgebraicMatrix > &  allJacobians,
const std::vector< AlgebraicMatrix > &  allProjections,
const std::vector< AlgebraicSymMatrix > &  allCurvChanges,
const std::vector< AlgebraicSymMatrix > &  allDeltaParaCovs 
) [protected, virtual]

internal method to add material effects to measurments covariance matrix

Definition at line 288 of file ReferenceTrajectory.cc.

References k, edm::es::l(), ReferenceTrajectoryBase::nMeasPerHit, and ReferenceTrajectoryBase::theMeasurementsCov.

Referenced by construct().

00292 {
00293   // the uncertainty due to multiple scattering is 'transferred' to the error matrix of the hits
00294 
00295   AlgebraicSymMatrix materialEffectsCov(nMeasPerHit * allJacobians.size(), 0);
00296 
00297   // additional covariance-matrix of the measurements due to material-effects (single measurement)
00298   AlgebraicSymMatrix deltaMaterialEffectsCov;
00299 
00300   // additional covariance-matrix of the parameters due to material-effects
00301   AlgebraicSymMatrix paramMaterialEffectsCov(allDeltaParameterCovs[0]); //initialization
00302 
00303   AlgebraicMatrix tempParameterCov;
00304   AlgebraicMatrix tempMeasurementCov;
00305 
00306   for (unsigned int k = 1; k < allJacobians.size(); ++k) {
00307     // error-propagation to next layer
00308     paramMaterialEffectsCov = paramMaterialEffectsCov.similarity(allJacobians[k]);
00309 
00310     // get dependences for the measurements
00311     deltaMaterialEffectsCov = paramMaterialEffectsCov.similarity(allProjections[k]);
00312     materialEffectsCov[nMeasPerHit*k  ][nMeasPerHit*k  ] = deltaMaterialEffectsCov[0][0];
00313     materialEffectsCov[nMeasPerHit*k  ][nMeasPerHit*k+1] = deltaMaterialEffectsCov[0][1];
00314     materialEffectsCov[nMeasPerHit*k+1][nMeasPerHit*k  ] = deltaMaterialEffectsCov[1][0];
00315     materialEffectsCov[nMeasPerHit*k+1][nMeasPerHit*k+1] = deltaMaterialEffectsCov[1][1];
00316 
00317     // add uncertainties for the following layers due to scattering at this layer
00318     paramMaterialEffectsCov += allDeltaParameterCovs[k];
00319 
00320     tempParameterCov = paramMaterialEffectsCov;
00321 
00322     // compute "inter-layer-dependencies"
00323     for (unsigned int l = k+1; l < allJacobians.size(); ++l) {
00324       tempParameterCov   = allJacobians[l]   * allCurvatureChanges[l] * tempParameterCov;
00325       tempMeasurementCov = allProjections[l] * tempParameterCov       * allProjections[k].T();
00326 
00327       materialEffectsCov[nMeasPerHit*l][nMeasPerHit*k] = tempMeasurementCov[0][0];
00328       materialEffectsCov[nMeasPerHit*k][nMeasPerHit*l] = tempMeasurementCov[0][0];
00329 
00330       materialEffectsCov[nMeasPerHit*l][nMeasPerHit*k+1] = tempMeasurementCov[0][1];
00331       materialEffectsCov[nMeasPerHit*k+1][nMeasPerHit*l] = tempMeasurementCov[0][1];
00332 
00333       materialEffectsCov[nMeasPerHit*l+1][nMeasPerHit*k] = tempMeasurementCov[1][0];
00334       materialEffectsCov[nMeasPerHit*k][nMeasPerHit*l+1] = tempMeasurementCov[1][0];
00335 
00336       materialEffectsCov[nMeasPerHit*l+1][nMeasPerHit*k+1] = tempMeasurementCov[1][1];
00337       materialEffectsCov[nMeasPerHit*k+1][nMeasPerHit*l+1] = tempMeasurementCov[1][1];
00338     }
00339 
00340     // error-propagation to state after energy loss
00341     paramMaterialEffectsCov = paramMaterialEffectsCov.similarity(allCurvatureChanges[k]);
00342   }
00343 
00344   theMeasurementsCov += materialEffectsCov;
00345 }

virtual ReferenceTrajectory* ReferenceTrajectory::clone ( void   )  const [inline, virtual]

Implements ReferenceTrajectoryBase.

Reimplemented in BzeroReferenceTrajectory.

Definition at line 65 of file ReferenceTrajectory.h.

References ReferenceTrajectory().

00065 { return new ReferenceTrajectory(*this); }

bool ReferenceTrajectory::construct ( const TrajectoryStateOnSurface referenceTsos,
const TransientTrackingRecHit::ConstRecHitContainer recHits,
double  mass,
MaterialEffects  materialEffects,
const PropagationDirection  propDir,
const MagneticField magField 
) [protected, virtual]

internal method to calculate members

Definition at line 70 of file ReferenceTrajectory.cc.

References addMaterialEffectsCov(), createUpdator(), fillDerivatives(), fillMeasurementAndError(), fillTrajectoryPositions(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localParameters(), LocalTrajectoryError::matrix(), ReferenceTrajectoryBase::nMeasPerHit, ReferenceTrajectoryBase::none, LocalTrajectoryParameters::signedInverseMomentum(), surfaceSide(), ReferenceTrajectoryBase::theDerivatives, ReferenceTrajectoryBase::theNumberOfHits, ReferenceTrajectoryBase::theParameters, ReferenceTrajectoryBase::theRecHits, ReferenceTrajectoryBase::theTrajectoryPositionCov, ReferenceTrajectoryBase::theTsosVec, MaterialEffectsUpdator::updateState(), and ReferenceTrajectoryBase::useRecHit().

Referenced by BzeroReferenceTrajectory::BzeroReferenceTrajectory(), and ReferenceTrajectory().

00074 {
00075   const SurfaceSide surfaceSide = this->surfaceSide(propDir);
00076   MaterialEffectsUpdator *aMaterialEffectsUpdator = this->createUpdator(materialEffects, mass);
00077   if (!aMaterialEffectsUpdator) return false;
00078 
00079   AlgebraicMatrix                 fullJacobian(theParameters.num_row(), theParameters.num_row());
00080   std::vector<AlgebraicMatrix>    allJacobians; 
00081   allJacobians.reserve(theNumberOfHits);
00082 
00083   TransientTrackingRecHit::ConstRecHitPointer  previousHitPtr;
00084   TrajectoryStateOnSurface                     previousTsos;
00085   AlgebraicSymMatrix              previousChangeInCurvature(theParameters.num_row(), 1);
00086   std::vector<AlgebraicSymMatrix> allCurvatureChanges; 
00087   allCurvatureChanges.reserve(theNumberOfHits);
00088 
00089   const LocalTrajectoryError zeroErrors(0., 0., 0., 0., 0.);
00090 
00091   std::vector<AlgebraicMatrix> allProjections;
00092   allProjections.reserve(theNumberOfHits);
00093   std::vector<AlgebraicSymMatrix> allDeltaParameterCovs;
00094   allDeltaParameterCovs.reserve(theNumberOfHits);
00095 
00096   unsigned int iRow = 0;
00097   TransientTrackingRecHit::ConstRecHitContainer::const_iterator itRecHit;
00098   for ( itRecHit = recHits.begin(); itRecHit != recHits.end(); ++itRecHit ) { 
00099 
00100     const TransientTrackingRecHit::ConstRecHitPointer &hitPtr = *itRecHit;
00101 
00102     if ( !useRecHit( hitPtr ) ) continue;
00103 
00104     theRecHits.push_back(hitPtr);
00105 
00106     if (0 == iRow) { 
00107       // compute the derivatives of the reference-track's parameters w.r.t. the initial ones
00108       // derivative of the initial reference-track parameters w.r.t. themselves is of course the identity 
00109       fullJacobian = AlgebraicMatrix(theParameters.num_row(), theParameters.num_row(), 1);
00110       allJacobians.push_back(fullJacobian);
00111       theTsosVec.push_back(refTsos);
00112     } else {
00113       AlgebraicMatrix nextJacobian;
00114       TrajectoryStateOnSurface nextTsos;
00115       if (!this->propagate(previousHitPtr->det()->surface(), previousTsos,
00116                            hitPtr->det()->surface(), nextTsos,
00117                            nextJacobian, propDir, magField)) {
00118         return false; // stop if problem...
00119       }
00120 
00121       allJacobians.push_back(nextJacobian);
00122       fullJacobian = nextJacobian * previousChangeInCurvature * fullJacobian;
00123       theTsosVec.push_back(nextTsos);
00124     }
00125 
00126     // take material effects into account. since trajectory-state is constructed with errors equal zero,
00127     // the updated state contains only the uncertainties due to interactions in the current layer.
00128     const TrajectoryStateOnSurface tmpTsos(theTsosVec.back().localParameters(), zeroErrors,
00129                                            theTsosVec.back().surface(), magField, surfaceSide);
00130     const TrajectoryStateOnSurface updatedTsos = aMaterialEffectsUpdator->updateState(tmpTsos, propDir);
00131 
00132     if ( !updatedTsos.isValid() ) return false;
00133 
00134     if ( theTsosVec.back().localParameters().charge() )
00135     {
00136       previousChangeInCurvature[0][0] = updatedTsos.localParameters().signedInverseMomentum() 
00137         / theTsosVec.back().localParameters().signedInverseMomentum();
00138     }
00139     
00140     // get multiple-scattering covariance-matrix
00141     allDeltaParameterCovs.push_back( asHepMatrix<5>(updatedTsos.localError().matrix()) );
00142 
00143     allCurvatureChanges.push_back(previousChangeInCurvature);
00144 
00145     // projection-matrix tsos-parameters -> measurement-coordinates
00146     allProjections.push_back(hitPtr->projectionMatrix());
00147 
00148     // set start-parameters for next propagation. trajectory-state without error
00149     //  - no error propagation needed here.
00150     previousHitPtr = hitPtr;
00151     previousTsos   = TrajectoryStateOnSurface(updatedTsos.globalParameters(),
00152                                               updatedTsos.surface(), surfaceSide);
00153 
00154     this->fillDerivatives(allProjections.back(), fullJacobian, iRow);
00155 
00156     AlgebraicVector mixedLocalParams = asHepVector<5>(theTsosVec.back().localParameters().mixedFormatVector());
00157     this->fillTrajectoryPositions(allProjections.back(), mixedLocalParams, iRow);
00158     this->fillMeasurementAndError(hitPtr, iRow, updatedTsos);
00159 
00160     iRow += nMeasPerHit;
00161   } // end of loop on hits
00162 
00163   if (materialEffects != none) {
00164     this->addMaterialEffectsCov(allJacobians, allProjections, allCurvatureChanges, allDeltaParameterCovs);
00165   }
00166 
00167   if (refTsos.hasError()) {
00168     AlgebraicSymMatrix parameterCov = asHepMatrix<5>(refTsos.localError().matrix());
00169     theTrajectoryPositionCov = parameterCov.similarity(theDerivatives);
00170   } else {
00171     theTrajectoryPositionCov = AlgebraicSymMatrix(theDerivatives.num_row(), 1);
00172   }
00173 
00174   delete aMaterialEffectsUpdator;
00175 
00176   return true;
00177 }

MaterialEffectsUpdator * ReferenceTrajectory::createUpdator ( MaterialEffects  materialEffects,
double  mass 
) const [protected]

internal method to get apropriate updator

Definition at line 182 of file ReferenceTrajectory.cc.

References ReferenceTrajectoryBase::combined, ReferenceTrajectoryBase::energyLoss, ReferenceTrajectoryBase::multipleScattering, and ReferenceTrajectoryBase::none.

Referenced by construct().

00183 {
00184   switch (materialEffects) {
00185     // MultipleScatteringUpdator doesn't change the trajectory-state
00186     // during update and can therefore be used if material effects should be ignored:
00187   case none:
00188   case multipleScattering: 
00189     return new MultipleScatteringUpdator(mass);
00190   case energyLoss:
00191     return new EnergyLossUpdator(mass);
00192   case combined:
00193     return new CombinedMaterialEffectsUpdator(mass);
00194   }
00195 
00196   return 0;
00197 }

void ReferenceTrajectory::fillDerivatives ( const AlgebraicMatrix projection,
const AlgebraicMatrix fullJacobian,
unsigned int  iRow 
) [protected, virtual]

internal method to fill derivatives for hit iRow/2

Definition at line 262 of file ReferenceTrajectory.cc.

References i, ReferenceTrajectoryBase::parameters(), and ReferenceTrajectoryBase::theDerivatives.

Referenced by construct().

00265 {
00266   // derivatives of the local coordinates of the reference track w.r.t. to the inital track-parameters
00267   const AlgebraicMatrix projectedJacobian(projection * fullJacobian);
00268   for (int i = 0; i < parameters().num_row(); ++i) {
00269     theDerivatives[iRow  ][i] = projectedJacobian[0][i];
00270     theDerivatives[iRow+1][i] = projectedJacobian[1][i];
00271   }
00272 }

void ReferenceTrajectory::fillMeasurementAndError ( const TransientTrackingRecHit::ConstRecHitPointer hitPtr,
unsigned int  iRow,
const TrajectoryStateOnSurface updatedTsos 
) [protected, virtual]

internal method to fill measurement and error matrix for hit iRow/2

Definition at line 240 of file ReferenceTrajectory.cc.

References ReferenceTrajectoryBase::theMeasurements, ReferenceTrajectoryBase::theMeasurementsCov, LocalError::xx(), LocalError::xy(), and LocalError::yy().

Referenced by construct().

00243 {
00244   // get the measurements and their errors, use information updated with tsos if improving
00245   // (GF: Also for measurements or only for errors or do the former not change?)
00246   TransientTrackingRecHit::ConstRecHitPointer newHitPtr(hitPtr->canImproveWithTrack() ?
00247                                                         hitPtr->clone(updatedTsos) : hitPtr);
00248 
00249   const LocalPoint localMeasurement    = newHitPtr->localPosition();
00250   const LocalError localMeasurementCov = newHitPtr->localPositionError();
00251 
00252   theMeasurements[iRow]   = localMeasurement.x();
00253   theMeasurements[iRow+1] = localMeasurement.y();
00254   theMeasurementsCov[iRow][iRow]     = localMeasurementCov.xx();
00255   theMeasurementsCov[iRow][iRow+1]   = localMeasurementCov.xy();
00256   theMeasurementsCov[iRow+1][iRow+1] = localMeasurementCov.yy();
00257 }

void ReferenceTrajectory::fillTrajectoryPositions ( const AlgebraicMatrix projection,
const AlgebraicVector mixedLocalParams,
unsigned int  iRow 
) [protected, virtual]

internal method to fill the trajectory positions for hit iRow/2

Definition at line 276 of file ReferenceTrajectory.cc.

References ReferenceTrajectoryBase::theTrajectoryPositions.

Referenced by construct().

00279 {
00280   // get the local coordinates of the reference trajectory
00281   const AlgebraicVector localPosition(projection * mixedLocalParams);
00282   theTrajectoryPositions[iRow] = localPosition[0];
00283   theTrajectoryPositions[iRow+1] = localPosition[1];
00284 }

bool ReferenceTrajectory::propagate ( const BoundPlane previousSurface,
const TrajectoryStateOnSurface previousTsos,
const BoundPlane newSurface,
TrajectoryStateOnSurface newTsos,
AlgebraicMatrix newJacobian,
const PropagationDirection  propDir,
const MagneticField magField 
) const [protected, virtual]

internal method to calculate jacobian

Definition at line 201 of file ReferenceTrajectory.cc.

References TrajectoryStateOnSurface::globalParameters(), TrajectoryStateOnSurface::localParameters(), and AnalyticalPropagator::propagateWithPath().

00204 {
00205   // propagate to next layer
00206   AnalyticalPropagator aPropagator(magField, propDir);
00207   const std::pair<TrajectoryStateOnSurface, double> tsosWithPath =
00208     aPropagator.propagateWithPath(previousTsos, newSurface);
00209 
00210   // stop if propagation wasn't successful
00211   if (!tsosWithPath.first.isValid())  return false;
00212 
00213   // calculate derivative of reference-track parameters on the actual layer w.r.t. the ones
00214   // on the previous layer (both in global coordinates)
00215   const AnalyticalCurvilinearJacobian aJacobian(previousTsos.globalParameters(), 
00216                                                 tsosWithPath.first.globalPosition(),
00217                                                 tsosWithPath.first.globalMomentum(),
00218                                                 tsosWithPath.second);
00219   const AlgebraicMatrix curvilinearJacobian = asHepMatrix<5,5>(aJacobian.jacobian());
00220 
00221 
00222   // jacobian of the track parameters on the previous layer for local->global transformation
00223   const JacobianLocalToCurvilinear startTrafo(previousSurface, previousTsos.localParameters(), *magField);
00224   const AlgebraicMatrix localToCurvilinear = asHepMatrix<5>(startTrafo.jacobian());
00225 
00226   // jacobian of the track parameters on the actual layer for global->local transformation
00227   const JacobianCurvilinearToLocal endTrafo(newSurface, tsosWithPath.first.localParameters(), *magField);
00228   const AlgebraicMatrix curvilinearToLocal = asHepMatrix<5>(endTrafo.jacobian());
00229 
00230   // compute derivative of reference-track parameters on the actual layer w.r.t. the ones on
00231   // the previous layer (both in their local representation)
00232   newJacobian = curvilinearToLocal * curvilinearJacobian * localToCurvilinear;
00233   newTsos     = tsosWithPath.first;
00234 
00235   return true;
00236 }

const SurfaceSide ReferenceTrajectory::surfaceSide ( const PropagationDirection  dir  )  const [inline, protected]

Definition at line 114 of file ReferenceTrajectory.h.

References SurfaceSideDefinition::afterSurface, alongMomentum, and SurfaceSideDefinition::beforeSurface.

Referenced by BzeroReferenceTrajectory::BzeroReferenceTrajectory(), and construct().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:30:42 2009 for CMSSW by  doxygen 1.5.4