Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions xfields/beam_elements/beambeam3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ class BeamBeamBiGaussian3D(xt.BeamElement):
#bhabha
'flag_bhabha': xo.Int64,
'compt_x_min': xo.Float64,
'compt_scale': xo.Float64,
'flag_beamsize_effect': xo.Int64,

#lumi
Expand Down Expand Up @@ -251,6 +252,7 @@ def __init__(self,

flag_bhabha=0,
compt_x_min=1e-4,
compt_scale=1.,
flag_beamsize_effect=1,

flag_luminosity=0,
Expand Down Expand Up @@ -330,6 +332,7 @@ def __init__(self,
slices_other_beam_sqrtSigma_{135}{135}_beamstrahlung (float array): Array storing the per-slice standard deviations of x (=1), y (=3) and zeta (=5) of the opposing bunch, in the unboosted accelerator frame. Length of the array is the number of longitudinal slices. Used for beamstrahlung only.
flag_bhabha (int): Flag to simulate small angle radiative Bhabha scattering. 1: ON (quantum), 0: OFF
compt_x_min (float): Low energy cut on virtual photon spectrum, used for Bhabha, in units of [gamma^-2] where gamma is the rel. Lorentz factor.
compt_scale (float): Scaling factor to scale up photon generation, used for Bhabha.
flag_beamsize_effect (int): Flag to simulate beamsize effect, used for Bhabha. 1: ON, 0: OFF. Results in ~factor 2 reduction in cross section.
flag_luminosity (int): Flag to record soft-Gaussian luminosity per bunch crossing in a buffer. Luminosity will be in units of [m^-2].
slices_other_beam_{x,px,y,py,zeta,pzeta}_center_star (float array): Array storing the per-slice centroid variables of the opposing bunch, in the unboosted accelerator frame. Length of the array is the number of longitudinal slices.
Expand Down Expand Up @@ -465,7 +468,7 @@ def __init__(self,
)

# initialize bhabha
self._init_bhabha(flag_bhabha, compt_x_min, flag_beamsize_effect)
self._init_bhabha(flag_bhabha, compt_x_min, compt_scale, flag_beamsize_effect)

self._init_luminosity(flag_luminosity)

Expand Down Expand Up @@ -635,9 +638,10 @@ def flag_beamstrahlung(self, flag_beamstrahlung):
'needs to be correctly set')
self._flag_beamstrahlung = flag_beamstrahlung

def _init_bhabha(self, flag_bhabha, compt_x_min, flag_beamsize_effect):
def _init_bhabha(self, flag_bhabha, compt_x_min, compt_scale, flag_beamsize_effect):
self.flag_beamsize_effect = flag_beamsize_effect
self.compt_x_min = compt_x_min
self.compt_scale = compt_scale
self.flag_bhabha = flag_bhabha # Trigger property setter

@property
Expand All @@ -649,6 +653,8 @@ def flag_bhabha(self, flag_bhabha):
if flag_bhabha == 1:
if self.compt_x_min <= 0:
raise ValueError('compt_x_min must be larger than 0')
if self.compt_scale <= 0:
raise ValueError('compt_scale must be larger than 0')
self._flag_bhabha = flag_bhabha

def _init_luminosity(self, flag_luminosity):
Expand Down
4 changes: 3 additions & 1 deletion xfields/beam_elements/beambeam_src/beambeam3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,11 @@ void do_bhabha(BeamBeamBiGaussian3DData el, LocalParticle *part,
py_photon = py_slice_star;
pzeta_photon = pzeta_slice_star;

const double compt_scale = BeamBeamBiGaussian3DData_get_compt_scale(el); // [1] can be used to scale up photon generation for tests

// for each virtual photon get compton scatterings; updates pzeta and energy vars inside
compt_do(part, bhabha_record, bhabha_table_index, bhabha_table,
e_photon, compt_x_min, q2,
e_photon, compt_x_min, compt_scale, q2,
x_photon, y_photon, S, px_photon, py_photon, pzeta_photon,
*wgt, px_star, py_star, pzeta_star, q0);

Expand Down
2 changes: 1 addition & 1 deletion xfields/headers/bhabha_spectrum.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ double compt_select(LocalParticle *part,
void compt_do(LocalParticle *part, BeamBeamBiGaussian3DRecordData bhabha_record, RecordIndex bhabha_table_index, BhabhaTableData bhabha_table,
double e_photon, // [GeV] single equivalent virtual photon energy before Compton scattering
const double compt_x_min, // [1] scaling factor in the minimum energy cutoff
double compt_scale, // [1] can be used to scale up photon generation for tests
double q2, // [GeV^2] single equivalent virtual photon virtuality
double x_photon, double y_photon, double z_photon, // [m] (boosted) coords of the virtual photon
double vx_photon, // [1] transverse x momentum component of virtual photon (vx = dx/ds/p0)
Expand Down Expand Up @@ -284,7 +285,6 @@ void compt_do(LocalParticle *part, BeamBeamBiGaussian3DRecordData bhabha_record,
double e_photon_prime, px_photon_prime, py_photon_prime; // [GeV, GeV/c] scattered (real) Compton photon momenta
double e_loss_primary; // [GeV] energy lost from one photon emission
double eps = 0.0; // 1e-5 in guinea, used due to limited resolution of RNG in the past
const double compt_scale = 1; // [1] can be used to scale up photon generation for tests
const double compt_emax = 200; // [GeV] upper cutoff on e_e_prime from guineapig
const double pair_ecut = 0.005; // [GeV] lower cutoff on e_e_prime from guineapig
double r1, r2; // [1] uniform random numbers
Expand Down