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 23 of file AnalyticalPropagator.h.

Member Typedef Documentation

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

Definition at line 119 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 27 of file AnalyticalPropagator.h.

Referenced by clone().

29  :
30  Propagator(dir),
32  theMaxDBzRatio(0.5),
33  theField(field),
34  isOldPropagationType(isOld) {}
Propagator(PropagationDirection dir=alongMomentum)
Definition: Propagator.h:46
const MagneticField * theField
dbl *** dir
Definition: mlp_gen.cc:35
AnalyticalPropagator::~AnalyticalPropagator ( )
inlineoverride

Member Function Documentation

AnalyticalPropagator* AnalyticalPropagator::clone ( void  ) const
inlineoverridevirtual

Implements Propagator.

Definition at line 70 of file AnalyticalPropagator.h.

References AnalyticalPropagator().

71  {
72  return new AnalyticalPropagator(*this);
73  }
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 116 of file AnalyticalPropagator.h.

References theField.

116 {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 110 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().

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

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

References funct::abs(), 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(), Geom::Phi< T >::phi(), PV3DBase< T, PVType, FrameType >::phi(), StraightLineBarrelCylinderCrossing::position(), StraightLinePlaneCrossing::position(), FreeTrajectoryState::position(), propagateWithLineCrossing(), alignCSCRings::s, indexGen::s2, tolerance, FreeTrajectoryState::transverseCurvature(), and UNLIKELY.

Referenced by setMaxRelativeChangeInBz().

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

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

Referenced by setMaxRelativeChangeInBz().

409  {
410  // get solution
411  std::pair<bool,double> propResult = planeCrossing.pathLength(plane);
412  if UNLIKELY( !propResult.first ) return false;
413 
414  s = propResult.second;
415  x = GlobalPoint(planeCrossing.position(s));
416  // direction (reconverted to GlobalVector, renormalised)
417  GlobalVector pGen = GlobalVector(planeCrossing.direction(s));
418  pGen *= pmag/pGen.mag();
419  p = pGen;
420  //
421  return true;
422 }
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:509
#define UNLIKELY(x)
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 65 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 79 of file AnalyticalPropagator.h.

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

79  {
80  theMaxDBzRatio = maxDBz;
81  }

Member Data Documentation

bool AnalyticalPropagator::isOldPropagationType
private

Definition at line 123 of file AnalyticalPropagator.h.

const MagneticField* AnalyticalPropagator::theField
private

Definition at line 122 of file AnalyticalPropagator.h.

Referenced by magneticField().

float AnalyticalPropagator::theMaxDBzRatio
private

Definition at line 121 of file AnalyticalPropagator.h.

Referenced by setMaxRelativeChangeInBz().

float AnalyticalPropagator::theMaxDPhi2
private

Definition at line 120 of file AnalyticalPropagator.h.

Referenced by setMaxDirectionChange().