showerpipe.generator.repeat_hadronize(gen: PythiaGenerator, reps: int | None = None, copy: bool = True) Generator[PythiaEvent, None, None][source]

Takes a PythiaGenerator instance with an unhadronised event already generated, and repeatedly hadronises the current event.

Parameters:
gen : PythiaGenerator

Instance of PythiaGenerator which has already generated at least one event, either by calling next(gen), or iterating with a for-loop.

reps : int, optional

Number of repetitions to queue in the iterator. If None, will produce an infinite iterator.

copy : bool

Whether to return copies of the events, orphaned from gen, the passed PythiaGenerator instance.Setting this to False may improve speed and reduce memory consumption, but will have side-effects on gen, such that its internal current event will be set to the most recent event yielded by this generator (until it terminates). Default is True.

Yields:

event (PythiaEvent) – The current event with new hadronisation.

Raises:
  • StopIteration – Either when the number of rehadronised events is equal to reps, or if this generator is invalidated by iterating the underlying PythiaGenerator instance passed to it.

  • RuntimeError – If gen is passed without a current event to rehadronise.

  • KeyError – If the cmnd file used to initialise gen contains flags which conflict with each other.

  • ValueError – If the cmnd file used to initialise gen does not set ‘HadronLevel:all = off’. See notes for more information.

  • UserWarning – If Pythia fails to perform the hadronization process for a given event, this iterator will be empty.

Notes

This function wraps the first method of rehadronisation described in https://pythia.org/latest-manual/HadronLevelStandalone.html. In order to use it, ‘HadronLevel:all’ must be set to ‘off’ in the cmnd settings file that gen was initialised with.

If reps is set so the generator has a finite length, the side-effects on gen will be reversed when the generator yields its last element.

If reps is set to None and copy is set to False, the side-effects on gen will persist, until gen is iterated either by passing it to next() or implicit iteration within a for loop.


Last update: Jun 27, 2025