src.generate_events module#

Generate oversampled signal and background histograms for meson decays.

For each target thickness L, with a given number of incident pi-, compute the expected number of true interactions producing pi0, eta, and other background events. Then, generate oversampled histograms for the signal (pi0 and eta decays to two photons) and background (two uncorrelated photons) processes with weights given by the ratio of expected to generated events. The histograms and metadata are saved to ROOT and JSON files, respectively. The generation includes detector effects and acceptance on the measured photon energies and directions.

src.generate_events.unit_vec_from_eta_phi(eta, phi)[source]#

Convert (eta, phi) to a 3D unit direction vector.

Parameters:
  • eta (float) – Pseudorapidity.

  • phi (float) – Azimuthal angle.

Returns:

nx, ny, nz (float) – Unit vector components.

src.generate_events.opening_angle_from_meas(eta1, phi1, eta2, phi2)[source]#

Angle between two reconstructed directions from (eta,phi).

Parameters:
  • eta1 (float) – Direction from photon 1.

  • phi1 (float) – Direction from photon 1.

  • eta2 (float) – Direction from photon 2.

  • phi2 (float) – Direction from photon 2.

Returns:

alpha (float) – Opening angle in [0, pi].

src.generate_events.mgg_from_meas(E1, E2, eta1, phi1, eta2, phi2)[source]#

Reconstruct invariant mass from measured energies and directions.

Parameters:
  • E1 (float) – Measured photon energies in GeV.

  • E2 (float) – Measured photon energies in GeV.

  • eta1 (float) – Direction from photon 1.

  • phi1 (float) – Direction from photon 1.

  • eta2 (float) – Direction from photon 2.

  • phi2 (float) – Direction from photon 2.

Returns:

m (float) – Reconstructed invariant mass in GeV.

src.generate_events.toy_background_two_photons(rng)[source]#

Very simple background: two uncorrelated photons.

  • energies: log-uniform between 0.1 and 50 GeV

  • directions: uniform in phi, and forward in eta (eta in [2, 6])

Parameters:

rng (np.random.Generator) – Random number generator.

Returns:

g1_lab, g2_lab (ROOT.TLorentzVector)

src.generate_events.expected_interactions(n_pions, L_cm, rng)[source]#

Compute the expected number of true interactions in the target.

Parameters:
  • n_pions (int) – Number of incident pi-.

  • L_cm (float) – Target thickness (cm).

  • rng (np.random.Generator) – Random number generator.

Returns:

  • N_pi0_phys (int) – Expected number of pi0 interactions.

  • N_eta_phys (int) – Expected number of eta interactions.

  • N_bkg_phys (int) – Expected number of background interactions.

src.generate_events.oversampled_background(N_bkg, L_cm, rng, N_pions)[source]#

Generate an oversampled background histogram.

Parameters:
  • N_bkg (int) – Number of oversampled background events to simulate.

  • L_cm (float) – Target thickness (cm).

  • rng (np.random.Generator) – Random number generator.

  • N_pions (int) – Number of incident pi-.

Returns:

  • h_bkg (ROOT.TH1) – Background oversampled histogram.

  • meta (dict) – Metadata for the background simulation.

src.generate_events.oversampled_signal(N_sig, channel, L_cm, rng, N_pions)[source]#

Generate an oversampled signal histogram.

Parameters:
  • N_sig (int) – Number of oversampled signal events to generate.

  • channel (str) – “pi0” or “eta”.

  • L_cm (float) – Target thickness (cm).

  • rng (np.random.Generator) – Random number generator.

  • N_pions (int) – Number of incident pi-.

Returns:

  • h_meson (ROOT.TH1) – Signal oversampled histogram.

  • meta (dict) – Metadata for the background simulation.

src.generate_events.save_histograms(L_values, rng, N_pions=100000, N_gen_bkg=10000, N_gen_pi0=10000, N_gen_eta=10000, suffix=None)[source]#

Generate and save signal and background histograms for each L.

Parameters:
  • L_values (array-like) – Array of target thickness values to scan.

  • rng (np.random.Generator) – Random number generator.

  • N_pions (int) – Number of pi- to simulate per L.

  • N_gen_pi0 (int) – Number of pi0 oversampled events to generate per interaction.

  • N_gen_eta (int) – Number of eta oversampled events to generate per interaction.

  • suffix (str or None) – Optional suffix for output files.

src.generate_events.main()[source]#

Execute the event generation with command-line arguments.

CLI Parameters#

–seedint

Random seed for reproducibility.

–suffixstr or None

Optional suffix for input/output files.

–N_pionsint

Number of incident pi- to simulate per target length.

–N_gen_bkgint

Number of background oversampled events to generate.

–N_gen_pi0int

Number of pi0 oversampled events to generate.

–N_gen_etaint

Number of eta oversampled events to generate.

–L_valueslist of float

List of target thickness values to simulate (cm).

–L_rangefloat float int

If set, override L_values with a linspace from Lmin to Lmax with N points.