Skip to content
Snippets Groups Projects
Commit a5f76dd8 authored by Christopher Dilks's avatar Christopher Dilks Committed by Wouter Deconinck
Browse files

ci: enable dRICH benchmarks and run 3 fixed-eta tests

parent a9393c70
Branches
No related tags found
1 merge request!306ci: enable dRICH benchmarks and run 3 fixed-eta tests
...@@ -112,6 +112,7 @@ include: ...@@ -112,6 +112,7 @@ include:
- local: 'benchmarks/imaging_ecal/config.yml' - local: 'benchmarks/imaging_ecal/config.yml'
- local: 'benchmarks/imaging_shower_ML/config.yml' - local: 'benchmarks/imaging_shower_ML/config.yml'
- local: 'benchmarks/far_forward/config.yml' - local: 'benchmarks/far_forward/config.yml'
- local: 'benchmarks/rich/config.yml'
final_report: final_report:
stage: finish stage: finish
......
rich_job_x: rich_compile:
stage: compile
extends: .compile_benchmark
script:
- cmake -S . -B build -DCMAKE_INSTALL_PREFIX=.local
- cmake --build build -j2
- cmake --install build
drich_fixed_eta:
extends: .rec_benchmark extends: .rec_benchmark
timeout: 24 hours timeout: 2 hours
stage: run stage: run
needs:
- rich_compile
script: script:
- bash benchmarks/rich/forward_hadrons.sh - |
for mode in fixedEtaIdeal fixedEtaMin fixedEtaMax ; do
ruby benchmarks/rich/run_benchmark.rb --ci -s $mode --num-events 50
done
rich_collect:
stage: collect
needs:
- drich_fixed_eta
script:
- echo "Done collecting artifacts."
...@@ -4,11 +4,16 @@ ...@@ -4,11 +4,16 @@
require 'optparse' require 'optparse'
require 'ostruct' require 'ostruct'
require 'fileutils'
################################### ###################################
# constants: # constants:
IdealTheta = 23.5 # [degrees] EtaTestValues = {
IdealEnergy = 20.0 # [GeV] :ideal => 2.0,
:min => 1.6,
:max => 3.5,
}
IdealEnergy = 12.0 # [GeV]
IdealParticle = 'pi+' IdealParticle = 'pi+'
################################### ###################################
...@@ -17,7 +22,7 @@ IdealParticle = 'pi+' ...@@ -17,7 +22,7 @@ IdealParticle = 'pi+'
# default opt # default opt
opt = OpenStruct.new opt = OpenStruct.new
opt.evgen = '' opt.sim_mode = ''
opt.sim_file = 'out/sim.edm4hep.root' opt.sim_file = 'out/sim.edm4hep.root'
opt.rec_file = 'out/rec.edm4hep.root' opt.rec_file = 'out/rec.edm4hep.root'
opt.ana_file = 'out/ana.edm4hep.root' opt.ana_file = 'out/ana.edm4hep.root'
...@@ -32,12 +37,13 @@ opt.algos = Array.new ...@@ -32,12 +37,13 @@ opt.algos = Array.new
opt.plots = Array.new opt.plots = Array.new
opt.verbosity = 0 opt.verbosity = 0
opt.dry_run = false opt.dry_run = false
opt.using_ci = false
# available event generation modes # available simulation modes
avail_evgens = [ avail_sim_modes = [
'idealAngle', 'fixedEtaIdeal',
'minTheta', 'fixedEtaMin',
'maxTheta', 'fixedEtaMax',
] ]
# parse options # parse options
...@@ -57,16 +63,16 @@ OptionParser.new do |o| ...@@ -57,16 +63,16 @@ OptionParser.new do |o|
required_set = true required_set = true
end end
o.separator '' o.separator ''
o.on("-e", "--evgen [EVGEN_MODE]", "Run the event generation, reconstruction, and analysis", o.on("-s", "--sim-mode [SIMULATION_MODE]", "Run the simulation, reconstruction, and analysis",
"[EVGEN_MODE] must be one of:") do |a| "[SIMULATION_MODE] must be one of:") do |a|
unless avail_evgens.include? a unless avail_sim_modes.include? a
$stderr.puts "ERROR: unknown event generation mode '#{a}'" $stderr.puts "ERROR: unknown simulation mode '#{a}'"
exit 1 exit 1
end end
opt.evgen = a opt.sim_mode = a
required_set = true required_set = true
end end
avail_evgens.each{ |it| o.separator ' '*40+it } avail_sim_modes.each{ |it| o.separator ' '*40+it }
o.separator '' o.separator ''
o.separator 'optional options:'.upcase o.separator 'optional options:'.upcase
o.separator '' o.separator ''
...@@ -90,6 +96,7 @@ OptionParser.new do |o| ...@@ -90,6 +96,7 @@ OptionParser.new do |o|
o.separator '' o.separator ''
o.on("-v", "--verbose", "Increase verbosity (-vv for more verbose)") { |a| opt.verbosity+=1 } o.on("-v", "--verbose", "Increase verbosity (-vv for more verbose)") { |a| opt.verbosity+=1 }
o.on("-d", "--dry-run", "Dry run (just print commands)") { |a| opt.dry_run=true } o.on("-d", "--dry-run", "Dry run (just print commands)") { |a| opt.dry_run=true }
o.on("--ci", "output plots to ./results, for CI artifact collection") { |a| opt.using_ci=true }
o.separator '' o.separator ''
o.on_tail("-h", "--help", "Show this message") do o.on_tail("-h", "--help", "Show this message") do
puts o puts o
...@@ -131,36 +138,53 @@ end ...@@ -131,36 +138,53 @@ end
compact_file = "#{ENV['DETECTOR_PATH']}/#{ENV['DETECTOR_CONFIG']}.xml" compact_file = "#{ENV['DETECTOR_PATH']}/#{ENV['DETECTOR_CONFIG']}.xml"
# event generator command generators # simulation command generators
# --------------------------------------------------- # ---------------------------------------------------
def theta2xyz(theta) def theta2xyz(theta)
rad = theta * Math::PI / 180 [ Math.sin(theta), 0.0, Math.cos(theta) ]
[ Math.sin(rad), 0.0, Math.cos(rad) ]
end end
def eta2theta(eta)
2 * Math.atan(Math.exp(-eta))
end
# fixed angle particle gun # fixed angle particle gun
evgen_fixed_angle = Proc.new do |theta, energy, particle| simulate_fixed_angle = Proc.new do |theta, energy, particle|
[ [
"npsim", "npsim",
"--runType batch", "--runType batch",
"--compactFile #{compact_file}", "--compactFile #{compact_file}",
"--outputFile #{opt.sim_file}", "--outputFile #{opt.sim_file}",
"--part.userParticleHandler=''", "--part.userParticleHandler=''", # allow opticalphotons in MC particles
"--enableGun", "--enableGun",
"--numberOfEvents #{opt.num_events}", "--numberOfEvents #{opt.num_events}",
"--gun.particle #{particle}", "--gun.particle #{particle}",
"--gun.energy #{energy}*GeV", "--gun.energy #{energy}*GeV",
"--gun.direction (#{theta2xyz(theta).join ", "})", "--gun.direction '(#{theta2xyz(theta).join ", "})'",
] ]
end end
# define event generator command # define simulation command
# --------------------------------------------------- # ---------------------------------------------------
evgen_cmd = Array.new sim_cmd = Array.new
case opt.evgen case opt.sim_mode
when 'idealAngle' when /^fixedEta/
evgen_cmd = evgen_fixed_angle.call IdealTheta, IdealEnergy, IdealParticle key = opt.sim_mode.sub('fixedEta','').downcase.to_sym
fixed_eta = EtaTestValues[key]
if fixed_eta.nil?
$stderr.puts "ERROR: EtaTestValues[#{key}] is not defined"
exit 1
end
fixed_theta = eta2theta fixed_eta
puts """Simulating fixed-eta events:
- eta = #{fixed_eta}
- theta = #{180.0 * fixed_theta / Math::PI} degrees
- energy = #{IdealEnergy} GeV
- particle = #{IdealParticle}
"""
sim_cmd = simulate_fixed_angle.call fixed_theta, IdealEnergy, IdealParticle
else else
exit 1 if run_step[:sim] exit 1 if run_step[:sim]
end end
...@@ -187,6 +211,7 @@ recon_cmd = [ ...@@ -187,6 +211,7 @@ recon_cmd = [
'-Pjana:debug_plugin_loading="1"', '-Pjana:debug_plugin_loading="1"',
'-Pacts:MaterialMap="calibrations/materials-map.cbor"', '-Pacts:MaterialMap="calibrations/materials-map.cbor"',
"-Ppodio:output_file=\"#{opt.rec_file}\"", "-Ppodio:output_file=\"#{opt.rec_file}\"",
'-PDRICH:DRICHIrtCherenkovParticleID:cheatPhotonVertex=true', # allow knowledge of true photons, for accurate residual determination
opt.sim_file, opt.sim_file,
] ]
...@@ -206,7 +231,7 @@ analysis_cmd.append '-' + 'v'*opt.verbosity if opt.verbosity > 0 ...@@ -206,7 +231,7 @@ analysis_cmd.append '-' + 'v'*opt.verbosity if opt.verbosity > 0
draw_cmd = [ draw_cmd = [
"#{__dir__}/draw_benchmark.py", "#{__dir__}/draw_benchmark.py",
"-i #{opt.ana_file}", "-i #{opt.ana_file}",
"-o #{opt.ana_file.gsub(/edm4hep.root$/,"plots")}" "-o #{opt.using_ci ? "results/#{opt.sim_mode}" : opt.ana_file.gsub(/edm4hep.root$/,"plots")}"
] ]
# execute commands # execute commands
...@@ -215,6 +240,14 @@ draw_cmd = [ ...@@ -215,6 +240,14 @@ draw_cmd = [
# proc: execute a command; raise runtime exception if failure (exit nonzero) # proc: execute a command; raise runtime exception if failure (exit nonzero)
exe = Proc.new do |cmd_args, name, step| exe = Proc.new do |cmd_args, name, step|
if run_step[step] if run_step[step]
case step
when :sim
FileUtils.mkdir_p File.dirname(opt.sim_file)
when :rec
FileUtils.mkdir_p File.dirname(opt.rec_file)
when :ana
FileUtils.mkdir_p File.dirname(opt.ana_file)
end
cmd = cmd_args.join ' ' cmd = cmd_args.join ' '
puts "benchmark #{name} command:".upcase puts "benchmark #{name} command:".upcase
cmd_args.each_with_index do |arg,i| cmd_args.each_with_index do |arg,i|
...@@ -234,7 +267,7 @@ end ...@@ -234,7 +267,7 @@ end
puts '-'*50 puts '-'*50
# execute the commands # execute the commands
exe.call evgen_cmd, 'event generation', :sim exe.call sim_cmd, 'simulation', :sim
exe.call recon_cmd, 'reconstruction', :rec exe.call recon_cmd, 'reconstruction', :rec
exe.call analysis_cmd, 'analysis', :ana exe.call analysis_cmd, 'analysis', :ana
exe.call draw_cmd, 'draw', :ana exe.call draw_cmd, 'draw', :ana
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment