Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating EvtCalc interface to work with any N-body decay #581

Merged
merged 6 commits into from
Dec 18, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions macro/convertEvtCalc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parse_file(infile):
data = np.loadtxt(current_block)
variables = [data[:, i] for i in range(data.shape[1])]
parsed_data.append((process_type, sampled_points, variables))

return parsed_data

except FileNotFoundError:
Expand Down Expand Up @@ -90,15 +90,15 @@ def convert_file(infile, outdir):
"decay_prob",
"vx",
"vy",
"vz"
"vz",
]
daughter_vars = [
"px_prod",
"py_prod",
"pz_prod",
"e_prod",
"mass_prod",
"pdg_prod"
"pdg_prod",
]
fname = infile.split("/")[-1]
command = f"cp {infile} {outdir}/{fname}"
Expand All @@ -108,16 +108,15 @@ def convert_file(infile, outdir):
else:
os.system(command)

infile = f"{outdir}/{fname}"
infile = f"{outdir}/{fname}"
parsed_data = parse_file(infile)
outfile = infile.split(".dat")[0] + ".root"
ncols = len(parsed_data[0][2])
nvardau = 6 # qualifiers for each daughter
nvardau = 6 #qualifiers for each daughter
olantwin marked this conversation as resolved.
Show resolved Hide resolved
remaining_vars = ncols - len(vars_names)

if (remaining_vars % nvardau)!=0:
raise ValueError(f"- convertEvtCalc - Error: number of daughters is not exact.")
sys.exit(1)

ndau = remaining_vars // nvardau
print(f"- convertEvtCalc - Max multiplicity of daughters: {ndau}")
Expand All @@ -140,7 +139,7 @@ def convert_file(infile, outdir):

branch_f = {}
for var in vars_names:
branch_f[var] = np.zeros(1, dtype=float)
branch_f[var] = np.zeros(1, dtype=float)
tree.Branch(var, branch_f[var], f"{var}/D")

for pt, sp, vars in parsed_data:
Expand Down
Loading