Skip to content

Commit

Permalink
Use better name for emun
Browse files Browse the repository at this point in the history
Use the explicit name "Strategy" for the emun type
instead of the generic "T" (this works better with the --help option)
  • Loading branch information
graeme-a-stewart committed Apr 3, 2024
1 parent f52c55c commit c9080f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions examples/jetreco.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function jet_process(
ptmin::Float64 = 5.0,
distance::Float64 = 0.4,
power::Integer = -1,
strategy::JetRecoStrategy.T,
strategy::JetRecoStrategy.Strategy,
nsamples::Integer = 1,
gcoff::Bool = false,
profile::Bool = false,
Expand Down Expand Up @@ -199,7 +199,7 @@ parse_command_line(args) = begin

"--strategy"
help = """Strategy for the algorithm, valid values: $(join(JetReconstruction.AllJetRecoStrategies, ", "))"""
arg_type = JetRecoStrategy.T
arg_type = JetRecoStrategy.Strategy
default = JetRecoStrategy.Best

"--nsamples", "-m"
Expand Down Expand Up @@ -238,8 +238,8 @@ parse_command_line(args) = begin
end


function ArgParse.parse_item(::Type{JetRecoStrategy.T}, x::AbstractString)
s = tryparse(JetRecoStrategy.T, x)
function ArgParse.parse_item(::Type{JetRecoStrategy.Strategy}, x::AbstractString)
s = tryparse(JetRecoStrategy.Strategy, x)
if s === nothing
throw(ErrorException("Invalid value for strategy: $(x)"))
end
Expand Down
4 changes: 2 additions & 2 deletions src/JetRecoStrategies.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EnumX

# Valid strategy enum (this is a scoped enum)
@enumx JetRecoStrategy Best N2Plain N2Tiled
@enumx T=Strategy JetRecoStrategy Best N2Plain N2Tiled

# Map from string to an enum value (used for CLI parsing)
Base.tryparse(E::Type{<:Enum}, str::String) =
Expand All @@ -10,5 +10,5 @@ Base.tryparse(E::Type{<:Enum}, str::String) =
p !== nothing ? insts[p] : nothing
end

const AllJetRecoStrategies = [ String(Symbol(x)) for x in instances(JetRecoStrategy.T) ]
const AllJetRecoStrategies = [ String(Symbol(x)) for x in instances(JetRecoStrategy.Strategy) ]

1 change: 0 additions & 1 deletion src/JetReconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Jet reconstruction (reclustering) in Julia.
module JetReconstruction

using LorentzVectorHEP
using MLStyle

# Import from LorentzVectorHEP methods for those 4-vector types
pt2(p::LorentzVector) = LorentzVectorHEP.pt2(p)
Expand Down

0 comments on commit c9080f6

Please sign in to comment.