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.

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(), x, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), and LocalError::yy().

Referenced by KfTrackProducerBase::putInEvt().

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 }
const LocalTrajectoryError & localError() const
void setResidualXY(int idx, float residualX, float residualY)
Log< level::Error, false > LogError
LocalError positionError() const
void resize(unsigned int nHits)
float yy() const
Definition: LocalError.h:24
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
T sqrt(T t)
Definition: SSEVec.h:19
static type combine(const A &_1, const B &_2)
Definition: Factorize.h:176
void setPullXY(int idx, float pullX, float pullY)
float x
float xx() const
Definition: LocalError.h:22