CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions
DualKalmanTrajectory Class Reference

#include <DualKalmanTrajectory.h>

Inheritance diagram for DualKalmanTrajectory:
ReferenceTrajectoryBase ReferenceCounted

Public Member Functions

virtual DualKalmanTrajectoryclone () const
 
 DualKalmanTrajectory (const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &forwardRecHitNums, const std::vector< unsigned int > &backwardRecHitNums, const MagneticField *magField, MaterialEffects materialEffects, PropagationDirection propDir, double mass, bool useBeamSpot, const reco::BeamSpot &beamSpot, int residualMethod)
 
virtual ~DualKalmanTrajectory ()
 
- Public Member Functions inherited from ReferenceTrajectoryBase
const AlgebraicMatrixderivatives () const
 
bool isValid ()
 
const AlgebraicMatrixlocalToTrajectory () const
 
const AlgebraicSymMatrixmeasurementErrors () const
 
const AlgebraicVectormeasurements () const
 
unsigned int numberOfHitMeas () const
 
unsigned int numberOfHits () const
 
unsigned int numberOfPar () const
 
unsigned int numberOfVirtualMeas () const
 
unsigned int numberOfVirtualPar () const
 
const AlgebraicSymMatrixparameterErrors () const
 
bool parameterErrorsAvailable () const
 
const AlgebraicVectorparameters () const
 
const
TransientTrackingRecHit::ConstRecHitContainer
recHits () const
 
void setParameterErrors (const AlgebraicSymMatrix &error)
 
const AlgebraicSymMatrixtrajectoryPositionErrors () const
 
const AlgebraicVectortrajectoryPositions () const
 
const std::vector
< TrajectoryStateOnSurface > & 
trajectoryStates () const
 
const AlgebraicMatrixtrajectoryToCurv () const
 
virtual ~ReferenceTrajectoryBase ()
 

Protected Member Functions

virtual bool construct (const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &forwardRecHitNums, const std::vector< unsigned int > &backwardRecHitNums, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField, bool useBeamSpot, const reco::BeamSpot &beamSpot, int residualMethod)
 calculate members More...
 
virtual ReferenceTrajectoryconstruct (const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &recHits, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField, bool useBeamSpot, const reco::BeamSpot &beamSpot) const
 Method to get a single ReferenceTrajectory for a half of the trajectory. More...
 
 DualKalmanTrajectory (unsigned int nPar=0, unsigned int nHits=0)
 
virtual AlgebraicVector extractParameters (const TrajectoryStateOnSurface &referenceTsos) const
 
bool fillKalmanPart (const Trajectory::DataContainer &trajMeasurements, const std::vector< unsigned int > &recHitNums, bool startFirst, unsigned int iNextHit, int residualMethod)
 Fill that part of data members that is different from DualReferenceTrajectory. More...
 
TrajectoryStateOnSurface fillMeasurementAndError1 (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr, unsigned int iHit, const TrajectoryMeasurement &trajMeasurement)
 helper for 'unbiased residual' method (i.e. returns merged fwd/bwd states) More...
 
TrajectoryStateOnSurface fillMeasurementAndError2 (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr, unsigned int iHit, const TrajectoryMeasurement &trajMeasurement, bool doPull)
 
void fillTrajectoryPositions (const AlgebraicMatrix &projection, const TrajectoryStateOnSurface &tsos, unsigned int iHit)
 fill trajectoryPositions More...
 
LocalError hitErrorWithAPE (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
 local error including APE if APE is on More...
 
const PropagationDirection oppositeDirection (const PropagationDirection propDir) const
 
- Protected Member Functions inherited from ReferenceTrajectoryBase
unsigned int numberOfUsedRecHits (const TransientTrackingRecHit::ConstRecHitContainer &recHits) const
 
 ReferenceTrajectoryBase (unsigned int nPar, unsigned int nHits, unsigned int nVirtualPar, unsigned int nVirtualMeas)
 
bool useRecHit (const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
 

Additional Inherited Members

- Public Types inherited from ReferenceTrajectoryBase
enum  MaterialEffects {
  none, multipleScattering, energyLoss, combined,
  breakPoints, brokenLinesCoarse, brokenLinesFine
}
 
typedef
ReferenceCountingPointer
< ReferenceTrajectoryBase
ReferenceTrajectoryPtr
 
- Protected Attributes inherited from ReferenceTrajectoryBase
AlgebraicMatrix theDerivatives
 
AlgebraicMatrix theInnerLocalToTrajectory
 
AlgebraicMatrix theInnerTrajectoryToCurvilinear
 
AlgebraicVector theMeasurements
 
AlgebraicSymMatrix theMeasurementsCov
 
unsigned int theNumberOfHits
 
unsigned int theNumberOfPars
 
unsigned int theNumberOfVirtualMeas
 
unsigned int theNumberOfVirtualPars
 
bool theParamCovFlag
 
AlgebraicSymMatrix theParameterCov
 
AlgebraicVector theParameters
 
TransientTrackingRecHit::ConstRecHitContainer theRecHits
 
AlgebraicSymMatrix theTrajectoryPositionCov
 
AlgebraicVector theTrajectoryPositions
 
std::vector
< TrajectoryStateOnSurface
theTsosVec
 
bool theValidityFlag
 
- Static Protected Attributes inherited from ReferenceTrajectoryBase
static const unsigned int nMeasPerHit = 2
 

Detailed Description

A trajectory that provides derivatives w.r.t. to the track parameters as the DualReferenceTrajectory, i.e. extrapolating a helix with five parameters from the hit in the middle. But measurements, trajectory positions and uncertainties are taken from the Kalman track fit. More precisely, the uncertainties are those of the residuals, i.e. of measurements() - trajectoryPositions().

Currently three methods to set residual and error can be choosen via cfg: 0: the hitError approach, i.e. residual w.r.t. updated state, but error from hit 1: the unbiased residal approach as in validation 2: the pull approach, i.e. residal w.r.t. to updated state withits error

Author
: Gero Flucke date : October 2008
Revision:
1.5
Date:
2010/09/10 13:08:05

(last update by

Author:
mussgill

)

Author
: Gero Flucke date : October 2008
Revision:
1.6
Date:
2010/09/10 13:09:00

(last update by

Author:
mussgill

)

Definition at line 34 of file DualKalmanTrajectory.h.

Constructor & Destructor Documentation

DualKalmanTrajectory::DualKalmanTrajectory ( const Trajectory::DataContainer trajMeasurements,
const TrajectoryStateOnSurface referenceTsos,
const std::vector< unsigned int > &  forwardRecHitNums,
const std::vector< unsigned int > &  backwardRecHitNums,
const MagneticField magField,
MaterialEffects  materialEffects,
PropagationDirection  propDir,
double  mass,
bool  useBeamSpot,
const reco::BeamSpot beamSpot,
int  residualMethod 
)

Definition at line 33 of file DualKalmanTrajectory.cc.

References construct(), and ReferenceTrajectoryBase::theValidityFlag.

Referenced by clone().

44  forwardRecHitNums.size() + backwardRecHitNums.size() - 1, 0, 0)
45 {
46  theValidityFlag = this->construct(trajMeasurements, referenceTsos,
47  forwardRecHitNums, backwardRecHitNums,
48  mass, materialEffects, propDir, magField,
49  useBeamSpot, beamSpot, residualMethod);
50 }
const LocalTrajectoryParameters & localParameters() const
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nVirtualPar, unsigned int nVirtualMeas)
virtual bool construct(const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &forwardRecHitNums, const std::vector< unsigned int > &backwardRecHitNums, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField, bool useBeamSpot, const reco::BeamSpot &beamSpot, int residualMethod)
calculate members
AlgebraicVector5 mixedFormatVector() const
tuple mass
Definition: scaleCards.py:27
virtual DualKalmanTrajectory::~DualKalmanTrajectory ( )
inlinevirtual

Definition at line 51 of file DualKalmanTrajectory.h.

51 {}
DualKalmanTrajectory::DualKalmanTrajectory ( unsigned int  nPar = 0,
unsigned int  nHits = 0 
)
protected

Definition at line 55 of file DualKalmanTrajectory.cc.

56  : ReferenceTrajectoryBase(nPar, nHits, 0, 0)
57 {}
ReferenceTrajectoryBase(unsigned int nPar, unsigned int nHits, unsigned int nVirtualPar, unsigned int nVirtualMeas)

Member Function Documentation

virtual DualKalmanTrajectory* DualKalmanTrajectory::clone ( void  ) const
inlinevirtual

Implements ReferenceTrajectoryBase.

Definition at line 53 of file DualKalmanTrajectory.h.

References DualKalmanTrajectory().

53 { return new DualKalmanTrajectory(*this); }
DualKalmanTrajectory(const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &forwardRecHitNums, const std::vector< unsigned int > &backwardRecHitNums, const MagneticField *magField, MaterialEffects materialEffects, PropagationDirection propDir, double mass, bool useBeamSpot, const reco::BeamSpot &beamSpot, int residualMethod)
bool DualKalmanTrajectory::construct ( const Trajectory::DataContainer trajMeasurements,
const TrajectoryStateOnSurface referenceTsos,
const std::vector< unsigned int > &  forwardRecHitNums,
const std::vector< unsigned int > &  backwardRecHitNums,
double  mass,
MaterialEffects  materialEffects,
const PropagationDirection  propDir,
const MagneticField magField,
bool  useBeamSpot,
const reco::BeamSpot beamSpot,
int  residualMethod 
)
protectedvirtual

calculate members

Definition at line 61 of file DualKalmanTrajectory.cc.

References extractParameters(), fillKalmanPart(), TrajectoryStateOnSurface::hasError(), TrajectoryStateOnSurface::localError(), LocalTrajectoryError::matrix(), ReferenceTrajectoryBase::nMeasPerHit, oppositeDirection(), ReferenceTrajectoryBase::theDerivatives, ReferenceTrajectoryBase::theParameters, ReferenceTrajectoryBase::theRecHits, and ReferenceTrajectoryBase::theTrajectoryPositionCov.

Referenced by DualKalmanTrajectory().

70 {
71 
72  ReferenceTrajectoryPtr fwdTraj = this->construct(trajMeasurements, refTsos, forwardRecHitNums,
73  mass, materialEffects,
74  propDir, magField, useBeamSpot, beamSpot);
75 
76  ReferenceTrajectoryPtr bwdTraj = this->construct(trajMeasurements, refTsos, backwardRecHitNums,
77  mass, materialEffects,
78  this->oppositeDirection(propDir), magField,
79  useBeamSpot, beamSpot);
80 
81  // edm::LogError("Alignment") << "@SUB=DualKalmanTrajectory::construct"
82  // << "valid fwd/bwd " << fwdTraj->isValid()
83  // << "/" << bwdTraj->isValid();
84 
85  if (!fwdTraj->isValid() || !bwdTraj->isValid()) {
86  return false;
87  }
88 
89  //
90  // Combine both reference trajactories to a dual reference trajectory
91  //
92 
93 // const std::vector<TrajectoryStateOnSurface>& fwdTsosVec = fwdTraj->trajectoryStates();
94 // const std::vector<TrajectoryStateOnSurface>& bwdTsosVec = bwdTraj->trajectoryStates();
95 // theTsosVec.insert( theTsosVec.end(), fwdTsosVec.begin(), fwdTsosVec.end() );
96 // theTsosVec.insert( theTsosVec.end(), ++bwdTsosVec.begin(), bwdTsosVec.end() );
97 
98  // Take hits as they come from the Kalman fit.
99  const ConstRecHitContainer &fwdRecHits = fwdTraj->recHits();
100  const ConstRecHitContainer &bwdRecHits = bwdTraj->recHits();
101  theRecHits.insert(theRecHits.end(), fwdRecHits.begin(), fwdRecHits.end());
102  theRecHits.insert(theRecHits.end(), ++bwdRecHits.begin(), bwdRecHits.end());
103 
104  theParameters = this->extractParameters(refTsos);
105 
106  unsigned int nParam = theParameters.num_row();
107  unsigned int nFwdMeas = nMeasPerHit * fwdTraj->numberOfHits();
108  unsigned int nBwdMeas = nMeasPerHit * bwdTraj->numberOfHits();
109 
110 // theMeasurements.sub( 1, fwdTraj->measurements() );
111 // theMeasurements.sub( nFwdMeas+1, bwdTraj->measurements().sub( nMeasPerHit+1, nBwdMeas ) );
112 
113 // theMeasurementsCov.sub( 1, fwdTraj->measurementErrors() );
114 // theMeasurementsCov.sub( nFwdMeas+1, bwdTraj->measurementErrors().sub( nMeasPerHit+1, nBwdMeas ) );
115 
116 // theTrajectoryPositions.sub( 1, fwdTraj->trajectoryPositions() );
117 // theTrajectoryPositions.sub( nFwdMeas+1, bwdTraj->trajectoryPositions().sub( nMeasPerHit+1, nBwdMeas ) );
118 
119 // theTrajectoryPositionCov.sub( 1, fwdTraj->trajectoryPositionErrors() );
120 // theTrajectoryPositionCov.sub( nFwdMeas+1, bwdTraj->trajectoryPositionErrors().sub( nMeasPerHit+1, nBwdMeas ) );
121 
122  theDerivatives.sub(1, 1, fwdTraj->derivatives());
123  theDerivatives.sub(nFwdMeas+1, 1,
124  bwdTraj->derivatives().sub(nMeasPerHit+1, nBwdMeas, 1, nParam));
125 
126  // FIXME: next lines stolen from ReferenceTrajectory, no idea whether OK or not...
127  if (refTsos.hasError()) {
128  AlgebraicSymMatrix parameterCov = asHepMatrix<5>(refTsos.localError().matrix());
129  theTrajectoryPositionCov = parameterCov.similarity(theDerivatives);
130  } else {
131  theTrajectoryPositionCov = AlgebraicSymMatrix(theDerivatives.num_row(), 1);
132  }
133 
134  // Fill Kalman part, first for forward, then for backward part.
135  return this->fillKalmanPart(trajMeasurements, forwardRecHitNums, true, 0, residualMethod)
136  && this->fillKalmanPart(trajMeasurements, backwardRecHitNums, false,
137  forwardRecHitNums.size(), residualMethod);
138 }
const PropagationDirection oppositeDirection(const PropagationDirection propDir) const
ReferenceCountingPointer< ReferenceTrajectoryBase > ReferenceTrajectoryPtr
bool fillKalmanPart(const Trajectory::DataContainer &trajMeasurements, const std::vector< unsigned int > &recHitNums, bool startFirst, unsigned int iNextHit, int residualMethod)
Fill that part of data members that is different from DualReferenceTrajectory.
virtual AlgebraicVector extractParameters(const TrajectoryStateOnSurface &referenceTsos) const
static const unsigned int nMeasPerHit
AlgebraicSymMatrix theTrajectoryPositionCov
TransientTrackingRecHit::ConstRecHitContainer theRecHits
virtual bool construct(const Trajectory::DataContainer &trajMeasurements, const TrajectoryStateOnSurface &referenceTsos, const std::vector< unsigned int > &forwardRecHitNums, const std::vector< unsigned int > &backwardRecHitNums, double mass, MaterialEffects materialEffects, const PropagationDirection propDir, const MagneticField *magField, bool useBeamSpot, const reco::BeamSpot &beamSpot, int residualMethod)
calculate members
tuple mass
Definition: scaleCards.py:27
CLHEP::HepSymMatrix AlgebraicSymMatrix
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
ReferenceTrajectory * DualKalmanTrajectory::construct ( const Trajectory::DataContainer trajMeasurements,
const TrajectoryStateOnSurface referenceTsos,
const std::vector< unsigned int > &  recHits,
double  mass,
MaterialEffects  materialEffects,
const PropagationDirection  propDir,
const MagneticField magField,
bool  useBeamSpot,
const reco::BeamSpot beamSpot 
) const
protectedvirtual

Method to get a single ReferenceTrajectory for a half of the trajectory.

Definition at line 143 of file DualKalmanTrajectory.cc.

References i, and ReferenceTrajectoryBase::recHits().

150 {
151 
153  recHits.reserve(recHitNums.size());
154  for (unsigned int i = 0; i < recHitNums.size(); ++i) {
155  recHits.push_back(trajMeasurements[recHitNums[i]].recHit());
156  }
157 
158  return new ReferenceTrajectory(referenceTsos, recHits, false, // hits are already ordered
159  magField, materialEffects, propDir, mass,
160  useBeamSpot, beamSpot);
161 }
int i
Definition: DBlmapReader.cc:9
const TransientTrackingRecHit::ConstRecHitContainer & recHits() const
tuple mass
Definition: scaleCards.py:27
TransientTrackingRecHit::ConstRecHitContainer ConstRecHitContainer
AlgebraicVector DualKalmanTrajectory::extractParameters ( const TrajectoryStateOnSurface referenceTsos) const
protectedvirtual

Definition at line 329 of file DualKalmanTrajectory.cc.

References TrajectoryStateOnSurface::localParameters(), and LocalTrajectoryParameters::mixedFormatVector().

Referenced by construct().

330 {
331  return asHepVector<5>( referenceTsos.localParameters().mixedFormatVector() );
332 }
const LocalTrajectoryParameters & localParameters() const
AlgebraicVector5 mixedFormatVector() const
bool DualKalmanTrajectory::fillKalmanPart ( const Trajectory::DataContainer trajMeasurements,
const std::vector< unsigned int > &  recHitNums,
bool  startFirst,
unsigned int  iNextHit,
int  residualMethod 
)
protected

Fill that part of data members that is different from DualReferenceTrajectory.

Definition at line 164 of file DualKalmanTrajectory.cc.

References edm::hlt::Exception, fillMeasurementAndError1(), fillMeasurementAndError2(), fillTrajectoryPositions(), TrajectoryStateOnSurface::isValid(), TrajectoryMeasurement::recHit(), and ReferenceTrajectoryBase::theTsosVec.

Referenced by construct().

168 {
169  // startFirst==false: skip first hit of recHitNums
170  // iNextHit: first hit number to fill data members with
171  //
172  // Three approaches, choosen by 'residualMethod':
173  // 0: Just take hit error and the updated state as millepede needs it to redo the last fit step.
174  // 1: Use the unbiased residuals as for residual monitoring.
175  // 2: Use the _updated_ state and calculate the sigma that is part of
176  // the pull as sqrt(sigma_hit^2 - sigma_tsos^2).
177  // This should lead to the pull as defined on p. 236 of Blobel's book.
178  // Not sure whether this is 100% applicable/correct here, at least it might lead to
179  // numerical instabilities, cf.:
180  // https://hypernews.cern.ch/HyperNews/CMS/get/recoTracking/517/1/1/1/1/1.html
181 
182  for (unsigned int iMeas = (startFirst ? 0 : 1); iMeas < recHitNums.size(); ++iMeas, ++iNextHit) {
183  const TrajectoryMeasurement &trajMeasurement = trajMeasurements[recHitNums[iMeas]];
184 
185  TrajectoryStateOnSurface tsos; // depends on method
186  switch (residualMethod) {
187  case 0:
188  tsos = this->fillMeasurementAndError2(trajMeasurement.recHit(), iNextHit, trajMeasurement,
189  false); // plain hit error, not pull
190  break;
191  case 1:
192  tsos = this->fillMeasurementAndError1(trajMeasurement.recHit(), iNextHit, trajMeasurement);
193  break;
194  case 2:
195  tsos = this->fillMeasurementAndError2(trajMeasurement.recHit(), iNextHit, trajMeasurement,
196  true); // error of pull
197  break;
198  default:
199  throw cms::Exception("BadConfig")
200  << "[DualKalmanTrajectory::fillKalmanPart] expect residualMethod == 0, 1 or 2, not "
201  << residualMethod << ".";
202  }
203 
204  if (!tsos.isValid()) return false;
205  theTsosVec.push_back(tsos);
206 
207  this->fillTrajectoryPositions(trajMeasurement.recHit()->projectionMatrix(),
208  tsos, iNextHit);
209  }
210 
211  return true;
212 }
void fillTrajectoryPositions(const AlgebraicMatrix &projection, const TrajectoryStateOnSurface &tsos, unsigned int iHit)
fill trajectoryPositions
TrajectoryStateOnSurface fillMeasurementAndError1(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr, unsigned int iHit, const TrajectoryMeasurement &trajMeasurement)
helper for &#39;unbiased residual&#39; method (i.e. returns merged fwd/bwd states)
ConstRecHitPointer recHit() const
TrajectoryStateOnSurface fillMeasurementAndError2(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr, unsigned int iHit, const TrajectoryMeasurement &trajMeasurement, bool doPull)
std::vector< TrajectoryStateOnSurface > theTsosVec
TrajectoryStateOnSurface DualKalmanTrajectory::fillMeasurementAndError1 ( const TransientTrackingRecHit::ConstRecHitPointer hitPtr,
unsigned int  iHit,
const TrajectoryMeasurement trajMeasurement 
)
protected

helper for 'unbiased residual' method (i.e. returns merged fwd/bwd states)

Definition at line 216 of file DualKalmanTrajectory.cc.

References TrajectoryMeasurement::backwardPredictedState(), TrajectoryMeasurement::forwardPredictedState(), hitErrorWithAPE(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), ReferenceTrajectoryBase::nMeasPerHit, LocalTrajectoryError::positionError(), ReferenceTrajectoryBase::theMeasurements, and ReferenceTrajectoryBase::theMeasurementsCov.

Referenced by fillKalmanPart().

219 {
220  // Get the measurements and their errors.
221  // We have to add error from hit and that tsos that is combination of fwd and bwd state.
222 
223  TrajectoryStateCombiner tsosComb;
224  const TrajectoryStateOnSurface tsos = tsosComb(trajMeasurement.forwardPredictedState(),
225  trajMeasurement.backwardPredictedState());
226  if (tsos.isValid()) {
227  // No update of hit with tsos: it comes already from fwd+bwd tsos combination.
228  // See also https://hypernews.cern.ch/HyperNews/CMS/get/recoTracking/517/1.html .
229  // ConstRecHitPointer newHitPtr(hitPtr->canImproveWithTrack() ? hitPtr->clone(tsos) : hitPtr);
230 
231  const LocalPoint localMeasurement(hitPtr->localPosition());
232  const LocalError hitErr(this->hitErrorWithAPE(hitPtr));
233  // tsos prediction includes APE of other hits:
234  const LocalError tsosErr(tsos.localError().positionError());
235  const LocalError localMeasurementCov(hitErr.xx() + tsosErr.xx(),
236  hitErr.xy() + tsosErr.xy(),
237  hitErr.yy() + tsosErr.yy());
238 
239  theMeasurements[nMeasPerHit*iHit] = localMeasurement.x();
240  theMeasurements[nMeasPerHit*iHit+1] = localMeasurement.y();
241  theMeasurementsCov[nMeasPerHit*iHit] [nMeasPerHit*iHit] = localMeasurementCov.xx();
242  theMeasurementsCov[nMeasPerHit*iHit] [nMeasPerHit*iHit+1] = localMeasurementCov.xy();
243  theMeasurementsCov[nMeasPerHit*iHit+1][nMeasPerHit*iHit+1] = localMeasurementCov.yy();
244  }
245 
246  return tsos;
247 }
TrajectoryStateOnSurface forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
static const unsigned int nMeasPerHit
LocalError positionError() const
const LocalTrajectoryError & localError() const
AlgebraicSymMatrix theMeasurementsCov
LocalError hitErrorWithAPE(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
local error including APE if APE is on
TrajectoryStateOnSurface backwardPredictedState() const
Access to backward predicted state (from smoother)
TrajectoryStateOnSurface DualKalmanTrajectory::fillMeasurementAndError2 ( const TransientTrackingRecHit::ConstRecHitPointer hitPtr,
unsigned int  iHit,
const TrajectoryMeasurement trajMeasurement,
bool  doPull 
)
protected

helper for 'pull' (doPull=true) or 'hitError' method (doPull=false), returns updated tsos in both cases

Definition at line 251 of file DualKalmanTrajectory.cc.

References hitErrorWithAPE(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), ReferenceTrajectoryBase::nMeasPerHit, LocalTrajectoryError::positionError(), mathSSE::sqrt(), ReferenceTrajectoryBase::theMeasurements, ReferenceTrajectoryBase::theMeasurementsCov, and TrajectoryMeasurement::updatedState().

Referenced by fillKalmanPart().

255 {
256  // Get the measurements and their errors.
257  // We have to subtract error of updated tsos from hit.
258 
259  const TrajectoryStateOnSurface tsos = trajMeasurement.updatedState();
260  if (tsos.isValid()) {
261  // No further update of hit:
262  // - The Kalman fit used hitPtr as it comes here (besides APE, see below).
263  // - If the hit errors improve, we might get (rare) problems of negative diagonal elements, see below.
264  // ConstRecHitPointer newHitPtr(hitPtr->canImproveWithTrack() ? hitPtr->clone(tsos) : hitPtr);
265 
266  const LocalPoint localMeasurement(hitPtr->localPosition());
267  // Add APE manually to avoid that the hit error might be smaller than tsos error:
268  // - hit local errors are always without APE,
269  // - the tsos errors include APE since they come from track fit.
270  const LocalError hitErr(this->hitErrorWithAPE(hitPtr));
271 
272  LocalError localMeasurementCov(hitErr.xx(), hitErr.xy(), hitErr.yy());
273  if (doPull) {
274  const LocalError tsosErr(tsos.localError().positionError());
275  // Should not be possible to become negative if all is correct - see above.
276  if (hitErr.xx() < tsosErr.xx() || hitErr.yy() < tsosErr.yy()) {
277  edm::LogError("Alignment") << "@SUB=DualKalmanTrajectory::fillMeasurementAndError2"
278  << "not OK in subdet " << hitPtr->geographicalId().subdetId()
279  << "\ns_x " << sqrt(hitErr.xx()) << " " << sqrt(tsosErr.xx())
280  << "\ns_xy " << hitErr.xy() << " " << tsosErr.xy()
281  << "\ns_y " << sqrt(hitErr.yy()) << " " << sqrt(tsosErr.yy());
282  return TrajectoryStateOnSurface(); // is invalid state
283  }
284  // cf. Blobel/Lohrmann, p. 236:
285  // But numerical stability? Should we return false if difference very small compared to values?
286  localMeasurementCov = LocalError(hitErr.xx() - tsosErr.xx(), // tsos puts correlation in,
287  hitErr.xy() - tsosErr.xy(), // even for 1D strip!
288  hitErr.yy() - tsosErr.yy());
289  }
290 
291  theMeasurements[nMeasPerHit*iHit] = localMeasurement.x();
292  theMeasurements[nMeasPerHit*iHit+1] = localMeasurement.y();
293  theMeasurementsCov[nMeasPerHit*iHit] [nMeasPerHit*iHit] = localMeasurementCov.xx();
294  theMeasurementsCov[nMeasPerHit*iHit] [nMeasPerHit*iHit+1] = localMeasurementCov.xy();
295  theMeasurementsCov[nMeasPerHit*iHit+1][nMeasPerHit*iHit+1] = localMeasurementCov.yy();
296  }
297 
298  return tsos;
299 }
static const unsigned int nMeasPerHit
LocalError positionError() const
T sqrt(T t)
Definition: SSEVec.h:46
TrajectoryStateOnSurface updatedState() const
const LocalTrajectoryError & localError() const
AlgebraicSymMatrix theMeasurementsCov
LocalError hitErrorWithAPE(const TransientTrackingRecHit::ConstRecHitPointer &hitPtr) const
local error including APE if APE is on
void DualKalmanTrajectory::fillTrajectoryPositions ( const AlgebraicMatrix projection,
const TrajectoryStateOnSurface tsos,
unsigned int  iHit 
)
protected

fill trajectoryPositions

Definition at line 302 of file DualKalmanTrajectory.cc.

References TrajectoryStateOnSurface::localParameters(), LocalTrajectoryParameters::mixedFormatVector(), ReferenceTrajectoryBase::nMeasPerHit, and ReferenceTrajectoryBase::theTrajectoryPositions.

Referenced by fillKalmanPart().

305 {
306  // get the local coordinates of the reference trajectory
307  // (~copied from ReferenceTrajectory::fillTrajectoryPositions)
308  AlgebraicVector mixedLocalParams = asHepVector<5>(tsos.localParameters().mixedFormatVector());
309  const AlgebraicVector localPosition(projection * mixedLocalParams);
310 
311  theTrajectoryPositions[nMeasPerHit*iHit] = localPosition[0];
312  theTrajectoryPositions[nMeasPerHit*iHit+1] = localPosition[1];
313 }
const LocalTrajectoryParameters & localParameters() const
static const unsigned int nMeasPerHit
CLHEP::HepVector AlgebraicVector
AlgebraicVector5 mixedFormatVector() const
LocalError DualKalmanTrajectory::hitErrorWithAPE ( const TransientTrackingRecHit::ConstRecHitPointer hitPtr) const
protected

local error including APE if APE is on

Definition at line 316 of file DualKalmanTrajectory.cc.

References alignCSCRings::help, and HelpertRecHit2DLocalPos::parError().

Referenced by fillMeasurementAndError1(), and fillMeasurementAndError2().

317 {
318  if (hitPtr->det() && hitPtr->det()->alignmentPositionError()) {
320  const AlgebraicSymMatrix errMat(help.parError(hitPtr->localPositionError(), *(hitPtr->det())));
321  return LocalError(errMat[0][0], errMat[0][1], errMat[1][1]);
322  } else {
323  return hitPtr->localPositionError();
324  }
325 }
CLHEP::HepSymMatrix AlgebraicSymMatrix
static AlgebraicSymMatrix parError(const LocalError &le, const GeomDet &det)
const PropagationDirection DualKalmanTrajectory::oppositeDirection ( const PropagationDirection  propDir) const
inlineprotected

Definition at line 102 of file DualKalmanTrajectory.h.

References alongMomentum, anyDirection, and oppositeToMomentum.

Referenced by construct().