remage package

Submodules

remage.cli module

remage.cli._cleanup_tmp_files(ipc_info)

Remove temporary files created by the C++ application, that might not have been cleaned up.

Parameters:

ipc_info (IpcResult)

Return type:

None

remage.cli._run_remage_cpp(args=None, is_cli=False)

run the remage-cpp executable and return the exit code as seen in bash.

Parameters:
Return type:

tuple[int, Signals, IpcResult]

remage.cli._setup_log()

Setup a colored logger for this package.

Return type:

Logger

remage.cli.remage_cli()
Return type:

int

remage.cli.remage_run(macros=(), *, gdml_files=(), output=None, threads=1, overwrite_output=False, merge_output_files=False, flat_output=False, time_window=None, macro_substitutions=None, log_level=None, raise_on_error=True, raise_on_warning=False)

Run the remage simulation utility with the provided args.

This is the main entry point for users wanting to run remage from Python code.

Parameters:
  • macros (Sequence[str] | str) – one or more remage/Geant4 macro command listings to execute.

  • gdml_files (Sequence[str] | str) – supply one or more GDML files describing the experimental geometry.

  • output (str | None) – output file for detector hits.

  • threads (int) – set the number of threads used by remage.

  • overwrite_output (bool) – overwrite existing output files.

  • merge_output_files (bool) – merge output files created by individual remage threads.

  • flat_output (bool) – if False, perform a reshaping of the output files so that each row in the output table contains data about all steps in a physical interaction in a detector, based on the time-window. This results in each column being a VectorOfVectors. If True, the output table will be flat with each row holding information about a single Geant4 step.

  • time_window (float | None) – time window to group together steps into hits, in microseconds.

  • macro_substitutions (Mapping[str, str] | None) – key-value-pairs that will be substituted in macros as Geant4 aliases.

  • log_level (str | None) – logging level. One of debug, detail, summary, warning, error, fatal, nothing.

  • raise_on_error (bool) – raise a RuntimeError when an error in the C++ application occurs. This applies to non-fatal errors being logged as well as fatal errors. If false, the function only returns the error code, the Python-based post-processing will be skipped in any case.

  • raise_on_warning (bool) – raise a RuntimeError when a warning (or error) is logged in the C++ application. If false, warnings are only logged and the python-based post-processing will be run normally.

Return type:

tuple[int, IpcResult]

remage.cli.remage_run_from_args(args=None, *, raise_on_error=True, raise_on_warning=False)

Run the remage simulation utility with the provided args.

Parameters:
Return type:

tuple[int, IpcResult]

remage.find_remage module

remage.find_remage._find_remage_from_config()
Return type:

Path | None

remage.find_remage.find_remage_cpp()

Find the remage executable, either by using the config stored into the package at build-time or by using the system PATH.

Return type:

Path

remage.ipc module

class remage.ipc.IpcResult(ipc_info)

Bases: object

get(name, expected_len=1)
Parameters:
  • name (str)

  • expected_len (int)

Return type:

list[str]

get_single(name, default)
Parameters:
Return type:

str

remove(name)
Parameters:

name (str)

Return type:

None

set(name, values)
Parameters:
Return type:

None

remage.ipc.handle_ipc_message(msg)
Parameters:

msg (bytes)

Return type:

tuple[bool, list, bool]

remage.ipc.ipc_thread_fn(pipe_r, proc, unhandled_ipc_messages)
Parameters:
Return type:

None

remage.utils module

remage.utils.get_extra_tables(file, detectors)

Extract the additional tables in the output file (not detectors).

Parameters:
Return type:

list[str]

remage.utils.get_rebooost_config(reshape_table_list, other_table_list, *, time_window=10)

Get the config file to run reboost.

Parameters:
  • reshape_table_list (list[str]) – a list of the table in the remage file that need to be reshaped (i.e. Germanium or Scintillator output)

  • other_table_list (list[str]) – other tables in the file.

  • time_window (float) – time window to use for building hits (in us).

Return type:

config file as a dictionary.

remage.utils.make_tmp(files)

Hide files.

Prepend a . to their name and rename them on disk.

Parameters:

files (list[str] | str)

Return type:

list[str]

remage.utils.tmp_renamed_files(remage_files)

Temporarily rename files, restoring originals on error and deleting temps on success.

remage.utils.un_make_tmp(files)

Un-hide files.

Remove . from name and rename on disk.

Parameters:

files (list[str] | str)

Return type:

list[str]