Belle II Software  release-05-02-19
CalibrationSettings Class Reference
Inheritance diagram for CalibrationSettings:
Collaboration diagram for CalibrationSettings:

Public Member Functions

def __new__ (cls, name, expert_username, description, input_data_formats=None, input_data_names=None, input_data_filters=None, depends_on=None, expert_config=None)
 
def json_dumps (self)
 
def __str__ (self)
 

Static Public Attributes

 allowed_data_formats = frozenset({"raw", "cdst", "mdst", "udst"})
 Allowed data file formats. More...
 

Detailed Description

Simple class to hold and display required information for a prompt calibration script (process).

Parameters:
    name (str): The unique calibration name, not longer than 64 characters.

    expert_username (str): The JIRA username of the expert to contact about this script.
        This username will be used to assign the default responsible person for submitting and checking prompt
        calibration jobs.

    description (str): Long form description of the calibration and what it does. Feel free to make this as long as you need.

    input_data_formats (frozenset(str)): The data formats {'raw', 'cdst', 'mdst', 'udst'} of the input files
        that should be used as input to the process. Used to figure out if this calibration should occur
        before the relevant data production e.g. before cDST files are created.

    input_data_names (frozenset(str)): The names that you will use when accessing the input data given to the
        prompt calibration process i.e. Use these in the ``get_calibrations`` function to access the correct input
        data files. e.g. input_data_names=["all_events", "offres_photon_events"]

    input_data_filters (dict): The data selection for the data input names, used for automated calibration.
        The keys should correspond to one of the ``input_data_names`` with the values being a list of the various data
        filters, e.g. Data Tag, Beam Energy, Run Type, Run Quality Tag and Magnet. All available filters can be found in the
        input_data_filters dictionary e.g. from prompt import input_data_filters with details about data tags and run quality
        tags found at: https://calibration.belle2.org/belle2/data_tags/list/.
        To exclude specific filters, pre-append with *NOT* e.g.
        {"all_events": ["mumutight_calib", "hadron_calib", "Good", "On"],
        "offres_photon_events": ["gamma_gamma_calib", "Good", "NOT On"]}.
        Not selecting a specfic filters (e.g. Magnet) is equivalent to not having any requirements, e.g. (Either)

    depends_on (list(CalibrationSettings)): The settings variables of the other prompt calibrations that you want
        want to depend on. This will allow the external automatic system to understand the overall ordering of
        scripts to run. If you encounter an import error when trying to run your prompt calibration script, it is
        likely that you have introduced a circular dependency.

    expert_config (dict): Default expert configuration for this calibration script. This is an optional dictionary
        (which must be JSON compliant) of configuration options for your get_calibrations(...) function.
        This is supposed to be used as a catch-all place to send in options for your calibration setup. For example,
        you may want to have an optional list of IoV boundaries so that your prompt script knows that it should split the
        input data between different IoV ranges. Or you might want to send if options like the maximum events per
        input file to process. The value in your settings object will be the *default*, but you can override the value via
        the caf_config.json sent into ``b2caf-prompt-run``.

Definition at line 49 of file __init__.py.

Member Function Documentation

◆ __new__()

def __new__ (   cls,
  name,
  expert_username,
  description,
  input_data_formats = None,
  input_data_names = None,
  input_data_filters = None,
  depends_on = None,
  expert_config = None 
)
The special method to create the tuple instance. Returning the instance
calls the __init__ method

Definition at line 99 of file __init__.py.

99  def __new__(cls, name, expert_username, description,
100  input_data_formats=None, input_data_names=None, input_data_filters=None, depends_on=None, expert_config=None):
101  """
102  The special method to create the tuple instance. Returning the instance
103  calls the __init__ method
104  """
105  if len(name) > 64:
106  raise ValueError("name cannot be longer than 64 characters!")
107  if not input_data_formats:
108  raise ValueError("You must specify at least one input data format")
109  input_data_formats = frozenset(map(lambda x: x.lower(), input_data_formats))
110  if input_data_formats.difference(cls.allowed_data_formats):
111  raise ValueError("There was a data format that is not in the allowed_data_formats attribute.")
112  if not input_data_names:
113  raise ValueError("You must specify at least one input data name")
114  input_data_names = frozenset(input_data_names)
115 
116  if expert_config:
117  # Check that it's a dictionary and not some other valid JSON object
118  if not isinstance(expert_config, dict):
119  raise TypeError("expert_config must be a dictionary")
120  # Check if it is JSONable since people might put objects in there by mistake
121  try:
122  json.dumps(expert_config)
123  except TypeError as e:
124  basf2.B2ERROR("expert_config could not be serialised to JSON. "
125  "Most likely you used a non-supported type e.g. datetime.")
126  raise e
127  else:
128  expert_config = {}
129 
130  if depends_on:
131  for calibration_settings in depends_on:
132  if not isinstance(calibration_settings, cls):
133  raise TypeError(f"A list of {str(cls)} object is required when setting the 'depends_on' keyword.")
134  else:
135  depends_on = []
136 
137  return super().__new__(cls, name, expert_username, description,
138  input_data_formats, input_data_names, input_data_filters, depends_on, expert_config)
139 

◆ json_dumps()

def json_dumps (   self)
Returns:
     str: A valid JSON format string of the attributes.

Definition at line 140 of file __init__.py.

Member Data Documentation

◆ allowed_data_formats

allowed_data_formats = frozenset({"raw", "cdst", "mdst", "udst"})
static

Allowed data file formats.

You should use these values for CalibrationSettings.input_data_formats. Right now you should only use "raw" or "cdst" because we don't actually run calibrations on "mdst" or "udst". They are here for completeness.

Definition at line 97 of file __init__.py.


The documentation for this class was generated from the following file: