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

A point body with mass, position, velocity, step count, time and an optional recorded path. More...

#include <particle.hpp>

Inheritance diagram for particle:
EMparticle

Public Member Functions

 particle (Double_t m0_=1, TVector3 x0_=TVector3(), TVector3 v0_=TVector3(), Bool_t Invincible_=false, Bool_t Record_=false)
 Make a particle.
 
 particle (const particle &p)
 Copy constructor: state, step count, time, charge, record flag and period, and a copy of the path.
 
 ~particle ()
 Destructor; deletes the path (not virtual: delete a particle through its own or its base type only, no member is allocated by subclasses).
 
void holdForce (const TVector3 f)
 Add a force to the pending force of this particle.
 
void releaseForce (const Double_t dt)
 Apply the held force for one step of dt (see applyForce()) and clear it.
 
void resetHold ()
 Discard the held force.
 
void finishStep (const Double_t dt)
 Close one integration step whose x, v were already updated by the event (step count, time and path record). Used by the selectable integrators.
 
TVector3 calculateCalibrateVelocity (event *ev_, Bool_t ignoreInvincible=kFALSE)
 Velocity change which makes the given velocity the one far from the other bodies.
 
TVector3 calibrateVelocity (event *ev_, Bool_t ignoreInvincible=kFALSE, Bool_t verbose=kFALSE)
 Apply calculateCalibrateVelocity() to this particle.
 
void applyMechanic (const TVector3 x_, const TVector3 v_)
 Set position and velocity (fm, c).
 
void applyX (const TVector3 x_)
 Set the position (fm).
 
void applyV (const TVector3 v_)
 Set the velocity (c).
 
void applyForce (const TVector3 f, const Double_t dt=1., Bool_t SR=kFALSE)
 Move the particle for one step under a constant force (the original Taylor step).
 
void applyDX (const TVector3 dx)
 Add dx (fm) to the position.
 
void applyDV (const TVector3 dv)
 Add dv (c) to the velocity.
 
void applyDelta (const TVector3 dx, const TVector3 dv)
 Add dx (fm) to the position and dv (c) to the velocity.
 
void SetName (const TString name_)
 Set a name for printing.
 
void AddRecord ()
 Append the present x, v and time to the path now, whatever the record period.
 
void SetRecordPeriod (Int_t n)
 Set the record period of the path.
 
Int_t GetRecordPeriod ()
 The record period (see SetRecordPeriod()).
 
TVector3 GetX ()
 Position in fm (a copy).
 
TVector3 GetV ()
 Velocity in c (a copy).
 
TVector3 GetP ()
 Non-relativistic momentum \(m_0 v\) in amu c (same as GetMomentum(kFALSE)).
 
TVector3 GetMomentum (Bool_t relativistic=kFALSE)
 Momentum in amu c.
 
Long_t GetECNT ()
 Number of derived steps ("evolved count"), counted also for an invincible particle.
 
Double_t GetM0 ()
 Rest mass in amu.
 
Double_t GetM (const Bool_t restmass=kTRUE)
 Mass in amu.
 
Double_t GetGamma ()
 Lorentz factor \(1/\sqrt{1 - v^2}\) (v in c); NaN for speed above c.
 
Double_t GetKE (const Bool_t SR=kFALSE)
 Kinetic energy in amu c^2.
 
Double_t GetQ ()
 Charge in e. 0 for a plain particle, set by EMparticle.
 
Double_t GetTime ()
 Evolved time in fm/c; does not advance for an invincible particle.
 
path * GetPath ()
 The recorded path (owned by the particle; a null pointer if not recording).
 
Bool_t IsInvincible ()
 Whether the particle is fixed (invincible).
 
Bool_t IsRecording ()
 Whether the particle records its path.
 
TString Print (Bool_t onlymechanic=kFALSE, Bool_t mute=kFALSE)
 Describe the particle as text "[ Particle x: [..], v: [..] ]".
 

Protected Attributes

Double_t q = 0
 charge in e
 

Private Member Functions

void recordStep ()
 

Private Attributes

TString name
 name for printing
 
TVector3 x = TVector3()
 position in fm
 
TVector3 v = TVector3()
 velocity in c
 
Double_t m0 = 1
 rest mass in amu
 
Bool_t Invincible = false
 fixed particle
 
Bool_t hold = false
 a force is held
 
TVector3 hF = TVector3()
 held force in amu c^2/fm
 
Double_t etime = 0.
 evolved time in fm/c
 
Long_t ecount = 0
 number of derived steps
 
Bool_t Record = false
 records the path
 
Int_t recordPeriod = 1
 a step is recorded when ecount is a multiple of it
 
path * ppath = nullptr
 the path (owned)
 

Friends

class inspectorP
 

Detailed Description

A point body with mass, position, velocity, step count, time and an optional recorded path.

Units: mass in amu, position in fm, velocity in c, time in fm/c, momentum in amu c, energy in amu c^2. The charge is 0 for a plain particle (see EMparticle).

Invincible particles
An invincible particle is a fixed one: it exerts forces on the others but is never moved by the event (the integrators skip it and applyForce() leaves it alone). It still counts every step (GetECNT(), so "CNT" inspectors work on it) and records its path, but its time GetTime() does not advance. The apply* setters change it anyway when called directly.
Step count, time and path
Every derived step increments GetECNT(). A moving particle also advances its time by dt. If the particle is recording, a point (x, v, time) is appended to the path after a step when the step count is a multiple of the record period (SetRecordPeriod(), default 1). The constructor does not record the initial state: call AddRecord() to store it.
Ownership and copying
The particle owns its path (deleted by the destructor, GetPath() only lends it). The copy constructor copies the state, the step count and time, the charge, the record flag and period, and the path (a deep copy). The default assignment operator is not suitable (it would share the path pointer): use the copy constructor.

Definition at line 36 of file particle.hpp.

Constructor & Destructor Documentation

◆ particle() [1/2]

particle::particle ( Double_t  m0_ = 1,
TVector3  x0_ = TVector3(),
TVector3  v0_ = TVector3(),
Bool_t  Invincible_ = false,
Bool_t  Record_ = false 
)

Make a particle.

Parameters
m0_rest mass in amu
x0_initial position in fm
v0_initial velocity in c
Invincible_true for a fixed particle that acts on others but never moves
Record_true to keep the track of the particle in a path (GetPath()); the path is then empty until the first recorded step

The charge is 0 (use EMparticle for a charged particle).

Definition at line 18 of file particle.cpp.

◆ particle() [2/2]

particle::particle ( const particle &  p)

Copy constructor: state, step count, time, charge, record flag and period, and a copy of the path.

Parameters
pparticle to copy

The copy continues the same step count, so "CNT" inspectors count from there. A copy of an EMparticle is a plain particle with the same charge.

Definition at line 39 of file particle.cpp.

◆ ~particle()

particle::~particle ( )
inline

Destructor; deletes the path (not virtual: delete a particle through its own or its base type only, no member is allocated by subclasses).

Definition at line 66 of file particle.hpp.

Member Function Documentation

◆ AddRecord()

void particle::AddRecord ( )
inline

Append the present x, v and time to the path now, whatever the record period.

Does nothing if the particle is not recording. Use it to store the initial state.

Definition at line 146 of file particle.hpp.

◆ applyDelta()

void particle::applyDelta ( const TVector3  dx,
const TVector3  dv 
)
inline

Add dx (fm) to the position and dv (c) to the velocity.

Definition at line 138 of file particle.hpp.

◆ applyDV()

void particle::applyDV ( const TVector3  dv)
inline

Add dv (c) to the velocity.

Definition at line 135 of file particle.hpp.

◆ applyDX()

void particle::applyDX ( const TVector3  dx)
inline

Add dx (fm) to the position.

Definition at line 132 of file particle.hpp.

◆ applyForce()

void particle::applyForce ( const TVector3  f,
const Double_t  dt = 1.,
Bool_t  SR = kFALSE 
)

Move the particle for one step under a constant force (the original Taylor step).

Parameters
fforce in amu c^2/fm
dttime step in fm/c (default 1)
SRfalse (default) : mass is the rest mass; true : mass is \(\gamma m_0\) (a crude correction, not full relativistic dynamics)

With a = f/m: x += v dt + a dt^2/2, v += a dt, time += dt. Always counts a step and records the path (according to the record period); an invincible particle is neither moved nor advanced in time.

Definition at line 117 of file particle.cpp.

◆ applyMechanic()

void particle::applyMechanic ( const TVector3  x_,
const TVector3  v_ 
)
inline

Set position and velocity (fm, c).

Definition at line 112 of file particle.hpp.

◆ applyV()

void particle::applyV ( const TVector3  v_)
inline

Set the velocity (c).

Definition at line 118 of file particle.hpp.

◆ applyX()

void particle::applyX ( const TVector3  x_)
inline

Set the position (fm).

Definition at line 115 of file particle.hpp.

◆ calculateCalibrateVelocity()

TVector3 particle::calculateCalibrateVelocity ( event *  ev_,
Bool_t  ignoreInvincible = kFALSE 
)

Velocity change which makes the given velocity the one far from the other bodies.

Parameters
ev_event the particle is in (the potentials come from its forces)
ignoreInvinciblefalse (default) : an invincible particle returns the zero vector; true : it is calibrated like the others
Returns
the vector to add to v (along the present direction of v, changing the speed to \(v'^2 = v^2 - (U_{all} + U_{inv})/m_0\), rest mass and non-relativistic). NaN if the radicand is negative. The particle is not changed.

\(U_{all}\) is event::GetPE() of this particle with every other body and \(U_{inv}\) the part with invincible bodies, so an invincible partner is removed fully and a moving partner by half (the energy of that pair is shared by the two bodies).

Definition at line 90 of file particle.cpp.

◆ calibrateVelocity()

TVector3 particle::calibrateVelocity ( event *  ev_,
Bool_t  ignoreInvincible = kFALSE,
Bool_t  verbose = kFALSE 
)

Apply calculateCalibrateVelocity() to this particle.

Parameters
ev_event the particle is in
ignoreInvinciblesee calculateCalibrateVelocity()
verbosetrue prints the kinetic energy before and after
Returns
the velocity change that was added.

Definition at line 107 of file particle.cpp.

◆ finishStep()

void particle::finishStep ( const Double_t  dt)

Close one integration step whose x, v were already updated by the event (step count, time and path record). Used by the selectable integrators.

Parameters
dttime step in fm/c; the time advances by dt unless the particle is invincible.

Definition at line 80 of file particle.cpp.

◆ GetECNT()

Long_t particle::GetECNT ( )
inline

Number of derived steps ("evolved count"), counted also for an invincible particle.

Definition at line 176 of file particle.hpp.

◆ GetGamma()

Double_t particle::GetGamma ( )

Lorentz factor \(1/\sqrt{1 - v^2}\) (v in c); NaN for speed above c.

Definition at line 146 of file particle.cpp.

◆ GetKE()

Double_t particle::GetKE ( const Bool_t  SR = kFALSE)
inline

Kinetic energy in amu c^2.

Parameters
SRkFALSE (default) : \(\frac12 m_0 v^2\) ; kTRUE : \(\frac12 \gamma m_0 v^2\).

Neither is the relativistic kinetic energy \((\gamma-1) m_0\); for that see event::GetNetKERel(). Not zero for an invincible particle (the event skips it).

Definition at line 193 of file particle.hpp.

◆ GetM()

Double_t particle::GetM ( const Bool_t  restmass = kTRUE)

Mass in amu.

Parameters
restmasskTRUE (default) : the rest mass; kFALSE : \(\gamma m_0\) (NaN for speed >= c).

Definition at line 138 of file particle.cpp.

◆ GetM0()

Double_t particle::GetM0 ( )
inline

Rest mass in amu.

Definition at line 179 of file particle.hpp.

◆ GetMomentum()

TVector3 particle::GetMomentum ( Bool_t  relativistic = kFALSE)

Momentum in amu c.

Parameters
relativisticfalse (default) : \(m_0 v\) ; true : \(\gamma m_0 v\)

Definition at line 152 of file particle.cpp.

◆ GetP()

TVector3 particle::GetP ( )
inline

Non-relativistic momentum \(m_0 v\) in amu c (same as GetMomentum(kFALSE)).

Not the momentum of the relativistic dynamics, see GetMomentum().

Definition at line 169 of file particle.hpp.

◆ GetPath()

path * particle::GetPath ( )
inline

The recorded path (owned by the particle; a null pointer if not recording).

Definition at line 205 of file particle.hpp.

◆ GetQ()

Double_t particle::GetQ ( )
inline

Charge in e. 0 for a plain particle, set by EMparticle.

It lives here (not only in EMparticle) so that forces read it from particle* without casting, and so that it survives event copies, which copy particles as particle.

Definition at line 199 of file particle.hpp.

◆ GetRecordPeriod()

Int_t particle::GetRecordPeriod ( )
inline

The record period (see SetRecordPeriod()).

Definition at line 158 of file particle.hpp.

◆ GetTime()

Double_t particle::GetTime ( )
inline

Evolved time in fm/c; does not advance for an invincible particle.

Definition at line 202 of file particle.hpp.

◆ GetV()

TVector3 particle::GetV ( )
inline

Velocity in c (a copy).

Definition at line 164 of file particle.hpp.

◆ GetX()

TVector3 particle::GetX ( )
inline

Position in fm (a copy).

Definition at line 161 of file particle.hpp.

◆ holdForce()

void particle::holdForce ( const TVector3  f)

Add a force to the pending force of this particle.

Parameters
fforce in amu c^2/fm. Several calls sum up until releaseForce() or resetHold().

Definition at line 60 of file particle.cpp.

◆ IsInvincible()

Bool_t particle::IsInvincible ( )
inline

Whether the particle is fixed (invincible).

Definition at line 208 of file particle.hpp.

◆ IsRecording()

Bool_t particle::IsRecording ( )
inline

Whether the particle records its path.

Definition at line 211 of file particle.hpp.

◆ Print()

TString particle::Print ( Bool_t  onlymechanic = kFALSE,
Bool_t  mute = kFALSE 
)

Describe the particle as text "[ Particle x: [..], v: [..] ]".

Parameters
onlymechanichas no effect at present
mutefalse (default) also prints the text to stdout
Returns
the text.

Definition at line 173 of file particle.cpp.

◆ recordStep()

void particle::recordStep ( )
inlineprivate

Definition at line 242 of file particle.hpp.

◆ releaseForce()

void particle::releaseForce ( const Double_t  dt)

Apply the held force for one step of dt (see applyForce()) and clear it.

Parameters
dttime step in fm/c

This is the step of the original scheme: it counts a step also for an invincible particle (which then does not move) and also when no force was held.

Definition at line 70 of file particle.cpp.

◆ resetHold()

void particle::resetHold ( )

Discard the held force.

Definition at line 75 of file particle.cpp.

◆ SetName()

void particle::SetName ( const TString  name_)
inline

Set a name for printing.

Definition at line 141 of file particle.hpp.

◆ SetRecordPeriod()

void particle::SetRecordPeriod ( Int_t  n)
inline

Set the record period of the path.

Parameters
na step is appended when the step count is a multiple of n (default 1 : every step). n < 1 is taken as 1.

With n > 1, path::GetLast*() is the last recorded step, NOT the final state of the particle unless the step count is a multiple of n: use GetX(), GetV(), GetTime() for the final state.

Definition at line 155 of file particle.hpp.

Friends And Related Symbol Documentation

◆ inspectorP

friend class inspectorP
friend

Definition at line 219 of file particle.hpp.

Member Data Documentation

◆ ecount

Long_t particle::ecount = 0
private

number of derived steps

Definition at line 235 of file particle.hpp.

◆ etime

Double_t particle::etime = 0.
private

evolved time in fm/c

Definition at line 234 of file particle.hpp.

◆ hF

TVector3 particle::hF = TVector3()
private

held force in amu c^2/fm

Definition at line 232 of file particle.hpp.

◆ hold

Bool_t particle::hold = false
private

a force is held

Definition at line 231 of file particle.hpp.

◆ Invincible

Bool_t particle::Invincible = false
private

fixed particle

Definition at line 230 of file particle.hpp.

◆ m0

Double_t particle::m0 = 1
private

rest mass in amu

Definition at line 228 of file particle.hpp.

◆ name

TString particle::name
private

name for printing

Definition at line 225 of file particle.hpp.

◆ ppath

path* particle::ppath = nullptr
private

the path (owned)

Definition at line 239 of file particle.hpp.

◆ q

Double_t particle::q = 0
protected

charge in e

Definition at line 222 of file particle.hpp.

◆ Record

Bool_t particle::Record = false
private

records the path

Definition at line 237 of file particle.hpp.

◆ recordPeriod

Int_t particle::recordPeriod = 1
private

a step is recorded when ecount is a multiple of it

Definition at line 238 of file particle.hpp.

◆ v

TVector3 particle::v = TVector3()
private

velocity in c

Definition at line 227 of file particle.hpp.

◆ x

TVector3 particle::x = TVector3()
private

position in fm

Definition at line 226 of file particle.hpp.


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