CMS 3D CMS Logo

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

#include <AnalyticalPropagator.h>

Inheritance diagram for AnalyticalPropagator:
Propagator

Public Member Functions

 AnalyticalPropagator (const MagneticField *field, PropagationDirection dir=alongMomentum, float maxDPhi=1.6, bool isOld=true)
 
AnalyticalPropagatorclone () const override
 
bool setMaxDirectionChange (float phiMax) override
 
void setMaxRelativeChangeInBz (const float maxDBz)
 
 ~AnalyticalPropagator () 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 void setPropagationDirection (PropagationDirection dir)
 
virtual ~Propagator ()
 

Private Types

typedef std::pair< TrajectoryStateOnSurface, double > TsosWP
 

Private Member Functions

const MagneticFieldmagneticField () const override
 
std::pair< TrajectoryStateOnSurface, double > propagatedStateWithPath (const FreeTrajectoryState &fts, const Surface &surface, const GlobalTrajectoryParameters &gtp, const double &s) const
 propagation of errors (if needed) and generation of a new TSOS More...
 
bool propagateParametersOnCylinder (const FreeTrajectoryState &fts, const Cylinder &cylinder, GlobalPoint &x, GlobalVector &p, double &s) const
 parameter propagation to cylinder (returns position, momentum and path length) More...
 
bool propagateParametersOnPlane (const FreeTrajectoryState &fts, const Plane &plane, GlobalPoint &x, GlobalVector &p, double &s) const
 parameter propagation to plane (returns position, momentum and path length) More...
 
bool propagateWithHelixCrossing (HelixPlaneCrossing &, const Plane &, const float, GlobalPoint &, GlobalVector &, double &s) const
 helix parameter propagation to a plane using HelixPlaneCrossing More...
 
bool propagateWithLineCrossing (const GlobalPoint &, const GlobalVector &, const Plane &, GlobalPoint &, double &) const
 straight line parameter propagation to a plane More...
 
bool propagateWithLineCrossing (const GlobalPoint &, const GlobalVector &, const Cylinder &, GlobalPoint &, double &) const
 straight line parameter propagation to a cylinder More...
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &fts, const Plane &plane) const override
 propagation to plane with path length More...
 
std::pair< TrajectoryStateOnSurface, double > propagateWithPath (const FreeTrajectoryState &fts, const Cylinder &cylinder) const override
 propagation to cylinder with path length More...
 

Private Attributes

bool isOldPropagationType
 
const MagneticFieldtheField
 
float theMaxDBzRatio
 
float theMaxDPhi2
 

Detailed Description

(Mostly) analytical helix propagation to cylindrical or planar surfaces. Based on GtfGeometricalPropagator with successive replacement of components (currently: propagation to arbitrary plane).

Definition at line 22 of file AnalyticalPropagator.h.

Member Typedef Documentation

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

Definition at line 106 of file AnalyticalPropagator.h.

Constructor & Destructor Documentation

AnalyticalPropagator::AnalyticalPropagator ( const MagneticField field,
PropagationDirection  dir = alongMomentum,
float  maxDPhi = 1.6,
bool  isOld = true 
)
inline

Definition at line 24 of file AnalyticalPropagator.h.

Referenced by clone().

28  : Propagator(dir),
30  theMaxDBzRatio(0.5),
31  theField(field),
32  isOldPropagationType(isOld) {}
Propagator(PropagationDirection dir=alongMomentum)
Definition: Propagator.h:46
const MagneticField * theField
AnalyticalPropagator::~AnalyticalPropagator ( )
inlineoverride

Member Function Documentation

AnalyticalPropagator* AnalyticalPropagator::clone ( void  ) const
inlineoverridevirtual

Implements Propagator.

Definition at line 64 of file AnalyticalPropagator.h.

References AnalyticalPropagator().

64 { return new AnalyticalPropagator(*this); }
AnalyticalPropagator(const MagneticField *field, PropagationDirection dir=alongMomentum, float maxDPhi=1.6, bool isOld=true)
const MagneticField* AnalyticalPropagator::magneticField ( ) const
inlineoverrideprivatevirtual

Implements Propagator.

Definition at line 103 of file AnalyticalPropagator.h.

References theField.

103 { return theField; }
const MagneticField * theField
std::pair< TrajectoryStateOnSurface, double > AnalyticalPropagator::propagatedStateWithPath ( const FreeTrajectoryState fts,
const Surface surface,
const GlobalTrajectoryParameters gtp,
const double &  s 
) const
private

propagation of errors (if needed) and generation of a new TSOS

Definition at line 112 of file AnalyticalPropagator.cc.

References SurfaceSideDefinition::afterSurface, alongMomentum, SurfaceSideDefinition::beforeSurface, FreeTrajectoryState::curvilinearError(), FreeTrajectoryState::hasError(), AnalyticalCurvilinearJacobian::jacobian(), CurvilinearTrajectoryError::matrix(), GlobalTrajectoryParameters::momentum(), FreeTrajectoryState::parameters(), GlobalTrajectoryParameters::position(), and alignCSCRings::s.

Referenced by setMaxRelativeChangeInBz().

116  {
117  //
118  // for forward propagation: state is before surface,
119  // for backward propagation: state is after surface
120  //
121  SurfaceSide side =
123  //
124  //
125  // error propagation (if needed) and conversion to a TrajectoryStateOnSurface
126  //
127  if (fts.hasError()) {
128  //
129  // compute jacobian
130  //
131  AnalyticalCurvilinearJacobian analyticalJacobian(fts.parameters(), gtp.position(), gtp.momentum(), s);
132  const AlgebraicMatrix55& jacobian = analyticalJacobian.jacobian();
133  // CurvilinearTrajectoryError cte(ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()));
134  return TsosWP(
135  TrajectoryStateOnSurface(gtp, ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()), surface, side),
136  s);
137  } else {
138  //
139  // return state without errors
140  //
141  return TsosWP(TrajectoryStateOnSurface(gtp, surface, side), s);
142  }
143 }
const GlobalTrajectoryParameters & parameters() const
const AlgebraicMatrix55 & jacobian() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
const CurvilinearTrajectoryError & curvilinearError() const
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
std::pair< TrajectoryStateOnSurface, double > TsosWP
const AlgebraicSymMatrix55 & matrix() const
bool AnalyticalPropagator::propagateParametersOnCylinder ( const FreeTrajectoryState fts,
const Cylinder cylinder,
GlobalPoint x,
GlobalVector p,
double &  s 
) const
private

parameter propagation to cylinder (returns position, momentum and path length)

Definition at line 145 of file AnalyticalPropagator.cc.

References funct::abs(), constexpr, MillePedeFileConverter_cfg::e, f, PV3DBase< T, PVType, FrameType >::mag(), FreeTrajectoryState::momentum(), AlCaHLTBitMon_ParallelJobs::p, GloballyPositioned< T >::position(), FreeTrajectoryState::position(), alignCSCRings::s, tolerance, FreeTrajectoryState::transverseCurvature(), Vector3DBase< T, FrameTag >::unit(), UNLIKELY, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by setMaxRelativeChangeInBz().

146  {
147  GlobalPoint const& sp = cylinder.position();
148  if
149  UNLIKELY(sp.x() != 0. || sp.y() != 0.) { throw PropagationException("Cannot propagate to an arbitrary cylinder"); }
150  // preset output
151  x = fts.position();
152  p = fts.momentum();
153  s = 0;
154  // (transverse) curvature
155  auto rho = fts.transverseCurvature();
156  //
157  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
158  // difference in transversal position at 10m.
159  //
160  if
161  UNLIKELY(std::abs(rho) < 1.e-10f)
162  return propagateWithLineCrossing(fts.position(), p, cylinder, x, s);
163  //
164  // Helix case
165  //
166  // check for possible intersection
167  constexpr float tolerance = 1.e-4; // 1 micron distance
168  auto rdiff = x.perp() - cylinder.radius();
169  if (std::abs(rdiff) < tolerance)
170  return true;
171  //
172  // Instantiate HelixBarrelCylinderCrossing and get solutions
173  //
174  HelixBarrelCylinderCrossing cylinderCrossing(fts.position(), fts.momentum(), rho, propagationDirection(), cylinder);
175  if
176  UNLIKELY(!cylinderCrossing.hasSolution()) return false;
177  // path length
178  s = cylinderCrossing.pathLength();
179  // point
180  x = cylinderCrossing.position();
181  // direction (renormalised)
182  p = cylinderCrossing.direction().unit() * fts.momentum().mag();
183  return true;
184 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const double tolerance
T y() const
Definition: PV3DBase.h:60
bool propagateWithLineCrossing(const GlobalPoint &, const GlobalVector &, const Plane &, GlobalPoint &, double &) const
straight line parameter propagation to a plane
return((rh^lh)&mask)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
Common base class.
GlobalVector momentum() const
GlobalPoint position() const
double transverseCurvature() const
T perp() const
Magnitude of transverse component.
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define UNLIKELY(x)
Definition: Likely.h:21
T x() const
Definition: PV3DBase.h:59
const PositionType & position() const
#define constexpr
Basic3DVector unit() const
bool AnalyticalPropagator::propagateParametersOnPlane ( const FreeTrajectoryState fts,
const Plane plane,
GlobalPoint x,
GlobalVector p,
double &  s 
) const
private

parameter propagation to plane (returns position, momentum and path length)

Definition at line 186 of file AnalyticalPropagator.cc.

References funct::abs(), DeadROC_duringRun::dir, MillePedeFileConverter_cfg::e, f, LIKELY, LogDebug, PV3DBase< T, PVType, FrameType >::mag(), Basic3DVector< T >::mag(), FreeTrajectoryState::momentum(), oppositeToMomentum, AlCaHLTBitMon_ParallelJobs::p, StraightLineBarrelCylinderCrossing::pathLength(), StraightLinePlaneCrossing::pathLength(), perp(), PV3DBase< T, PVType, FrameType >::phi(), StraightLineBarrelCylinderCrossing::position(), StraightLinePlaneCrossing::position(), FreeTrajectoryState::position(), propagateWithLineCrossing(), alignCSCRings::s, indexGen::s2, tolerance, FreeTrajectoryState::transverseCurvature(), and UNLIKELY.

Referenced by setMaxRelativeChangeInBz().

187  {
188  // initialisation of position, momentum and path length
189  x = fts.position();
190  p = fts.momentum();
191  s = 0;
192  // (transverse) curvature
193  auto rho = fts.transverseCurvature();
194  //
195  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
196  // difference in transversal position at 10m.
197  //
198  if
199  UNLIKELY(std::abs(rho) < 1.e-10f)
200  return propagateWithLineCrossing(fts.position(), p, plane, x, s);
201  //
202  // Helix case
203  //
204 
205  //
206  // Frame-independant point and vector are created explicitely to
207  // avoid confusing gcc (refuses to compile with temporary objects
208  // in the constructor).
209  //
210  HelixPlaneCrossing::PositionType helixPos(x);
211  HelixPlaneCrossing::DirectionType helixDir(p);
212  if
214  OptimalHelixPlaneCrossing planeCrossing(plane, helixPos, helixDir, rho, propagationDirection());
215  return propagateWithHelixCrossing(*planeCrossing, plane, fts.momentum().mag(), x, p, s);
216  }
217 
218  //--- Alternative implementation to be used for the propagation of the parameters of looping
219  // particles that cross twice the (infinite) surface of the plane. It is not trivial to determine
220  // which of the two intersections has to be returned.
221 
222  //---- FIXME: WHAT FOLLOWS HAS TO BE REWRITTEN IN A CLEANER (AND CPU-OPTIMIZED) WAY ---------
223  LogDebug("AnalyticalPropagator") << "In AnaliticalProp, calling HAPC "
224  << "\n"
225  << "plane is centered in xyz: " << plane.position().x() << " , "
226  << plane.position().y() << " , " << plane.position().z() << "\n";
227 
228  GlobalPoint gp1 = fts.position();
229  GlobalVector gm1 = fts.momentum();
230  double s1 = 0;
231  double rho1 = fts.transverseCurvature();
232  HelixPlaneCrossing::PositionType helixPos1(gp1);
233  HelixPlaneCrossing::DirectionType helixDir1(gm1);
234  LogDebug("AnalyticalPropagator") << "gp1 before calling planeCrossing1: " << gp1 << "\n";
235  OptimalHelixPlaneCrossing planeCrossing1(plane, helixPos1, helixDir1, rho1, propagationDirection());
236 
239 
240  double tolerance(0.0050);
242  tolerance *= -1;
243 
244  bool check1 = propagateWithHelixCrossing(*planeCrossing1, plane, fts.momentum().mag(), gp1, gm1, s1);
245  double dphi1 = fabs(fts.momentum().phi() - gm1.phi());
246  LogDebug("AnalyticalPropagator") << "check1, s1, dphi, gp1: " << check1 << " , " << s1 << " , " << dphi1 << " , "
247  << gp1 << "\n";
248 
249  //move forward a bit to avoid that the propagator doesn't propagate because the state is already on surface.
250  //we want to go to the other point of intersection between the helix and the plane
251  xGen = (*planeCrossing1).position(s1 + tolerance);
252  pGen = (*planeCrossing1).direction(s1 + tolerance);
253 
254  /*
255  if(!check1 || s1>170 ){
256  //PropagationDirection newDir = (propagationDirection() == alongMomentum) ? oppositeToMomentum : alongMomentum;
257  PropagationDirection newDir = anyDirection;
258  HelixArbitraryPlaneCrossing planeCrossing1B(helixPos1,helixDir1,rho1,newDir);
259  check1 = propagateWithHelixCrossing(planeCrossing1B,plane,fts.momentum().mag(),gp1,gm1,s1);
260  LogDebug("AnalyticalPropagator") << "after second attempt, check1, s1,gp1: "
261  << check1 << " , "
262  << s1 << " , " << gp1 << "\n";
263 
264  xGen = planeCrossing1B.position(s1+tolerance);
265  pGen = planeCrossing1B.direction(s1+tolerance);
266  }
267  */
268 
269  if (!check1) {
270  LogDebug("AnalyticalPropagator") << "failed also second attempt. No idea what to do, then bailout"
271  << "\n";
272  }
273 
274  pGen *= gm1.mag() / pGen.mag();
275  GlobalPoint gp2(xGen);
276  GlobalVector gm2(pGen);
277  double s2 = 0;
278  double rho2 = rho1;
279  HelixPlaneCrossing::PositionType helixPos2(gp2);
280  HelixPlaneCrossing::DirectionType helixDir2(gm2);
281  OptimalHelixPlaneCrossing planeCrossing2(plane, helixPos2, helixDir2, rho2, propagationDirection());
282 
283  bool check2 = propagateWithHelixCrossing(*planeCrossing2, plane, gm2.mag(), gp2, gm2, s2);
284 
285  if (!check2) {
286  x = gp1;
287  p = gm1;
288  s = s1;
289  return check1;
290  }
291 
292  if (!check1) {
293  edm::LogError("AnalyticalPropagator") << "LOGIC ERROR: I should not have entered here!"
294  << "\n";
295  return false;
296  }
297 
298  LogDebug("AnalyticalPropagator") << "check2, s2, gp2: " << check2 << " , " << s2 << " , " << gp2 << "\n";
299 
300  double dist1 = (plane.position() - gp1).perp();
301  double dist2 = (plane.position() - gp2).perp();
302 
303  LogDebug("AnalyticalPropagator") << "propDir, dist1, dist2: " << propagationDirection() << " , " << dist1 << " , "
304  << dist2 << "\n";
305 
306  //If there are two solutions, the one which is the closest to the module's center is chosen
307  if (dist1 < 2 * dist2) {
308  x = gp1;
309  p = gm1;
310  s = s1;
311  return check1;
312  } else if (dist2 < 2 * dist1) {
313  x = gp2;
314  p = gm2;
315  s = s1 + s2 + tolerance;
316  return check2;
317  } else {
318  if (fabs(s1) < fabs(s2)) {
319  x = gp1;
320  p = gm1;
321  s = s1;
322  return check1;
323  } else {
324  x = gp2;
325  p = gm2;
326  s = s1 + s2 + tolerance;
327  return check2;
328  }
329  }
330 
331  //-------- END of ugly piece of code ---------------
332 }
#define LogDebug(id)
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const double tolerance
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
#define LIKELY(x)
Definition: Likely.h:20
bool propagateWithLineCrossing(const GlobalPoint &, const GlobalVector &, const Plane &, GlobalPoint &, double &) const
straight line parameter propagation to a plane
return((rh^lh)&mask)
Point3DBase< Scalar, GlobalTag > PositionType
Definition: Definitions.h:28
T mag() const
Definition: PV3DBase.h:64
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
bool propagateWithHelixCrossing(HelixPlaneCrossing &, const Plane &, const float, GlobalPoint &, GlobalVector &, double &s) const
helix parameter propagation to a plane using HelixPlaneCrossing
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
GlobalVector momentum() const
GlobalPoint position() const
double transverseCurvature() const
T perp() const
Magnitude of transverse component.
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define UNLIKELY(x)
Definition: Likely.h:21
bool AnalyticalPropagator::propagateWithHelixCrossing ( HelixPlaneCrossing planeCrossing,
const Plane plane,
const float  pmag,
GlobalPoint x,
GlobalVector p,
double &  s 
) const
private

helix parameter propagation to a plane using HelixPlaneCrossing

Definition at line 380 of file AnalyticalPropagator.cc.

References HelixPlaneCrossing::direction(), PV3DBase< T, PVType, FrameType >::mag(), HelixPlaneCrossing::pathLength(), HelixPlaneCrossing::position(), and UNLIKELY.

Referenced by setMaxRelativeChangeInBz().

385  {
386  // get solution
387  std::pair<bool, double> propResult = planeCrossing.pathLength(plane);
388  if
389  UNLIKELY(!propResult.first) return false;
390 
391  s = propResult.second;
392  x = GlobalPoint(planeCrossing.position(s));
393  // direction (reconverted to GlobalVector, renormalised)
394  GlobalVector pGen = GlobalVector(planeCrossing.direction(s));
395  pGen *= pmag / pGen.mag();
396  p = pGen;
397  //
398  return true;
399 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
return((rh^lh)&mask)
U second(std::pair< T, U > const &p)
virtual std::pair< bool, double > pathLength(const Plane &)=0
static int position[264][3]
Definition: ReadPGInfo.cc:289
#define UNLIKELY(x)
Definition: Likely.h:21
bool AnalyticalPropagator::propagateWithLineCrossing ( const GlobalPoint ,
const GlobalVector ,
const Plane ,
GlobalPoint ,
double &   
) const
private

straight line parameter propagation to a plane

Referenced by propagateParametersOnPlane(), and setMaxRelativeChangeInBz().

bool AnalyticalPropagator::propagateWithLineCrossing ( const GlobalPoint ,
const GlobalVector ,
const Cylinder ,
GlobalPoint ,
double &   
) const
private

straight line parameter propagation to a cylinder

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

propagation to cylinder with path length

Implements Propagator.

bool AnalyticalPropagator::setMaxDirectionChange ( float  phiMax)
inlineoverridevirtual

limitation of change in transverse direction (to avoid loops).

Reimplemented from Propagator.

Definition at line 59 of file AnalyticalPropagator.h.

References AlignmentTrackSelector_cfi::phiMax, and theMaxDPhi2.

void AnalyticalPropagator::setMaxRelativeChangeInBz ( const float  maxDBz)
inline

Set the maximum relative change in Bz (Bz_at_end-Bz_at_start)/Bz_at_start for a single propagation. The default is no limit. NB: this propagator assumes constant, non-zero magnetic field parallel to the z-axis!

Definition at line 70 of file AnalyticalPropagator.h.

References dso_internal, AlCaHLTBitMon_ParallelJobs::p, propagatedStateWithPath(), propagateParametersOnCylinder(), propagateParametersOnPlane(), propagateWithHelixCrossing(), propagateWithLineCrossing(), alignCSCRings::s, theMaxDBzRatio, and x.

70 { theMaxDBzRatio = maxDBz; }

Member Data Documentation

bool AnalyticalPropagator::isOldPropagationType
private

Definition at line 110 of file AnalyticalPropagator.h.

const MagneticField* AnalyticalPropagator::theField
private

Definition at line 109 of file AnalyticalPropagator.h.

Referenced by magneticField().

float AnalyticalPropagator::theMaxDBzRatio
private

Definition at line 108 of file AnalyticalPropagator.h.

Referenced by setMaxRelativeChangeInBz().

float AnalyticalPropagator::theMaxDPhi2
private

Definition at line 107 of file AnalyticalPropagator.h.

Referenced by setMaxDirectionChange().