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 tags found
1 merge request!18Migrate 'master' to G4 v10r3p1
......@@ -55,7 +55,7 @@ template = '''#================================================
#/gun/particle proton
#/gun/energy 20. GeV
#
/run/beamOn 0
/run/beamOn 1
#
'''
......@@ -74,21 +74,25 @@ def process(particle, target, phys_list):
with NamedTemporaryFile() as tmp:
tmp.write(template.format(particle=particle, target=target))
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"):
os.makedirs("tables")
tables = open(os.path.join('tables', '{0}_{1}_{2}.txt'.format(phys_list, particle, target)),"w")
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.]+)')
found = False
energy = array('d')
elastic = array('d')
inelastic = array('d')
total = array('d')
for line in job.stdout:
for line in job_out.split(os.linesep):
if found:
m = regex.match(line)
if m:
......@@ -156,12 +160,12 @@ for p,ap in zip(part,apart) :
if "kaon" in p :
gr0.SetMaximum(1.5)
gr0.Draw("AL")
gr1.SetLineWidth(2)
gr1.SetLineColor(1)
gr1.SetLineStyle(2)
gr1.Draw("samesL")
gr2.SetLineWidth(2);
gr2.SetLineStyle(1)
gr2.SetLineColor(4);
......@@ -184,5 +188,3 @@ for p,ap in zip(part,apart) :
c1.SetGridx();
c1.Print("phys_list_comparison_"+p.replace("-","")+".pdf")
c1.Print("phys_list_comparison_"+p.replace("-","")+".C")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment