Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ROOT Map() showing errors for any written TTrees with TBaskets #931

Open
ioanaif opened this issue Aug 10, 2023 · 1 comment
Open

ROOT Map() showing errors for any written TTrees with TBaskets #931

ioanaif opened this issue Aug 10, 2023 · 1 comment
Labels
big-project This will take some time, perhaps as a Fellowship or GSoC project bug The problem described is something that must be fixed

Comments

@ioanaif
Copy link
Collaborator

ioanaif commented Aug 10, 2023

An issue was introduced in between uproot 4.1.1 and 4.1.5, where ROOT .Map() shows errors for any TTrees with TBaskets (where the TBaskets can be empty or not).

>>> import uproot
>>> import ROOT
>>> import numpy as np
>>> uproot.__version__
5.0.10
>>> file = uproot.recreate("simple_reproducer.root")
>>> file["tree"] = {"some_array": np.array([1,2,3])}
>>> rf = ROOT.TFile("simple_reproducer.root")
>>> rf.Map()
20230810/162540  At:100     N=142       TFile                     
20230810/162557  At:242     N=101       TBasket                   
Address = 343	Nbytes = 0	=====E R R O R=======
0/000000  At:343     N=1         END           
@ioanaif ioanaif added the bug The problem described is something that must be fixed label Aug 10, 2023
@ioanaif ioanaif self-assigned this Aug 10, 2023
@ioanaif
Copy link
Collaborator Author

ioanaif commented Jan 25, 2024

I looked into this error and attempted to fix it. I didn’t find the fix, but I did isolate where the issue is coming from. Thus, I will write here my findings. 




The problem is in writable.py:

for model in (
uproot.models.TLeaf.Model_TLeafB_v1,
uproot.models.TLeaf.Model_TLeafS_v1,
uproot.models.TLeaf.Model_TLeafI_v1,
uproot.models.TLeaf.Model_TLeafL_v1,
uproot.models.TLeaf.Model_TLeafF_v1,
uproot.models.TLeaf.Model_TLeafD_v1,
uproot.models.TLeaf.Model_TLeafC_v1,
uproot.models.TLeaf.Model_TLeafO_v1,
uproot.models.TBranch.Model_TBranch_v13,
uproot.models.TTree.Model_TTree_v20,
):

If we only have L1333, i.e. uproot.models.TTree.Model_TTree_v20 in the list of models, then the Map() issue disappears.

Thus, the issue comes from some of the streamers in TLeaf and TBranch. In each TLeaf type the issue goes away if we comment out this part:

_rawstreamer_TLeaf_v2,
(
None,
b"@\x00\x02\x14\xff\xff\xff\xffTStreamerInfo\x00@\x00\x01\xfe\x00\t@\x00\x00\x14\x00\x01\x00\x01\x00\x00\x00\x00\x03\x01\x00\x00\x06TLeafB\x00\x0f\x1eK^\x00\x00\x00\x01@\x00\x01\xd8\xff\xff\xff\xffTObjArray\x00@\x00\x01\xc6\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00@\x00\x00\x89\xff\xff\xff\xffTStreamerBase\x00@\x00\x00s\x00\x03@\x00\x00i\x00\x04@\x00\x00:\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x05TLeaf'Leaf: description of a Branch data type\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00m\x1e\x81R\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04BASE\x00\x00\x00\x02@\x00\x00\x8e\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00s\x00\x02@\x00\x00m\x00\x04@\x00\x00>\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x08fMinimum(Minimum value if leaf range is specified\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04char@\x00\x00\x8e\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00s\x00\x02@\x00\x00m\x00\x04@\x00\x00>\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x08fMaximum(Maximum value if leaf range is specified\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04char\x00",
"TLeafB",
1,
),
)

Where _rawstreamer_TLeaf_v2 is defined here:

_rawstreamer_TLeaf_v2 = (
None,
b"@\x00\x05\x04\xff\xff\xff\xffTStreamerInfo\x00@\x00\x04\xee\x00\t@\x00\x00\x13\x00\x01\x00\x01\x00\x00\x00\x00\x03\x01\x00\x00\x05TLeaf\x00m\x1e\x81R\x00\x00\x00\x02@\x00\x04\xc9\xff\xff\xff\xffTObjArray\x00@\x00\x04\xb7\x00\x03\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00\x00\x00\x00@\x00\x00\x8d\xff\xff\xff\xffTStreamerBase\x00@\x00\x00w\x00\x03@\x00\x00m\x00\x04@\x00\x00>\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x06TNamed*The basis for a named object (name, title)\x00\x00\x00C\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xdf\xb7J<\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04BASE\x00\x00\x00\x01@\x00\x00\x94\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00y\x00\x02@\x00\x00s\x00\x04@\x00\x00E\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x04fLen3Number of fixed length elements in the leaf's data.\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03int@\x00\x00\x87\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00l\x00\x02@\x00\x00f\x00\x04@\x00\x008\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x08fLenType\"Number of bytes for this data type\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03int@\x00\x00\x89\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00n\x00\x02@\x00\x00h\x00\x04@\x00\x00:\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x07fOffset%Offset in ClonesArray object (if one)\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03int@\x00\x01\x14\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00\xf9\x00\x02@\x00\x00\xf3\x00\x04@\x00\x00\xc4\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x08fIsRange\xae(=kTRUE if leaf has a range, kFALSE otherwise). This is equivalent to being a 'leafcount'. For a TLeafElement the range information is actually store in the TBranchElement.\x00\x00\x00\x12\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04bool@\x00\x00\x8f\xff\xff\xff\xffTStreamerBasicType\x00@\x00\x00t\x00\x02@\x00\x00n\x00\x04@\x00\x00?\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\x0bfIsUnsigned&(=kTRUE if unsigned, kFALSE otherwise)\x00\x00\x00\x12\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04bool@\x00\x00\xb2\xff\xff\xff\xffTStreamerObjectPointer\x00@\x00\x00\x93\x00\x02@\x00\x00\x8d\x00\x04@\x00\x00\\\x00\x01\x00\x01\x00\x00\x00\x00\x03\x00\x00\x00\nfLeafCountDPointer to Leaf count if variable length (we do not own the counter)\x00\x00\x00@\x00\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06TLeaf*\x00",
"TLeaf",
2,
)

As for TBranch, the issue is fixed when commenting out lines 562 to 568:

class_rawstreamers = (
uproot.models.TH._rawstreamer_TCollection_v3,
uproot.models.TH._rawstreamer_TSeqCollection_v0,
uproot.models.TObjArray._rawstreamer_TObjArray_v3,
_rawstreamer_ROOT_3a3a_TIOFeatures_v1,
uproot.models.TH._rawstreamer_TAttFill_v2,
uproot.models.TH._rawstreamer_TString_v2,
uproot.models.TH._rawstreamer_TObject_v1,
uproot.models.TH._rawstreamer_TNamed_v1,
_rawstreamer_TBranch_v13,
)

@jpivarski jpivarski added this to Before in Finalization Jan 30, 2024
@jpivarski jpivarski removed this from Before in Finalization Jan 30, 2024
@jpivarski jpivarski added the big-project This will take some time, perhaps as a Fellowship or GSoC project label Jan 30, 2024
@ioanaif ioanaif removed their assignment Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
big-project This will take some time, perhaps as a Fellowship or GSoC project bug The problem described is something that must be fixed
Projects
None yet
Development

No branches or pull requests

2 participants