RooParticle
Particle scattering simulator with ROOT
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
path Class Reference

Time-ordered list of (position, velocity, time) samples of one particle. More...

#include <path.hpp>

Public Member Functions

 path ()
 Create an empty path.
 
 path (const path &path_)
 Copy constructor: copies all records (deep copy of the three vectors).
 
 ~path ()
 Destructor: clears the records.
 
void AddRecord (TVector3 x_, TVector3 v_, Double_t time_)
 Append one record at the end.
 
Int_t GetRecordSize ()
 Number of stored records (size of the position vector).
 
TVector3 GetRecordX (Int_t i)
 Position of record i (fm).
 
TVector3 GetRecordV (Int_t i)
 Velocity of record i (c); same failure behaviour as GetRecordX().
 
Double_t GetRecordT (Int_t i)
 Time of record i (fm/c).
 
void GetRecord (Int_t i, TVector3 &x_, TVector3 &v_, Double_t &t_)
 Position, velocity and time of record i in one call.
 
TVector3 GetInitX ()
 Position of the first record (fm); null vector plus message if the path is empty.
 
TVector3 GetInitV ()
 Velocity of the first record (c); null vector plus message if the path is empty.
 
Double_t GetInitT ()
 Time of the first record (fm/c); 0 plus message if the path is empty.
 
void GetInit (TVector3 &x_, TVector3 &v_, Double_t &t_)
 First record as position (fm), velocity (c) and time (fm/c).
 
TVector3 GetLastX ()
 Position of the last stored record (fm); null vector plus message if empty.
 
TVector3 GetLastV ()
 Velocity of the last stored record (c); null vector plus message if empty.
 
Double_t GetLastT ()
 Time of the last stored record (fm/c); 0 plus message if empty.
 
void GetLast (TVector3 &x_, TVector3 &v_, Double_t &t_)
 Last stored record as position (fm), velocity (c) and time (fm/c).
 
void GetDCA (const TVector3 pos_, Double_t &DCA, Double_t &outtime, Bool_t verbose=false, Bool_t interpolate=true)
 Distance of closest approach of this path to a fixed point.
 
void GetDCA (path *timepath, Double_t &DCA, Double_t &outtime, Bool_t verbose=false, Bool_t interpolate=true)
 Distance of closest approach between this path and another path.
 
Long64_t GetMaxNumber ()
 Number of stored time stamps (as a 64-bit integer); equals GetRecordSize().
 

Protected Member Functions

Bool_t lengthChk (path *target)
 True if target has the same number of records; otherwise prints a message on std::cerr and returns false.
 
Bool_t timeChk (path *target)
 True if target has the same length and exactly equal times in every record; prints a message on std::cerr and returns false otherwise.
 

Private Attributes

std::vector< TVector3 > pos
 positions (fm)
 
std::vector< TVector3 > vel
 velocities (c)
 
std::vector< Double_t > t
 times (fm/c)
 

Detailed Description

Time-ordered list of (position, velocity, time) samples of one particle.

A particle owns one path when its recording is switched on; every recorded step appends one record with the particle's position (fm), velocity (c) and its own clock etime (fm/c). The three internal vectors always have the same length, record i is the i-th stored sample (not the i-th simulation step: see particle::SetRecordPeriod).

Warning
With a record period n > 1 only every n-th step is stored, so GetLast() / GetLastX() is NOT the final state of the particle (use the particle itself for that). The DCA search also sees only the stored samples, so a coarse record period makes the discrete minimum coarse (the interpolation of GetDCA() only partly compensates).
Note
An invincible (fixed) particle does not advance its own clock, so the times in its path stay constant; such a path does not share a time grid with the path of a moving particle (see the path-vs-path GetDCA()). For a fixed centre use the point overload instead.
The getters never throw. For an out-of-range index or an empty path they print a message on std::cerr and return a null vector / 0.

Definition at line 37 of file path.hpp.

Constructor & Destructor Documentation

◆ path() [1/2]

path::path ( )

Create an empty path.

Definition at line 12 of file path.cpp.

◆ path() [2/2]

path::path ( const path &  path_)

Copy constructor: copies all records (deep copy of the three vectors).

Definition at line 15 of file path.cpp.

◆ ~path()

path::~path ( )

Destructor: clears the records.

Definition at line 32 of file path.cpp.

Member Function Documentation

◆ AddRecord()

void path::AddRecord ( TVector3  x_,
TVector3  v_,
Double_t  time_ = -1. 
)

Append one record at the end.

Parameters
x_position in fm
v_velocity in c
time_time in fm/c (the particle's own clock)
Note
The definition in path.cpp declares a default time of -1, but the header has none, so callers must always pass the time.

Definition at line 42 of file path.cpp.

◆ GetDCA() [1/2]

void path::GetDCA ( const TVector3  pos_,
Double_t &  DCA,
Double_t &  outtime,
Bool_t  verbose = false,
Bool_t  interpolate = true 
)

Distance of closest approach of this path to a fixed point.

The distance squared \(d_i^2 = |\vec x_i - \vec p|^2\) is evaluated at every stored record and the smallest one (first one on a tie) is taken. With interpolate the result is refined: a parabola through the distance squared of the three records around the discrete minimum (indices k-1, k, k+1; the time grid need not be uniform) gives the sub-step minimum and the time at which it occurs. The refined value is \(\sqrt{d^2_{\min}}\) with \(d^2_{\min}\) the parabola's vertex value. The discrete values are kept instead if the minimum is the first or last record, if the times around it are not strictly increasing, if the parabola does not open upwards, or if its vertex lies outside [t(k-1), t(k+1)]. Without interpolate the discrete minimum is returned.

Parameters
pos_the point (fm); only the path moves, the point is fixed
[out]DCAdistance of closest approach (fm), or -1 on failure
[out]outtimetime of the closest approach (fm/c, the path's own clock), or -1 on failure
verboseif true, print the index, DCA and time on std::cerr
interpolateif true (default), refine by the parabola
Note
Failure: if the path is empty (or its position and time vectors differ in length), both outputs are set to the sentinel -1 and a message goes to std::cerr. The sentinel -1 is distinguishable from a result because a real distance is never negative.
The path only knows its stored samples. With a record period > 1 the true minimum may be missed between samples.

Definition at line 181 of file path.cpp.

◆ GetDCA() [2/2]

void path::GetDCA ( path *  timepath,
Double_t &  DCA,
Double_t &  outtime,
Bool_t  verbose = false,
Bool_t  interpolate = true 
)

Distance of closest approach between this path and another path.

The two paths are compared record by record, so they must lie on the same time grid: the same number of records and equal times in every record (exact floating-point equality). The relative distance squared \(|\vec x^{(a)}_i - \vec x^{(b)}_i|^2\) is minimised exactly as in GetDCA(const TVector3, Double_t&, Double_t&, Bool_t, Bool_t) and refined by the same parabola when interpolate is true. The time is taken from this path.

Parameters
timepaththe other path, not owned; must not be null
[out]DCAdistance of closest approach (fm), or -1 on failure
[out]outtimetime of the closest approach (fm/c), or -1 on failure
verboseif true, print the index, DCA and time on std::cerr
interpolateif true (default), refine by the parabola
Note
Failure (both outputs set to the sentinel -1, message on std::cerr): timepath is null; the paths differ in length or in any time; this path is empty.
Warning
Two paths from particles with different clocks (e.g. an invincible particle, whose clock does not advance) or with different record periods do not share a time grid and give -1.

Definition at line 210 of file path.cpp.

◆ GetInit()

void path::GetInit ( TVector3 &  x_,
TVector3 &  v_,
Double_t &  t_ 
)

First record as position (fm), velocity (c) and time (fm/c).

Parameters
[out]x_position
[out]v_velocity
[out]t_time

Definition at line 106 of file path.cpp.

◆ GetInitT()

Double_t path::GetInitT ( )

Time of the first record (fm/c); 0 plus message if the path is empty.

Definition at line 98 of file path.cpp.

◆ GetInitV()

TVector3 path::GetInitV ( )

Velocity of the first record (c); null vector plus message if the path is empty.

Definition at line 90 of file path.cpp.

◆ GetInitX()

TVector3 path::GetInitX ( )

Position of the first record (fm); null vector plus message if the path is empty.

Definition at line 82 of file path.cpp.

◆ GetLast()

void path::GetLast ( TVector3 &  x_,
TVector3 &  v_,
Double_t &  t_ 
)

Last stored record as position (fm), velocity (c) and time (fm/c).

Parameters
[out]x_position
[out]v_velocity
[out]t_time

Definition at line 138 of file path.cpp.

◆ GetLastT()

Double_t path::GetLastT ( )

Time of the last stored record (fm/c); 0 plus message if empty.

Definition at line 130 of file path.cpp.

◆ GetLastV()

TVector3 path::GetLastV ( )

Velocity of the last stored record (c); null vector plus message if empty.

Definition at line 122 of file path.cpp.

◆ GetLastX()

TVector3 path::GetLastX ( )

Position of the last stored record (fm); null vector plus message if empty.

Warning
Not the final state of the particle when the record period is > 1.

Definition at line 114 of file path.cpp.

◆ GetMaxNumber()

Long64_t path::GetMaxNumber ( )
inline

Number of stored time stamps (as a 64-bit integer); equals GetRecordSize().

Definition at line 152 of file path.hpp.

◆ GetRecord()

void path::GetRecord ( Int_t  i,
TVector3 &  x_,
TVector3 &  v_,
Double_t &  t_ 
)

Position, velocity and time of record i in one call.

Parameters
irecord index
[out]x_position (fm)
[out]v_velocity (c)
[out]t_time (fm/c) Each output falls back individually as in GetRecordX(), GetRecordV(), GetRecordT().

Definition at line 73 of file path.cpp.

◆ GetRecordSize()

Int_t path::GetRecordSize ( )
inline

Number of stored records (size of the position vector).

Definition at line 54 of file path.hpp.

◆ GetRecordT()

Double_t path::GetRecordT ( Int_t  i)

Time of record i (fm/c).

Returns
the time, or 0 (and a message on std::cerr) if the path is empty or i is out of range. Note that 0 is also a valid time.

Definition at line 65 of file path.cpp.

◆ GetRecordV()

TVector3 path::GetRecordV ( Int_t  i)

Velocity of record i (c); same failure behaviour as GetRecordX().

Definition at line 57 of file path.cpp.

◆ GetRecordX()

TVector3 path::GetRecordX ( Int_t  i)

Position of record i (fm).

Parameters
irecord index, 0 .. size-1
Returns
the position, or a null vector (and a message on std::cerr) if the path is empty or i is out of range (a negative i also counts)

Definition at line 48 of file path.cpp.

◆ lengthChk()

Bool_t path::lengthChk ( path *  target)
protected

True if target has the same number of records; otherwise prints a message on std::cerr and returns false.

Definition at line 246 of file path.cpp.

◆ timeChk()

Bool_t path::timeChk ( path *  target)
protected

True if target has the same length and exactly equal times in every record; prints a message on std::cerr and returns false otherwise.

Definition at line 256 of file path.cpp.

Member Data Documentation

◆ pos

std::vector<TVector3> path::pos
private

positions (fm)

Definition at line 163 of file path.hpp.

◆ t

std::vector<Double_t> path::t
private

times (fm/c)

Definition at line 165 of file path.hpp.

◆ vel

std::vector<TVector3> path::vel
private

velocities (c)

Definition at line 164 of file path.hpp.


The documentation for this class was generated from the following files: