Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/km3net/km3buu

Python GiBUU wrapper for KM3NeT
https://github.com/km3net/km3buu

buu gibuu km3net neutrino neutrino-generator particle physics python scattering

Last synced: 8 days ago
JSON representation

Python GiBUU wrapper for KM3NeT

Awesome Lists containing this project

README

        

.. image:: https://git.km3net.de/simulation/km3buu/-/raw/master/doc/_static/km3buu_logo.svg
:width: 300em
:alt: KM3BUU Logo

KM3BUU
======

.. image:: https://img.shields.io/badge/docs-stable-blue.svg
:target: https://simulation.pages.km3net.de/km3buu

.. image:: https://git.km3net.de/simulation/km3buu/badges/master/pipeline.svg
:target: https://git.km3net.de/simulation/km3buu/pipelines

.. image:: https://git.km3net.de/simulation/km3buu/badges/master/coverage.svg

.. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.8243040.svg
:target: https://doi.org/10.5281/zenodo.8243040

**This is NOT an official KM3NeT software package.**

The KM3BUU project is an integrated python framework for wrapping the GiBUU particle interaction simulation https://gibuu.hepforge.org/trac/wiki . It is specifically designed for studies within the KM3NeT experiment and focuses on the neutrino simulation functionality of GiBUU.

The main code repository can be found at: https://git.km3net.de/simulation/km3buu

The framework covers all parts of the GiBUU workflow, which includes setting up the simulation configuarion inside a so-called jobcarb, running GiBUU and parsing the output files.

Installation
------------

The main `KM3BUU` project is a python based framework, which can be used with a
local GiBUU installation or used within a docker container. In order to install the `km3buu` python module the repository has to be retreived from the Git server first.

From KM3NeT GitLab:

.. code-block:: console

git clone https://git.km3net.de/simulation/km3buu
cd km3buu

From GitHub:

.. code-block:: console

git clone https://github.com/KM3NeT/km3buu
cd km3buu

After downloading the repository the package can be installed via:

.. code-block:: console

pip install -e

(Up to now `KM3BUU` is not provided via python package manager.)

If working inside a docker environment is recommended, the KM3BUU image can be copied&run directly from the KM3NeT docker server:

.. code-block:: console

docker run -it --rm docker.km3net.de/simulation/km3buu:latest /bin/bash

or built locally:

.. code-block:: console

cd km3buu
docker build .

The docker image contains the latest release of `km3buu` as well as the GiBUU 2021 Patch 4 (release from 2023-03-23) including RootTuple extension is installed (km3buu v1.0.0).

Getting started
---------------
The GiBUU workflow starts from a jobcard which contains the configuration which should be simulated. The jobcards are technically FORTRAN namelists and can be created using a `Jobcard` object. In the example this is done via loading an existing jobcard:

.. code-block:: python3

>>> from km3buu.jobcard import Jobcard, read_jobcard

>>> jc = read_jobcard("jobcards/examples/example.job")

Alternatively a neutrino jobcard can be generated from scratch via

.. code-block:: python3

>>> from km3buu.jobcard import Jobcard, generate_neutrino_jobcard

>>> generate_neutrino_jobcard(1000, 1, "CC", "muon", (1,10))

This jobcard is subsequently forwarded to GiBUU via the `run_jobcard` function. The second argument takes a directory which should be used to write out all the output files generated by GiBUU.

.. code-block:: python3

>>> from km3buu.ctrl import run_jobcard

>>> run_jobcard(jc, "./output")
0

Finally, the output can be parsed using a `GiBUUOutput` object:

.. code-block:: python3

>>> from km3buu.output import GiBUUOutput

>>> data = GiBUUOutput("./output")

The event data can further be converted to a pandas dataframe

.. code-block:: python3

>>> df = data.df

or an awkward array

.. code-block:: python3

>>> arr = data.arrays