CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 &, enum reco::TrackResiduals::ResidualType=reco::TrackResiduals::X_Y_PULLS)
 

Function Documentation

Definition at line 7 of file TrajectoryToResiduals.cc.

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

Referenced by KfTrackProducerBase::putInEvt().

9 {
10  reco::TrackResiduals residuals(type);
11  int i_residual = 0;
12  Trajectory::DataContainer::const_iterator i_fwd =
13  trajectory.measurements().begin();
14  Trajectory::DataContainer::const_reverse_iterator i_bwd =
15  trajectory.measurements().rbegin();
16  Trajectory::DataContainer::const_iterator i_end =
17  trajectory.measurements().end();
18  Trajectory::DataContainer::const_reverse_iterator i_rend =
19  trajectory.measurements().rend();
20  bool forward = trajectory.direction() == alongMomentum;
21  for (; forward ? i_fwd != i_end : i_bwd != i_rend;
22  ++i_fwd, ++i_bwd, ++i_residual) {
23  const TrajectoryMeasurement *i = forward ? &*i_fwd : &*i_bwd;
24  if (!i->recHit()->isValid()||i->recHit()->det()==0)
25  continue;
28  {
29  edm::LogError("InvalideState")<<"one of the step is invalid";
30  continue;
31  }
32 
35 
36  if (!combo.isValid()){
37  edm::LogError("InvalideState")<<"the combined state is invalid";
38  continue;
39  }
40 
41  LocalPoint && combo_localpos = combo.localPosition();
42  LocalError && combo_localerr = combo.localError().positionError();
43  LocalPoint && dethit_localpos = i->recHit()->localPosition();
44  LocalError && dethit_localerr = i->recHit()->localPositionError();
45  auto const & error_including_alignment = dethit_localerr; // align error nwo is included
46  switch (type) {
48  {
49  auto x = (dethit_localpos.x() - combo_localpos.x()) /
50  std::sqrt(error_including_alignment.xx());
51  auto y = (dethit_localpos.y() - combo_localpos.y()) /
52  std::sqrt(error_including_alignment.yy());
53  residuals.setResidualXY(i_residual, x, y);
54  break;
55  }
57  {
58  auto x = (dethit_localpos.x() - combo_localpos.x()) /
59  std::sqrt(error_including_alignment.xx() + combo_localerr.xx());
60  auto y = (dethit_localpos.y() - combo_localpos.y()) /
61  std::sqrt(error_including_alignment.yy() + combo_localerr.yy());
62  residuals.setPullXY(i_residual, x, y);
63  break;
64  }
65  default:
66  assert(0);
67  }
68  }
69  return residuals;
70 }
type
Definition: HCALResponse.h:21
int i
Definition: DBlmapReader.cc:9
float xx() const
Definition: LocalError.h:24
ConstRecHitPointer const & recHit() const
T y() const
Definition: PV3DBase.h:63
LocalError positionError() const
float yy() const
Definition: LocalError.h:26
T sqrt(T t)
Definition: SSEVec.h:48
static type combine(const A &_1, const B &_2)
Definition: Factorize.h:186
const LocalTrajectoryError & localError() const
TrajectoryStateOnSurface const & forwardPredictedState() const
Access to forward predicted state (from fitter or builder)
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
TrajectoryStateOnSurface const & backwardPredictedState() const
Access to backward predicted state (from smoother)