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
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
< Trajectory
createTrajectory (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 16 of file StraightTrajectory.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 22 of file StraightTrajectory.h.

22 : 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 28 of file StraightTrajectory.h.

28 : 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 36 of file StraightTrajectory.h.

36 { 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 71 of file StraightTrajectory.cc.

References fastsim::Constants::speedOfLight.

71  {
72  position_.SetXYZT(position_.X() + momentum_.X() / momentum_.E() * deltaTimeC,
73  position_.Y() + momentum_.Y() / momentum_.E() * deltaTimeC,
74  position_.Z() + momentum_.Z() / momentum_.E() * deltaTimeC,
75  position_.T() + deltaTimeC / fastsim::Constants::speedOfLight);
76 }
static double constexpr speedOfLight
Speed of light [cm / ns].
Definition: Constants.h:12
math::XYZTLorentzVector position_
position of the particle that was used to create trajectory
Definition: Trajectory.h:91
math::XYZTLorentzVector momentum_
momentum of the particle that was used to create trajectory
Definition: Trajectory.h:92
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, c, CommonMethods::delta(), fastsim::BarrelSimplifiedGeometry::getRadius(), fastsim::Trajectory::momentum_, fastsim::Trajectory::position_, and mathSSE::sqrt().

Referenced by 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  return -1;
37  }
38  double sqrtDelta = sqrt(delta);
39 
40  //
41  // return the earliest solution > 0,
42  // return -1 if no positive solution exists
43  // note: 'a' always positive, sqrtDelta always positive
44  //
45  double tc1 = (-b - sqrtDelta) / a * momentum_.E();
46  double tc2 = (-b + sqrtDelta) / a * momentum_.E();
47 
48  if (onLayer && tc2 > 0) {
49  bool particleMovesInwards = momentum_.X() * position_.X() + momentum_.Y() * position_.Y() < 0;
50 
51  double posX2 = position_.X() + momentum_.X() / momentum_.E() * tc2;
52  double posY2 = position_.Y() + momentum_.Y() / momentum_.E() * tc2;
53  bool particleMovesInwards2 = momentum_.X() * posX2 + momentum_.Y() * posY2 < 0;
54 
55  if (particleMovesInwards != particleMovesInwards2) {
56  return tc2;
57  }
58 
59  return -1;
60  }
61 
62  if (tc1 > 0) {
63  return tc1;
64  } else if (tc2 > 0) {
65  return tc2;
66  }
67 
68  return -1.;
69 }
const edm::EventSetup & c
constexpr std::array< uint8_t, layerIndexSize > layer
math::XYZTLorentzVector position_
position of the particle that was used to create trajectory
Definition: Trajectory.h:91
T sqrt(T t)
Definition: SSEVec.h:19
double b
Definition: hdecay.h:118
double a
Definition: hdecay.h:119
math::XYZTLorentzVector momentum_
momentum of the particle that was used to create trajectory
Definition: Trajectory.h:92