Producers
- class code_generation.producer.BaseFilter(name, call, input, scopes)[source]
A BaseFilter is a Producer which does not produce any output, but is used to filter events. This class should not be used by the user, use the Filter class instead.
- Parameters:
name (str) – name of the filter
call (str) – The call to be made in C++, with placeholders for the parameters
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]]]) – The inputs of the filter,
objects (either a list of Quantity)
value (or a dict with the scope as key and a list of Quantity objects as)
scopes (List[str]) – The scopes in which the filter is to be called
- writecall(config, scope, shift='')[source]
Do not use, filters do not support method writecall!
- Parameters:
config (Dict[str, Dict[str, Dict[str, str]]])
scope (str)
shift (str)
- Return type:
str
- writecalls(config, scope)[source]
The writecalls function of a BaseFilter is used to generate the C++ calls for the filter
- Parameters:
config (Dict[str, Dict[str, Dict[str, str]]]) – The configuration dict containing the
filter (parameters and input / output information for the)
scope (str) – The scope in which the filter is to be called
- Raises:
Exception – Raises an Exception, if the requested scope is not valid for the filter
- Returns:
Returns a list of C++ calls for the filter
- Return type:
List[str]
- code_generation.producer.CollectProducerOutput(producer, scope)[source]
- Parameters:
producer (ProducerGroup | Producer)
scope (str)
- Return type:
Set[Quantity]
- code_generation.producer.CollectProducersOutput(producers, scope)[source]
- Parameters:
producers (List[Producer | ProducerGroup])
scope (str)
- Return type:
Set[Quantity]
- class code_generation.producer.ExtendedVectorProducer(name, call, input, output, scope, vec_config)[source]
A ExtendedVectorProducer is a Producer which can be configured to produce multiple calls and outputs at once
- Parameters:
name (str) – Name of the producer
call (str) – The call to be made in C++, with placeholders for the parameters
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]]]) – The inputs of the producer, either a list of Quantity objects, or a dict with the scope as key and a list of Quantity objects as value
output (Union[List[q.Quantity], None]) – The outputs of the producer, either a list of Quantity objects, or None if the producer does not produce any output
scopes (List[str]) – The scopes in which the producer is to be called
vec_configs (List[str]) – The key of the vec config in the config dict
scope (Union[List[str], str])
vec_config (str)
- property output_group: QuantityGroup
- writecalls(config, scope)[source]
Function to generate all calls for all shifts of the ExtendedVectorProducer, wraping the writecall function
- Parameters:
ExtendedVectorProducer (Configuration dict containing the parameter and input / output information for the)
scope (str) – The scope in which the ExtendedVectorProducer is to be called
config (Dict[str, Dict[str, Dict[str, Any]]])
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the ExtendedVectorProducer
- Returns:
Returns a list of C++ calls for all shifts of the ExtendedVectorProducer
- Return type:
List[str]
- class code_generation.producer.Filter(name, call, input, scopes, subproducers)[source]
A Filter is used to filter events. Wraps the BaseFilter class, and is a ProducerGroup.
- Parameters:
name (str) – name of the filter
call (str) – the C++ function call to be used for the filter
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]]]) – The input quantities for the filter
scopes (List[str]) – The scopes in which the filter is to be called
subproducers (Union[ List[Producer | ProducerGroup], Dict[str, List[Producer | ProducerGroup]], ]) – The subproducers of the filter
- class code_generation.producer.Producer(name, call, input, output, scopes)[source]
A Producer is a class that holds all information about a producer. Input quantities are
- Parameters:
name (str) – Name of the producer
call (str) – The call of the producer. This is the C++ function call of the producer
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]]]) – A list of input quantities or a dict with scope specific input quantities
output (Union[List[q.Quantity], None]) – A list of output quantities
scopes (List[str]) – A list of scopes in which the producer is used
- extract_parameters()[source]
Function used to extract all parameters from a producer call. Parameters are enclosed in curly brackets. Reserved parameters are: - {output} : will be replaced by the output quantities - {input} : will be replaced by the input quantities - {output_vec} : will be replaced by the output quantities in vector form - {input_vec} : will be replaced by the input quantities in vector form - {df} : will be replaced by the dataframe name - {vec_open} : will be replaced by the opening bracket of the vector - {vec_close} : will be replaced by the closing bracket of the vector
- Return type:
Dict[str, Set[str]]
- get_inputs(scope)[source]
Get a list of all inputs of the producer in a given scope
- Parameters:
scope (str) – The scope in which the inputs are requested
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the producer
- Returns:
Returns a list of Quantity objects, which are the inputs of the producer
- Return type:
List[str]
- get_outputs(scope)[source]
Get a list of all outputs of the producer in a given scope
- Parameters:
scope (str) – The scope in which the outputs are requested
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the producer
- Returns:
Returns a list of Quantity objects, which are the outputs of the producer
- Return type:
List[Union[q.QuantityGroup, q.Quantity]]
- ignore_shift(name, scope='global')[source]
Ingore a given shift for a producer. This in an internal function and should not be called by the user.
- Parameters:
name (str) – Name of the shift
scope (str, optional) – Name of the scope where the shift is to be ignored. Defaults to “global”.
- Raises:
Exception – If the producer does not have any output, or if the producer does not exist in the given scope, an exception is thrown
- Return type:
None
- reserve_output(scope)[source]
Check if a output_quantity is already used as an output by another producer within the same scope. This is an internal function and should not be called by the user.
- Parameters:
scope (str) – The scope in which the output is reserved
- Return type:
None
- shift(name, scope='global')[source]
Add a shift to the producer. This is an internal function and should not be called by the user.
- Parameters:
name (str) – Name of the shift
scope (str, optional) – Name of the scope where the shift is to be applied. Defaults to “global”.
- Raises:
Exception – If the producer does not have any output, or if the producer does not exist in the given scope, an exception is thrown
- Return type:
None
- shift_inputs(name, scope, inputs_to_shift)[source]
Shift all inputs of a producer. This is an internal function and should not be called by the user.
- Parameters:
name (str) – Name of the shift
scope (str) – Name of the scope where the shift is to be applied
inputs_to_shift (List[str])
- Return type:
None
- writecall(config, scope, shift='nominal')[source]
Function to generate the nessessary C++ calls for the code generation
- Parameters:
config (Dict[str, Dict[str, Any]]) – Configuration dict containing the parameter and input / output information for the producer
scope (str) – The scope in which the producer is to be called
shift (str, optional) – The shift, for which the function call should be generated. Defaults to “nominal”.
- Raises:
Exception – Raises an expection, the the requested shift is not available in the configuration
- Returns:
The generated C++ call
- Return type:
str
- writecalls(config, scope)[source]
Function to generate calls for all shifts of a producer, wraping the writecall function
- Parameters:
producer (Configuration dict containing the parameter and input / output information for the)
scope (str) – The scope in which the producer is to be called
config (Dict[str, Dict[str, Dict[str, str]]])
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the producer
- Returns:
Returns a list of C++ calls for all shifts of the producer
- Return type:
List[str]
- class code_generation.producer.ProducerGroup(name, call, input, output, scopes, subproducers)[source]
A ProducerGroup can be used to group multiple producers. This is useful to keep the configuration simpler and to ensure that the producers are called in the correct order. ProducerGroups can be nested.
- Parameters:
name (str) – Name of the ProducerGroup
call (Union[str, None]) – Typically, this is None
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]], None]) – The inputs of the ProducerGroup
output (Union[List[q.Quantity], None]) – Output quantities of the Producer Group
scopes (List[str]) – The scopes in which the ProducerGroup is to be called
subproducers (Union[ List[Producer | ProducerGroup], Dict[str, List[Producer | ProducerGroup]], ]) – The subproducers of the ProducerGroup, either a list of Producer or ProducerGroup objects, or a dict with the scope as key and a list of Producer or ProducerGroup objects as value
- PG_count = 1
- check_producer_scopes()[source]
Function to validate the scopes of the subproducers. Internal function.
- Raises:
Exception – If a scope is not found in the subproducer configuration, an exception is raised
- Return type:
None
- get_inputs(scope)[source]
Get a list of all inputs of the ProducerGroup in a given scope
- Parameters:
scope (str) – The scope in which the inputs are requested
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the ProducerGroup
- Returns:
Returns a list of Quantity objects, which are the inputs of the ProducerGroup
- Return type:
List[str]
- get_outputs(scope)[source]
Get a list of all outputs of the ProducerGroup in a given scope
- Parameters:
scope (str) – The scope in which the outputs are requested
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the ProducerGroup
- Returns:
Returns a list of Quantity objects, which are the outputs of the ProducerGroup
- Return type:
List[Union[q.QuantityGroup, q.Quantity]]
- ignore_shift(name, scope='global')[source]
Function used to ignore a shift for every producer in the group. Wraps the ignore_shift function of a producer. Internal function.
- Parameters:
name (str) – name of the shift to be ingored
scope (str, optional) – name of the scope. Defaults to “global”.
- Return type:
None
- reserve_output(scope)[source]
Function used to reserve the output for every producer in the group. Internal function.
- Parameters:
scope (str) – Scope for which the output is reserved
- Return type:
None
- setup_own_producer()[source]
Function to setup a new producer within the ProducerGroup. Internal function.
- Return type:
None
- shift(name, scope='global')[source]
Function used to add a shift for every producer in the group. Wraps the shift function of a producer. Internal function.
- Parameters:
name (str) – name of the shift
scope (str, optional) – name of the scope. Defaults to “global”.
- Return type:
None
- writecall(config, scope, shift='')[source]
- Parameters:
config (Dict[str, Dict[str, Dict[str, str]]])
scope (str)
shift (str)
- Return type:
str
- writecalls(config, scope)[source]
Function to generate all calls for all shifts and all producer in the group, wraping the writecall function
- Parameters:
ProducerGroup (Configuration dict containing the parameter and input / output information for the)
scope (str) – The scope in which the ProducerGroup is to be called
config (Dict[str, Dict[str, Dict[str, str]]])
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the ProducerGroup
- Returns:
Returns a list of C++ calls for all shifts of the ProducerGroup
- Return type:
List[str]
- class code_generation.producer.VectorProducer(name, call, input, output, scopes, vec_configs)[source]
A Vector Producer is a Producer which can be configured to produce multiple calls and outputs at once, deprecated in favor of the ExtendedVectorProducer
- Parameters:
name (str) – Name of the producer
call (str) – The call to be made in C++, with placeholders for the parameters
input (Union[List[q.Quantity], Dict[str, List[q.Quantity]]]) – The inputs of the producer, either a list of Quantity objects, or a dict with the scope as key and a list of Quantity objects as value
output (Union[List[q.Quantity], None]) – The outputs of the producer, either a list of Quantity objects, or None if the producer does not produce any output
scopes (List[str]) – The scopes in which the producer is to be called
vec_configs (List[str]) – A list of strings, which are the names of the parameters to be varied in the vectorized call
- writecalls(config, scope)[source]
Function to generate calls for all shifts of a producer, wraping the writecall function
- Parameters:
producer (Configuration dict containing the parameter and input / output information for the)
scope (str) – The scope in which the producer is to be called
config (Dict[str, Dict[str, Dict[str, str]]])
- Raises:
Exception – Raises an Exception, of the requested scope is not valid for the producer
- Returns:
Returns a list of C++ calls for all shifts of the producer
- Return type:
List[str]