Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.
Open
Changes from all 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
19 changes: 10 additions & 9 deletions utils/fluka_to_slcio.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def bytes_from_file(filename):
break

# Extracting relevant values from the line
fid,e, x,y,z, cx,cy,cz, toff,toff_mo = (data[n][0] for n in [
fid,e_kin, x,y,z, cx,cy,cz, toff,toff_mo = (data[n][0] for n in [
'fid', 'E',
'x','y','z',
'cx', 'cy', 'cz',
Expand All @@ -143,21 +143,22 @@ def bytes_from_file(filename):
if args.t_max is not None and t > args.t_max:
continue

# Calculating the components of the momentum vector
mom = np.array([cx, cy, cz], dtype=np.float32)
mom *= e

# Skipping if it's a neutron with too low kinetic energy
if args.ne_min is not None and abs(pdg) == 2112 and np.linalg.norm(mom) < args.ne_min:
continue

# Getting the charge and mass of the particle
if pdg not in PDG_PROPS:
print('WARNING! No properties defined for PDG ID: {0:d}'.format(pdg))
print(' Skpping the particle...')
continue
charge, mass = PDG_PROPS[pdg]

# Calculating the components of the momentum vector from the kinetic energy
mom_tot = sqrt(e_kin**2 + 2 * e_kin * mass)
mom = np.array([cx, cy, cz], dtype=np.float32)
mom *= mom_tot

# Skipping if it's a neutron with too low kinetic energy
if args.ne_min is not None and abs(pdg) == 2112 and e_kin < args.ne_min:
continue

# Calculating how many random copies of the particle to create according to the weight
nP_frac, nP = math.modf(args.normalization)
if nP_frac > 0 and random.random() < nP_frac:
Expand Down