cabinetry
cabinetry copied to clipboard
Template building functions specified in the configuration
The way cabinetry
currently provides to execute arbitrary functions to built template histograms is described in the documentation. User-provided functions need to be decorated, the arguments of the decorator specify when the function should be called.
@gordonwatts suggested another approach, where the function is directly specified in the config (slightly modified example):
Samples:
- Name: "Signal"
Reader:
Name: "generate_histograms"
Dataset: "prediction.root"
Parameter1: 33.3
Parameter2: 44.4
Weight: "weight"
generate_histograms
would be a function that cabinetry
can call (like the uproot
backend for histogram production), and the function would receive the Reader
dictionary as input and return a histogram. The input to the function should follow the same logic of overriding settings specified at lower settings (see #210). The function itself could also vary, though that would require a consistent API.
This format makes it easier for users to define their own custom backends, and to pass arbitrary information to those backends. It might be useful to define a default template creating function somewhere, and override as needed instead of having to specify duplicate information in many places.
The proposed format can benefit from the overriding idea used in the config, which is harder to achieve with the current approach. One possible concern is that configs building the same statistical models may become harder to read if different backends are used, and those backends use different naming conventions for parameters.
Related content This would likely require #210 to work properly. Also related to #43.
Based on discussion related to coffea-to-cabinetry
.