Skip to content

Commit b0464df

Browse files
authored
Merge branch 'main' into exorcise_lv
2 parents fa51402 + eb1e269 commit b0464df

File tree

14 files changed

+145
-27
lines changed

14 files changed

+145
-27
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ LorentzVectors = "0.4.3"
3434
Makie = "0.20, 0.21"
3535
MuladdMacro = "0.2.4"
3636
SIMD = "3.6"
37-
StructArrays = "0.6.18"
37+
StructArrays = "0.6.18, 0.7"
3838
julia = "1.9"
3939

4040
[extras]

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Adding Documentation
44

5-
`Documenter.jl` is used to generate package documentation.
5+
`Documenter.jl` is used to generate package documentation.
66

77
The general guidelines are to have documentation split into meaningful sections,
88
none of which are too long. If a new functionality is added then create a new

docs/src/examples.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ showing how the jets merge from their different constituents.
6161
The `examples/EDM4hep` folder contains examples of using EDM4hep reconstructed
6262
particles as input to jet reconstruction. See the specific `README.md` file in
6363
that directory as well as [EDM4hep Inputs](@ref).
64+
65+
## Jet Constituents
66+
67+
The `examples/constituents` folder shows an example of the two mechanisms to
68+
retrieve jet constituents.

docs/src/index.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ sorted_jets = sort!(inclusive_jets(cs::ClusterSequence; ptmin=5.0),
8888
by=JetReconstruction.energy, rev=true)
8989
```
9090

91+
## Jet Constituents
92+
93+
There are two ways to retrieve jet constituents. The first way is just to
94+
retrieve the *indexes* of the constituent jets. These indexes refer to the
95+
original collection of particles passed in to the reconstruction.
96+
97+
- [`constituent_indexes`](@ref)
98+
99+
The alternative it to retrieve the actual jets from the reconstruction sequence.
100+
In this case the returned array contains references to the jet objects (of type
101+
`T`) used internally in the reconstruction.
102+
103+
- [`constituents`](@ref)
104+
105+
Note that in both these cases the cluster sequence object from the
106+
reconstruction is required (to avoid circular dependencies and improve memory
107+
management reconstructed jets do not contain a link back to their cluster
108+
sequence).
109+
91110
## References
92111

93112
Although it has been developed further since the CHEP2023 conference, the CHEP

examples/EDM4hep/SimpleRecoEDM4hep.jl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ using JetReconstruction
66
input_file = joinpath("/", "Users", "graemes", "code", "EDM4hepJets", "data",
77
"events_196755633.root")
88
reader = RootIO.Reader(input_file)
9-
events = RootIO.get(reader, "events")
9+
events = RootIO.get(reader, "events");
1010

11-
evt = events[1]
11+
evt = events[1];
1212

1313
recps = RootIO.get(reader, evt, "ReconstructedParticles")
1414

15+
# Reconstruct and print the jets
1516
cs = jet_reconstruct(recps; algorithm = JetAlgorithm.Durham)
16-
for jet in exclusive_jets(cs; njets = 2, T = EEjet)
17+
dijets = exclusive_jets(cs; njets = 2, T = EEjet)
18+
for jet in dijets
1719
println(jet)
1820
end
21+
22+
# Get constituents
23+
for (i, jet) in enumerate(dijets)
24+
my_constituent_indexes = constituent_indexes(jet, cs)
25+
println("Jet $i constituents: $my_constituent_indexes")
26+
end

examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ This directory has a number of example files that show how to used the
66
Because of extra dependencies in these scripts, one must use the `Project.toml`
77
file in this directory.
88

9+
Some features are demonstrated in their own subdirectories, in which case use
10+
the `Project.toml` file in that folder.
11+
912
## `jetreco.jl`
1013

1114
This is a basic jet reconstruction example that shows how to call the package to

examples/constituents/Project.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[deps]
2+
JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196"
3+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
4+
LorentzVectorHEP = "f612022c-142a-473f-8cfd-a09cf3793c6c"

examples/constituents/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Jet Consitituents
2+
3+
The `jetreco-constituents.jl` example shows how to retrieve jet constituents (by
4+
index and by reference to jet objects).
5+
6+
The `jetreco-constituents-nb.jl` is the same example, just in Pluto notebook
7+
form.

examples/jetreco-constituents-nb.jl renamed to examples/constituents/jetreco-constituents-nb.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.19.45
2+
# v0.20.3
33

44
using Markdown
55
using InteractiveUtils
@@ -8,7 +8,7 @@ using InteractiveUtils
88
using Pkg
99

1010
# ╔═╡ cd974dcf-ab96-4ff2-b76a-e18032343581
11-
Pkg.activate(".")
11+
Pkg.activate("..")
1212

1313
# ╔═╡ d25974b4-6531-408f-a0f7-ae7ae4a731d4
1414
using Revise
@@ -23,8 +23,6 @@ Perform a simple reconstruction example and show how to retrieve constituent jet
2323

2424
# ╔═╡ b16f99a0-31ec-4e8f-99c6-7a6fcb16cbee
2525
md"As this is running in development, use `Pkg` to activate the local development version of the package and use `Revise` to track code changes.
26-
27-
(Currently you must use the `jet-constituents` branch of `JetReconstruction`.)
2826
"
2927

3028
# ╔═╡ 79f24ec1-a63e-4e96-bd67-49661125be66
@@ -63,9 +61,18 @@ begin
6361
end
6462
end
6563

64+
# ╔═╡ c9ce9c76-82ef-42ff-bb2e-3b3b8085d8bc
65+
begin
66+
my_constituent_indexes = constituent_indexes(pj_jets[1], cluster_seq)
67+
println("\nConsitituent indexes for jet number $(event_no): $my_constituent_indexes")
68+
for i in my_constituent_indexes
69+
println(" Constituent jet $i: $(events[1][i])")
70+
end
71+
end
72+
6673
# ╔═╡ Cell order:
6774
# ╟─dff6a188-2cbe-11ef-32d0-73c4c05efad2
68-
# ╟─b16f99a0-31ec-4e8f-99c6-7a6fcb16cbee
75+
# ╠═b16f99a0-31ec-4e8f-99c6-7a6fcb16cbee
6976
# ╠═f3a6edec-9d40-4044-89bc-4ff1656f634f
7077
# ╠═cd974dcf-ab96-4ff2-b76a-e18032343581
7178
# ╠═d25974b4-6531-408f-a0f7-ae7ae4a731d4
@@ -80,3 +87,4 @@ end
8087
# ╟─0bd764f9-d427-43fc-8342-603b6759ec8f
8188
# ╠═46a64c6f-51d7-4083-a953-ecc76882f21e
8289
# ╠═300879ca-b53d-40b3-864a-1d46f2094123
90+
# ╠═c9ce9c76-82ef-42ff-bb2e-3b3b8085d8bc

examples/jetreco-constituents.jl renamed to examples/constituents/jetreco-constituents.jl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# # Jet Reconstruction Constituents Example
22
#
33
# Perform a simple reconstruction example and show how to retrieve constituent jets.
4-
#
5-
# N.B. currently you must use the `jet-constituents` branch of `JetReconstruction`.
64
using JetReconstruction
75
using LorentzVectorHEP
86
using Logging
@@ -30,8 +28,9 @@ for c in my_constituents
3028
println(" $c")
3129
end
3230

33-
# Now show how to convert to LorentzVectorCyl:
34-
println("\nConstituents of jet number $(event_no) as LorentzVectorCyl:")
35-
for c in my_constituents
36-
println(" $(LorentzVectorCyl(JetReconstruction.pt(c), JetReconstruction.rapidity(c), JetReconstruction.phi(c), JetReconstruction.mass(c)))")
31+
# Just retrieve the indexes of the constituents
32+
my_constituent_indexes = constituent_indexes(pj_jets[1], cluster_seq)
33+
println("\nConsitituent indexes for jet number $(event_no): $my_constituent_indexes")
34+
for i in my_constituent_indexes
35+
println(" Constituent jet $i: $(events[1][i])")
3736
end

0 commit comments

Comments
 (0)