EventGenerator

class madspace.EventGenerator(self: madspace._madspace_py.EventGenerator, contexts: collections.abc.Sequence[madspace._madspace_py.Context], channels: collections.abc.Sequence[madspace._madspace_py.ChannelEventGenerator], seed: SupportsInt, status_file: madspace._madspace_py.StatusFile = None, config: madspace._madspace_py.GeneratorConfig = EventGenerator.default_config)

Bases: pybind11_object

Drives event generation across every channel of a subprocess.

Coordinates a group of ChannelEventGenerator instances that share the same list of Context devices: runs their survey, dispatches and collects generation batches so multiple channels and devices stay busy concurrently, and combines the resulting per-channel weighted events into unweighted output (combine_to_compact_npy, combine_to_lhe_npy, combine_to_lhe).

Parameters:
  • contexts – One context per device to run on, shared by every channel.

  • channels – The channels to generate, e.g. one per Topology channel of the subprocess.

  • seed – Top-level run seed every channel’s RNG streams are derived from.

  • status_file – Optional status file progress is periodically written to.

  • config – Generator configuration.

channel_status(self: madspace._madspace_py.EventGenerator) → list[madspace._madspace_py.GeneratorStatus]

Per-channel progress snapshots.

channels(self: madspace._madspace_py.EventGenerator) → list[madspace._madspace_py.ChannelEventGenerator]

The channels passed to the constructor.

combine_to_compact_npy(self: madspace._madspace_py.EventGenerator, file_name: str, systematics: madspace._madspace_py.SystematicsCalculator = None, histograms: madspace._madspace_py.EventHistograms = None) → None

Combine every channel’s generated events into a single unweighted .npy file.

Parameters:
  • file_name – Output file base name.

  • systematics – Optional; adds the scale/PDF variation weights to the written events (.npy columns rwgt_<id>).

  • histograms – Optional; filled with the written events and all their weights (recorded in info.json’s "event_histograms").

combine_to_lhe(self: madspace._madspace_py.EventGenerator, file_name: str, lhe_completer: madspace._madspace_py.LHECompleter, meta: madspace._madspace_py.LHEMeta = LHEMeta(), systematics: madspace._madspace_py.SystematicsCalculator = None, histograms: madspace._madspace_py.EventHistograms = None) → None

Like combine_to_lhe_npy, writing a complete LHE file with meta as its <init> header instead of a .npy file.

combine_to_lhe_npy(self: madspace._madspace_py.EventGenerator, file_name: str, lhe_completer: madspace._madspace_py.LHECompleter, systematics: madspace._madspace_py.SystematicsCalculator = None, histograms: madspace._madspace_py.EventHistograms = None) → None

Like combine_to_compact_npy, additionally completing every event with lhe_completer and writing its LHE-ready particle records to the .npy file.

default_config = <madspace._madspace_py.GeneratorConfig object>
fix_max_weights(self: madspace._madspace_py.EventGenerator) → None

Like generate, but every channel with a nonzero cross section runs until it has freeze_max_weight_after unweighted events, regardless of its share of the cross section, so that its maximum weight is final (see ChannelEventGenerator::max_weight).

The events are not meant to be combined.

generate(self: madspace._madspace_py.EventGenerator) → None

Generate unweighted events until every channel reaches its target count.

histograms(self: madspace._madspace_py.EventGenerator) → list[madspace._madspace_py.Histogram]

Combined observable histograms over every channel.

optimize(self: madspace._madspace_py.EventGenerator) → None

Run only the VEGAS and channel-weight optimization of every channel that still needs it, until all are optimized.

No events are kept.

status(self: madspace._madspace_py.EventGenerator) → madspace._madspace_py.GeneratorStatus

Combined progress snapshot over every channel.

survey(self: madspace._madspace_py.EventGenerator, survey_pass: SupportsInt = 0) → None

Run the survey/optimization phase of every channel.

survey_pass salts job seeds so repeated calls on the same channels (e.g. re-surveying after simplification) don’t share a seed stream.

used_globals(self: madspace._madspace_py.EventGenerator) → set[str]

Names of the compute-graph globals used by any channel’s integrand.