root_mcp.extended.root_native.templates module
Pre-built code templates for common ROOT operations.
Templates generate Python/PyROOT code strings that can be passed to RootCodeExecutor.execute(). Each template function returns a complete, runnable Python script as a string.
- root_mcp.extended.root_native.templates.rdataframe_histogram(file_path, tree_name, branch, bins, range_min, range_max, selection=None, weight=None, output_path=None)[source]
Generate RDataFrame code to compute a 1D histogram.
- Parameters:
file_path (str) – Path to the ROOT file.
tree_name (str) – Name of the TTree or RNTuple.
branch (str) – Branch to histogram.
bins (int) – Number of bins.
range_min (float) – Histogram range.
range_max (float) – Histogram range.
selection (str | None) – Optional cut expression (C++ syntax for RDF Filter).
weight (str | None) – Optional weight column name.
output_path (str | None) – If provided, save histogram as PNG to this path.
- Returns:
Complete Python script.
- Return type:
- root_mcp.extended.root_native.templates.rdataframe_snapshot(file_path, tree_name, branches, output_path, output_tree_name=None, selection=None)[source]
Generate RDataFrame code to write a filtered/selected subset to a new ROOT file.
- Parameters:
- Returns:
Complete Python script.
- Return type:
- root_mcp.extended.root_native.templates.roofit_fit(file_path, workspace_name, model_name, data_name, output_path=None)[source]
Generate RooFit code to perform a fit from a workspace.
- Parameters:
- Returns:
Complete Python script.
- Return type:
- root_mcp.extended.root_native.templates.root_file_write(data, output_path, tree_name='tree')[source]
Generate code to write columnar data to a new ROOT file.
- root_mcp.extended.root_native.templates.root_macro(macro_code, output_path=None)[source]
Generate code to execute a ROOT C++ macro via gROOT.ProcessLine.
- root_mcp.extended.root_native.templates.tcanvas_plot(file_path, tree_name, draw_expr, output_path, selection=None, title=None, width=800, height=600)[source]
Generate TTree::Draw + TCanvas code to create a plot.
- Parameters:
file_path (str) – Path to the ROOT file.
tree_name (str) – Name of the TTree or RNTuple.
draw_expr (str) – TTree::Draw expression (e.g. “px:py”, “mass>>h(100,0,200)”).
output_path (str) – Output file path for the plot (png, pdf, svg).
selection (str | None) – Optional cut expression.
title (str | None) – Plot title.
width (int) – Canvas dimensions in pixels.
height (int) – Canvas dimensions in pixels.
- Returns:
Complete Python script.
- Return type: