Recent Changes · Search:

Dispense


Navigation Tips - Dritte


PmWiki

pmwiki.org

edit SideBar

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

  • pip install uproot [--upgrade] --user
  • the following examples has been worked out for LEM data (using PostPileUp histograms 21-28

Latest top

  • works for all, filepath = ['data/flame26_his_00090.root','data/deltatbc_tdc_gps_2026_0177.root']
 
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
  • old files
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(

  • data = uproot.open(filename)
  • header = data['RunHeader'].members['fFolders']
  • header[0:6] are strings; eg header[0][0][:] is '000 - Version: git-sha: dae9ef0ffba4 -@0', whereas headr[6] contains strings of distinct scaler counts from [6][0][:] to [6][7][:]
  • see musrfit/CCO/run-09-24/LEM/underdoped/Analysis/muheader_root.py
    • header[0] is general; header[1] is histo info (t0 and length); [3:5] are cryo, magnet and beamline names; [5] is beamline info, Temperatures [128:132]; [6] is sums
  • histoLeftPPC = data['histos'].members["fFolders"][0].members['fFolders'][8].counts()
  • histoLeftPPC = data['histos'].members["fFolders"][0].members['fFolders'][8].counts()
  • Now offending limit is n<nhisto
  • for LEM use 0-7 and always switch to 8-15? wait for Zaher's answer

LEM replicated detectors 20-27 (as seen in musrfit) are actually histo(8)-histo(1) in the root file

  • histo(8) - histo(0), 9-1 and so on are zero based decay functions starting from ~12 whereas e-g 9-0 ranges from 30 to -10 counts
  • This confirms the assignment 0 -> 8, 1 -> 9 etc, but the difference is not a smooth function, i.e. 8 is not 0 minus a function. What is it then?

• for LEM use 0-7 as indices and switch automatically to 8-15 if they exist


MusrRoot

  • Works on wsl now, removed with ... that made muroot2py().run disappears before being used
  • Damn, Bulk and lem are different.

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
  • find counts at muroot2py().run['histos'].members['fFolders'][2].members['fFolders'][1].counts() in both
  • lemkeys = runlem.__dict__['_histo_dictionary'].keys()
  • gpskeys = rungps.__dict__['_histo_dictionary'].keys() # redo with '_header_dictionary'
  • set(lemkeys)-set(gpskeys) and viceversa shows unique set(lemkeys)&set(gpskeys) common ones

< How to update the distribution | Index

Edit - History - Print - PDF - Recent Changes - Search
Page last modified on October 14, 2026, at 08:26 AM