Belle II Software  release-05-01-25
__init__.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 The main module of the Belle II Analysis Software Framework
6 """
7 
8 # import most things to be backwards compatible
9 from basf2.core import * # noqa
10 from basf2.utils import print_params, print_path # noqa
11 import sys as _sys
12 
13 # check for jupyter notebook
14 _is_ipython = hasattr(__builtins__, '__IPYTHON__') or 'IPython' in _sys.modules
15 if _is_ipython:
16  from IPython import get_ipython as _get_ipython
17  _ip = _get_ipython()
18  if hasattr(_ip, "kernel"):
19  # we're in a notebook, reset log system to print to python sys.stdout
20  logging.enable_python_logging = True
21  # also in this case we really don't need a log summary
22  logging.enable_summary(False)
23 
24  # convenience wrap the process() function to use a calculation object
25  def process(path, max_event=0):
26  """
27  Start processing events using the modules in the given `basf2.Path` object.
28 
29  Can be called multiple times in one steering file (some restrictions apply:
30  modules need to perform proper cleanup & reinitialisation, if Geometry is
31  involved this might be difficult to achieve.)
32 
33  This is a convenience wrapper which will automatically call the
34  `process()` function in a separate process using `hep_ipython_tools`
35 
36  Parameters:
37  path: The path with which the processing starts
38  max_event: The maximal number of events which will be processed, 0 for no limit
39 
40  Returns:
41  a `hep_ipython_tools.calculation.Calculation` object
42  """
43 
44  from hep_ipython_tools.ipython_handler_basf2 import handler as _handler
45  calculation = _handler.process(path, max_event=max_event)
46  calculation.start()
47  calculation.wait_for_end()
48  calculation.show_log()
49  return calculation
basf2.core
Definition: core.py:1
basf2.utils
Definition: utils.py:1
hep_ipython_tools.ipython_handler_basf2
Definition: __init__.py:1