Particle

class Particle.Particle(input_format=None, particle_array=None)[source]

Defines a particle object.

The member variables of the Particle class are the quantities in the OSCAR2013/OSCAR2013Extended or JETSCAPE hadron output. If they are not set, they stay np.nan to throw an error if one tries to access a non existing quantity. If a particle with an unknown PDG is provided, a warning is thrown and and np.nan is returned for charge, spin, and spin degeneracy.

Notes

If a member of the Particle class is not set or a quantity should be computed and the needed member variables are not set, then np.nan is returned by default. All quantities are saved in a numpy array member variable data_. The datatype of this array is float, therefore casting is required when int or bool values are required.

When JETSCAPE creates particle objects, which are partons, the charge is multiplied by 3 to make it an integer. The functions is_strange() and is_heavy_flavor() should not be used in this case.

Examples

To use the particle class a particle has to be created and the attributes can be set or obtained with the corresponding functions.

1>>> from sparkx.Particle import Particle
2>>>
3>>> particle = Particle()
4>>> particle.t = 1.0
5>>> print(particle.t)
61.0

The class can be used to construct a particle from different input formats. Supported formats include:

  • “Oscar2013”

  • “Oscar2013Extended”

  • “Oscar2013Extended_IC”

  • “Oscar2013Extended_Photons”

  • “JETSCAPE”

1>>> particle_quantity_JETSCAPE = np.array([0,2114,11,2.01351754,1.30688601,-0.422958786,-0.512249773])
2>>> particle = Particle(input_format="JETSCAPE", particle_array=particle_quantity_JETSCAPE)
Attributes:
tfloat

Get or set the time of the particle.

xfloat

Get or set the x-position of the particle.

yfloat

Get or set the y-position of the particle.

zfloat

Get or set the z-position of the particle.

massfloat

Get or set the mass of the particle.

Efloat

Get or set the energy of the particle.

pxfloat

Get or set the momentum x-component of the particle.

pyfloat

Get or set the momentum y-component of the particle.

pzfloat

Get or set the momentum z-component of the particle.

pdgint

Get or set the PDG code of the particle.

pdg_validbool

Get the validity of the PDG code of the particle.

IDint

Get or set the ID of the particle.

chargeint

Get or set the electrical charge of the particle.

ncollint

Get or set the number of collisions of the particle.

form_timedouble

Get or set the formation time of the particle.

xsecfacdouble

Get or set the cross section scaling factor of the particle.

proc_id_originint

Get or set the process ID of the particle’s origin.

proc_type_originint

Get or set the process type of the particle’s origin.

t_last_colldouble

Get or set the last time of a collision of the particle.

pdg_mother1int

Get the PDG code of the first mother particle.

pdg_mother2int

Get the PDG code of the second mother particle.

statusint

Get the hadron status (stores information on the module origin of a JETSCAPE hadron).

baryon_numberint

Get the baryon number of the particle.

strangenessint

Get the strangeness of the particle.

weightfloat

Get the weight of the particle.

Methods

t:

Get/set t

x:

Get/set x

y:

Get/set y

z:

Get/set z

mass:

Get/set mass

E:

Get/set E

px:

Get/set px

py:

Get/set py

pz:

Get/set pz

pdg:

Get/set pdg

ID:

Get/set ID

charge:

Get/set charge

ncoll:

Get/set ncoll

form_time:

Get/set form_time

xsecfac:

Get/set xsecfactor

proc_id_origin:

Get/set proc_id_origin

proc_type_origin:

Get/set proc_type_origin

t_last_coll:

Get/set t_last_coll

pdg_mother1:

Get/set pdg_mother1

pdg_mother2:

Get/set pdg_mother2

status:

Get/set status

baryon_number:

Get/set baryon_number

strangeness:

Get/set strangeness

print_particle:

Print the particle as CSV to terminal

angular_momentum:

Compute angular momentum

momentum_rapidity_Y:

Compute momentum rapidity

p_abs:

Compute absolute momentum

pt_abs:

Compute absolute value of transverse momentum

phi:

Compute azimuthal angle

theta:

Compute polar angle

pseudorapidity:

Compute pseudorapidity

spatial_rapidity:

Compute spatial rapidity

proper_time:

Compute proper time

compute_mass_from_energy_momentum:

Compute mass from energy momentum relation

compute_charge_from_pdg:

Compute charge from PDG code

is_meson:

Is the particle a meson?

is_baryon:

Is the particle a baryon?

is_hadron:

Is the particle a hadron?

is_strange:

Is the particle a strange particle?

is_heavy_flavor:

Is the particle a heavy flavor particle?

weight:

What is the weight of the particle?

spin:

Total spin \(J\) of the particle.

spin_degeneracy:

Total spin \(2J + 1\) of the particle.

Particle.print_particle()[source]

Print the whole particle information as csv string.

This function prints a header line with the different quantities. All particle quantities are then printed in the next line separated by a comma.

Particle.angular_momentum()[source]

Compute the angular momentum \(\vec{L}=\vec{r} \times \vec{p}\) of a particle.

Returns:
angular_momentumnumpy.ndarray

Array containing all three components of the angular momentum as \([L_x, L_y, L_z]\).

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.momentum_rapidity_Y()[source]

Compute the momentum rapidity \(Y=\frac{1}{2}\ln\left(\frac{E+p_z}{E-p_z}\right)\) of the particle.

Returns:
float

momentum rapidity

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.p_abs()[source]

Compute the absolute momentum \(|\vec{p}|=\sqrt{p_x^2+p_y^2+p_z^2}\) of the particle.

Returns:
float

absolute momentum

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.pt_abs()[source]

Compute the absolute transverse momentum \(|\vec{p}_{\mathrm{T}}|=\sqrt{p_x^2+p_y^2}\) of the particle.

Returns:
float

absolute transverse momentum

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.phi()[source]

Compute the azimuthal angle of the particle.

Returns:
float

azimuthal angle

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.theta()[source]

Compute the polar angle of the particle.

Returns:
float

polar angle

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.pseudorapidity()[source]

Compute the pseudorapidity \(\eta=\frac{1}{2}\ln\left(\frac{|\vec{p}|+p_z}{|\vec{p}|-p_z}\right)\) of the particle.

Returns:
float

pseudorapidity

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.spatial_rapidity()[source]

Compute the spatial rapidity \(y=\frac{1}{2}\ln\left(\frac{t+z}{t-z}\right)\) of the particle.

Returns:
float

spatial rapidity

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.proper_time()[source]

Compute the proper time \(\tau=\sqrt{t^2-z^2}\) of the particle.

Returns:
float

proper time

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.compute_mass_from_energy_momentum()[source]

Compute the mass from the energy momentum relation.

This function is called automatically if a JETSCAPE file is read in.

Returns:
float

mass

Notes

If one of the needed particle quantities is not given, then np.nan is returned.

Particle.compute_charge_from_pdg()[source]

Compute the charge from the PDG code.

This function is called automatically if a JETSCAPE file is read in.

Returns:
float

charge

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.is_meson()[source]

Is the particle a meson?

Returns:
bool

True, False

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.is_baryon()[source]

Is the particle a baryon?

Returns:
bool

True, False

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.is_hadron()[source]

Is the particle a hadron?

Returns:
bool

True, False

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.is_strange()[source]

Does the particle contain strangeness?

Returns:
bool

True, False

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.is_heavy_flavor()[source]

Is the particle a heavy flavor hadron?

Returns:
bool

True, False

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.spin()[source]

Get the total spin \(J\) of the particle.

Returns:
float

Total spin \(J\)

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.

Particle.spin_degeneracy()[source]

Get the number of all possible spin projections (\(2J + 1\)).

Returns:
int

Spin degeneracy \(2J + 1\)

Notes

If the PDG ID is not known by PDGID, then np.nan is returned.