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

fix GenesisElectronDist.twiss() miscalculation #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
28 changes: 14 additions & 14 deletions ocelot/adaptors/genesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -868,20 +868,20 @@ def twiss(self):
xp = self.xp
yp = self.yp

mean_x2 = mean(x**2)
mean_y2 = mean(y**2)
mean_px2 = mean(xp**2)
mean_py2 = mean(yp**2)
mean_xpx = mean(x * xp)
mean_ypy = mean(y * yp)
mean_g = mean(self.g)

tws.emit_x = mean_g * (mean_x2 * mean_px2 - mean_xpx**2)**0.5 / mean_g
tws.emit_y = mean_g * (mean_y2 * mean_py2 - mean_ypy**2)**0.5 / mean_g
tws.beta_x = mean_g * mean_x2 / tws.emit_x
tws.beta_y = mean_g * mean_y2 / tws.emit_y
tws.alpha_x = -mean_g * mean_xpx / tws.emit_x
tws.alpha_y = -mean_g * mean_ypy / tws.emit_y
mean_x2 = np.mean(x**2)
mean_y2 = np.mean(y**2)
mean_px2 = np.mean(xp**2)
mean_py2 = np.mean(yp**2)
mean_xpx = np.mean(x * xp)
mean_ypy = np.mean(y * yp)
mean_g = np.mean(self.g)

tws.emit_x = (mean_x2 * mean_px2 - mean_xpx**2)**0.5
tws.emit_y = (mean_y2 * mean_py2 - mean_ypy**2)**0.5
tws.beta_x = mean_x2 / tws.emit_x
tws.beta_y = mean_y2 / tws.emit_y
tws.alpha_x = - mean_xpx / tws.emit_x
tws.alpha_y = - mean_ypy / tws.emit_y
tws.E = mean_g * m_e_GeV

return tws
Expand Down