mm = 1e-3;
MHz = 1e6;

#========================================================
#  difinition: initial condition of electorn beam
#========================================================
Energy=100e+3;         # beam energy [MeV]

G=1-qe*Energy/(me*c^2);

setparticles("beam",10000,me,qe,-1e-9);
setrxydist("beam","u", 1.25*mm, 2.5*mm);
setphidist("beam","u", 0, 2*pi);
setzdist("beam","u", -287*mm/2, 287*mm);
setGBrxydist("beam","u",0, 0);
setGBphidist("beam","u",0, 0);
setGdist("beam","u",G, 0);


#========================================================
#  difinition: prebuncher
#========================================================

facc   = 2856*MHz;                      # Operating freq. [Hz]
pb_pwr = 1e3;                           # PB power [w]
omega = 2*pi*facc;
# --- from SUPERFISH results --------------
pb_U 	= 0.0010478;			# Stored energy output of SF [Joules]
pb_Q 	= 12093.3;			# Q value in SF
pb_sf_pwr = omega*pb_U/pb_Q;
pb_fac 	= sqrt(pb_pwr/pb_sf_pwr);
pp("pb_fac:", pb_fac);

map25D_TM("wcs", "z", 100*mm, "PB.gdf", "R", "Z", "Er", "Ez", "H", pb_fac, 0, 0, omega);

#========================================================
# beam control
#========================================================
tout(0, 8/facc, 1/(6*facc));