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)
 
virtual AnalyticalPropagatorclone () const override
 
virtual bool setMaxDirectionChange (float phiMax) override
 
void setMaxRelativeChangeInBz (const float maxDBz)
 
 ~AnalyticalPropagator ()
 
- 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

virtual 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 ( )
inline

Member Function Documentation

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

113 {
114  //
115  // for forward propagation: state is before surface,
116  // for backward propagation: state is after surface
117  //
120  //
121  //
122  // error propagation (if needed) and conversion to a TrajectoryStateOnSurface
123  //
124  if (fts.hasError()) {
125  //
126  // compute jacobian
127  //
128  AnalyticalCurvilinearJacobian analyticalJacobian(fts.parameters(), gtp.position(), gtp.momentum(), s);
129  const AlgebraicMatrix55 &jacobian = analyticalJacobian.jacobian();
130  // CurvilinearTrajectoryError cte(ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()));
131  return TsosWP(TrajectoryStateOnSurface(gtp,
132  ROOT::Math::Similarity(jacobian, fts.curvilinearError().matrix()),
133  surface,side),s);
134  }
135  else {
136  //
137  // return state without errors
138  //
139  return TsosWP(TrajectoryStateOnSurface(gtp,surface,side),s);
140  }
141 }
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 143 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, RecoTauCleanerPlugins::tolerance, FreeTrajectoryState::transverseCurvature(), Vector3DBase< T, FrameTag >::unit(), unlikely, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by setMaxRelativeChangeInBz().

146 {
147 
148  GlobalPoint const & sp = cylinder.position();
149  if unlikely(sp.x()!=0. || sp.y()!=0.) {
150  throw PropagationException("Cannot propagate to an arbitrary cylinder");
151  }
152  // preset output
153  x = fts.position();
154  p = fts.momentum();
155  s = 0;
156  // (transverse) curvature
157  auto rho = fts.transverseCurvature();
158  //
159  // Straight line approximation? |rho|<1.e-10 equivalent to ~ 1um
160  // difference in transversal position at 10m.
161  //
162  if unlikely( std::abs(rho)<1.e-10f )
163  return propagateWithLineCrossing(fts.position(),p,cylinder,x,s);
164  //
165  // Helix case
166  //
167  // check for possible intersection
168  constexpr float tolerance = 1.e-4; // 1 micron distance
169  auto rdiff = x.perp() - cylinder.radius();
170  if ( std::abs(rdiff) < tolerance ) return true;
171  //
172  // Instantiate HelixBarrelCylinderCrossing and get solutions
173  //
174  HelixBarrelCylinderCrossing cylinderCrossing(fts.position(),fts.momentum(),rho,
175  propagationDirection(),cylinder);
176  if 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())
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
#define unlikely(x)
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
return(e1-e2)*(e1-e2)+dp *dp
T perp() const
Magnitude of transverse component.
if(dp >Float(M_PI)) dp-
static int position[264][3]
Definition: ReadPGInfo.cc:509
T x() const
Definition: PV3DBase.h:62
const PositionType & position() 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 187 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, RecoTauCleanerPlugins::tolerance, FreeTrajectoryState::transverseCurvature(), and unlikely.

Referenced by setMaxRelativeChangeInBz().

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

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

Referenced by setMaxRelativeChangeInBz().

408  {
409  // get solution
410  std::pair<bool,double> propResult = planeCrossing.pathLength(plane);
411  if unlikely( !propResult.first ) return false;
412 
413  s = propResult.second;
414  x = GlobalPoint(planeCrossing.position(s));
415  // direction (reconverted to GlobalVector, renormalised)
416  GlobalVector pGen = GlobalVector(planeCrossing.direction(s));
417  pGen *= pmag/pGen.mag();
418  p = pGen;
419  //
420  return true;
421 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
#define unlikely(x)
U second(std::pair< T, U > const &p)
virtual std::pair< bool, double > pathLength(const Plane &)=0
return(e1-e2)*(e1-e2)+dp *dp
static int position[264][3]
Definition: ReadPGInfo.cc:509
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.

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