Skip to content

Commit d45440a

Browse files
Add cluster_hist_index argument for EDM4hep reconstructed particles (#229)
* Add cluster_hist_index argument It is necessary for construction of EEJets from ::ReconstructedParticle that the cluster_hist_index is used. * Add basic EDM4hep tests Use a EDM4hep ReconstructedParticle (made "by hand") to check that our jets can be made from this type of input.
1 parent 1b82703 commit d45440a

File tree

4 files changed

+37
-5
lines changed

4 files changed

+37
-5
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ julia = "1.10"
4848
[extras]
4949
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
5050
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
51+
EDM4hep = "eb32b910-dde9-4347-8fce-cd6be3498f0c"
5152
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
5253
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
5354
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5455

5556
[targets]
56-
test = ["Aqua", "ArgParse", "Test", "JSON", "Random"]
57+
test = ["Aqua", "ArgParse", "Test", "JSON", "Random", "EDM4hep"]

ext/EDM4hepJets.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,23 @@ JetReconstruction.energy(recoparticle::ReconstructedParticle) = recoparticle.ene
3838
3939
Construct an EEJet from a ReconstructedParticle.
4040
"""
41-
function JetReconstruction.EEJet(recoparticle::ReconstructedParticle)
41+
function JetReconstruction.EEJet(recoparticle::ReconstructedParticle;
42+
cluster_hist_index::Int = 0)
4243
EEJet(JetReconstruction.px(recoparticle), JetReconstruction.py(recoparticle),
43-
JetReconstruction.pz(recoparticle), JetReconstruction.energy(recoparticle))
44+
JetReconstruction.pz(recoparticle), JetReconstruction.energy(recoparticle);
45+
cluster_hist_index)
4446
end
4547

4648
"""
4749
JetReconstruction.PseudoJet(recoparticle::ReconstructedParticle)
4850
4951
Construct an PseudoJet from a ReconstructedParticle.
5052
"""
51-
function JetReconstruction.PseudoJet(recoparticle::ReconstructedParticle)
53+
function JetReconstruction.PseudoJet(recoparticle::ReconstructedParticle;
54+
cluster_hist_index::Int = 0)
5255
PseudoJet(JetReconstruction.px(recoparticle), JetReconstruction.py(recoparticle),
53-
JetReconstruction.pz(recoparticle), JetReconstruction.energy(recoparticle))
56+
JetReconstruction.pz(recoparticle), JetReconstruction.energy(recoparticle);
57+
cluster_hist_index)
5458
end
5559

5660
end

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function main()
99
# Basic tests for the Jet types
1010
include("test-jet-types.jl")
1111
include("test-jet-constructors.jl")
12+
include("test-edm4hep.jl")
1213

1314
# Jet utilities tests
1415
include("test-jet-utils.jl")

test/test-edm4hep.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Test that we can work with EDM4hep particles
2+
3+
include("common.jl")
4+
5+
using EDM4hep
6+
7+
dummyRecoParticle = ReconstructedParticle(energy = 4.0f0,
8+
momentum = Vector3f(1.0f0, 2.0f0, 3.0f0))
9+
10+
@testset "Construction of jets from EDM4hep particles" begin
11+
eej = EEJet(dummyRecoParticle)
12+
pj = PseudoJet(dummyRecoParticle)
13+
@test typeof(EEJet(dummyRecoParticle)) === EEJet
14+
@test typeof(EEJet(dummyRecoParticle; cluster_hist_index = 99)) === EEJet
15+
@test JetReconstruction.energy(eej) == dummyRecoParticle.energy
16+
@test JetReconstruction.px(eej) == dummyRecoParticle.momentum.x
17+
@test JetReconstruction.py(eej) == dummyRecoParticle.momentum.y
18+
@test JetReconstruction.pz(eej) == dummyRecoParticle.momentum.z
19+
20+
@test typeof(PseudoJet(dummyRecoParticle)) === PseudoJet
21+
@test typeof(PseudoJet(dummyRecoParticle; cluster_hist_index = 99)) === PseudoJet
22+
@test JetReconstruction.energy(pj) == dummyRecoParticle.energy
23+
@test JetReconstruction.px(pj) == dummyRecoParticle.momentum.x
24+
@test JetReconstruction.py(pj) == dummyRecoParticle.momentum.y
25+
@test JetReconstruction.pz(pj) == dummyRecoParticle.momentum.z
26+
end

0 commit comments

Comments
 (0)