From 4f9bc46ffee944702c1e7af895f7d8e66f89cf46 Mon Sep 17 00:00:00 2001 From: gbrogginess Date: Thu, 21 Aug 2025 16:05:57 +0200 Subject: [PATCH] Add `compt_scale` as a user parameter. `compt_scale` is a multiplicative factor applied to the total Compton cross-section. Increasing this factor scales up photon generation in the radiative Bhabha model. This can be useful for testing or for producing a larger number of radiative Bhabha scattering events. --- xfields/beam_elements/beambeam3d.py | 10 ++++++++-- xfields/beam_elements/beambeam_src/beambeam3d.h | 4 +++- xfields/headers/bhabha_spectrum.h | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/xfields/beam_elements/beambeam3d.py b/xfields/beam_elements/beambeam3d.py index 46dbbaa6..e32103e9 100644 --- a/xfields/beam_elements/beambeam3d.py +++ b/xfields/beam_elements/beambeam3d.py @@ -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 @@ -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, @@ -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. @@ -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) @@ -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 @@ -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): diff --git a/xfields/beam_elements/beambeam_src/beambeam3d.h b/xfields/beam_elements/beambeam_src/beambeam3d.h index e028c020..482d9c36 100644 --- a/xfields/beam_elements/beambeam_src/beambeam3d.h +++ b/xfields/beam_elements/beambeam_src/beambeam3d.h @@ -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); diff --git a/xfields/headers/bhabha_spectrum.h b/xfields/headers/bhabha_spectrum.h index 0e2f9c11..a732842d 100644 --- a/xfields/headers/bhabha_spectrum.h +++ b/xfields/headers/bhabha_spectrum.h @@ -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) @@ -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