Skip to content
Snippets Groups Projects
Commit 9410644f authored by Dmitry Popov's avatar Dmitry Popov
Browse files

Fixed hadronic test to check return code; beamOn 1, not zero

parent 3240a090
No related branches found
No related tags found
No related merge requests found
...@@ -55,7 +55,7 @@ template = '''#================================================ ...@@ -55,7 +55,7 @@ template = '''#================================================
#/gun/particle proton #/gun/particle proton
#/gun/energy 20. GeV #/gun/energy 20. GeV
# #
/run/beamOn 0 /run/beamOn 1
# #
''' '''
...@@ -74,21 +74,25 @@ def process(particle, target, phys_list): ...@@ -74,21 +74,25 @@ def process(particle, target, phys_list):
with NamedTemporaryFile() as tmp: with NamedTemporaryFile() as tmp:
tmp.write(template.format(particle=particle, target=target)) tmp.write(template.format(particle=particle, target=target))
tmp.flush() tmp.flush()
job = Popen(['hadr00.exe', tmp.name, phys_list], stdout=PIPE, stderr=PIPE)
job_out, job_err = job.communicate()
if job.returncode:
sys.exit('ERROR: hadr00.exe exited with an error code!')
if not os.path.exists("tables"): if not os.path.exists("tables"):
os.makedirs("tables") os.makedirs("tables")
tables = open(os.path.join('tables', '{0}_{1}_{2}.txt'.format(phys_list, particle, target)),"w") tables = open(os.path.join('tables', '{0}_{1}_{2}.txt'.format(phys_list, particle, target)),"w")
tables.write("Energy Elastic Inelastic Total\n") tables.write("Energy Elastic Inelastic Total\n")
job = Popen(['hadr00.exe', tmp.name, phys_list], stdout=PIPE)
regex = re.compile(r'^\s*\d+\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)') regex = re.compile(r'^\s*\d+\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)')
found = False found = False
energy = array('d') energy = array('d')
elastic = array('d') elastic = array('d')
inelastic = array('d') inelastic = array('d')
total = array('d') total = array('d')
for line in job.stdout: for line in job_out.split(os.linesep):
if found: if found:
m = regex.match(line) m = regex.match(line)
if m: if m:
...@@ -156,12 +160,12 @@ for p,ap in zip(part,apart) : ...@@ -156,12 +160,12 @@ for p,ap in zip(part,apart) :
if "kaon" in p : if "kaon" in p :
gr0.SetMaximum(1.5) gr0.SetMaximum(1.5)
gr0.Draw("AL") gr0.Draw("AL")
gr1.SetLineWidth(2) gr1.SetLineWidth(2)
gr1.SetLineColor(1) gr1.SetLineColor(1)
gr1.SetLineStyle(2) gr1.SetLineStyle(2)
gr1.Draw("samesL") gr1.Draw("samesL")
gr2.SetLineWidth(2); gr2.SetLineWidth(2);
gr2.SetLineStyle(1) gr2.SetLineStyle(1)
gr2.SetLineColor(4); gr2.SetLineColor(4);
...@@ -184,5 +188,3 @@ for p,ap in zip(part,apart) : ...@@ -184,5 +188,3 @@ for p,ap in zip(part,apart) :
c1.SetGridx(); c1.SetGridx();
c1.Print("phys_list_comparison_"+p.replace("-","")+".pdf") c1.Print("phys_list_comparison_"+p.replace("-","")+".pdf")
c1.Print("phys_list_comparison_"+p.replace("-","")+".C") c1.Print("phys_list_comparison_"+p.replace("-","")+".C")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment