Skip to content

Commit e4276c1

Browse files
authored
TLeafG Support (#379)
* Add TLeafG support * Add TLeafG test * Improve error reporting
1 parent e766112 commit e4276c1

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

src/bootstrap.jl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,41 @@ end
349349

350350
primitivetype(l::TLeafL) = l.fIsUnsigned ? UInt64 : Int64
351351

352+
# FIXME this should be generated and inherited from TLeaf
353+
@with_kw struct TLeafG
354+
# from TNamed
355+
fName
356+
fTitle
357+
358+
# from TLeaf
359+
fLen
360+
fLenType
361+
fOffset
362+
fIsRange
363+
fIsUnsigned
364+
fLeafCount
365+
366+
# own fields
367+
fMinimum
368+
fMaximum
369+
end
370+
371+
function parsefields!(io, fields, T::Type{TLeafG})
372+
preamble = Preamble(io, T)
373+
parsefields!(io, fields, TLeaf)
374+
fields[:fMinimum] = readtype(io, Int64)
375+
fields[:fMaximum] = readtype(io, Int64)
376+
endcheck(io, preamble)
377+
end
378+
379+
function unpack(io, tkey::TKey, refs::Dict{Int32, Any}, T::Type{TLeafG})
380+
@initparse
381+
parsefields!(io, fields, T)
382+
T(;fields...)
383+
end
384+
385+
primitivetype(l::TLeafG) = Int64
386+
352387
# FIXME this should be generated and inherited from TLeaf
353388
@with_kw struct TLeafO
354389
# from TNamed

src/streamers.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ function readobjany!(io, tkey::TKey, refs)
240240
try
241241
streamer = getfield(@__MODULE__, Symbol(cname))
242242
catch UndefVarError
243-
@error "Could not get streamer for '$(cname)'"
243+
@warn "Could not get streamer for '$(cname)' (TKey: $(tkey))"
244+
return missing
244245
end
245246
end
246247

test/bootstrapping.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,11 @@ end
186186
@test (UnROOT.basketarray_iter(t.b1) .|> length) == [1228, 1228, 44]
187187
@test length(UnROOT.basketarray(t.b1, 1)) == 1228
188188
end
189+
190+
@testset "primitives" begin
191+
f = UnROOT.samplefile("TLeafG.root")
192+
toa = UnROOT.array(f, "TOA/TOA_NS")
193+
@test 55548 == length(toa)
194+
@test 1675274976213420032 == toa[1]
195+
@test 1675275224652052992 == toa[end]
196+
end

test/samples/TLeafG.root

492 KB
Binary file not shown.

0 commit comments

Comments
 (0)