CMS 3D CMS Logo

Functions
TrajectoryToResiduals.h File Reference
#include "DataFormats/TrackReco/interface/TrackResiduals.h"

Go to the source code of this file.

Functions

reco::TrackResiduals trajectoryToResiduals (const Trajectory &)
 

Function Documentation

◆ trajectoryToResiduals()

reco::TrackResiduals trajectoryToResiduals ( const Trajectory )

Definition at line 7 of file TrajectoryToResiduals.cc.

7  {
8  reco::TrackResiduals residuals;
9  residuals.resize(trajectory.measurements().size());
10  int i_residual = 0;
11  Trajectory::DataContainer::const_iterator i_fwd = trajectory.measurements().begin();
12  Trajectory::DataContainer::const_reverse_iterator i_bwd = trajectory.measurements().rbegin();
13  Trajectory::DataContainer::const_iterator i_end = trajectory.measurements().end();
14  Trajectory::DataContainer::const_reverse_iterator i_rend = trajectory.measurements().rend();
15  bool forward = trajectory.direction() == alongMomentum;
16  for (; forward ? i_fwd != i_end : i_bwd != i_rend; ++i_fwd, ++i_bwd, ++i_residual) {
17  const TrajectoryMeasurement *i = forward ? &*i_fwd : &*i_bwd;
18  if (!i->recHit()->isValid() || i->recHit()->det() == nullptr)
19  continue;
21  if (!i->forwardPredictedState().isValid() || !i->backwardPredictedState().isValid()) {
22  edm::LogError("InvalideState") << "one of the step is invalid";
23  continue;
24  }
25 
26  TrajectoryStateOnSurface &&combo = combine(i->forwardPredictedState(), i->backwardPredictedState());
27 
28  if (!combo.isValid()) {
29  edm::LogError("InvalideState") << "the combined state is invalid";
30  continue;
31  }
32 
33  LocalPoint &&combo_localpos = combo.localPosition();
34  LocalError &&combo_localerr = combo.localError().positionError();
35  LocalPoint &&dethit_localpos = i->recHit()->localPosition();
36  LocalError &&dethit_localerr = i->recHit()->localPositionError();
37  auto const &error_including_alignment = dethit_localerr; // align error nwo is included
38  {
39  auto x = (dethit_localpos.x() - combo_localpos.x());
40  auto y = (dethit_localpos.y() - combo_localpos.y());
41  residuals.setResidualXY(i_residual, x, y);
42  }
43  {
44  auto x =
45  (dethit_localpos.x() - combo_localpos.x()) / std::sqrt(error_including_alignment.xx() + combo_localerr.xx());
46  auto y =
47  (dethit_localpos.y() - combo_localpos.y()) / std::sqrt(error_including_alignment.yy() + combo_localerr.yy());
48  residuals.setPullXY(i_residual, x, y);
49  }
50  }
51  return residuals;
52 }

References alongMomentum, funct::combine(), Trajectory::direction(), mps_fire::i, TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localError(), TrajectoryStateOnSurface::localPosition(), Trajectory::measurements(), LocalTrajectoryError::positionError(), reco::TrackResiduals::resize(), reco::TrackResiduals::setPullXY(), reco::TrackResiduals::setResidualXY(), mathSSE::sqrt(), genVertex_cff::x, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by KfTrackProducerBase::putInEvt().

mps_fire.i
i
Definition: mps_fire.py:428
LocalTrajectoryError::positionError
LocalError positionError() const
Definition: LocalTrajectoryError.h:81
PV3DBase::x
T x() const
Definition: PV3DBase.h:59
reco::TrackResiduals::setPullXY
void setPullXY(int idx, float pullX, float pullY)
Definition: TrackResiduals.cc:34
reco::TrackResiduals
Definition: TrackResiduals.h:8
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
LocalError::xx
float xx() const
Definition: LocalError.h:22
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
Point3DBase< float, LocalTag >
TrajectoryStateCombiner
Definition: TrajectoryStateCombiner.h:13
TrajectoryStateOnSurface::localPosition
LocalPoint localPosition() const
Definition: TrajectoryStateOnSurface.h:74
funct::combine
static type combine(const A &_1, const B &_2)
Definition: Factorize.h:176
LocalError
Definition: LocalError.h:12
PV3DBase::y
T y() const
Definition: PV3DBase.h:60
edm::LogError
Log< level::Error, false > LogError
Definition: MessageLogger.h:123
reco::TrackResiduals::setResidualXY
void setResidualXY(int idx, float residualX, float residualY)
Definition: TrackResiduals.cc:30
reco::TrackResiduals::resize
void resize(unsigned int nHits)
Definition: TrackResiduals.h:14
genVertex_cff.x
x
Definition: genVertex_cff.py:12
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
TrajectoryStateOnSurface::localError
const LocalTrajectoryError & localError() const
Definition: TrajectoryStateOnSurface.h:77
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
LocalError::yy
float yy() const
Definition: LocalError.h:24
alongMomentum
Definition: PropagationDirection.h:4
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54