Reproduce “Parsing TTree Formula in Python” on OpenResearch

Turn your favorite coding agents into research agents that review literature, develop hypotheses, and run experiments.

Universal app for Apple silicon and Intel. Requires macOS 11 or later.

About this paper

Aryan Roy, Jim Pivarski

This work introduces a Python solution for parsing and translating CERN ROOT's TTreeFormula expressions into native Python code, addressing a critical gap for physicists using Python's data science ecosystem. The new implementation dramatically improves parsing speed, achieving up to a 526-fold speedup, and provides a formal EBNF grammar for the TTreeFormula language.

Key insights

  • Formalizing the TTreeFormula language with Extended Backus-Naur Form (EBNF) provides a precise and previously missing specification.
  • Utilizing a LALR(1) parser with the Lark toolkit significantly improves parsing performance for TTreeFormula expressions compared to previous methods.
  • An Abstract Syntax Tree (AST) serves as an effective intermediate representation for transpiling TTreeFormula expressions into different Python-compatible libraries like NumExpr and Awkward Array.

Summary by alphaXiv.

Tip: change arxiv.org to autoarxiv.org in any arXiv abstract link to open the paper here.