Configuration

class code_generation.configuration.Configuration(era, sample, scopes, shifts, available_sample_types, available_eras, available_scopes)[source]

Configuration class for for the CROWN configuration. This class holds all parts of the configuration, from the sample, era, scope, and systematics, to the output. All modifications to the configuration should be done through this class.

Initiation of a new configuration.

Parameters:
  • era (str) – The era of the sample.

  • sample (str) – The sample type of the sample.

  • scopes (Union[str, List[str]]) – The scopes to be used in the configuration. By default, the global scope will always be added and run first, all other scopes will be run in parallel as children of the global scope.

  • shifts (Union[str, List[str], Set[str]]) – The systematics to be used in the configuration.

  • available_sample_types (Union[str, List[str]]) – The available sample types.

  • available_eras (Union[str, List[str]]) – The available eras.

  • available_scopes (Union[str, List[str]]) – The available scopes.

add_config_parameters(scopes, parameters)[source]

Function to add new config parameters to the configuration. Modifiers are used to modify the configuration, are directly resolved using the resolve_modifiers function.

Parameters:
  • scopes (str | List[str]) – The scopes to which the parameters should be added. This can be a list of scopes or a single scope.

  • parameters (Dict[str, List[str | int | float | bool | Dict[Any, Any]] | str | int | float | bool | EraModifier | SampleModifier | Dict[Any, Any]]) – The parameters to be added. This must be a dictionary of parameters. If multiple scopes are given, the parameters are added to all scopes.

Returns:

None

Return type:

None

add_modification_rule(scopes, rule)[source]

Function used to add a rule to the configuration.

Parameters:
  • scopes (str | List[str]) – The scopes to which the rule should be added. This can be a list of scopes or a single scope.

  • rule (ProducerRule) – The rule to be added. This must be a ProducerRule object.

Returns:

None

Return type:

None

add_outputs(scopes, output)[source]

Function used to add outputs to the configuration.

Parameters:
  • scopes (str | List[str]) – The scopes to which the outputs should be added. This can be a list of scopes or a single scope.

  • output (Quantity | NanoAODQuantity | List[Quantity | NanoAODQuantity]) – The outputs to be added. If multiple scopes are given, the outputs are added to all scopes.

Returns:

None

Return type:

None

add_producers(scopes, producers)[source]

Function used to add producers to the configuration. Internally, a set of all available outputs is updated, which is later used to check if all required ouputs are available.

Parameters:
  • scopes (str | List[str]) – The scopes to which the producers should be added. This can be a list of scopes or a single scope.

  • producers (Producer | ProducerGroup | List[Producer | ProducerGroup]) – The producers to be added. If multiple scopes are given, the producers are added to all scopes.

Returns:

None

Return type:

None

add_shift(shift, samples=None, exclude_samples=None)[source]

Function used to add a systematics shift to the configuration. During this step, the shift is validated and applied.

Parameters:
  • shift (SystematicShift | SystematicShiftByQuantity) – The shift to be added. This must be a SystematicShift object.

  • samples (str | List[str] | None) – The samples to which the shift should be applied. This can be a list of samples or a single sample. If ths option is not set, the shift is applied, regardless of the sample type.

  • exclude_samples (str | List[str] | None) – The samples to which the shift should not be applied. This can be a list of samples or a single sample. if exclude_samples is set, samples cannot be used.

Returns:

None

Return type:

None

expanded_configuration()[source]

Function used to generate an expanded version of the configuration, where all shifts are applied. This expanded configuration is used by the code generator to generate the C++ code.

Returns:

Expanded configuration

Return type:

Configuration

optimize()[source]

Function used to optimize the configuration. Optimizaion steps are:

  1. Remove empty scopes

  2. Apply rules

  3. Optimizing producer ordering (this does not change the configuration, but only the order of producers)

Parameters:

None

Returns:

None

Return type:

None

report()[source]

Function used to log a summary of the configuration in form of a report.

Parameters:

None

Returns:

None

Return type:

None

resolve_modifiers(configuration_dict)[source]

Function used to resolve mofifiers used in the configuration. This function is called by the add_config_parameters function.

Parameters:

configuration_dict (Dict[Any, Any]) – The configuration dictionary to be resolved.

Returns:

The resolved configuration dictionary.

Return type:

dict

setup_defaults()[source]

Function used to add some defaults to the configuration. This function is called by the __init__ function. For all configured scopes, the nessessay variables are added to the configuration. The validation of the initial settings is also done here.

Parameters:

None

Returns:

None

Return type:

None

unpack_producergroups(scope, producers, parent=None, depth=0)[source]

Function used to add producers to the configuration. Internally, a set of all available outputs is updated, which is later used to check if all required ouputs are available.

Parameters:
Returns:

None

Return type:

None

validate()[source]

Function used to validate the configuration. During the validation, the following steps are performed:

  • Validate the outputs

  • Validate the shifts

Parameters:

None

Returns:

None

Return type:

None