src.diff_cross_section module#
Sample Mandelstam t from binned dsigma/dt tables stored in ROOT files.
Provide functionality to:
Load dsigma/dt data from ROOT TGraphAsymmErrors.
Build a piecewise-constant PDF and CDF for tau = -t.
Sample t values according to the PDF.
Convert sampled t to cos(theta*) in the CM frame for pi^- p -> X n
- class src.diff_cross_section.DtPdf[source]#
Bases:
objectPiecewise-constant PDF built from a binned dsigma/dt table.
- src.diff_cross_section.load_graph(root_path)[source]#
Load Table dsigma/dt stored as TGraphAsymmErrors Graph1D_y1.
- Parameters:
root_path – Path to the ROOT file.
- Returns:
ROOT.TGraphAsymmErrors – The graph object.
- src.diff_cross_section.build_pdf_from_graph(g)[source]#
Build a CDF from a TGraphAsymmErrors containing binned dsigma/dt.
For each point i in the graph:
Get x_i, y_i, and bin width from asymmetric errors.
Compute weight w_i = max(0, y_i) * width_i for central value generation.
Build CDF from normalized weights.
- Parameters:
g (ROOT.TGraphAsymmErrors) – Graph containing binned dsigma/dt.
- Returns:
DtPdf – Precomputed bin edges + CDF.
- src.diff_cross_section.sample_t(pdf, rng, size)[source]#
Sample Mandelstam t (negative) from the dsigma/dt CDF table.
- Parameters:
pdf (DtPdf) – Precomputed PDF and CDF.
rng (numpy.random.Generator) – Random number generator (same instance used everywhere).
size (int) – Number of samples
- Returns:
t (float) – Sampled Mandelstam t value.
- src.diff_cross_section.plot_binned_pdf_cdf(pdf, rng, n_samples, plot_name='pi0')[source]#
Plot the binned PDF and CDF from the provided DtPdf object.
Plot:
Top: piecewise-constant PDF p(tau) + histogram of sampled tau=-t
Bottom: CDF F(tau)
- Parameters:
pdf (DtPdf) – Precomputed bin edges and CDF.
rng (numpy.random.Generator) – Random number generator (same instance used everywhere).
n_samples (int) – Number of tau=-t samples for the diagnostic histogram.
plot_name (str) – Name of the output plot file (without extension).
- src.diff_cross_section.cos_theta_from_t(s, m_a, m_b, m_c, m_d, rng, pdf, n_samples=1000)[source]#
Convert Mandelstam t -> cos(theta*) in the CM frame for a+b -> c+d.
Convention:
t = (p_a - p_c)^2, metric (+,-,-,-).
theta* is the angle between incoming a and outgoing c in the CM.
- Parameters:
s (float) – Mandelstam s in (GeV)^2.
m_a (float) – Particle masses in GeV.
m_b (float) – Particle masses in GeV.
m_c (float) – Particle masses in GeV.
m_d (float) – Particle masses in GeV.
rng (np.random.Generator) – Random number generator.
pdf (DtPdf) – Precomputed PDF and CDF for t sampling.
n_samples (int) – Number of samples to generate.
- Returns:
cos_theta (float or np.ndarray) – cos(theta*) corresponding to t.