Particle

class Particle.Particle(input_format: str | None = None, particle_array: ndarray | None = None, attribute_list: List[str] = [])[source]

Defines a particle object.

The member variables of the Particle class are the quantities in the Oscar2013/Oscar2013Extended/Oscar2013Extended_IC/Oscar2013Extended_Photons/ ASCII or JETSCAPE hadron/parton 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.

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”

  • “ASCII”

  • “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

rapidity:

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

spacetime_rapidity:

Compute space-time rapidity

proper_time:

Compute proper time

mass_from_energy_momentum:

Compute mass from energy momentum relation

charge_from_pdg:

Compute charge from PDG code

mT:

Compute transverse mass

is_quark:

Is the particle a quark?

is_lepton:

Is the particle a lepton?

is_meson:

Is the particle a meson?

is_baryon:

Is the particle a baryon?

is_hadron:

Is the particle a hadron?

is_heavy_flavor:

Is the particle a heavy flavor particle?

has_down:

Does the particle have a down quark?

has_up:

Does the particle have an up quark?

has_strange:

Does the particle have a strange quark?

has_charm:

Does the particle have a charm quark?

has_bottom:

Does the particle have a bottom quark?

has_top:

Does the particle have a top quark?

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() None[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() ndarray | float[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.rapidity() float[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() float[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() float[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() float[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() float[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() float[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.spacetime_rapidity() float[source]

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

Returns:
float

space-time rapidity

Notes

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

Particle.proper_time() float[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.mass_from_energy_momentum() float[source]

Compute the mass from the energy momentum relation.

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

We consider particles with the following PDG codes as massless: photons (22), gluons (21), e-neutrinos (12, -12), mu-neutrinos (14, -14), tau-neutrinos (16, -16), tau-prime-neutrinos (18, -18).

Returns:
float

mass

Notes

If one of the needed particle quantities (four-momentum) is not given, then np.nan is returned.

Particle.charge_from_pdg() float[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.mT() float[source]

Compute the transverse mass \(m_{T}=\sqrt{E^2-p_z^2}\) of the particle.

Returns:
float

transverse mass

Notes

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

Particle.is_quark() bool | float[source]

Is the particle a quark?

Returns:
bool

True, False

Notes

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

Particle.is_lepton() bool | float[source]

Is the particle a lepton?

Returns:
bool

True, False

Notes

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

Particle.is_meson() bool | float[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() bool | float[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() bool | float[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_heavy_flavor() bool | float[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.has_down() bool | float[source]

Does the particle contain a down quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.has_up() bool | float[source]

Does the particle contain an up quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.has_strange() bool | float[source]

Does the particle contain a strange quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.has_charm() bool | float[source]

Does the particle contain a charm quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.has_bottom() bool | float[source]

Does the particle contain a bottom quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.has_top() bool | float[source]

Does the particle contain a top quark? Does not work with partons.

Returns:
bool

True, False

Notes

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

Particle.spin() float[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() int | float[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.