Skip to content

Commit

Permalink
Update parser.py to python3
Browse files Browse the repository at this point in the history
Use python3 on el9 lxplus machine for geant-val analysis.
  • Loading branch information
lopezzot committed Apr 15, 2024
1 parent 57c6d16 commit f0ff51e
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions geantval_scripts/ATLHECTB/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ def parse(self, jobs):
pienergies = [float(x["ENERGY"]) for x in pijobs]
pifiles = [os.path.join(x["path"], "ATLHECTBout_Run0.root")
for x in pijobs]
print "Found "+str(len(jobs))+" runs in jobs:"
print "--->" + str(len(ectrjobs)) + " jobs with e-, energies (GeV): " + str(ectrenergies) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print("Found "+str(len(jobs))+" runs in jobs:")
print("--->" + str(len(ectrjobs)) + " jobs with e-, energies (GeV): " + str(ectrenergies) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
# print "------> files: ", ectrfiles
print "--->" + str(len(pijobs)) + " jobs with pi-, energies (GeV): " + str(pienergies) + " ,physlist: " + str(set([x["PHYSLIST"] for x in pijobs]))
print("--->" + str(len(pijobs)) + " jobs with pi-, energies (GeV): " + str(pienergies) + " ,physlist: " + str(set([x["PHYSLIST"] for x in pijobs])))
# print "------> files: ", pifiles

# e- analysis
#
print "Running e- analysis"
print("Running e- analysis")
sampfractions = []
ersampfractions = []
resolutions = []
Expand All @@ -71,8 +71,8 @@ def parse(self, jobs):
* 100) # percent value
sampfractions.append(H1sampfraction.GetMean())
ersampfractions.append(H1sampfraction.GetMeanError())
print "--->e- sampling fraction: " + str(sampfractions) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print "--->e- avg sampling fraction: " + str(np.mean(sampfractions)) + "%" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print("--->e- sampling fraction: " + str(sampfractions) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
print("--->e- avg sampling fraction: " + str(np.mean(sampfractions)) + "%" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
outfile = TFile.Open("OUTe-"+str(ectrjobs[0]["PHYSLIST"])+".root", "RECREATE")
for energy in eenergies:
# Find e- job with corresponding energy
Expand Down Expand Up @@ -107,9 +107,9 @@ def parse(self, jobs):
erecenergies.append(recenergy.GetFunction("gaus").GetParameter(1))
outfile.cd()
recenergy.Write()
print "--->e- sampling terms in resolution: " + str(resolutions) + " %GeV^{1/2}" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print "--->e- avg sampling term in resolution: " + str(np.mean(resolutions)) + " %GeV^{1/2}" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print "-->e- reconstructed energies: " + str(erecenergies) + ",physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print("--->e- sampling terms in resolution: " + str(resolutions) + " %GeV^{1/2}" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
print("--->e- avg sampling term in resolution: " + str(np.mean(resolutions)) + " %GeV^{1/2}" + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
print("-->e- reconstructed energies: " + str(erecenergies) + ",physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))

# This contains e- reconstructed energies or 99% of beam energy
# if no data are available
Expand Down Expand Up @@ -159,7 +159,7 @@ def parse(self, jobs):

# pi- analysis
#
print "Running pi- analysis"
print("Running pi- analysis")
responses = []
erresponses = []
resolutions = []
Expand Down Expand Up @@ -363,16 +363,16 @@ def parse(self, jobs):
erL0 = [0.005*x for x in L0]
ersigmaL0 = [0.005*x for x in sigmaL0]

print "--->pi- pi/e: " + str(responses) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs]))
print "--->pi- avg pi/e: " + str(np.mean(responses))
print "--->pi- resolutions: " + str(resolutions) + " %"
print "--->pi- avg resolution: " + str(np.mean(resolutions)) + " %"
print "--->pi- F1: " + str(F1)
print "--->pi- F2: " + str(F2)
print "--->pi- F3: " + str(F3)
print "--->pi- F4: " + str(F4)
print "--->pi- L0 [cm]: " + str(L0)
print "--->pi- sigmaL0 [cm]: " + str(sigmaL0)
print("--->pi- pi/e: " + str(responses) + " ,physlist: " + str(set([x["PHYSLIST"] for x in ectrjobs])))
print("--->pi- avg pi/e: " + str(np.mean(responses)))
print("--->pi- resolutions: " + str(resolutions) + " %")
print("--->pi- avg resolution: " + str(np.mean(resolutions)) + " %")
print("--->pi- F1: " + str(F1))
print("--->pi- F2: " + str(F2))
print("--->pi- F3: " + str(F3))
print("--->pi- F4: " + str(F4))
print("--->pi- L0 [cm]: " + str(L0))
print("--->pi- sigmaL0 [cm]: " + str(sigmaL0))

# Create JSON output files for pi- energy resolution (graph)
#
Expand Down

0 comments on commit f0ff51e

Please sign in to comment.