Reference

YAML configuration parsing

A plotIt YAML configuration file should have the following structure:

configuration:
  # Configuration block
files:
  file_name:
    # File block
  ...
groups: # optional
  group_name:
    # Group block
  ...
plots:
  plot_name:
    # Plot block
  ...
systematics: # optional
  # just name (for shape) or name with systematic block
  ...
legend: # optional
  # legend block

Such YAML files can be parsed with the loadFromYAML() method. It will return instances of the classes defined in the plotit.config module, whose attribute listings below serve as a reference of the allowed attributes in each block, and their types.

plotit.loadFromYAML(histodir=None, eras=None)

Parse a plotIt YAML file. The returned objects are stateless, except for the list of samples, which consists of stateful Group or ungrouped File instances that carry a TFile pointer.

Parameters:
  • yamlFileName (str) – config file path

  • histodir (str | None) – base path for finding histograms (to be combined with 'root' in configuration and the sample file names; yamlFileName directory by default)

  • eras (None | str | List[str]) – selected era, or list of selected eras (default: all that are present)

Return type:

Tuple[Configuration, List[File | Group], List[Plot], List[SystVar], Legend]

The plotit.config module contains classes that represent parts of the YAML configuration file, and helper methods for parsing the different blocks. Configuration, File, Group, Configuration, Label, Legend, Plot, Point, and Position are the “stateless” classes mentioned here.

class plotit.config.Configuration(width=800, height=800, margin_left=0.17, margin_right=0.03, margin_top=0.05, margin_bottom=0.13, eras=<factory>, luminosity=<factory>, scale=1.0, no_lumi_rescaling=False, luminosity_error=0.0, y_axis_format='%1% / %2$.2f', ratio_y_axis_title='Data / MC', ratio_style='P0', error_fill_color=42, error_fill_style=3154, fit_n_points=1000, fit_line_color=46, fit_line_width=1, fit_line_style=1, fit_error_fill_color=42, fit_error_fill_style=1001, ratio_fit_n_points=1000, ratio_fit_line_color=46, ratio_fit_line_width=1, ratio_fit_line_style=1, ratio_fit_error_fill_color=42, ratio_fit_error_fill_style=1001, experiment='CMS', extra_label='', luminosity_label='', root='.', transparent_background=False, show_overflow=False, errors_type='Poisson', x_axis_label_size=18, y_axis_label_size=18, x_axis_top_ticks=True, y_axis_right_ticks=True, blinded_range_fill_color=42, blinded_range_fill_style=1001, yields_table_stretch=1.15, yields_table_align='h', yields_table_text_align='c', yields_table_numerical_precision_yields=1, yields_table_numerical_precision_ratio=2)
blinded_range_fill_color: int = 42
blinded_range_fill_style: int = 1001
eras: List[str]
error_fill_color: int = 42
error_fill_style: int = 3154
errors_type: str = 'Poisson'
experiment: str = 'CMS'
extra_label: str = ''
fit_error_fill_color: int = 42
fit_error_fill_style: int = 1001
fit_line_color: int = 46
fit_line_style: int = 1
fit_line_width: int = 1
fit_n_points: int = 1000
getLumi(eras=None)
Return type:

float

height: int = 800
luminosity: Dict[str, float]
luminosity_error: float = 0.0
luminosity_label: str = ''
margin_bottom: float = 0.13
margin_left: float = 0.17
margin_right: float = 0.03
margin_top: float = 0.05
no_lumi_rescaling: bool = False
ratio_fit_error_fill_color: int = 42
ratio_fit_error_fill_style: int = 1001
ratio_fit_line_color: int = 46
ratio_fit_line_style: int = 1
ratio_fit_line_width: int = 1
ratio_fit_n_points: int = 1000
ratio_style: str = 'P0'
ratio_y_axis_title: str = 'Data / MC'
root: str = '.'
scale: float = 1.0
show_overflow: bool = False
transparent_background: bool = False
width: int = 800
x_axis_label_size: int = 18
x_axis_top_ticks: bool = True
y_axis_format: str = '%1% / %2$.2f'
y_axis_label_size: int = 18
y_axis_right_ticks: bool = True
yields_table_align: str = 'h'
yields_table_numerical_precision_ratio: int = 2
yields_table_numerical_precision_yields: int = 1
yields_table_stretch: float = 1.15
yields_table_text_align: str = 'c'
class plotit.config.File(type, name, order=None, legend='', legend_style=None, legend_order=0, drawing_options='', marker_size=None, marker_color=None, marker_type=None, fill_color=None, fill_type=None, line_width=None, line_color=None, line_type=None, era=None, group=None, cross_section=1.0, branching_ratio=1.0, generated_events=1.0, scale=1.0, pretty_name=None, yields_title=None, yields_group=None, legend_group=None)

Configuration for a single sample

branching_ratio: float = 1.0
cross_section: float = 1.0
era: str | None = None
generated_events: float = 1.0
group: str | None = None
legend_group: str | None = None
pretty_name: str | None = None
scale: float = 1.0
yields_group: str | None = None
yields_title: str | None = None
class plotit.config.Group(type, name, order=None, legend='', legend_style=None, legend_order=0, drawing_options='', marker_size=None, marker_color=None, marker_type=None, fill_color=None, fill_type=None, line_width=None, line_color=None, line_type=None, files=<factory>)
files: List[File]
class plotit.config.Label(text, position, size=18)
position: Point
size: int = 18
text: str
class plotit.config.Legend(position=<factory>, columns=1, entries=<factory>)
class Entry(label, type='MC', order=0)
label: str
order: int = 0
type: str = 'MC'
columns: int = 1
entries: List[Entry]
position: Position
class plotit.config.Plot(name, x_axis='', x_axis_format='', y_axis='', y_axis_format=None, normalized=False, no_data=False, override=False, log_y=False, log_x=False, save_extensions=<factory>, book_keeping_folder='', show_ratio=False, fit=False, fit_ratio=False, fit_function='', fit_legend='', fit_legend_position=None, fit_range=None, ratio_fit_function='', ratio_fit_legend='', ratio_fit_legend_position=None, ratio_fit_range=None, show_errors=True, x_axis_range=None, y_axis_range=None, log_y_axis_range=None, ratio_y_axis_range=None, blinded_range=None, y_axis_show_zero=False, inherits_from=None, rebin=1, labels=<factory>, extra_label=None, legend_position=None, legend_columns=1, show_overflow=False, errors_type='Poisson', binning_x=None, binning_y=None, draw_string=None, selection_string=None, for_yields=True, yields_title=True, yields_table_order=True, sort_by_yields=False, vertical_lines=<factory>, horizontal_lines=<factory>, lines=<factory>)
binning_x: str | None = None
binning_y: str | None = None
blinded_range: List[float] | None = None
book_keeping_folder: str = ''
draw_string: str | None = None
errors_type: str = 'Poisson'
exclude = ''
extra_label: str | None = None
fit: bool = False
fit_function: str = ''
fit_legend: str = ''
fit_legend_position: Position | None = None
fit_range: List[float] | None = None
fit_ratio: bool = False
for_yields: bool = True
horizontal_lines: List[float]
inherits_from: str | None = None
labels: List[Label]
legend_columns: int = 1
legend_position: Position | None = None
lines: List[str]
log_x: bool = False
log_y: bool = False
log_y_axis_range: List[float] | None = None
name: str
no_data: bool = False
normalized: bool = False
override: bool = False
ratio_fit_function: str = ''
ratio_fit_legend: str = ''
ratio_fit_legend_position: Position | None = None
ratio_fit_range: List[float] | None = None
ratio_y_axis_range: List[float] | None = None
rebin: int = 1
save_extensions: List[str]
selection_string: str | None = None
show_errors: bool = True
show_overflow: bool = False
show_ratio: bool = False
sort_by_yields: bool = False
vertical_lines: List[float]
x_axis: str = ''
x_axis_format: str = ''
x_axis_range: List[float] | None = None
y_axis: str = ''
y_axis_format: str | None = None
y_axis_range: List[float] | None = None
y_axis_show_zero: bool = False
yields_table_order: bool = True
yields_title: bool = True
class plotit.config.Point(x, y)
x: float
y: float
class plotit.config.Position(x1, y1, x2, y2)
x1: float
x2: float
y1: float
y2: float
plotit.config.loadConfiguration(confConfig=None)

Load a Configuration from a dict

Return type:

Configuration

plotit.config.loadFiles(fileConfigs=None)

Load a list of File instances from a dictionary with settings

Return type:

List[File]

plotit.config.loadGroups(groupConfigs=None, files=None, includeEmpty=False)

Load a list of Group instances from a dictionary with settings

Return type:

List[Group]

plotit.config.loadLegend(legendConfig=None)

Load a Legend instance from a dictionary with settings

Return type:

Legend

plotit.config.loadPlots(plotsConfig, defaultStyle=None)

Load a list of Plot instances from a config dictionary

Return type:

List[Plot]

plotit.config.loadSystematics(systConfigs, configuration)

Load a list of SystVar instances from config entries

Return type:

List[Any]

plotit.config.parseWithIncludes(yamlPath)

Parse a YAML file, with ‘includes’ relative to its path

Return type:

Any