diff options
author | tlatorre <tlatorre@uchicago.edu> | 2018-10-03 09:45:33 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2018-10-03 09:45:33 -0500 |
commit | 3650f72cc3570b51dc225886fd947f86d999e7a3 (patch) | |
tree | bbb2c0538a4c869edf4edcf5d788bd317c41ba86 /macros/snogen | |
parent | 21015c7a428ab3bbc4d58dac930ee44c8cd262c5 (diff) | |
download | sddm-3650f72cc3570b51dc225886fd947f86d999e7a3.tar.gz sddm-3650f72cc3570b51dc225886fd947f86d999e7a3.tar.bz2 sddm-3650f72cc3570b51dc225886fd947f86d999e7a3.zip |
add a python script to generate SNOMAN command files
Diffstat (limited to 'macros/snogen')
-rwxr-xr-x | macros/snogen | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/macros/snogen b/macros/snogen new file mode 100755 index 0000000..089f34d --- /dev/null +++ b/macros/snogen @@ -0,0 +1,45 @@ +#!/usr/bin/env python +""" +snogen is a script to generate SNOMAN command files. + +Example: + + # simulate 100 1 GeV muons + $ snogen -n 100 -e 1000 -p mu_minus | /path/to/snoman.exe + +The output filename can be specified on the command line: + + $ snogen -o [output filename] + +By default it will be [particle name]_[energy]_[number of events].zdab. +""" +from __future__ import print_function, division +import string + +class MyTemplate(string.Template): + delimiter = '@' + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser("generate a SNOMAN command file") + parser.add_argument("-p", "--particle-id", default="e_minus", + help="particle id") + parser.add_argument("-e", "--mc-energy", default=500.0, type=float, + help="total energy") + parser.add_argument("-n", "--num-events", default=100, type=int, + help="number of events") + parser.add_argument("-o", "--output", default=None, + help="output file name") + args = parser.parse_args() + + if args.output is None: + output = "%s_%.0f_%i.zdab" % (args.particle_id,args.mc_energy,1000) + else: + output = args.output + + with open("mc_run_10000_macro.cmd") as f: + s = f.read() + + template = MyTemplate(s) + print(template.safe_substitute(particle_id=args.particle_id,mc_energy=args.mc_energy,num_events=args.num_events,output=output)) |