Skip to main content

Useful tools for root in python

Project description

JusflPyRoot

a library to ease the life with powerfull python numpy and powerfull ROOT classes.

in progress, very early stage

Installation

Use uv{.verbatim} from astral to handle the environment.

 uv tool install jusflpyroot
# OR classically
 pip install jusflpyroot

Use example

Self-explanatory, create TH1F, induce NumpyTH1, save, destoy, repeat, etc...

if __name__ == "__main__":

    NumpyTH1.list_file("bobes.root") #  list the file content if exists
    #   create one ROOT  histogram
    h = ROOT.TH1F("namea", "histogram that goes to file", 100, 0, 100)

    print("i... filling-in with a binary pattern to distinguish under/ovrflow and the content")
    h.Fill(- 1 )            # underflow
    h.Fill(0, 2)            # 2x inside
    h.Fill(100 - 0.0001, 4) # 4x inside
    h.Fill(100 , 8)         # 8x overflow

    #   create THE OBJECT
    nh = NumpyTH1.from_th1(h)
    nh.save("bobes.root", save_format="root")
    nh.force_del()  # brutally remove the object from instances

    # once more, but empty, I dont care about 'h'
    h = ROOT.TH1F("nameb", "histogram that also goes to file", 100, 0, 100)
    nh = NumpyTH1.from_th1(h)
    nh.save("bobes.root", save_format="root")
    nh.force_del()

    # last time, but dont delete this time
    h = ROOT.TH1F("namec", "histogram just here", 100, 0, 100)
    nh = NumpyTH1.from_th1(h)
    nh2 = NumpyTH1.load("bobes.root", "namea", load_format="root")

    print(" ... _______ I expect to see 'namec' (still in memory)   and 'namea' from disk")
    NumpyTH1.list()
    print(" ... _______ on disk:")
    NumpyTH1.list_file("bobes.root")

The output should look like this:

i... filling-in with a binary pattern to distinguish under/ovrflow and the content
i...  saving   histo 'namea'  into   'bobes.root'
D...  deleting histo 'namea'  #instances   1 =>   0
i...  saving   histo 'nameb'  into   'bobes.root'
D...  deleting histo 'nameb'  #instances   1 =>   0
i...  loading        'namea'    from bobes.root
i... there is 2 histograms total in the file
 ... _______ I expect to see 'namec' (still in memory)   and 'namea' from disk
 0. namec      'histogram just here                '  2025-07-09 14:21:17.876   100   <0.0 - 100.0)   [ 0.0 / 0.0 / 0.0 ]
 1. namea      'histogram that goes to file        '  2025-07-09 14:21:17.876   100   <0.0 - 100.0)   [ 1.0 / 6.0 / 8.0 ]
 ... _______ on disk:
f...   ...   namea     (TH1 in bobes.root)
f...   ...   nameb     (TH1 in bobes.root)

Project details


Download files

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

Source Distribution

jusflpyroot-0.1.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

jusflpyroot-0.1.2-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file jusflpyroot-0.1.2.tar.gz.

File metadata

  • Download URL: jusflpyroot-0.1.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for jusflpyroot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 fdea83a7fd234fd5f18e08f629277a6b8ea96a36efe24480c82bb02475ecb7e4
MD5 104f37d29d7a624634d3b44733a0e9a1
BLAKE2b-256 0f14a0eff2bac1a49a136d022c7413b23057186e06bb8ba3bf075bcffd390f81

See more details on using hashes here.

File details

Details for the file jusflpyroot-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for jusflpyroot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 512506bdec1d6bad203a3a3a0fd6bb368f9db68975329bd1f4c1842ae565102e
MD5 8c7ddf2c2b6fffdea19c45b21e6a81d4
BLAKE2b-256 a6741cf7a6c19454577bff7757bb63b0edfe251e64166aefe14cc88023a4ff8e

See more details on using hashes here.

Supported by

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