Skip to content
Snippets Groups Projects

Add ML benchmark for imaging calorimetry

Merged Chao Peng requested to merge add_ml_benchmark into master
1 file
+ 6
2
Compare changes
  • Side-by-side
  • Inline
@@ -38,6 +38,7 @@ tag_dir = os.path.join('tag_data', '{nametag}_{pmin}_{pmax}'.format(**kwargs))
@@ -38,6 +38,7 @@ tag_dir = os.path.join('tag_data', '{nametag}_{pmin}_{pmax}'.format(**kwargs))
os.makedirs(tag_dir, exist_ok=True)
os.makedirs(tag_dir, exist_ok=True)
procs = [p.strip() for p in args.process.split(',')]
procs = [p.strip() for p in args.process.split(',')]
 
sdir = os.path.dirname(os.path.realpath(__file__))
if 'sim' in procs:
if 'sim' in procs:
# generate particles
# generate particles
@@ -60,6 +61,7 @@ if 'sim' in procs:
@@ -60,6 +61,7 @@ if 'sim' in procs:
if args.seed > 0:
if args.seed > 0:
sim_cmd += ['--random.seed', args.seed]
sim_cmd += ['--random.seed', args.seed]
return_code = subprocess.run(sim_cmd).returncode
return_code = subprocess.run(sim_cmd).returncode
 
print(return_code)
if return_code is not None and return_code < 0:
if return_code is not None and return_code < 0:
print("ERROR running simulation!")
print("ERROR running simulation!")
exit(return_code)
exit(return_code)
@@ -76,8 +78,9 @@ if 'rec' in procs:
@@ -76,8 +78,9 @@ if 'rec' in procs:
os.environ['IMCAL_ML_N_HITS'] = '{}'.format(args.nhit)
os.environ['IMCAL_ML_N_HITS'] = '{}'.format(args.nhit)
juggler_xenv = os.path.join(os.environ.get('JUGGLER_INTALL_PREFIX', '../local'), 'Juggler.xenv')
juggler_xenv = os.path.join(os.environ.get('JUGGLER_INTALL_PREFIX', '../local'), 'Juggler.xenv')
rec_cmd = ['xenv', '-x', juggler_xenv, 'gaudirun.py', 'options/imaging_ml_data.py']
rec_cmd = ['xenv', '-x', juggler_xenv, 'gaudirun.py', os.path.join(sdir, 'options', 'imaging_ml_data.py')]
return_code = subprocess.run(rec_cmd).returncode
return_code = subprocess.run(rec_cmd).returncode
 
print(return_code)
if return_code is not None and return_code < 0:
if return_code is not None and return_code < 0:
print("ERROR running juggler (reconstruction)!")
print("ERROR running juggler (reconstruction)!")
exit(return_code)
exit(return_code)
@@ -85,10 +88,11 @@ if 'rec' in procs:
@@ -85,10 +88,11 @@ if 'rec' in procs:
if 'tag' in procs:
if 'tag' in procs:
tag_cmd = ['python', 'scripts/prepare_tf_dataset.py', rec_file,
tag_cmd = ['python', os.path.join(sdir, 'scripts', 'prepare_tf_dataset.py'), rec_file,
'-o', tag_dir,
'-o', tag_dir,
'--shape', '{nlayer},{nhit},3'.format(**kwargs)]
'--shape', '{nlayer},{nhit},3'.format(**kwargs)]
return_code = subprocess.run(tag_cmd).returncode
return_code = subprocess.run(tag_cmd).returncode
 
print(return_code)
if return_code is not None and return_code < 0:
if return_code is not None and return_code < 0:
print("ERROR running ML data tagging!")
print("ERROR running ML data tagging!")
exit(return_code)
exit(return_code)
Loading