Skip to content

Commit 4422bc1

Browse files
Add support for EDM4hep inputs (#80)
* Jet class constructors from Real The jet class constructors (EEjet, Pseudojet) were typed to Float64, which is too narrow. Now retype to Real (which in particular allows passing in Float32s). * Add EDM4hep extensions Accessors px, py, pz, energy for EDM4hep reconstructed particles Allow direct construction of internal jet structs from a reco particle This extension only activated if EDM4hep is loaded in the environment * Add example of reconstruction from EDM4hep Simple example of how to run jet reconstruction from an EDM4hep input file * Change input particle type to 1D AbstractArray There is no need that the input particles be explicitly a vector, in fact from EDM4hep files one gets a StructArrays.StructVector, which is a subtype of AbstractArray. This allows jet reconstruction directly from the ReconstructedParticles object of EDM4hep, without needing to copy the data into another container. * Add a REPL friendly EDM4hep testing script * Update documentation for EDM4hep * Allow 0.20 versions of Makie Overcomes compatibility issues with EDM4hep via FHist * Rework documentation Remove Vitepress formatting from documentation as it is impossible to preview correctly locally (even with suggested work arounds). Add documentation to the EDM4hep extension file. * Update compatibility requirements
1 parent 63d59d3 commit 4422bc1

22 files changed

+271
-86
lines changed

.github/workflows/Documentation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- uses: julia-actions/setup-julia@v2
2020
with:
2121
version: '1'
22-
- uses: julia-actions/cache@v1
22+
- uses: julia-actions/cache@v2
2323
- name: Install dependencies
2424
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
2525
- name: Build and deploy

Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,22 @@ StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
1717

1818
[weakdeps]
1919
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
20+
EDM4hep = "eb32b910-dde9-4347-8fce-cd6be3498f0c"
2021

2122
[extensions]
2223
JetVisualisation = "Makie"
24+
EDM4hepJets = "EDM4hep"
2325

2426
[compat]
2527
Accessors = "0.1.36"
2628
CodecZlib = "0.7.4"
29+
EDM4hep = "0.4.0"
2730
EnumX = "1.0.4"
2831
JSON = "0.21.4"
2932
LoopVectorization = "0.12.170"
3033
LorentzVectorHEP = "0.1.6"
3134
LorentzVectors = "0.4.3"
32-
Makie = "0.21"
35+
Makie = "0.20, 0.21"
3336
MuladdMacro = "0.2.4"
3437
StructArrays = "0.6.18"
3538
julia = "1.9"

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ algorithm and generalised $`k_\text{T}`$ for $`e^+e^-`$.
2222
The simplest interface is to call:
2323

2424
```julia
25-
cs = jet_reconstruct(particles::Vector{T}; algorithm = JetAlgorithm.AntiKt, R = 1.0, [p = -1,] [recombine = +,] [strategy = RecoStrategy.Best])
25+
cs = jet_reconstruct(particles::AbstractArray{T, 1}; algorithm = JetAlgorithm.AntiKt, R = 1.0, [p = -1,] [recombine = +,] [strategy = RecoStrategy.Best])
2626
```
2727

28-
- `particles` - a vector of input particles for the clustering
28+
- `particles` - a one dimensional array (vector) of input particles for the clustering
2929
- Any type that supplies the methods `pt2()`, `phi()`, `rapidity()`, `px()`, `py()`, `pz()`, `energy()` can be used
3030
- These methods have to be defined in the namespace of this package, i.e., `JetReconstruction.pt2(::T)`
31-
- The `PseudoJet` type from this package, or a 4-vector from `LorentzVectorHEP` are suitable (and have the appropriate definitions)
31+
- The `PseudoJet` or `EEjet` types from this package, a 4-vector from `LorentzVectorHEP`, or a `ReconstructedParticle` from [EDM4hep](https://github.com/peremato/EDM4hep.jl) are suitable (and have the appropriate definitions)
3232
- `algorithm` is the name of the jet algorithm to be used (from the `JetAlgorithm` enum)
3333
- `JetAlgorithm.AntiKt` anti-$`{k}_\text{T}`$ clustering (default)
3434
- `JetAlgorithm.CA` Cambridge/Aachen clustering
@@ -59,7 +59,7 @@ To obtain the final inclusive jets, use the `inclusive_jets` method:
5959
final_jets = inclusive_jets(cs::ClusterSequence; ptmin=0.0)
6060
```
6161

62-
Only jets passing the cut $p_T > p_{Tmin}$ will be returned. The result is returned as a `Vector{LorentzVectorHEP}`.
62+
Only jets passing the cut $p_T > p_{Tmin}$ will be returned. The result is returned as a `Vector{LorentzVectorHEP}`, but different return types can be specified (e.g., `T = EEjet`).
6363

6464
#### Sorting
6565

docs/Project.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[deps]
22
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
33
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
4-
DocumenterVitepress = "4710194d-e776-4893-9690-8d956a29c365"
4+
EDM4hep = "eb32b910-dde9-4347-8fce-cd6be3498f0c"
55
JetReconstruction = "44e8cb2c-dfab-4825-9c70-d4808a591196"
6+
LiveServer = "16fef848-5104-11e9-1b77-fb7a48bbb589"
67
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
78

89
[compat]
910
Documenter = "1.4"
11+
EDM4hep = "0.4"
12+
Makie = "0.20, 0.21"

docs/make.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
using Documenter
2-
using DocumenterVitepress
32
using CairoMakie
3+
using EDM4hep
44
using JetReconstruction
55

66
push!(LOAD_PATH, "../ext/")
77

88
include(joinpath(@__DIR__, "..", "ext", "JetVisualisation.jl"))
9+
include(joinpath(@__DIR__, "..", "ext", "EDM4hepJets.jl"))
910

1011
makedocs(sitename = "JetReconstruction.jl",
11-
format = MarkdownVitepress(repo = "github.com/JuliaHEP/JetReconstruction.jl"),
12+
clean = false,
1213
pages = [
1314
"Home" => "index.md",
1415
"Examples" => "examples.md",
16+
"EDM4hep" => "EDM4hep.md",
17+
"Visualisation" => "visualisation.md",
1518
"Reference" => Any["Public API" => "lib/public.md",
16-
"Internal API" => "lib/internal.md",
17-
"Visualisation API" => "lib/visualisation.md"]
19+
"Internal API" => "lib/internal.md"]
1820
])
1921

2022
deploydocs(repo = "github.com/JuliaHEP/JetReconstruction.jl.git",

docs/src/EDM4hep.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# EDM4hep
2+
3+
Extension functionality to read EDM4hep ReconstructedParticles
4+
5+
## Index
6+
7+
```@index
8+
Pages = ["EDM4hep.md"]
9+
```
10+
11+
## EDM4hep Interfaces
12+
13+
```@autodocs
14+
Modules = [EDM4hepJets]
15+
Order = [:function]
16+
```

docs/src/examples.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ usage.
66
*Note:* because of extra dependencies in these scripts, one must use the
77
`Project.toml` file in the `examples` directory.
88

9-
## `jetreco.jl`
9+
## Standalone Examples
10+
11+
### `jetreco.jl`
1012

1113
This is a basic jet reconstruction example that shows how to call the package to
1214
perform a jet reconstruction, with different algorithms and (optionally)
@@ -23,7 +25,7 @@ julia --project=examples examples/jetreco.jl --maxevents=10 --strategy=N2Plain -
2325

2426
There are options to explicitly set the algorithm (use `--help` to see these).
2527

26-
## `instrumented-jetreco.jl`
28+
### `instrumented-jetreco.jl`
2729

2830
This is a more sophisticated example that allows performance measurements to be
2931
made of the reconstruction, as well as profiling (flamegraphs and memory
@@ -34,20 +36,26 @@ performance for the AntiKt algorithm using the tiled strategy:
3436
julia --project instrumented-jetreco.jl -S N2Tiled -A AntiKt --nsamples 100 ../test/data/events.hepmc3
3537
```
3638

37-
## `visualise-jets.jl`
39+
### `visualise-jets.jl`
3840

3941
This script will produce a PNG/PDF showing the results of a jet reconstruction.
4042
This is a 3D plot where all the initial energy deposits are visualised, with
4143
colours that indicate in which final cluster the deposit ended up in.
4244

43-
## `visualise-jets.ipynb`
45+
### `visualise-jets.ipynb`
4446

4547
Similar to `visualise-jets.jl` this notebook will produce a visualisation of jet
4648
reconstruction in the browser. This is a 3D plot where all the initial energy
4749
deposits are visualised, with colours that indicate in which final cluster the
4850
deposit ended up in.
4951

50-
## `animate-reconstruction.jl`
52+
### `animate-reconstruction.jl`
5153

5254
Performs jet reconstruction and then produces and animation of the process,
5355
showing how the jets merge from their different constituents.
56+
57+
## EDM4hep
58+
59+
The `examples/EDM4hep` folder contains examples of using EDM4hep reconstructed
60+
particles as input to jet reconstruction. See the specific `README.md` file in
61+
that directory.

docs/src/index.md

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
```@raw html
2-
---
3-
layout: home
4-
5-
hero:
6-
name: "JetReconstruction.jl"
7-
tagline: "Jet reconstruction (reclustering) with Julia"
8-
image:
9-
src: /logo.png
10-
alt: DocumenterVitepress
11-
actions:
12-
- theme: brand
13-
text: Examples
14-
link: /examples
15-
- theme: alt
16-
text: Public APIs
17-
link: /lib/public
18-
19-
---
20-
```
21-
221
# Jet Reconstruction
232

243
This package implements sequential Jet Reconstruction (clustering) algorithms,
25-
which are used in high-energy physics as part of event reconstruction for $pp$
26-
and $e^+e^-$ colliders.
4+
which are used in high-energy physics as part of event reconstruction for ``pp``
5+
and ``e^+e^-`` colliders.
276

287
## Algorithms
298

@@ -59,6 +38,31 @@ the `R` value is ignored.
5938
The object returned is a [`ClusterSequence`](@ref), which internally tracks all
6039
merge steps.
6140

41+
### Input Particle Types
42+
43+
For the `particles` input to the reconstruction any one dimensional
44+
`AbstractArray{T, 1}` can be used, where the type `T` has to implement methods
45+
to extract the 4-vector components, viz, the following are required:
46+
47+
- `JetReconstuction.px(particle::T)`
48+
- `JetReconstuction.py(particle::T)`
49+
- `JetReconstuction.pz(particle::T)`
50+
- `JetReconstuction.energy(particle::T)`
51+
52+
Currently built-in supported types are
53+
[`LorentzVectorHEP`](https://github.com/JuliaHEP/LorentzVectorHEP.jl), the
54+
`PseudoJet` and `EEjet`s from this package, and `ReconstructedParticles` from
55+
[EDM4hep](https://github.com/peremato/EDM4hep.jl).
56+
57+
If you require support for a different input collection type then ensure you
58+
define the `px()`, etc. methods *for your specific type* and *in the
59+
`JetReconstruction` package*. This use of what might be considered type piracy
60+
is blessed as long as you are en *end user* of the jet reconstruction package.
61+
62+
If your type is used in several places or by different users, please consider
63+
writing a package extension that will support your type, following the model for
64+
EDM4hep in `ext/EDM4hepJets.jl`.
65+
6266
### Algorithm Types
6367

6468
Each known algorithm is referenced using a `JetAlgorithm` scoped enum value.
@@ -80,8 +84,8 @@ given instead of the algorithm name. However, this should be considered
8084

8185
## Strategy
8286

83-
Three strategies are available for the different algorithms, which can be
84-
specified by passing the named argument `strategy=...`.
87+
For the ``pp`` algorithms three strategies are available for the different
88+
algorithms, which can be specified by passing the named argument `strategy=...`.
8589

8690
| Strategy Name | Notes | Interface |
8791
|---|---|---|
@@ -93,15 +97,8 @@ Generally one can use the `jet_reconstruct` interface, shown above, as the
9397
*Best* strategy safely as the overhead is extremely low. That interface supports
9498
a `strategy` option to switch to a different option.
9599

96-
Another option, if one wishes to use a specific strategy, is to call that
97-
strategy's interface directly, e.g.,
98-
99-
```julia
100-
# For N2Plain strategy called directly
101-
plain_jet_reconstruct(particles::Vector{T}; algorithm = JetAlgorithm.AntiKt, R = 1.0, recombine = +)
102-
```
103-
104-
(There is no `strategy` option in these interfaces.)
100+
For ``e^+e^-`` algorithms particle densities are low, so the only implementation
101+
is of the same type as `N2Plain`.
105102

106103
## Inclusive and Exclusive Selections
107104

docs/src/lib/internal.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CollapsedDocStrings = true
1414
Pages = ["internal.md"]
1515
```
1616

17-
## Public Interface
17+
## Internal Methods and Types
1818

1919
```@autodocs
2020
Modules = [JetReconstruction]
File renamed without changes.

0 commit comments

Comments
 (0)