bachelor_thesis/prog/python/qqgg/tangled/observables.py

60 lines
1.1 KiB
Python
Raw Normal View History

2020-03-31 15:19:51 +02:00
"""This module defines some observables on arrays of 4-pulses."""
import numpy as np
2020-05-08 15:50:33 +02:00
from utility import minkowski_product
2020-03-31 15:19:51 +02:00
2020-05-17 18:05:21 +02:00
2020-03-31 15:19:51 +02:00
def p_t(p):
2020-04-02 15:55:07 +02:00
"""Transverse momentum
2020-03-31 15:19:51 +02:00
2020-04-02 16:35:43 +02:00
:param p: array of 4-momenta
2020-03-31 15:19:51 +02:00
"""
2020-05-17 18:05:21 +02:00
return np.linalg.norm(p[:, 1:3], axis=1)
2020-03-31 15:19:51 +02:00
def η(p):
"""Pseudo rapidity.
2020-04-02 16:35:43 +02:00
:param p: array of 4-momenta
2020-03-31 15:19:51 +02:00
"""
2020-05-17 18:05:21 +02:00
return np.arccosh(np.linalg.norm(p[:, 1:], axis=1) / p_t(p)) * np.sign(p[:, 3])
2020-05-08 15:50:33 +02:00
def inv_m(p_1, p_2):
"""Invariant mass off the final state system.
:param p_1: array of 4-momenta, first fs particle
:param p_2: array of 4-momenta, second fs particle
"""
total_p = p_1 + p_2
return np.sqrt(minkowski_product(total_p, total_p))
2020-05-17 18:05:21 +02:00
2020-05-08 15:50:33 +02:00
def cosθ(p):
return p[:, 3] / p[:, 0]
2020-05-17 18:05:21 +02:00
2020-05-17 18:14:19 +02:00
def o_angle(p_1, p_2):
eta_1 = η(p_1)
eta_2 = η(p_2)
return np.abs(np.tanh((eta_1 - eta_2) / 2))
2020-05-17 18:05:21 +02:00
def o_angle_cs(p_1, p_2):
eta_1 = η(p_1)
eta_2 = η(p_2)
pT_1 = p_t(p_1)
pT_2 = p_t(p_2)
total_pT = p_t(p_1 + p_2)
m = inv_m(p_1, p_2)
return np.abs(
np.sinh(eta_1 - eta_2)
* 2
* pT_1
* pT_2
/ np.sqrt(m ** 2 + total_pT ** 2)
/ m
)