Skip to main content

Functional Analysis Description Language backend for accessing ATLAS xAOD files.

Project description

func_adl_xAOD

Backend that converts qastle to run on an ATLAS xAOD backend.

GitHub Actions Status Code Coverage

PyPI version Supported Python versions

Introduction

This allows you to query hierarchical data stored in a root file that has been written using the ATLAS xAOD format. This code allows you to query that.

Features

A short list of some of the features that are supported by the xAOD C++ translator follows.

Python

Many, but not all, parts of the python language are supported. As a general rule, anything that is a statement or flow control is not supported. So no if or while or for statements, for example. Assignment isn't supported, which may sound limiting - but this is a functional implementation so it is less to than one might think.

What follows are the parts of the language that are covered:

  • Function calls, method calls, and lambda calls (and lambda functions), with some limitations.
  • Integer indexing into arrays
  • Limited tuple support as a means of collecting information together, or as an output to a ROOT file.
  • Limited list support (in same way as above). In particular, the append method is not supported as that modifies the list, rather than creating a new one.
  • Unary, Binary, and comparison operations. Only 2 argument comparisons are supported (e.g. a > b and not a > b > c).
  • Using and and or to combine conditional expressions. Note that this is written as & and | when writing an expression due to the fact python demands a bool return from and and or when written in code.
  • The conditional if expression (10 if a > 10 else 20)
  • Floating point numbers, integers, and strings.

xAOD Functions

You can call the functions that are supported by the C++ objects as long as the required arguments are primitive types. Listed below are special extra functions attached to various objects in the ATLAS xAOD data model.

The Event

The event object has the following special functions to access collections:

  • Jets, Tracks, EventInfo, TruthParticles, Electrons, Muons, and MissingET. Each function takes a single argument, the name of the bank in the xAOD. For example, for the electrons one can pass "Electrons".

Adding new collections is fairly easy.

The Jet Object

Template functions don't make sense yet in python.

  • getAttribute - this function is templated, so must be called as either getAttributeFloat or getAttributeVectorFloat.

Math

  • Math Operators: +, -, *, /, %
  • Comparison Operators: <, <=, >, >=, ==, !=
  • Unary Operators: +, -, not
  • Math functions are pulled from the C++ cmath library: sin, cos, tan, acos, asin, atan, atan2, sinh, cosh, tanh, asinh, acosh, atanh, exp, ldexp, log, ln, log10, exp2, expm1, ilogb, log1p, log2, scalbn, scalbln, pow, sqrt, cbrt, hypot, erf, erfc, tgamma, lgamma, ceil, floor, fmod, trunc, round, rint, nearbyint, remainder, remquo, copysign, nan, nextafter, nexttoward, fdim, fmax, fmin, fabs, abs, fma.
  • Do not use math.sin in a call. However sin is just fine. If you do, you'll get an exception during resolution that it doesn't know how to translate math.
  • for things like sum, min, max, etc., use the Sum, Min, Max LINQ predicates.

Output Formats

The xAOD code only renders the func_adl expression as a ROOT file. The ROOT file contains a simple TTree in its root directory.

  • If AsROOTTTree is the top level func_adl node, then the tree name and file name are taken from that expression. Only a sequence of python tuples or a single item can be understood by AsROOTTTree.
  • If a Select sequence of int or double is the last func_adl expression, then a file called xaod_output.root will be generated, and it will contain a TTree called atlas_xaod_tree with a single column, called col1.
  • If a Select sequence of a tuple is the last func_adl expression, then a file called xaod_output.root will be generated, and it will contain a TTree called atlas_xaod_tree with a columns named col1, col2, etc.
  • If a Select sequence of dictionary's is the last func_adl expression, then a file called xaod_output.root will be generated, and it will contain a TTree called atlas_xaod_tree, with column names taken from the dictionary keys.

ServiceX (and the servicex frontend package) can convert from ROOT to other formats like a pandas.DataFrame or an awkward array.

Testing and Development

Setting up the development environment:

  • After creating a virtual environment, do a setup-in-place: pip install -e .[test]

To run tests:

  • pytest -m "not atlas_xaod_runner and not cms_aod_runner" will run the fast tests.
  • pytest -m "atlas_xaod_runner" and pytest -m "cms_aod_runner" will run the slow tests for ATLAS and CMS respectively that require docker installed on your command line. docker is involved via pythons os.system - so it needs to be available to the test runner.
  • The CI on github is setup to run tests against python 3.7, 3.8, and 3.9 (only the non-xaod-runner tests).

Contributing:

  • Develop in another repo or on a branch
  • Submit a PR against the master branch.

In general, the master branch should pass all tests all the time. Releases are made by tagging on the master branch.

Publishing to PyPi:

  • Automated by declaring a new release (or pre-release) in github's web interface

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

func_adl_xAOD-1.3b6.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

func_adl_xAOD-1.3b6-py3-none-any.whl (53.9 kB view details)

Uploaded Python 3

File details

Details for the file func_adl_xAOD-1.3b6.tar.gz.

File metadata

  • Download URL: func_adl_xAOD-1.3b6.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for func_adl_xAOD-1.3b6.tar.gz
Algorithm Hash digest
SHA256 46636b7f844ecdb9afeeb40f05704a2cba57ec0a3fe6eb10ffbe0b4802af2550
MD5 4831f22d8d29b0d57d538253df445856
BLAKE2b-256 797e478face56e66ec696293aacdceaf799fd46a4634bbc46711ab632f3982ec

See more details on using hashes here.

File details

Details for the file func_adl_xAOD-1.3b6-py3-none-any.whl.

File metadata

  • Download URL: func_adl_xAOD-1.3b6-py3-none-any.whl
  • Upload date:
  • Size: 53.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

File hashes

Hashes for func_adl_xAOD-1.3b6-py3-none-any.whl
Algorithm Hash digest
SHA256 0adea9b2d2efa1d86c86383d6681862f80ec0b57304992073748057d84db0d1f
MD5 a1006761577859d4918bd6072b8074e7
BLAKE2b-256 937efc064cc33e73c3bceca816a9575929cec92cd3769baf42076f06078ce9af

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page