root_mcp.extended.analysis package
Extended analysis operations.
- class root_mcp.extended.analysis.AnalysisOperations(config, file_manager)[source]
Bases:
objectHigh-level physics analysis operations.
Provides histogramming, selection, projections, and derived quantities.
- Parameters:
config (Config)
file_manager (FileManager)
- __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.
- compute_histogram(path, tree_name, branch, bins, range=None, selection=None, weights=None, defines=None, flatten=True)[source]
Compute a 1D histogram.
- Parameters:
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:
- 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:
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:
- compute_histogram_arithmetic(operation, data1, data2)[source]
Perform arithmetic on two histograms.
- 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 ofinvariant_mass,invariant_mass_squared,transverse_mass,delta_r,delta_phi),particles(list of branch prefixes), and optionallycomponents(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:
- class root_mcp.extended.analysis.CorrelationAnalysis(config, file_manager)[source]
Bases:
objectStatistical correlation and covariance analysis.
Provides: - Pearson correlation coefficients - Spearman rank correlation - Covariance matrices - Correlation matrices - Significance testing
- Parameters:
config (Config)
file_manager (FileManager)
- __init__(config, file_manager)[source]
Initialize correlation analysis.
- Parameters:
config (Config) – Server configuration
file_manager (FileManager) – File manager instance
- compute_correlation(path, tree_name, branch_x, branch_y, selection=None, method='pearson')[source]
Compute correlation coefficient between two branches.
- Parameters:
- Returns:
Correlation coefficient, p-value, and metadata
- Return type:
- compute_correlation_matrix(path, tree_name, branches, selection=None, method='pearson')[source]
Compute correlation matrix for multiple branches.
- compute_covariance_matrix(path, tree_name, branches, selection=None)[source]
Compute covariance matrix for multiple branches.
- class root_mcp.extended.analysis.HistogramOperations(config, file_manager)[source]
Bases:
objectAdvanced histogram operations with scipy-based fitting.
Extends core histogram capabilities with: - 2D and 3D histograms - Profile histograms - Weighted histograms with proper error propagation - Histogram arithmetic
- Parameters:
config (Config)
file_manager (FileManager)
- __init__(config, file_manager)[source]
Initialize histogram operations.
- Parameters:
config (Config) – Server configuration
file_manager (FileManager) – File manager instance
- compute_histogram_1d(path, tree_name, branch, bins, range=None, selection=None, weights=None)[source]
Compute a 1D histogram with advanced features.
- Parameters:
- Returns:
Histogram data with metadata
- Return type:
- compute_histogram_2d(path, tree_name, branch_x, branch_y, bins_x, bins_y, range_x=None, range_y=None, selection=None, weights=None)[source]
Compute a 2D histogram.
- Parameters:
path (str) – File path
tree_name (str) – Tree name
branch_x (str) – X-axis branch
branch_y (str) – Y-axis branch
bins_x (int) – Number of bins in X
bins_y (int) – Number of bins in Y
range_x (tuple[float, float] | None) – (min, max) for X axis
range_y (tuple[float, float] | None) – (min, max) for Y axis
selection (str | None) – Optional cut expression
weights (str | None) – Optional weight branch
- Returns:
2D histogram data
- Return type:
- class root_mcp.extended.analysis.KinematicsOperations(config, file_manager)[source]
Bases:
objectParticle physics kinematics calculations.
Provides: - Invariant mass calculations - Transverse momentum (pT) - Pseudorapidity (eta) - Azimuthal angle (phi) - Delta R separation - Lorentz transformations - Dalitz variables
- Parameters:
config (Config)
file_manager (FileManager)
- __init__(config, file_manager)[source]
Initialize kinematics operations.
- Parameters:
config (Config) – Server configuration
file_manager (FileManager) – File manager instance
- compute_boost_to_cm(path, tree_name, pt_branches, eta_branches, phi_branches, mass_branches, selection=None)[source]
Boost particles to center-of-mass frame.
- Parameters:
- Returns:
Dictionary with boosted 4-vectors
- Return type:
- compute_dalitz_variables(path, tree_name, pt_branches, eta_branches, phi_branches, mass_branches, selection=None)[source]
Compute Dalitz plot variables for 3-body decay.
- Parameters:
- Returns:
Dictionary with m12_squared and m23_squared arrays
- Return type:
- compute_delta_r(path, tree_name, eta1, phi1, eta2, phi2, selection=None)[source]
Compute Delta R separation between two objects.
- Parameters:
- Returns:
Dictionary with Delta R array
- Return type:
- compute_invariant_mass(path, tree_name, pt_branches, eta_branches, phi_branches, mass_branches=None, selection=None)[source]
Compute invariant mass from 4-vectors.
- class root_mcp.extended.analysis.SafeExprEvaluator(names)[source]
Bases:
NodeVisitorSafe expression evaluator for limited math subset. Uses abstract syntax tree to evaluate expressions without eval().
- visit_Expression(node)[source]
- Parameters:
node (Expression)
- Return type:
- root_mcp.extended.analysis.fit_histogram(data, model, initial_guess=None, bounds=None, fixed_parameters=None)[source]
Fit a model to histogram data.
- Parameters:
model (str | list[str | dict[str, Any]] | dict[str, Any]) – Model definition. Can be: - str: Name of built-in model (e.g., “gaussian”) - list[str]: List of built-in models (e.g., [“gaussian”, “exponential”]) - list[dict]: List of models with config (e.g.,
[{"name": "gaussian", "prefix": "s_"}]) - dict: Custom model definition (e.g. {“expr”: “A*x + B”, “params”: [“A”, “B”]})initial_guess (list[float] | None) – Initial parameter values
bounds (list[list[float]] | None) – List of [min, max] pairs for each parameter. Use [-np.inf, np.inf] for no bound.
fixed_parameters (dict[str | int, float] | None) – Dictionary of parameters to fix. Keys can be index (int) or name (str).
- Returns:
Dictionary with fitted parameters, errors, and stats
- Return type:
- root_mcp.extended.analysis.fit_histogram_2d(x, y, z, z_errors=None, model='gaussian_2d', initial_params=None, fixed_params=None, bounds=None)[source]
Fit a 2D histogram with a model function.
- Parameters:
x (ndarray) – X-coordinate array (flattened)
y (ndarray) – Y-coordinate array (flattened)
z (ndarray) – Z-values (bin contents, flattened)
z_errors (ndarray | None) – Errors on z-values
model (str) – Model name from MODEL_REGISTRY_2D
initial_params (list[float] | None) – Initial parameter guesses
fixed_params (dict[str, float] | None) – Dictionary of {param_name: value} for fixed parameters
bounds (tuple[list[float], list[float]] | None) – Tuple of (lower_bounds, upper_bounds)
- Returns:
Dictionary with fit results
- Return type:
- root_mcp.extended.analysis.generate_plot(data, plot_type='histogram', fit_data=None, options=None, config=None)[source]
Generate a plot from analysis data.
- Parameters:
- Returns:
Dictionary with base64 encoded image
- Return type:
- root_mcp.extended.analysis.strip_outer_parens(expr)[source]
Strip outer parentheses from expression.
- root_mcp.extended.analysis.translate_leaf_expr(expr)[source]
Translate C++ style expression to Python.
Submodules
- root_mcp.extended.analysis.correlations module
- root_mcp.extended.analysis.expression module
- root_mcp.extended.analysis.fitting module
- root_mcp.extended.analysis.histograms module
- root_mcp.extended.analysis.kinematics module
- root_mcp.extended.analysis.operations module
AnalysisOperationsAnalysisOperations.__init__()AnalysisOperations.apply_selection()AnalysisOperations.compute_histogram()AnalysisOperations.compute_histogram_2d()AnalysisOperations.compute_histogram_arithmetic()AnalysisOperations.compute_kinematics()AnalysisOperations.compute_profile()AnalysisOperations.export_to_formats()
- root_mcp.extended.analysis.plotting module