Systematics

class code_generation.systematics.SystematicShift(name, shift_config, producers, scopes=None, ignore_producers={})[source]

Class containing systematic shifts. A systematic shift is a variation of a set of configuration parameters.

A dummy shift looks like this:

SystematicShift(
        name="shiftname",
        shift_config={
            ("scope1", "scope2"): {
                "paramter1": True,
                "paramter2": 42.0,
            },
        },
        producers={
            "scope1": modified_producer1,
            "scope2": modified_producer2,
        },
        ignore_producers={
            "scope1": ignored_producer1,
            "scope2": ignored_producer2,
        },
    )
Parameters:
  • name (str) – Name of the systematic shift.

  • shift_config (Dict[Union[str, Tuple[str, ...]], TConfiguration]) – Dictionary containing the configuration parameters. The dictionary keys have to be strings, or tuples, in case the same configuration change is used for multiple scopes. The dictionary values have to be dictionaries containing the changed configuration parameters.

  • producers (Dict[Union[str, Tuple[str, ...]], TProducerInput]) – Dictionary containing the producers that are affected by the systematic shift. The dictionary keys have to be strings, or tuples, in case the same producer is affected by the systematic shift in multiple scopes. The dictionary values have to be the modified producers.

  • ignore_producers (Dict[Union[str, Tuple[str, ...]], TProducerInput]) – Dictionary containing the producers that are not affected by the systematic shift. The dictionary keys have to be strings, or tuples, in case the same producer is not affected by the systematic shift in multiple scopes. The dictionary values have to be the ignored producers.

  • scopes (List[str], optional) – List of scopes that are affected by the systematic shift. If not given, all scopes are affected.

add_config(config, scope)[source]

Function used to add a configuration to the list of configurations for a scope. After adding the configuration, the shift is validated.

Parameters:
  • config (Dict[str, List[str | int | float | bool | Dict[Any, Any]] | str | int | float | bool | EraModifier | SampleModifier | Dict[Any, Any]]) – Configuration to add.

  • scope (str) – Scope to which the configuration should be added.

Returns:

None

Return type:

None

add_ignore_producer(producer, scopes=None)[source]

Function used to add an ignored producer to the list of ignored producers, which are untouched by the systematic shift. After adding the ignored producer, the shift is validated.

Parameters:
  • producer (Producer) – Producer to ignore.

  • scope – Scope to which the ignored producer should be added. If no sopce is provided, the ignored producer is added to all scopes of the systematic.

  • scopes (str | None | Set[str] | List[str])

Returns:

None

Return type:

None

add_producer(producer, input_scope=None)[source]

Function used to add a producer to the list of producers affected by the systematic shift. After adding the producer, the shift is validated.

Parameters:
  • producer (Producer) – Producer to add.

  • scope – Scope to which the producer should be added. If no sopce is provided, the producer is added to all scopes of the systematic.

  • input_scope (List[str] | None)

Returns:

None

Return type:

None

add_scope(scope)[source]

Function used to add a scope to the list of scopes affected by the systematic shift. After adding the scope, the shift is validated.

Parameters:

scope (str) – Scope to add.

Returns:

None

Return type:

None

apply(scope)[source]

Function used to apply the systematic shift to the given producers. For the given scope, all producers aer shifted using producer.shift, while, for all ignored producers, the producer.ignore_shift function is called. If the scope is not defined in the shift, no shift is applied.

Parameters:

scope (str) – Scope for which the shift should be applied.

Returns:

None

Return type:

None

determine_scopes(scopes)[source]

Function used to determine the scopes that are affected by the systematic shift. If no scope is specified by the user, the scopes are determined from the shift_config, producers and ignore_producers.

Parameters:

scopes (set) – Set of scopes that are affected by the systematic shift.

Returns:

Set of scopes that are affected by the systematic shift.

Return type:

set

expand_configuration_dict_keys(dict_to_expand)[source]

Function used to expand the configuration dictionary. If the key is a string, it is returned as is. If the key is a tuple, the tuple is expanded and the resulting dict with one key per tuple entry is returned.

Parameters:

dict_to_expand (dict) – Dictionary to expand.

Returns:

Expanded dictionary.

Return type:

dict

expand_producer_dict_keys(dict_to_expand)[source]

Function used to expand dictionaries. If the key is a string, it is returned as is. If the key is a tuple, the tuple is expanded and the resulting dict with one key per tuple entry is returned.

Parameters:

dict_to_expand (dict) – Dictionary to expand.

Returns:

Expanded dictionary.

Return type:

dict

TProducerListStore = Dict[str, Dict[str, List[Union[Producer, ProducerGroup]]]]

get_scopes()[source]

This function returns a set of all scopes that are affected by the systematic shift.

Parameters:

None

Returns:

Set of scopes that are affected by the systematic shift.

Return type:

set

get_shift_config(scope)[source]

This function returns the configuration for a given scope.

Parameters:

scope (str) – Scope for which the configuration should be returned.

Returns:

Configuration for the given scope.

Return type:

dict

normalize_inputs(input_producers)[source]

Helper function used in the validation of the systematic shift. If makes sure, that the provided dict of producers is in a defined format, meaning a dict with one key per scope and a list of producers as value.

Parameters:
  • producers – Producers can be a single Producer object, a list of Producer objects or a dict with one key per scope and a list of producers as value.

  • input_producers (Dict[str, Producer | ProducerGroup | List[Producer | ProducerGroup]])

Returns:

Dictionary containing the producers with one key per scope and a list of producers as value.

Return type:

dict

validate()[source]

Function used to validate the systematic shift. The provided producers and ignore_producers are converted into a defined format. If no configuration is provided for a scope, an empty dict is used.

Parameters:

None

Returns:

None

Return type:

None

class code_generation.systematics.SystematicShiftByQuantity(name, quantity_change, scopes=None)[source]

Class used to define a systematic shift that is defined by a quantity.

Constructor for the SystematicShiftByQuantity class.

Parameters:
  • name (str) – Name of the systematic shift.

  • quantity_change (Dict[NanoAODQuantity, Union[str, NanoAODQuantity]]) – Dictionary of quantities that should be changed.

  • scopes (Union[List[str], None]) – List of scopes that are affected by the systematic shift.

apply(scope)[source]

Function used to apply the systematic shift to the given producers. For the given scope, all producers aer shifted using producer.shift, while, for all ignored producers, the producer.ignore_shift function is called. If the scope is not defined in the shift, no shift is applied.

Parameters:

scope (str) – Scope for which the shift should be applied.

Returns:

None

Return type:

None