CMS 3D CMS Logo

List of all members | Public Member Functions
fastsim::StraightTrajectory Class Reference

Mathematical representation of a straight trajectory. More...

#include <StraightTrajectory.h>

Inheritance diagram for fastsim::StraightTrajectory:
fastsim::Trajectory

Public Member Functions

bool crosses (const BarrelSimplifiedGeometry &layer) const override
 Check if an intersection of the trajectory with a barrel layer exists. More...
 
void move (double deltaTimeC) override
 Move the particle along the helix trajectory for a given time. More...
 
double nextCrossingTimeC (const BarrelSimplifiedGeometry &layer, bool onLayer=false) const override
 Return delta time (t*c) of the next intersection of trajectory and barrel layer. More...
 
 StraightTrajectory (const Particle &particle)
 Constructor. More...
 
 StraightTrajectory (const Trajectory &trajectory)
 Use Copy Constructor. More...
 
- Public Member Functions inherited from fastsim::Trajectory
const math::XYZTLorentzVectorgetMomentum ()
 Simple getter: return momentum of the particle that was used to create trajectory. More...
 
const math::XYZTLorentzVectorgetPosition ()
 Simple getter: return position of the particle that was used to create trajectory. More...
 
double nextCrossingTimeC (const SimplifiedGeometry &layer, bool onLayer=false) const
 Return delta time (t*c) of the next intersection of trajectory and generic layer. More...
 
double nextCrossingTimeC (const ForwardSimplifiedGeometry &layer, bool onLayer=false) const
 Return delta time (t*c) of the next intersection of trajectory and forward layer. More...
 
virtual ~Trajectory ()
 

Additional Inherited Members

- Static Public Member Functions inherited from fastsim::Trajectory
static std::unique_ptr< TrajectorycreateTrajectory (const fastsim::Particle &particle, const double magneticFieldZ)
 Calls constructor of derived classes. More...
 
- Protected Member Functions inherited from fastsim::Trajectory
 Trajectory (const fastsim::Particle &particle)
 Constructor of base class. More...
 
- Protected Attributes inherited from fastsim::Trajectory
math::XYZTLorentzVector momentum_
 momentum of the particle that was used to create trajectory More...
 
math::XYZTLorentzVector position_
 position of the particle that was used to create trajectory More...
 

Detailed Description

Mathematical representation of a straight trajectory.

Reflects trajectory of a uncharged particle.

Definition at line 19 of file StraightTrajectory.h.

Constructor & Destructor Documentation

fastsim::StraightTrajectory::StraightTrajectory ( const Particle particle)
inline

Constructor.

Definition at line 26 of file StraightTrajectory.h.

26 : Trajectory(particle) {;}
Trajectory(const fastsim::Particle &particle)
Constructor of base class.
Definition: Trajectory.cc:12
fastsim::StraightTrajectory::StraightTrajectory ( const Trajectory trajectory)
inline

Use Copy Constructor.

Definition at line 32 of file StraightTrajectory.h.

32 : Trajectory(trajectory) {;}
Trajectory(const fastsim::Particle &particle)
Constructor of base class.
Definition: Trajectory.cc:12

Member Function Documentation

bool fastsim::StraightTrajectory::crosses ( const BarrelSimplifiedGeometry layer) const
inlineoverridevirtual

Check if an intersection of the trajectory with a barrel layer exists.

There is always an intersection between a straight line and a barrel layer unless the trajectory is parallel to z axis. In this case, the particle is not propagated anyways since it will not hit any detector material.

Parameters
layerA barrel layer.
Returns
true

Implements fastsim::Trajectory.

Definition at line 40 of file StraightTrajectory.h.

References move(), and nextCrossingTimeC().

40 {return true;}
void fastsim::StraightTrajectory::move ( double  deltaTimeC)
overridevirtual

Move the particle along the helix trajectory for a given time.

Parameters
deltaTimeCTime in units of t*c..

Implements fastsim::Trajectory.

Definition at line 81 of file StraightTrajectory.cc.

References fastsim::Trajectory::momentum_, fastsim::Trajectory::position_, and fastsim::Constants::speedOfLight.

Referenced by Vispa.Gui.WidgetContainer.WidgetContainer::autosize(), crosses(), Vispa.Gui.VispaWidget.VispaWidget::dragWidget(), Vispa.Gui.VispaWidget.VispaWidget::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

82 {
83  position_.SetXYZT(
84  position_.X() + momentum_.X()/momentum_.E()*deltaTimeC,
85  position_.Y() + momentum_.Y()/momentum_.E()*deltaTimeC,
86  position_.Z() + momentum_.Z()/momentum_.E()*deltaTimeC,
87  position_.T() + deltaTimeC / fastsim::Constants::speedOfLight);
88 }
static double constexpr speedOfLight
Speed of light [cm / ns].
Definition: Constants.h:16
math::XYZTLorentzVector position_
position of the particle that was used to create trajectory
Definition: Trajectory.h:95
math::XYZTLorentzVector momentum_
momentum of the particle that was used to create trajectory
Definition: Trajectory.h:96
double fastsim::StraightTrajectory::nextCrossingTimeC ( const BarrelSimplifiedGeometry layer,
bool  onLayer = false 
) const
overridevirtual

Return delta time (t*c) of the next intersection of trajectory and barrel layer.

This function solves the quadratic equation (basically intersection a circle with a given radius and a straight line) in order to calculate the moment in time when the particle's trajectory intersects with a given barrel layer.

Parameters
layerA barrel layer.
onLayerSpecify if the particle already is on the layer (in that case the second solution has to be picked).
Returns
t*c [ns * cm/ns] of next intersection (-1 if there is none).

Implements fastsim::Trajectory.

Definition at line 8 of file StraightTrajectory.cc.

References a, b, EnergyCorrector::c, delta, fastsim::BarrelSimplifiedGeometry::getRadius(), fastsim::Trajectory::momentum_, fastsim::Trajectory::position_, and mathSSE::sqrt().

Referenced by crosses(), and fastsim::HelixTrajectory::nextCrossingTimeC().

9 {
10  //
11  // solve the equation
12  // (x^2 + y^2 = R^2), (1)
13  // x = x_0 + v_x*t, (2)
14  // y = y_0 + v_y*t (3)
15  // for t
16  //
17  // subsitute (2) and (3) in (1):
18  // => t^2*(v_x^2 + v_y^2) + t*( 2*x_0*v_x + 2*y_0*v_y ) + x_0^2 + y_0^2 - R^2 = 0
19  // => t = (-b +/- sqrt(b^2 - ac) ) / a see https://en.wikipedia.org/wiki/Quadratic_formula, divide equation by 2
20  // with a = v_x^2 + v_y^2;
21  // with b = x_0*v_x + y_0*v_y
22  // with c = x_0^2 + y_0^2 - R^2
23  //
24  // substitute: v_x = p_x / E * c ( note: extra * c absorbed in p_x units)
25  // substitute: v_y = p_y / E * c ( note: extra * c absorbed in p_y units)
26  // => t*c = (-b +/- sqrt(b^2 - ac) ) / a * E
27  // with a = p_x^2 + p_y^2
28  // with b = p_x*x_0 + p_y*y_0
29  // with c = x_0^2 + y_0^2 - R^2
30  double a = momentum_.Perp2();
31  double b = (position_.X()*momentum_.X() + position_.Y()*momentum_.Y() );
32  double c = position_.Perp2() - layer.getRadius()*layer.getRadius();
33 
34  double delta = b*b - a*c;
35  if(delta < 0)
36  {
37  return -1;
38  }
39  double sqrtDelta = sqrt(delta);
40 
41  //
42  // return the earliest solution > 0,
43  // return -1 if no positive solution exists
44  // note: 'a' always positive, sqrtDelta always positive
45  //
46  double tc1 = (-b - sqrtDelta)/a*momentum_.E();
47  double tc2 = (-b + sqrtDelta)/a*momentum_.E();
48 
49  if(onLayer && tc2 > 0)
50  {
51  bool particleMovesInwards = momentum_.X()*position_.X() + momentum_.Y()*position_.Y() < 0;
52 
53  double posX2 = position_.X() + momentum_.X()/momentum_.E()*tc2;
54  double posY2 = position_.Y() + momentum_.Y()/momentum_.E()*tc2;
55  bool particleMovesInwards2 = momentum_.X()*posX2 + momentum_.Y()*posY2 < 0;
56 
57  if(particleMovesInwards != particleMovesInwards2)
58  {
59  return tc2;
60  }
61 
62  return -1;
63 
64  }
65 
66  if(tc1 > 0)
67  {
68  return tc1;
69  }
70  else if(tc2 > 0)
71  {
72  return tc2;
73  }
74 
75  return -1.;
76 
77 
78 
79 }
dbl * delta
Definition: mlp_gen.cc:36
math::XYZTLorentzVector position_
position of the particle that was used to create trajectory
Definition: Trajectory.h:95
T sqrt(T t)
Definition: SSEVec.h:18
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
math::XYZTLorentzVector momentum_
momentum of the particle that was used to create trajectory
Definition: Trajectory.h:96