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

How can I "dump" / get the content of objects of "experiment specific" / "custom" classes (from a TTree) #949

Open
jpivarski opened this issue Aug 24, 2023 Discussed in #948 · 0 comments
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged

Comments

@jpivarski
Copy link
Member

Discussed in #948

Originally posted by JacekHoleczek August 24, 2023
I need to "move" (to here) my original StackOverflow topic: How can I "dump" / get the content of objects of "experiment specific" / "custom" classes (from a TTree)
Apparently, they do not allow any discussions there (they simply deleted my follow-up).

Many thanks for your reply on the StackOverflow.

The standard ROOT provides the TFile::MakeProject method, which can generate "source code" for classes present in the file (only "data members" are "recovered" from the "streamer info", of course).
I understand uproot does not provide such functionality (i.e., I cannot get "automatically generated" Python classes).

To start, I'd now like to play with a small "header" tree with just a single branch:

POTInfo_v2                      | Header                               | AsObjects(Model_Header)

The root_directory.file.show_streamers('Header') returns:

Header (v1)
    _POT_CountedPerFile: double (TStreamerBasicType)
    _POT_NoCut: double (TStreamerBasicType)
    _POT_BadBeam: double (TStreamerBasicType)
    _POT_BadND280: double (TStreamerBasicType)
    _POT_GoodBeamGoodND280: double (TStreamerBasicType)
    _POT_0KA: double (TStreamerBasicType)
    _POT_200KA: double (TStreamerBasicType)
    _POT_250KA: double (TStreamerBasicType)
    _POT_m250KA: double (TStreamerBasicType)
    _POT_OtherKA: double (TStreamerBasicType)
    _POTInfo: double (TStreamerBasicType)
    _Spill_NoCut: int (TStreamerBasicType)
    _Spill_BadBeam: int (TStreamerBasicType)
    _Spill_BadND280: int (TStreamerBasicType)
    _Spill_GoodBeamGoodND280: int (TStreamerBasicType)
    _SpillInfo: int (TStreamerBasicType)
    _IsMC: bool (TStreamerBasicType)
    _SoftwareVersion: string (TStreamerSTLstring)
    _pot_def_counter: int (TStreamerBasicType)
    _spill_def_counter: int (TStreamerBasicType)

So, there are just some double, some int, one bool, and one std::string ordinary variables (no arrays at all).

When I try to retrieve just the first entry:

root_directory['header']['POTInfo_v2'].array(entry_stop=1)

I get (note: it now thinks _POTInfo and _SpillInfo are arrays):

(...)
DeserializationError: while reading

    Header version 6792 as uproot.dynamic.Model_Header_v1 (71320410 bytes)
        _POT_CountedPerFile: 2.6612249000050942e-110
        _POT_NoCut: 0.0
        _POT_BadBeam: 0.0
        _POT_BadND280: 0.0
        _POT_GoodBeamGoodND280: 0.0
        _POT_0KA: 0.0
        _POT_200KA: 0.0
        _POT_250KA: 0.0
        _POT_m250KA: 0.0
        _POT_OtherKA: 3.7076069415964e-310
        _POTInfo: array([7.67844769e-239, 0.00000000e+000, 0.00000000e+000, 3.70760694e-310,
       7.67844769e-239, 0.00000000e+000, 0.00000000e+000, 0.00000000e+000,
       0.00000000e+000, 0.00000000e+000, 0.00000000e+000, 0.00000000e+000,
       0.00000000e+000], dtype='>f8')
        _Spill_NoCut: 0
        _Spill_BadBeam: 0
        _Spill_BadND280: 96
        _Spill_GoodBeamGoodND280: -1051394048
        _SpillInfo: array([          0,           0,          96, -1051394048,         320,
              2304], dtype='>i4')
        _IsMC: True
Members for Header: (_POT_CountedPerFile), (_POT_NoCut), (_POT_BadBeam), (_POT_BadND280), (_POT_GoodBeamGoodND280), (_POT_0KA), (_POT_200KA), (_POT_250KA), (_POT_m250KA), (_POT_OtherKA), (_POTInfo), (_Spill_NoCut), (_Spill_BadBeam), (_Spill_BadND280), (_Spill_GoodBeamGoodND280), (_SpillInfo), (_IsMC), _SoftwareVersion, _pot_def_counter, _spill_def_counter

attempting to get bytes 234:283
outside expected range 0:246 for this Chunk
in file NumuCCMultiPi_MCrun4.root
in object /header;1

It seems I'm missing something again (adding "library='ak'", "library='np'", or "library='pd'" does not help).

There's nothing exotic about this class definition, so Uproot should be able to read it. I've labeled it "bug (unverified)" as a reminder to try to reproduce it and fix whatever the problem is.

@jpivarski jpivarski added the bug (unverified) The problem described would be a bug, but needs to be triaged label Aug 24, 2023
@jpivarski jpivarski added this to Before in Finalization Jan 30, 2024
@jpivarski jpivarski moved this from Before to Mar 14‒21 in Finalization Jan 30, 2024
@ioanaif ioanaif moved this from Mar 14‒21 to Mar 21‒28 in Finalization Mar 21, 2024
@jpivarski jpivarski moved this from Stretch goals to Dask and high-level behavior in Finalization Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unverified) The problem described would be a bug, but needs to be triaged
Projects
Finalization
Dask and high-level behavior
Development

No branches or pull requests

1 participant