|
RooParticle
Particle scattering simulator with ROOT
|
A point body with mass, position, velocity, step count, time and an optional recorded path. More...
#include <particle.hpp>
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 |
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).
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.Definition at line 36 of file particle.hpp.
| particle::particle | ( | Double_t | m0_ = 1, |
| TVector3 | x0_ = TVector3(), |
||
| TVector3 | v0_ = TVector3(), |
||
| Bool_t | Invincible_ = false, |
||
| Bool_t | Record_ = false |
||
| ) |
Make a particle.
| 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::particle | ( | const particle & | p | ) |
Copy constructor: state, step count, time, charge, record flag and period, and a copy of the path.
| p | particle 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.
|
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.
|
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.
|
inline |
Add dx (fm) to the position and dv (c) to the velocity.
Definition at line 138 of file particle.hpp.
|
inline |
Add dv (c) to the velocity.
Definition at line 135 of file particle.hpp.
|
inline |
Add dx (fm) to the position.
Definition at line 132 of file particle.hpp.
| 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).
| f | force in amu c^2/fm |
| dt | time step in fm/c (default 1) |
| SR | false (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.
|
inline |
Set position and velocity (fm, c).
Definition at line 112 of file particle.hpp.
|
inline |
Set the velocity (c).
Definition at line 118 of file particle.hpp.
|
inline |
Set the position (fm).
Definition at line 115 of file particle.hpp.
| TVector3 particle::calculateCalibrateVelocity | ( | event * | ev_, |
| Bool_t | ignoreInvincible = kFALSE |
||
| ) |
Velocity change which makes the given velocity the one far from the other bodies.
| ev_ | event the particle is in (the potentials come from its forces) |
| ignoreInvincible | false (default) : an invincible particle returns the zero vector; true : it is calibrated like the others |
\(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.
| TVector3 particle::calibrateVelocity | ( | event * | ev_, |
| Bool_t | ignoreInvincible = kFALSE, |
||
| Bool_t | verbose = kFALSE |
||
| ) |
Apply calculateCalibrateVelocity() to this particle.
| ev_ | event the particle is in |
| ignoreInvincible | see calculateCalibrateVelocity() |
| verbose | true prints the kinetic energy before and after |
Definition at line 107 of file particle.cpp.
| 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.
| dt | time step in fm/c; the time advances by dt unless the particle is invincible. |
Definition at line 80 of file particle.cpp.
|
inline |
Number of derived steps ("evolved count"), counted also for an invincible particle.
Definition at line 176 of file particle.hpp.
| 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.
|
inline |
Kinetic energy in amu c^2.
| SR | kFALSE (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.
| Double_t particle::GetM | ( | const Bool_t | restmass = kTRUE | ) |
Mass in amu.
| restmass | kTRUE (default) : the rest mass; kFALSE : \(\gamma m_0\) (NaN for speed >= c). |
Definition at line 138 of file particle.cpp.
|
inline |
Rest mass in amu.
Definition at line 179 of file particle.hpp.
| TVector3 particle::GetMomentum | ( | Bool_t | relativistic = kFALSE | ) |
Momentum in amu c.
| relativistic | false (default) : \(m_0 v\) ; true : \(\gamma m_0 v\) |
Definition at line 152 of file particle.cpp.
|
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.
|
inline |
The recorded path (owned by the particle; a null pointer if not recording).
Definition at line 205 of file particle.hpp.
|
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.
|
inline |
The record period (see SetRecordPeriod()).
Definition at line 158 of file particle.hpp.
|
inline |
Evolved time in fm/c; does not advance for an invincible particle.
Definition at line 202 of file particle.hpp.
|
inline |
Velocity in c (a copy).
Definition at line 164 of file particle.hpp.
|
inline |
Position in fm (a copy).
Definition at line 161 of file particle.hpp.
| void particle::holdForce | ( | const TVector3 | f | ) |
Add a force to the pending force of this particle.
| f | force in amu c^2/fm. Several calls sum up until releaseForce() or resetHold(). |
Definition at line 60 of file particle.cpp.
|
inline |
Whether the particle is fixed (invincible).
Definition at line 208 of file particle.hpp.
|
inline |
Whether the particle records its path.
Definition at line 211 of file particle.hpp.
| TString particle::Print | ( | Bool_t | onlymechanic = kFALSE, |
| Bool_t | mute = kFALSE |
||
| ) |
Describe the particle as text "[ Particle x: [..], v: [..] ]".
| onlymechanic | has no effect at present |
| mute | false (default) also prints the text to stdout |
Definition at line 173 of file particle.cpp.
|
inlineprivate |
Definition at line 242 of file particle.hpp.
| void particle::releaseForce | ( | const Double_t | dt | ) |
Apply the held force for one step of dt (see applyForce()) and clear it.
| dt | time 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.
| void particle::resetHold | ( | ) |
Discard the held force.
Definition at line 75 of file particle.cpp.
|
inline |
Set a name for printing.
Definition at line 141 of file particle.hpp.
|
inline |
Set the record period of the path.
| n | a 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.
|
friend |
Definition at line 219 of file particle.hpp.
|
private |
number of derived steps
Definition at line 235 of file particle.hpp.
|
private |
evolved time in fm/c
Definition at line 234 of file particle.hpp.
|
private |
held force in amu c^2/fm
Definition at line 232 of file particle.hpp.
|
private |
a force is held
Definition at line 231 of file particle.hpp.
|
private |
fixed particle
Definition at line 230 of file particle.hpp.
|
private |
rest mass in amu
Definition at line 228 of file particle.hpp.
|
private |
name for printing
Definition at line 225 of file particle.hpp.
|
private |
the path (owned)
Definition at line 239 of file particle.hpp.
|
protected |
charge in e
Definition at line 222 of file particle.hpp.
|
private |
records the path
Definition at line 237 of file particle.hpp.
|
private |
a step is recorded when ecount is a multiple of it
Definition at line 238 of file particle.hpp.
|
private |
velocity in c
Definition at line 227 of file particle.hpp.
|
private |
position in fm
Definition at line 226 of file particle.hpp.