CMS 3D CMS Logo

List of all members | Public Member Functions | Private Types | Private Member Functions | Private Attributes
RKPropagatorInS Class Referencefinal

#include <RKPropagatorInS.h>

Inheritance diagram for RKPropagatorInS:
Propagator

Public Member Functions

Propagatorclone () const override
 
const MagneticFieldmagneticField () const override
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const final
 
template<typename STA , typename SUR >
TrajectoryStateOnSurface propagate (STA const &state, SUR const &surface) const
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const final
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Cylinder &) const=0
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const
 Propagate to PCA to a line (given by beamSpot position and slope) given a starting point. More...
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const
 Propagate to PCA to a line (given by 2 points) given a starting point. More...
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Surface &) const final
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Cylinder &sur) const
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Surface &sur) const final
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Plane &) const=0
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Plane &sur) const
 
 RKPropagatorInS (const MagVolume &vol, PropagationDirection dir=alongMomentum, double tolerance=5.e-5)
 
 ~RKPropagatorInS () override
 
- Public Member Functions inherited from Propagator
template<typename STA , typename SUR >
TrajectoryStateOnSurface propagate (STA const &state, SUR const &surface) const
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const final
 
virtual FreeTrajectoryState propagate (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const final
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Surface &) const final
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Surface &sur) const final
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Plane &sur) const
 
virtual std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const TrajectoryStateOnSurface &tsos, const Cylinder &sur) const
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest1, const GlobalPoint &pDest2) const
 Propagate to PCA to a line (given by 2 points) given a starting point. More...
 
virtual std::pair< FreeTrajectoryState, double > propagateWithPath (const FreeTrajectoryState &ftsStart, const reco::BeamSpot &beamSpot) const
 Propagate to PCA to a line (given by beamSpot position and slope) given a starting point. More...
 
virtual PropagationDirection propagationDirection () const final
 
 Propagator (PropagationDirection dir=alongMomentum)
 
virtual bool setMaxDirectionChange (float phiMax)
 
virtual void setPropagationDirection (PropagationDirection dir)
 
virtual ~Propagator ()
 

Private Types

typedef std::pair< TrajectoryStateOnSurface, double > TsosWP
 

Private Member Functions

RKLocalFieldProvider fieldProvider () const
 
RKLocalFieldProvider fieldProvider (const Cylinder &cyl) const
 
GlobalVector globalMomentum (const Basic3DVector< float > &mom) const
 
GlobalPoint globalPosition (const Basic3DVector< float > &pos) const
 
GlobalTrajectoryParameters gtpFromLocal (const Basic3DVector< float > &lpos, const Basic3DVector< float > &lmom, TrackCharge ch, const Surface &surf) const
 
GlobalTrajectoryParameters gtpFromVolumeLocal (const CartesianStateAdaptor &state, TrackCharge charge) const
 
PropagationDirection invertDirection (PropagationDirection dir) const
 
GlobalParametersWithPath propagateParametersOnCylinder (const FreeTrajectoryState &ts, const Cylinder &cyl) const
 
GlobalParametersWithPath propagateParametersOnPlane (const FreeTrajectoryState &ts, const Plane &plane) const
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Plane &) const override
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &, const Cylinder &) const override
 
Basic3DVector< double > rkMomentum (const GlobalVector &mom) const
 
Basic3DVector< double > rkPosition (const GlobalPoint &pos) const
 

Private Attributes

double theTolerance
 
const MagVolumetheVolume
 

Detailed Description

Definition at line 19 of file RKPropagatorInS.h.

Member Typedef Documentation

◆ TsosWP

typedef std::pair<TrajectoryStateOnSurface, double> RKPropagatorInS::TsosWP
private

Definition at line 46 of file RKPropagatorInS.h.

Constructor & Destructor Documentation

◆ RKPropagatorInS()

RKPropagatorInS::RKPropagatorInS ( const MagVolume vol,
PropagationDirection  dir = alongMomentum,
double  tolerance = 5.e-5 
)
inlineexplicit

Definition at line 25 of file RKPropagatorInS.h.

Referenced by clone().

Propagator(PropagationDirection dir=alongMomentum)
Definition: Propagator.h:46
const double tolerance
const MagVolume * theVolume

◆ ~RKPropagatorInS()

RKPropagatorInS::~RKPropagatorInS ( )
inlineoverride

Definition at line 28 of file RKPropagatorInS.h.

28 {}

Member Function Documentation

◆ clone()

Propagator * RKPropagatorInS::clone ( void  ) const
overridevirtual

Implements Propagator.

Definition at line 304 of file RKPropagatorInS.cc.

References RKPropagatorInS().

304 { return new RKPropagatorInS(*this); }
RKPropagatorInS(const MagVolume &vol, PropagationDirection dir=alongMomentum, double tolerance=5.e-5)

◆ fieldProvider() [1/2]

RKLocalFieldProvider RKPropagatorInS::fieldProvider ( ) const
private

◆ fieldProvider() [2/2]

RKLocalFieldProvider RKPropagatorInS::fieldProvider ( const Cylinder cyl) const
private

Definition at line 315 of file RKPropagatorInS.cc.

References theVolume.

315  {
316  return RKLocalFieldProvider(*theVolume, cyl);
317 }
const MagVolume * theVolume

◆ globalMomentum()

GlobalVector RKPropagatorInS::globalMomentum ( const Basic3DVector< float > &  mom) const
private

Definition at line 346 of file RKPropagatorInS.cc.

References theVolume, and GloballyPositioned< T >::toGlobal().

Referenced by gtpFromVolumeLocal().

348 {
349  if (theVolume != nullptr)
350  return theVolume->toGlobal(LocalVector(mom));
351  else
352  return GlobalVector(mom);
353 }
GlobalPoint toGlobal(const LocalPoint &lp) const
Local3DVector LocalVector
Definition: LocalVector.h:12
const MagVolume * theVolume
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ globalPosition()

GlobalPoint RKPropagatorInS::globalPosition ( const Basic3DVector< float > &  pos) const
private

Definition at line 339 of file RKPropagatorInS.cc.

References theVolume, and GloballyPositioned< T >::toGlobal().

Referenced by gtpFromVolumeLocal(), and propagateParametersOnPlane().

339  {
340  if (theVolume != nullptr)
341  return theVolume->toGlobal(LocalPoint(pos));
342  else
343  return GlobalPoint(pos);
344 }
GlobalPoint toGlobal(const LocalPoint &lp) const
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const MagVolume * theVolume

◆ gtpFromLocal()

GlobalTrajectoryParameters RKPropagatorInS::gtpFromLocal ( const Basic3DVector< float > &  lpos,
const Basic3DVector< float > &  lmom,
TrackCharge  ch,
const Surface surf 
) const
private

Definition at line 306 of file RKPropagatorInS.cc.

References theVolume, and Surface::toGlobal().

Referenced by propagateParametersOnCylinder().

309  {
310  return GlobalTrajectoryParameters(surf.toGlobal(LocalPoint(lpos)), surf.toGlobal(LocalVector(lmom)), ch, theVolume);
311 }
Local3DVector LocalVector
Definition: LocalVector.h:12
const MagVolume * theVolume
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Definition: Surface.h:79

◆ gtpFromVolumeLocal()

GlobalTrajectoryParameters RKPropagatorInS::gtpFromVolumeLocal ( const CartesianStateAdaptor state,
TrackCharge  charge 
) const
private

Definition at line 355 of file RKPropagatorInS.cc.

References ALCARECOTkAlJpsiMuMu_cff::charge, globalMomentum(), globalPosition(), and theVolume.

Referenced by propagateParametersOnPlane().

356  {
358  globalPosition(state.position()), globalMomentum(state.momentum()), charge, theVolume);
359 }
GlobalVector globalMomentum(const Basic3DVector< float > &mom) const
const MagVolume * theVolume
GlobalPoint globalPosition(const Basic3DVector< float > &pos) const

◆ invertDirection()

PropagationDirection RKPropagatorInS::invertDirection ( PropagationDirection  dir) const
private

◆ magneticField()

const MagneticField* RKPropagatorInS::magneticField ( ) const
inlineoverridevirtual

Implements Propagator.

Definition at line 43 of file RKPropagatorInS.h.

References theVolume.

43 { return theVolume; }
const MagVolume * theVolume

◆ propagate() [1/4]

template<typename STA , typename SUR >
TrajectoryStateOnSurface Propagator::propagate ( typename STA  ,
typename SUR   
)
inline

Definition at line 50 of file Propagator.h.

50  {
51  return propagateWithPath(state, surface).first;
52  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagate() [2/4]

virtual FreeTrajectoryState Propagator::propagate
inlinefinal

Definition at line 109 of file Propagator.h.

109  {
110  return propagateWithPath(ftsStart, pDest).first;
111  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagate() [3/4]

virtual FreeTrajectoryState Propagator::propagate
inlinefinal

Definition at line 112 of file Propagator.h.

114  {
115  return propagateWithPath(ftsStart, pDest1, pDest2).first;
116  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagate() [4/4]

virtual FreeTrajectoryState Propagator::propagate
inlinefinal

Definition at line 117 of file Propagator.h.

118  {
119  return propagateWithPath(ftsStart, beamSpot).first;
120  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagateParametersOnCylinder()

GlobalParametersWithPath RKPropagatorInS::propagateParametersOnCylinder ( const FreeTrajectoryState ts,
const Cylinder cyl 
) const
private

Definition at line 186 of file RKPropagatorInS.cc.

References funct::abs(), FreeTrajectoryState::charge(), MillePedeFileConverter_cfg::e, HLT_2022v11_cff::eps, fieldProvider(), gtpFromLocal(), invertDirection(), LIKELY, LogDebug, CartesianStateAdaptor::momentum(), FreeTrajectoryState::momentum(), castor_dqm_sourceclient_file_cfg::path, StraightLineCylinderCrossing::pathLength(), StraightLineBarrelCylinderCrossing::pathLength(), Basic3DVector< T >::perp(), perp(), CartesianStateAdaptor::position(), StraightLineBarrelCylinderCrossing::position(), GloballyPositioned< T >::position(), FreeTrajectoryState::position(), Propagator::propagationDirection(), Cylinder::radius(), rho, CartesianStateAdaptor::rkstate(), alignCSCRings::s, command_line::start, theTolerance, theVolume, GloballyPositioned< T >::toLocal(), FreeTrajectoryState::transverseCurvature(), UNLIKELY, x, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and Basic3DVector< T >::z().

Referenced by propagateWithPath().

187  {
189  typedef Solver::Vector RKVector;
190 
191  const GlobalPoint& sp = cyl.position();
192  if UNLIKELY (sp.x() != 0. || sp.y() != 0.) {
193  throw PropagationException("Cannot propagate to an arbitrary cylinder");
194  }
195 
196  GlobalPoint gpos(ts.position());
197  GlobalVector gmom(ts.momentum());
198  LocalPoint pos(cyl.toLocal(gpos));
199  LocalVector mom(cyl.toLocal(gmom));
200  double startR = cyl.radius() - pos.perp();
201 
202  // LogDebug("RKPropagatorInS") << "RKPropagatorInS: starting from FTS " << ts ;
203 
204  // (transverse) curvature
205  double rho = ts.transverseCurvature();
206  //
207  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
208  // difference in transversal position at 10m.
209  //
210  if UNLIKELY (fabs(rho) < 1.e-10) {
211  //
212  // Instantiate auxiliary object for finding intersection.
213  // Frame-independant point and vector are created explicitely to
214  // avoid confusing gcc (refuses to compile with temporary objects
215  // in the constructor).
216  //
217 
218  StraightLineBarrelCylinderCrossing cylCrossing(gpos, gmom, propagationDirection());
219 
220  //
221  // get solution
222  //
223  std::pair<bool, double> propResult = cylCrossing.pathLength(cyl);
224  if LIKELY (propResult.first && theVolume != nullptr) {
225  double s = propResult.second;
226  // point (reconverted to GlobalPoint)
227  GlobalPoint x(cylCrossing.position(s));
229  LogDebug("RKPropagatorInS") << "Straight line propagation to cylinder succeeded !!";
230  return GlobalParametersWithPath(res, s);
231  }
232 
233  //do someting
234  edm::LogError("RKPropagatorInS") << "Straight line propagation to cylinder failed !!";
235  return GlobalParametersWithPath();
236  }
237 
239  // StraightLineCylinderCrossing pathLength( pos, mom, propagationDirection());
240  CartesianLorentzForce deriv(field, ts.charge());
241 
242  RKCartesianDistance dist;
243  double eps = theTolerance;
244  Solver solver;
245  double stot = 0;
246  PropagationDirection currentDirection = propagationDirection();
247 
248  RKVector start(CartesianStateAdaptor::rkstate(pos.basicVector(), mom.basicVector()));
249  int safeGuard = 0;
250  while (safeGuard++ < 100) {
251  CartesianStateAdaptor startState(start);
252  StraightLineCylinderCrossing pathLength(
253  LocalPoint(startState.position()), LocalVector(startState.momentum()), currentDirection, eps);
254 
255  std::pair<bool, double> path = pathLength.pathLength(cyl);
256  if UNLIKELY (!path.first) {
257  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Path length calculation to cylinder failed!"
258  << "Radius " << cyl.radius() << " pos.perp() "
259  << LocalPoint(startState.position()).perp();
260  return GlobalParametersWithPath();
261  }
262 
263  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Path lenght to cylinder is " << path.second << " from point (R,z) "
264  << startState.position().perp() << ", " << startState.position().z() << " to R "
265  << cyl.radius();
266 
267  double sstep = path.second;
268  if UNLIKELY (std::abs(sstep) < eps) {
269  LogDebug("RKPropagatorInS") << "accuracy not reached, but pathLength calculation says we are there! "
270  << path.second;
271 
272  GlobalTrajectoryParameters res(gtpFromLocal(startState.position(), startState.momentum(), ts.charge(), cyl));
273  return GlobalParametersWithPath(res, stot);
274  }
275 
276  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Solving for " << sstep << " current distance to cylinder is "
277  << startR;
278 
279  RKVector rkresult = solver(0, start, sstep, deriv, dist, eps);
280  stot += sstep;
281  CartesianStateAdaptor cur(rkresult);
282  double remainingR = cyl.radius() - cur.position().perp();
283 
284  if (fabs(remainingR) < eps) {
285  LogDebug("RKPropagatorInS") << "Accuracy reached! " << remainingR;
286  GlobalTrajectoryParameters res(gtpFromLocal(cur.position(), cur.momentum(), ts.charge(), cyl));
287  return GlobalParametersWithPath(res, stot);
288  }
289 
290  start = rkresult;
291  if (remainingR * startR > 0) {
292  LogDebug("RKPropagatorInS") << "Accuracy not reached yet, trying in same direction again " << remainingR;
293  } else {
294  LogDebug("RKPropagatorInS") << "Accuracy not reached yet, trying in opposite direction " << remainingR;
295  currentDirection = invertDirection(currentDirection);
296  }
297  startR = remainingR;
298  }
299 
300  edm::LogError("FailedPropagation") << " too many iterations trying to reach cylinder ";
301  return GlobalParametersWithPath();
302 }
Definition: start.py:1
Local3DVector LocalVector
Definition: LocalVector.h:12
Point3DBase< Scalar, LocalTag > LocalPoint
Definition: Definitions.h:30
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
RKLocalFieldProvider fieldProvider() const
#define LIKELY(x)
Definition: Likely.h:20
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
PropagationDirection
Log< level::Error, false > LogError
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: Electron.h:6
GlobalPoint position() const
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
Estimator of the distance between two state vectors, e.g. for convergence test.
TrackCharge charge() const
Derivative calculation for the 6D cartesian case.
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const MagVolume * theVolume
Common base class.
T perp() const
Magnitude of transverse component.
double transverseCurvature() const
const PositionType & position() const
PropagationDirection invertDirection(PropagationDirection dir) const
GlobalTrajectoryParameters gtpFromLocal(const Basic3DVector< float > &lpos, const Basic3DVector< float > &lmom, TrackCharge ch, const Surface &surf) const
Scalar radius() const
Radius of the cylinder.
Definition: Cylinder.h:64
#define UNLIKELY(x)
Definition: Likely.h:21
static RKSmallVector< double, 6 > rkstate(const Vector3D &pos, const Vector3D &mom)
#define LogDebug(id)

◆ propagateParametersOnPlane()

GlobalParametersWithPath RKPropagatorInS::propagateParametersOnPlane ( const FreeTrajectoryState ts,
const Plane plane 
) const
private

Definition at line 51 of file RKPropagatorInS.cc.

References funct::abs(), PV3DBase< T, PVType, FrameType >::basicVector(), FreeTrajectoryState::charge(), cross(), DeadROC_duringRun::dir, MillePedeFileConverter_cfg::e, HLT_2022v11_cff::eps, fieldProvider(), RKLocalFieldProvider::frame(), globalPosition(), gtpFromVolumeLocal(), RKLocalFieldProvider::inTesla(), invertDirection(), LIKELY, Plane::localZ(), LogDebug, CartesianStateAdaptor::momentum(), FreeTrajectoryState::momentum(), castor_dqm_sourceclient_file_cfg::path, StraightLinePlaneCrossing::pathLength(), CartesianStateAdaptor::position(), GloballyPositioned< T >::position(), StraightLinePlaneCrossing::position(), FreeTrajectoryState::position(), Propagator::propagationDirection(), rho, rkMomentum(), rkPosition(), CartesianStateAdaptor::rkstate(), alignCSCRings::s, command_line::start, theTolerance, theVolume, GloballyPositioned< T >::toGlobal(), GloballyPositioned< T >::toLocal(), FrameChanger::transformPlane(), FreeTrajectoryState::transverseCurvature(), UNLIKELY, and x.

Referenced by propagateWithPath().

52  {
53  GlobalPoint gpos(ts.position());
54  GlobalVector gmom(ts.momentum());
55  double startZ = plane.localZ(gpos);
56  // (transverse) curvature
57  double rho = ts.transverseCurvature();
58  //
59  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
60  // difference in transversal position at 10m.
61  //
62  if UNLIKELY (fabs(rho) < 1.e-10) {
63  //
64  // Instantiate auxiliary object for finding intersection.
65  // Frame-independant point and vector are created explicitely to
66  // avoid confusing gcc (refuses to compile with temporary objects
67  // in the constructor).
68  //
69  LogDebug("RKPropagatorInS") << " startZ = " << startZ;
70 
71  if UNLIKELY (fabs(startZ) < 1e-5) {
72  LogDebug("RKPropagatorInS") << "Propagation is not performed: state is already on final surface.";
74  return GlobalParametersWithPath(res, 0.0);
75  }
76 
80  //
81  // get solution
82  //
83  std::pair<bool, double> propResult = planeCrossing.pathLength(plane);
84  if LIKELY (propResult.first && theVolume != nullptr) {
85  double s = propResult.second;
86  // point (reconverted to GlobalPoint)
87  GlobalPoint x(planeCrossing.position(s));
90  }
91  //do someting
92  LogDebug("RKPropagatorInS") << "Straight line propgation to plane failed !!";
93  return GlobalParametersWithPath();
94  }
95 
96 #ifdef EDM_ML_DEBUG
97  if (theVolume != 0) {
98  LogDebug("RKPropagatorInS") << "RKPropagatorInS: starting prop to plane in volume with pos "
99  << theVolume->position() << " Z axis " << theVolume->toGlobal(LocalVector(0, 0, 1));
100 
101  LogDebug("RKPropagatorInS") << "The starting position is " << ts.position() << " (global) "
102  << theVolume->toLocal(ts.position()) << " (local) ";
103 
104  FrameChanger changer;
105  auto localPlane = changer.transformPlane(plane, *theVolume);
106  LogDebug("RKPropagatorInS") << "The plane position is " << plane.position() << " (global) " << localPlane.position()
107  << " (local) ";
108 
109  LogDebug("RKPropagatorInS") << "The initial distance to plane is " << plane.localZ(ts.position());
110 
112  std::pair<bool, double> res3 = cross.pathLength(plane);
113  LogDebug("RKPropagatorInS") << "straight line distance " << res3.first << " " << res3.second;
114  }
115 #endif
116 
118  typedef Solver::Vector RKVector;
119 
121  PathToPlane2Order pathLength(field, &field.frame());
122  CartesianLorentzForce deriv(field, ts.charge());
123 
124  RKCartesianDistance dist;
125  double eps = theTolerance;
126  Solver solver;
127  double stot = 0;
128  PropagationDirection currentDirection = propagationDirection();
129 
130  // in magVolume frame
132  int safeGuard = 0;
133  while (safeGuard++ < 100) {
134  CartesianStateAdaptor startState(start);
135 
136  std::pair<bool, double> path =
137  pathLength(plane, startState.position(), startState.momentum(), (double)ts.charge(), currentDirection);
138  if UNLIKELY (!path.first) {
139  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Path length calculation to plane failed!"
140  << "...distance to plane " << plane.localZ(globalPosition(startState.position()))
141  << "...Local starting position in volume " << startState.position()
142  << "...Magnetic field " << field.inTesla(startState.position());
143 
144  return GlobalParametersWithPath();
145  }
146 
147  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Path lenght to plane is " << path.second;
148 
149  double sstep = path.second;
150  if UNLIKELY (std::abs(sstep) < eps) {
151  LogDebug("RKPropagatorInS") << "On-surface accuracy not reached, but pathLength calculation says we are there! "
152  << "path " << path.second << " distance to plane is " << startZ;
154  return GlobalParametersWithPath(res, stot);
155  }
156 
157  LogDebug("RKPropagatorInS") << "RKPropagatorInS: Solving for " << sstep << " current distance to plane is "
158  << startZ;
159 
160  RKVector rkresult = solver(0, start, sstep, deriv, dist, eps);
161  stot += sstep;
162  CartesianStateAdaptor cur(rkresult);
163  double remainingZ = plane.localZ(globalPosition(cur.position()));
164 
165  if (fabs(remainingZ) < eps) {
166  LogDebug("RKPropagatorInS") << "On-surface accuracy reached! " << remainingZ;
168  return GlobalParametersWithPath(res, stot);
169  }
170 
171  start = rkresult;
172 
173  if (remainingZ * startZ > 0) {
174  LogDebug("RKPropagatorInS") << "Accuracy not reached yet, trying in same direction again " << remainingZ;
175  } else {
176  LogDebug("RKPropagatorInS") << "Accuracy not reached yet, trying in opposite direction " << remainingZ;
177  currentDirection = invertDirection(currentDirection);
178  }
179  startZ = remainingZ;
180  }
181 
182  edm::LogError("FailedPropagation") << " too many iterations trying to reach plane ";
183  return GlobalParametersWithPath();
184 }
GlobalPoint toGlobal(const LocalPoint &lp) const
Definition: start.py:1
Basic3DVector cross(const Basic3DVector &v) const
Vector product, or "cross" product, with a vector of same type.
Local3DVector LocalVector
Definition: LocalVector.h:12
ROOT::Math::Plane3D::Vector Vector
Definition: EcalHitMaker.cc:29
RKLocalFieldProvider fieldProvider() const
#define LIKELY(x)
Definition: Likely.h:20
Basic3DVector< double > rkPosition(const GlobalPoint &pos) const
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
PropagationDirection
Log< level::Error, false > LogError
LocalPoint toLocal(const GlobalPoint &gp) const
Definition: Electron.h:6
GlobalPoint position() const
Estimator of the distance between two state vectors, e.g. for convergence test.
TrackCharge charge() const
Derivative calculation for the 6D cartesian case.
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GlobalTrajectoryParameters gtpFromVolumeLocal(const CartesianStateAdaptor &state, TrackCharge charge) const
const MagVolume * theVolume
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53
float localZ(const GlobalPoint &gp) const
Definition: Plane.h:45
double transverseCurvature() const
static Plane transformPlane(const Plane &plane, const GloballyPositioned< T > &frame)
Definition: FrameChanger.h:14
const PositionType & position() const
PropagationDirection invertDirection(PropagationDirection dir) const
GlobalPoint globalPosition(const Basic3DVector< float > &pos) const
#define UNLIKELY(x)
Definition: Likely.h:21
static RKSmallVector< double, 6 > rkstate(const Vector3D &pos, const Vector3D &mom)
Basic3DVector< double > rkMomentum(const GlobalVector &mom) const
#define LogDebug(id)

◆ propagateWithPath() [1/11]

std::pair< FreeTrajectoryState, double > Propagator::propagateWithPath

Propagate to PCA to a line (given by 2 points) given a starting point.

Definition at line 47 of file Propagator.cc.

49  {
50  throw cms::Exception("Propagator::propagate(FTS,GlobalPoint,GlobalPoint) not implemented");
51  return std::pair<FreeTrajectoryState, double>();
52 }

◆ propagateWithPath() [2/11]

std::pair< FreeTrajectoryState, double > Propagator::propagateWithPath

Propagate to PCA to a line (given by beamSpot position and slope) given a starting point.

Definition at line 53 of file Propagator.cc.

54  {
55  throw cms::Exception("Propagator::propagate(FTS,beamSpot) not implemented");
56  return std::pair<FreeTrajectoryState, double>();
57 }

◆ propagateWithPath() [3/11]

virtual std::pair<TrajectoryStateOnSurface, double> Propagator::propagateWithPath
inline

Definition at line 86 of file Propagator.h.

87  {
88  return propagateWithPath(*tsos.freeState(), sur);
89  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagateWithPath() [4/11]

virtual std::pair<TrajectoryStateOnSurface, double> Propagator::propagateWithPath

◆ propagateWithPath() [5/11]

std::pair< TrajectoryStateOnSurface, double > Propagator::propagateWithPath
final

The methods propagateWithPath() are identical to the corresponding methods propagate() in what concerns the resulting TrajectoryStateOnSurface, but they provide in addition the exact path length along the trajectory.Only use the generic method if the surface type (plane or cylinder) is not known at the calling point.

Definition at line 10 of file Propagator.cc.

11  {
12  // try plane first, most probable case (disk "is a" plane too)
13  const Plane* bp = dynamic_cast<const Plane*>(&sur);
14  if (bp != nullptr)
15  return propagateWithPath(state, *bp);
16 
17  // if not plane try cylinder
18  const Cylinder* bc = dynamic_cast<const Cylinder*>(&sur);
19  if (bc != nullptr)
20  return propagateWithPath(state, *bc);
21 
22  // unknown surface - can't do it!
23  throw PropagationException("The surface is neither Cylinder nor Plane");
24 }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override
Definition: Plane.h:16
Common base class.

◆ propagateWithPath() [6/11]

virtual std::pair<TrajectoryStateOnSurface, double> Propagator::propagateWithPath

◆ propagateWithPath() [7/11]

virtual std::pair<TrajectoryStateOnSurface, double> Propagator::propagateWithPath
inline

Definition at line 91 of file Propagator.h.

92  {
93  return propagateWithPath(*tsos.freeState(), sur);
94  }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override

◆ propagateWithPath() [8/11]

std::pair< TrajectoryStateOnSurface, double > Propagator::propagateWithPath
final

The following three methods are equivalent to the corresponding methods above, but if the starting state is a TrajectoryStateOnSurface, it's better to use it as such rather than use just the FreeTrajectoryState part. It may help some concrete propagators.Only use the generic method if the surface type (plane or cylinder) is not known at the calling point.

Definition at line 26 of file Propagator.cc.

27  {
28  // try plane first, most probable case (disk "is a" plane too)
29  const Plane* bp = dynamic_cast<const Plane*>(&sur);
30  if (bp != nullptr)
31  return propagateWithPath(state, *bp);
32 
33  // if not plane try cylinder
34  const Cylinder* bc = dynamic_cast<const Cylinder*>(&sur);
35  if (bc != nullptr)
36  return propagateWithPath(state, *bc);
37 
38  // unknown surface - can't do it!
39  throw PropagationException("The surface is neither Cylinder nor Plane");
40 }
std::pair< TrajectoryStateOnSurface, double > propagateWithPath(const FreeTrajectoryState &, const Plane &) const override
Definition: Plane.h:16
Common base class.

◆ propagateWithPath() [9/11]

std::pair< FreeTrajectoryState, double > Propagator::propagateWithPath

implemented by Stepping Helix Propagate to PCA to point given a starting point

Definition at line 42 of file Propagator.cc.

43  {
44  throw cms::Exception("Propagator::propagate(FTS,GlobalPoint) not implemented");
45  return std::pair<FreeTrajectoryState, double>();
46 }

◆ propagateWithPath() [10/11]

std::pair< TrajectoryStateOnSurface, double > RKPropagatorInS::propagateWithPath ( const FreeTrajectoryState fts,
const Plane plane 
) const
overrideprivatevirtual

Implements Propagator.

Definition at line 25 of file RKPropagatorInS.cc.

References SurfaceSideDefinition::afterSurface, alongMomentum, analyticalErrorPropagation(), SurfaceSideDefinition::beforeSurface, runTauDisplay::gp, propagateParametersOnPlane(), Propagator::propagationDirection(), and UNLIKELY.

26  {
28  if UNLIKELY (!gp)
29  return TsosWP(TrajectoryStateOnSurface(), 0.);
30 
35  return analyticalErrorPropagation(fts, plane, side, gp.parameters(), gp.s());
36 }
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
std::pair< TrajectoryStateOnSurface, double > analyticalErrorPropagation(const FreeTrajectoryState &startingState, const Surface &surface, SurfaceSideDefinition::SurfaceSide side, const GlobalTrajectoryParameters &destParameters, const double &s)
GlobalParametersWithPath propagateParametersOnPlane(const FreeTrajectoryState &ts, const Plane &plane) const
std::pair< TrajectoryStateOnSurface, double > TsosWP
#define UNLIKELY(x)
Definition: Likely.h:21

◆ propagateWithPath() [11/11]

std::pair< TrajectoryStateOnSurface, double > RKPropagatorInS::propagateWithPath ( const FreeTrajectoryState fts,
const Cylinder cyl 
) const
overrideprivatevirtual

Implements Propagator.

Definition at line 38 of file RKPropagatorInS.cc.

References SurfaceSideDefinition::afterSurface, alongMomentum, analyticalErrorPropagation(), SurfaceSideDefinition::beforeSurface, runTauDisplay::gp, propagateParametersOnCylinder(), Propagator::propagationDirection(), and UNLIKELY.

39  {
41  if UNLIKELY (!gp)
42  return TsosWP(TrajectoryStateOnSurface(), 0.);
43 
48  return analyticalErrorPropagation(fts, cyl, side, gp.parameters(), gp.s());
49 }
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
std::pair< TrajectoryStateOnSurface, double > analyticalErrorPropagation(const FreeTrajectoryState &startingState, const Surface &surface, SurfaceSideDefinition::SurfaceSide side, const GlobalTrajectoryParameters &destParameters, const double &s)
std::pair< TrajectoryStateOnSurface, double > TsosWP
GlobalParametersWithPath propagateParametersOnCylinder(const FreeTrajectoryState &ts, const Cylinder &cyl) const
#define UNLIKELY(x)
Definition: Likely.h:21

◆ rkMomentum()

Basic3DVector< double > RKPropagatorInS::rkMomentum ( const GlobalVector mom) const
private

Definition at line 332 of file RKPropagatorInS.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), theVolume, and GloballyPositioned< T >::toLocal().

Referenced by propagateParametersOnPlane().

332  {
333  if (theVolume != nullptr)
334  return theVolume->toLocal(mom).basicVector();
335  else
336  return mom.basicVector();
337 }
LocalPoint toLocal(const GlobalPoint &gp) const
const MagVolume * theVolume
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53

◆ rkPosition()

Basic3DVector< double > RKPropagatorInS::rkPosition ( const GlobalPoint pos) const
private

Definition at line 325 of file RKPropagatorInS.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), theVolume, and GloballyPositioned< T >::toLocal().

Referenced by propagateParametersOnPlane().

325  {
326  if (theVolume != nullptr)
327  return theVolume->toLocal(pos).basicVector();
328  else
329  return pos.basicVector();
330 }
LocalPoint toLocal(const GlobalPoint &gp) const
const MagVolume * theVolume
const BasicVectorType & basicVector() const
Definition: PV3DBase.h:53

Member Data Documentation

◆ theTolerance

double RKPropagatorInS::theTolerance
private

Definition at line 49 of file RKPropagatorInS.h.

Referenced by propagateParametersOnCylinder(), and propagateParametersOnPlane().

◆ theVolume

const MagVolume* RKPropagatorInS::theVolume
private