Component
Component is an ensemble of plugins. In general, users can register Plugin`s to `Component, and tell it the varibales you wanna get. Component will auto-deduce the workflow based on the registered plugins’ depends_on and provides.
In addition, if some component is fixed, i.e. the distribution of variables is independent on the parameters, component will not do the deduction and simulation.
The base class is Component.
- class appletree.Component(name: Optional[str] = None, llh_name: Optional[str] = None, **kwargs)[source]
Bases:
objectBase class of component.
- __init__(name: Optional[str] = None, llh_name: Optional[str] = None, **kwargs)[source]
Initialization.
- Parameters
bins – bins to generate the histogram. * For irreg bins_type, bins must be bin edges of the two dimensions. * For meshgrid bins_type, bins are sent to jnp.histogramdd.
bins_type – binning scheme, can be either irreg or meshgrid.
- get_normalization(hist, parameters, batch_size=None)[source]
Return the normalization factor of the histogram.
- implement_binning(mc, eff)[source]
Apply binning to MC data.
- Parameters
mc – data from simulation.
eff – efficiency of each event, as the weight when making a histogram.
- property lineage
- property lineage_hash
- multiple_simulations(key, batch_size, parameters, times, apply_eff=False)[source]
Simulate many times and move results to CPU because the memory limit of GPU.
For the component that needs simulation, we have a child class ComponentSim.
- class appletree.ComponentSim(*args, **kwargs)[source]
Bases:
ComponentComponent that needs MC simulations.
- property code
Code of simulation function.
- deduce(data_names: Union[List[str], Tuple[str]] = ['cs1', 'cs2'], func_name: str = 'simulate', nodep_data_name: str = 'batch_size', force_no_eff: bool = False)[source]
Deduce workflow and code.
- Parameters
data_names – data names that simulation will output.
func_name – name of the simulation function, used to cache it.
nodep_data_name – data_name without dependency will not be deduced.
force_no_eff – force to ignore the efficiency, used in yield prediction.
- dependencies_deduce(data_names: Union[List[str], Tuple[str]] = ['cs1', 'cs2', 'eff'], dependencies: Optional[List[Dict]] = None, nodep_data_name: str = 'batch_size') list[source]
Deduce dependencies.
- Parameters
data_names – data names that simulation will output.
dependencies – dependency tree.
nodep_data_name – data_name without dependency will not be deduced.
- flush_source_code(data_names: Union[List[str], Tuple[str]] = ['cs1', 'cs2', 'eff'], func_name: str = 'simulate', nodep_data_name: str = 'batch_size')[source]
Infer the simulation code from the dependency tree.
- property lineage
- new_component(llh_name: Optional[str] = None, pass_binning: bool = True)[source]
Generate new component with same binning, usually used on predicting yields.
- register_all(module)[source]
Register all plugins defined in module.
Can pass a list/tuple of modules to register all in each.
- set_config(configs)[source]
Set new global configuration options.
- Parameters
configs – dict, configuration file name or dictionary
- show_config(data_names: Union[List[str], Tuple[str]] = ['cs1', 'cs2', 'eff'])[source]
Return configuration options that affect data_names.
- Parameters
data_names – Data type name
For the component that is fixed, ComponentFixed should be used instead.
- class appletree.ComponentFixed(*args, **kwargs)[source]
Bases:
ComponentComponent whose shape is fixed.
- deduce(data_names: Union[List[str], Tuple[str]] = ['cs1', 'cs2'])[source]
Deduce the needed parameters and make the fixed histogram.
- property lineage
There are some default plugins with registrations in appletree.components. Check them as a quick start on how to build your own component. See also