|
Mujpy /
Root< How to update the distribution | Index Latest on MusrRoot as of 10/2026 it is announced as unique format for 2027 data. See below for first lem implementation, bottom for new problem: Use uproot
Latest top
uproot._ReadOnlyFile(filepath).root_directory.keys() # lists the root keys
file = uproot.ReadOnlyFile(filepath)
histos = file.root_directory['histos']
header = file.root_directory['RunHeader']
lists = header.members['fFolders][0] if type(header)
for lstr in lem_lists:
...: if isinstance(lstr,str):
...: print(lstr)
...: else:
...: for string in lstr:
...: print('******************* Enter sublist')
...: print(string
histo[0] = np.array(histos.members['fFolders'][0].members['fFolders'][0].counts()) header_lists = header.members['fFolders']* new files histo[0] = np.array(file.root_directory['histos/DecayAnaModule/hDecay001'].counts(
LEM replicated detectors 20-27 (as seen in musrfit) are actually histo(8)-histo(1) in the root file
• for LEM use 0-7 as indices and switch automatically to 8-15 if they exist MusrRoot
from uproot import open as lem_open
from uproot.reading import open as bulk_open
# are the same, also uproot.ReadOnlyFile('file').root_directory
# find a way to read more humanly by uproot methods, seems to promose python like addressing but the structure is Root, Tobjects, not python native, quite clumsy.
# also Root promises to enforce TDictionary instead of TFolder object. The second is discovered looking for .members[`fFolders'] of a Tlist, which key to do the samefor a TDirectory? ['fDirectory'] or ['fDirectories'] ...
import numpy as np
from os.path import split
filename = split(path_filename)[-1]i
root_open = bulk_open if filename[0]=='d' else lem_open
run = root_open(path_filename) # path_filename is a deltatbc_tdc_gps file
run['RunHeader'].members['fFolders'][0][2] # notice, no () for bulk_open
|