diff --git a/benchmarks/rich/run_benchmark.rb b/benchmarks/rich/run_benchmark.rb index a410eed12989d38c3037e98988093f64f5a74649..e8edcfa25a908b5c226997a9df615e303618bf67 100755 --- a/benchmarks/rich/run_benchmark.rb +++ b/benchmarks/rich/run_benchmark.rb @@ -84,10 +84,19 @@ OptionParser.new do |o| exit 2 end end.parse!(ARGV.length>0 ? ARGV : ['--help']) + +# print options puts 'settings: {'.upcase opt.each_pair { |k,v| puts "#{k.to_s.rjust(20)} => #{v}" } puts '}' +# check for required options +if opt.evgen=='' and opt.ana_only==false + $stderr.puts "ERROR: required options have not been set" + $stderr.puts "run '#{$0} --help' for guidance" + exit 1 +end + # get compact file if ENV['DETECTOR_PATH'].nil? or ENV['DETECTOR_CONFIG'].nil? $stderr.puts "ERROR: unknown DETECTOR_PATH or DETECTOR_CONFIG" @@ -106,16 +115,16 @@ end # fixed angle particle gun evgen_fixed_angle = Proc.new do |theta, energy, particle| [ - 'npsim', - '--runType', 'batch', - '--compactFile', compact_file, - '--outputFile', opt.sim_file, - '--part.userParticleHandler=""', - '--enableGun', - '--numberOfEvents', opt.num_events, - '--gun.particle', particle, - '--gun.energy', "#{energy}*GeV", - '--gun.direction', "(#{theta2xyz(theta).join ', '})", + "npsim", + "--runType batch", + "--compactFile #{compact_file}", + "--outputFile #{opt.sim_file}", + "--part.userParticleHandler=''", + "--enableGun", + "--numberOfEvents #{opt.num_events}", + "--gun.particle #{particle}", + "--gun.energy #{energy}*GeV", + "--gun.direction (#{theta2xyz(theta).join ", "})", ] end @@ -154,14 +163,32 @@ recon_cmd = [ opt.sim_file, ] + +# define analysis benchmark command +# --------------------------------------------------- +analysis_cmd = [ + opt.benchmark_exe, + "-i #{opt.rec_file}", + "-o #{opt.ana_file}", +] +analysis_cmd.append "-a #{opt.algos.join ' '}" if opt.algos.size > 0 +analysis_cmd.append '-' + 'v'*opt.verbosity if opt.verbosity > 0 + # execute commands # --------------------------------------------------- exe = Proc.new do |cmd_args, name| cmd = cmd_args.join ' ' puts "#{name} command:".upcase - puts cmd + cmd_args.each_with_index do |arg,i| + line = i==0 ? '' : ' ' + line += arg + line += ' \\' unless i+1==cmd_args.size + puts line + end unless opt.dry_run + puts '-'*50 + puts "#{name} execution:".upcase system cmd or raise "#{name} failed!" end puts '-'*50 @@ -172,3 +199,6 @@ unless opt.ana_only exe.call evgen_cmd, 'event generator' if opt.run_sim exe.call recon_cmd, 'reconstruction' if opt.run_rec end +if opt.ana_only or opt.run_ana + exe.call analysis_cmd, 'benchmark analysis' +end