EventGenerator

class EventGenerator

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).

Public Functions

EventGenerator(const std::vector<ContextPtr> &contexts, const std::vector<std::shared_ptr<ChannelEventGenerator>> &channels, std::uint64_t seed, std::shared_ptr<StatusFile> status_file = nullptr, const GeneratorConfig &config = default_config)
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.

EventGenerator(EventGenerator&&) = default
EventGenerator &operator=(EventGenerator&&) = default
EventGenerator(const EventGenerator&) = delete
EventGenerator &operator=(const EventGenerator&) = delete
void survey(std::size_t survey_pass = 0)

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.

void generate()

Generate unweighted events until every channel reaches its target count.

void optimize()

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

No events are kept.

void fix_max_weights()

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.

void combine_to_compact_npy(const std::string &file_name, SystematicsCalculator *systematics = nullptr, EventHistograms *histograms = nullptr)

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").

void combine_to_lhe_npy(const std::string &file_name, LHECompleter &lhe_completer, SystematicsCalculator *systematics = nullptr, EventHistograms *histograms = nullptr)

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

void combine_to_lhe(const std::string &file_name, LHECompleter &lhe_completer, const LHEMeta &meta = {}, SystematicsCalculator *systematics = nullptr, EventHistograms *histograms = nullptr)

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

inline GeneratorStatus status() const

Combined progress snapshot over every channel.

std::vector<GeneratorStatus> channel_status() const

Per-channel progress snapshots.

std::vector<Histogram> histograms() const

Combined observable histograms over every channel.

std::unordered_set<std::string> used_globals() const

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

inline const std::vector<std::shared_ptr<ChannelEventGenerator>> &channels() const

The channels passed to the constructor.

Public Static Functions

static inline void set_abort_check_function(std::function<void(void)> func)

Install func, called periodically during generate to check for a requested abort.

Public Static Attributes

static const GeneratorConfig default_config

Default-constructed GeneratorConfig.