-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathissues.jl
More file actions
131 lines (109 loc) · 5.07 KB
/
Copy pathissues.jl
File metadata and controls
131 lines (109 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using Test
using UnROOT
SAMPLES_DIR = joinpath(@__DIR__, "samples")
@testset "Issues" begin
rootfile = UnROOT.samplefile("issue7.root")
@test 2 == length(keys(rootfile))
@test [1.0, 2.0, 3.0] == UnROOT.array(rootfile, "TreeD/nums")
@test [1.0, 2.0, 3.0] == UnROOT.array(rootfile, "TreeF/nums")
close(rootfile)
# issue #55 and #156
rootfile = UnROOT.samplefile("cms_ntuple_wjet.root")
pts1 = UnROOT.array(rootfile, "variable/met_p4/fCoordinates/fCoordinates.fPt"; raw=false)
pts2 = LazyTree(rootfile, "variable", [r"met_p4/fCoordinates/.*", "mll"])[!, Symbol("met_p4_fPt")]
pts3 = LazyBranch(rootfile, "variable/good_jets_p4/good_jets_p4.fCoordinates.fPt")
@test 24 == length(pts1)
@test Float32[69.96958, 25.149912, 131.66693, 150.56802] == pts1[1:4]
@test pts1 == pts2
@test pts3[1:2] == [[454.0, 217.5, 89.5, 30.640625], [184.375, 33.28125, 32.28125, 28.46875]]
close(rootfile)
# issue 61
rootfile = UnROOT.samplefile("issue61.root")
@test LazyBranch(rootfile, "Events/Jet_pt")[:] == Vector{Float32}[[], [27.324587, 24.889547, 20.853024], [], [20.33066], [], []]
close(rootfile)
# issue 78
rootfile = UnROOT.samplefile("issue61.root")
arr = LazyTree(rootfile,"Events").Jet_pt;
_ = length.(arr);
@test length.(arr.buffer) == length.(arr.buffer_range)
close(rootfile)
# issue 108
# unsigned short -> Int16, ulong64 -> UInt64
# file minified with `rooteventselector --recreate -l 2 "trackntuple.root:trackingNtuple/tree" issue108_small.root`
rootfile = UnROOT.samplefile("issue108_small.root")
@test LazyBranch(rootfile, "tree/trk_algoMask")[2] == [0x0000000000004000, 0x0000000000004000, 0x0000000000004000, 0x0000000000004000]
@test LazyBranch(rootfile, "tree/pix_ladder")[3][1:5] == UInt16[0x0001, 0x0001, 0x0001, 0x0001, 0x0003]
close(rootfile)
# issue 116
rootfile = UnROOT.samplefile("issue116.root")
@test length(rootfile["fTree"].fBranches.elements) == 112
close(rootfile)
# issue 246
arr = LazyTree(joinpath(SAMPLES_DIR, "issue246.root"), "tree_NOMINAL").v_mcGenWgt
@test all(reduce(vcat, arr) .== 1.0)
# issue 323
f = UnROOT.samplefile("issue323.root")
t = LazyTree(f, "sim", [r"ghost/ghost\.(.*)" => s"\1"])
@test 1200 == length(t)
@test t[1].time[2] ≈ 36.396744f0
@test t[end].xpos[end] ≈ 788.35144f0
# issue 377
f = UnROOT.samplefile("issue377.root")
arr = UnROOT.array(f, "podio_metadata/events___CollectionTypeInfo/events___CollectionTypeInfo.dataType")
t = LazyTree(f, "podio_metadata", ["events___CollectionTypeInfo"])
@test 1 == length(t.events___CollectionTypeInfo_dataType)
@test 26 == length(t.events___CollectionTypeInfo_dataType[1])
@test "edm4hep::CaloHitContributionCollection" == t.events___CollectionTypeInfo_dataType[1][1]
@test "podio::LinkCollection<edm4hep::Vertex,edm4hep::ReconstructedParticle>" == t.events___CollectionTypeInfo_dataType[1][end]
@test arr == t.events___CollectionTypeInfo_dataType
end
function _test_clean_GC(fname)
for i in 1:5
f = UnROOT.samplefile(fname)
t = LazyTree(f, "t1")
f = t = nothing
end
end
@testset "Clean GC issue #260" begin
fname = "tree_with_large_array_lzma.root"
_test_clean_GC(fname)
GC.gc()
GC.gc()
sleep(2)
GC.gc()
sleep(2)
pid = getpid()
@static if Sys.islinux()
@test isempty(filter(contains(fname), readlines("/proc/$pid/smaps")))
elseif Sys.isapple()
@test isempty(filter(contains(fname), readlines(`vmmap $(getpid())`)))
elseif Sys.iswindows()
# TODO: add test for windows
end
end
@testset "PR 266" begin
f = UnROOT.samplefile("edm4hep_266.root")
tree = LazyTree(f, "events", r"PandoraPFOs/PandoraPFOs.[(a-z)(A-Z))]")
@test length(tree.PandoraPFOs_energy[1]) == 79
@test length(tree.var"PandoraPFOs_covMatrix[10]"[1]) == 790
end
@testset "PR 342 TLeafC" begin
df = LazyTree(UnROOT.samplefile("TLeafC_pr342.root"), "G4Sim")
@test all(df.Process[1:10] .== ["Radioactivation", "msc", "eIoni", "Transportation", "ionIoni", "Radioactivation", "msc", "eIoni", "ionIoni", "Radioactivation"])
end
# Issue: EOF when trying to open files with recovered/embedded baskets
# Files with embedded baskets (fNbytes <= fKeylen) from premature closure
# are not yet fully supported. This is a known limitation.
# See: https://github.com/JuliaHEP/UnROOT.jl/issues/XXX
@testset "Embedded baskets limitation" begin
# This test documents the known limitation with files containing embedded baskets
# Such files occur when ROOT files are closed prematurely (e.g., process crash)
# and ROOT's recovery mechanism stores uncompressed basket data inline
# TODO: Add test file with embedded baskets when support is implemented
# For now, this serves as documentation that such files are not yet supported
# Example of what should eventually work:
# f = UnROOT.samplefile("file_with_embedded_baskets.root")
# tree = f["tree_name"]
# @test tree.fEntries > 0
@test_skip false # Placeholder - remove when support is added
end