CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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),
29  theMaxDPhi2(maxDPhi * maxDPhi),
30  theMaxDBzRatio(0.5),
31  theField(field),
32  isOldPropagationType(isOld) {}
Propagator(PropagationDirection dir=alongMomentum)
Definition: Propagator.h:46
const MagneticField * theField
AnalyticalPropagator::~AnalyticalPropagator ( )
inlineoverride

Definition at line 34 of file AnalyticalPropagator.h.

34 {}

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 106 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.

110  {
111  //
112  // for forward propagation: state is before surface,
113  // for backward propagation: state is after surface
114  //
115  SurfaceSide side =
117  //
118  //
119  // error propagation (if needed) and conversion to a TrajectoryStateOnSurface
120  //
121  if (fts.hasError()) {
122  //
123  // compute jacobian
124  //
125  AnalyticalCurvilinearJacobian analyticalJacobian(fts.parameters(), gtp.position(), gtp.momentum(), s);
126  const AlgebraicMatrix55& jacobian = analyticalJacobian.jacobian();
127  // CurvilinearTrajectoryError cte(ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()));
128  return TsosWP(
129  TrajectoryStateOnSurface(gtp, ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()), surface, side),
130  s);
131  } else {
132  //
133  // return state without errors
134  //
135  return TsosWP(TrajectoryStateOnSurface(gtp, surface, side), s);
136  }
137 }
const GlobalTrajectoryParameters & parameters() const
const AlgebraicMatrix55 & jacobian() const
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepStd< double, 5, 5 > > AlgebraicMatrix55
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
const CurvilinearTrajectoryError & curvilinearError() const
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 139 of file AnalyticalPropagator.cc.

References funct::abs(), alignCSCRings::e, validate-o2o-wbm::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().

140  {
141  GlobalPoint const& sp = cylinder.position();
142  if UNLIKELY (sp.x() != 0. || sp.y() != 0.) {
143  throw PropagationException("Cannot propagate to an arbitrary cylinder");
144  }
145  // preset output
146  x = fts.position();
147  p = fts.momentum();
148  s = 0;
149  // (transverse) curvature
150  auto rho = fts.transverseCurvature();
151  //
152  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
153  // difference in transversal position at 10m.
154  //
155  if UNLIKELY (std::abs(rho) < 1.e-10f)
156  return propagateWithLineCrossing(fts.position(), p, cylinder, x, s);
157  //
158  // Helix case
159  //
160  // check for possible intersection
161  constexpr float tolerance = 1.e-4; // 1 micron distance
162  auto rdiff = x.perp() - cylinder.radius();
163  if (std::abs(rdiff) < tolerance)
164  return true;
165  //
166  // Instantiate HelixBarrelCylinderCrossing and get solutions
167  //
168  HelixBarrelCylinderCrossing cylinderCrossing(fts.position(), fts.momentum(), rho, propagationDirection(), cylinder);
169  if UNLIKELY (!cylinderCrossing.hasSolution())
170  return false;
171  // path length
172  s = cylinderCrossing.pathLength();
173  // point
174  x = cylinderCrossing.position();
175  // direction (renormalised)
176  p = cylinderCrossing.direction().unit() * fts.momentum().mag();
177  return true;
178 }
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
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:139
if(conf_.getParameter< bool >("UseStripCablingDB"))
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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
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 180 of file AnalyticalPropagator.cc.

References funct::abs(), alignCSCRings::e, validate-o2o-wbm::f, LIKELY, LogDebug, PV3DBase< T, PVType, FrameType >::mag(), Basic3DVector< T >::mag(), FreeTrajectoryState::momentum(), oppositeToMomentum, AlCaHLTBitMon_ParallelJobs::p, perp(), PV3DBase< T, PVType, FrameType >::phi(), FreeTrajectoryState::position(), alignCSCRings::s, tolerance, FreeTrajectoryState::transverseCurvature(), and UNLIKELY.

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

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

377  {
378  // get solution
379  std::pair<bool, double> propResult = planeCrossing.pathLength(plane);
380  if UNLIKELY (!propResult.first)
381  return false;
382 
383  s = propResult.second;
384  x = GlobalPoint(planeCrossing.position(s));
385  // direction (reconverted to GlobalVector, renormalised)
386  GlobalVector pGen = GlobalVector(planeCrossing.direction(s));
387  pGen *= pmag / pGen.mag();
388  p = pGen;
389  //
390  return true;
391 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
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

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

propagation to plane with path length

Implements Propagator.

Referenced by DualBzeroTrajectoryFactory::propagateExternal(), and DualTrajectoryFactory::propagateExternal().

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 L1TMuonDQMOffline_cfi::phiMax, and theMaxDPhi2.

59  {
61  return true;
62  }
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 theMaxDBzRatio.

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().