root_mcp.extended.analysis.operations module

High-level analysis operations.

class root_mcp.extended.analysis.operations.AnalysisOperations(config, file_manager)[source]

Bases: object

High-level physics analysis operations.

Provides histogramming, selection, projections, and derived quantities.

Parameters:
__init__(config, file_manager)[source]

Initialize analysis operations.

Parameters:
  • config (Config) – Server configuration

  • file_manager (FileManager) – File manager instance

apply_selection(path, tree_name, selection, defines=None)[source]

Count entries passing a selection.

Parameters:
  • path (str) – File path

  • tree_name (str) – Tree name

  • selection (str) – Cut expression

  • defines (dict[str, str] | None) – Optional variable definitions

Returns:

Selection statistics

Return type:

dict[str, Any]

compute_histogram(path, tree_name, branch, bins, range=None, selection=None, weights=None, defines=None, flatten=True)[source]

Compute a 1D histogram.

Parameters:
  • path (str | list[str]) – File path or list of file paths

  • tree_name (str) – Tree name

  • branch (str) – Branch to histogram

  • bins (int) – Number of bins

  • range (tuple[float, float] | None) – (min, max) for histogram range (auto if None, based on first file)

  • selection (str | None) – Optional cut expression

  • weights (str | None) – Optional branch for weights

  • defines (dict[str, str] | None) – Optional derived variable definitions

  • flatten (bool) – Flatten jagged arrays before histogramming

Returns:

Histogram data and metadata

Return type:

dict[str, Any]

compute_histogram_2d(path, tree_name, x_branch, y_branch, x_bins, y_bins, x_range=None, y_range=None, selection=None, defines=None, flatten=True)[source]

Compute a 2D histogram.

Parameters:
  • path (str | list[str]) – File path or list of paths

  • tree_name (str) – Tree name

  • x_branch (str) – Branch for x-axis

  • y_branch (str) – Branch for y-axis

  • x_bins (int) – Number of bins in x

  • y_bins (int) – Number of bins in y

  • x_range (tuple[float, float] | None) – (min, max) for x-axis

  • y_range (tuple[float, float] | None) – (min, max) for y-axis

  • selection (str | None) – Optional cut expression

  • defines (dict[str, str] | None) – Optional derived variable definitions

  • flatten (bool) – Flatten jagged arrays

Returns:

2D histogram data and metadata

Return type:

dict[str, Any]

compute_histogram_arithmetic(operation, data1, data2)[source]

Perform arithmetic on two histograms.

Parameters:
  • operation (str) – One of “add”, “subtract”, “multiply”, “divide”, “asymmetry”

  • data1 (dict[str, Any]) – First histogram object

  • data2 (dict[str, Any]) – Second histogram object

Returns:

New histogram object with computed values.

Return type:

dict[str, Any]

compute_kinematics(path, tree_name, computations, selection=None, limit=None)[source]

Compute kinematic quantities from four-momenta.

Parameters:
  • path (str) – File path

  • tree_name (str) – Tree name

  • computations (list[dict[str, Any]]) – List of kinematic calculations. Each entry is a dict with keys name (output variable name), type (one of invariant_mass, invariant_mass_squared, transverse_mass, delta_r, delta_phi), particles (list of branch prefixes), and optionally components (component suffixes; defaults vary by type).

  • selection (str | None) – Optional cut expression

  • limit (int | None) – Maximum entries to process

Returns:

Dictionary with computed kinematic quantities

Return type:

dict[str, Any]

compute_profile(path, tree_name, x_branch, y_branch, x_bins, x_range=None, selection=None)[source]

Compute a profile histogram (mean of y vs binned x).

Parameters:
  • path (str) – File path

  • tree_name (str) – Tree name

  • x_branch (str) – Branch to bin

  • y_branch (str) – Branch to average

  • x_bins (int) – Number of bins in x

  • x_range (tuple[float, float] | None) – (min, max) for x-axis

  • selection (str | None) – Optional cut

Returns:

Profile data and metadata

Return type:

dict[str, Any]

export_to_formats(data, output_path, format)[source]

Export data to various formats.

Parameters:
  • data (awkward.Array) – Awkward array to export

  • output_path (str) – Destination path

  • format (str) – Output format (json, csv, parquet)

Returns:

Export metadata

Return type:

dict[str, Any]