Belle II Software  release-05-02-19
BBBrem Class Reference

Generator for low scattering angle radiative Bhabha events (Beam-Beam Bremsstrahlung). More...

#include <BBBrem.h>

Public Member Functions

 BBBrem ()
 Constructor.
 
 ~BBBrem ()
 Destructor.
 
void init (double cmsEnergy, double minPhotonEFrac, bool unweighted=true, double maxWeight=2000.0, int densitymode=1, double densityparameter=1.68e-17)
 Initializes the generator. More...
 
double generateEvent (MCParticleGraph &mcGraph, TVector3 vertex, TLorentzRotation boost)
 Generates one single event. More...
 
double getCrossSection ()
 Returns the total cross section of the generated process in millibarn. More...
 
double getCrossSectionError ()
 Returns the error on the total cross section of the generated process in millibarn. More...
 
double getCrossSectionOver ()
 Returns the total overweight bias cross section of the generated process in millibarn. More...
 
double getCrossSectionErrorOver ()
 Returns the error on the total overweight bias cross section of the generated process in millibarn. More...
 
double getMaxWeightDelivered ()
 Returns the maximum weight given by the BBBrem generation. More...
 
double getSumWeightDelivered ()
 Returns the sum of all weights returned by the BBBrem generation. More...
 
void term ()
 Terminates the generator.
 

Protected Member Functions

void calcOutgoingLeptonsAndWeight ()
 Calculate the outgoing leptons and the event weight for one single radiative Bhabha scattering. More...
 
void storeParticle (MCParticleGraph &mcGraph, const double *mom, int pdg, TVector3 vertex, TLorentzRotation boost, bool isVirtual=false, bool isInitial=false)
 Store a single generated particle into the MonteCarlo graph. More...
 

Protected Attributes

int m_eventCount
 Internal event counter. More...
 
bool m_unweighted
 True if BBBrem should produce unweighted events.
 
long m_weightCount
 Internal weighted event counter. More...
 
long m_weightCountOver
 Internal overweighted event counter. More...
 
double m_maxWeight
 The maximum weight. More...
 
double m_maxWeightDelivered
 The maximum weight given by the BBBrem generation.
 
double m_sumWeightDelivered
 The sum of all weights returned by the BBBrem generation.
 
double m_sumWeightDeliveredSqr
 The square of the sum of all weights returned by the BBBrem generation.
 
double m_sumWeightDeliveredOver
 The sum of all overweights.
 
double m_sumWeightDeliveredSqrOver
 The square of the sum of all overweights.
 
double m_cmsEnergy
 Center of mass energy (sqrt(s)).
 
double m_photonEFrac
 Minimum photon energy fraction.
 
double m_crossSection
 The cross-section in millibarns.
 
double m_crossSectionError
 The error on the cross-section in millibarns.
 
double m_crossSectionOver
 The overweight bias cross-section in millibarns.
 
double m_crossSectionErrorOver
 The overweight bias error on the cross-section in millibarns.
 
int m_densityCorrectionMode
 Mode for bunch density correction.
 
double m_densityCorrectionParameter
 Density correction parameter tc.
 

Private Attributes

double alpha
 variable

 
double rme
 in MeV
 
double s
 variable

 
double rme2
 variable

 
double rme2s
 variable

 
double rls
 variable

 
double z0
 variable

 
double a1
 variable

 
double a2
 variable

 
double ac
 variable

 
double sigapp
 variable

 
double eb
 variable

 
double pb
 variable

 
double rin2pb
 variable

 
double p1 [4]
 variable

 
double p2 [4]
 variable

 
double q1 [4]
 variable

 
double q2 [4]
 variable

 
double qk [4]
 variable

 
double weight
 variable

 

Static Private Attributes

static constexpr double tomb = 3.8937966e5 / 1e6
 Conversion factor (hc)^2.
 
static constexpr double twopi = 2.0 * M_PI
 2*pi. More...
 

Detailed Description

Generator for low scattering angle radiative Bhabha events (Beam-Beam Bremsstrahlung).

Based on the FORTRAN source code from R. Kleiss. In order to be consistent with the original source code, the variable names are kept and might therefore violate the coding conventions.

Original authors: r. Kleiss and h. Burkhardt Reference: [arXiv:hep-ph/9401333v1]

Definition at line 40 of file BBBrem.h.

Member Function Documentation

◆ calcOutgoingLeptonsAndWeight()

void calcOutgoingLeptonsAndWeight ( )
protected

Calculate the outgoing leptons and the event weight for one single radiative Bhabha scattering.

The main method. A direct translation from the BBBrem Fortran source code.

Definition at line 157 of file BBBrem.cc.

158 {
159  //Generate z
160  double z;
161  if (gRandom->Uniform() < ac) {
162  double temp1 = gRandom->Uniform();
163 // z = 1.0 / (temp1 * (exp(a1 * gRandom->Uniform()) - 1.0));
164 // Expression 'exp(x) - 1' is replaced by 'expm1(x)' to avoid loss of precision.
165  z = 1.0 / (temp1 * (expm1(a1 * gRandom->Uniform())));
166  } else {
167  z = z0 / gRandom->Uniform();
168  }
169 
170  //Bounds on t
171  double y = rme2s * z;
172  double q0 = eb * y;
173  double temp1 = pb * pb - eb * q0;
174  double temp2 = temp1 * temp1 - rme2 - q0 * q0;
175 
176  //If temp2<0 (very very rare): set weight to 0
177  if (temp2 < 0.0) {
178  B2WARNING("BBBrem: y too large: delta_t^2 = " << temp2 << " !!!");
179  weight = 0.0;
180  } else {
181  double tmin = -2.0 * (temp1 + sqrt(temp2));
182  double tmax = rme2 * s * y * y / tmin;
183 
184  //Generate t
185  double sy = s * y;
186  double w2 = sy + rme2;
187  temp1 = sy + tmax;
188  double rlamx = sqrt(temp1 * temp1 - 4.0 * w2 * tmax);
189 
190  if (temp1 <= 0.0) {
191  temp1 = rlamx - temp1;
192  } else {
193  temp1 = -4.0 * w2 * tmax / (rlamx + temp1);
194  }
195 
196  double t = 0.0;
197  do {
198  double b;
199 // b = exp(gRandom->Uniform() * log(1.0 + 2.0 * sy / temp1));
200 // Expression 'log(1 + x)' is replaced by 'log1p(x)' to avoid loss of precision.
201  b = exp(gRandom->Uniform() * log1p(2.0 * sy / temp1));
202  t = -b * z * z * rme2 / ((b - 1) * (b * z + b - 1));
203  } while (t <= tmin);
204 
205  //Generate cgam
206  double rlam = sqrt((sy - t) * (sy - t) - 4 * rme2 * t);
207  double eps = 4 * rme2 * w2 / (rlam * (rlam + w2 + rme2 - t));
208  double rl = log((2 + eps) / eps);
209 // double vgam = eps * (exp(gRandom->Uniform() * rl) - 1.0);
210 // Expression 'exp(x) - 1' is replaced by 'expm1(x)' to avoid loss of precision.
211  double vgam = eps * (expm1(gRandom->Uniform() * rl));
212  double cgam = 1.0 - vgam;
213  double sgam = sqrt(vgam * (2 - vgam));
214 
215  //Generate azimuthal angles
216  double phi = twopi * gRandom->Uniform();
217  double phig = twopi * gRandom->Uniform();
218 
219  //Construct momentum transfer q(mu)
220  double ql = (2.0 * eb * q0 - t) * rin2pb;
221  double qt = sqrt((tmax - t) * (t - tmin)) * rin2pb;
222  double q[4];
223  q[0] = qt * sin(phi);
224  q[1] = qt * cos(phi);
225  q[2] = ql;
226  q[3] = q0;
227 
228  //Construct momentum of outgoing positron in lab frame
229  q2[0] = q1[0] - q[0];
230  q2[1] = q1[1] - q[1];
231  q2[2] = q1[2] - q[2];
232  q2[3] = q1[3] - q[3];
233 
234  //Find euler angles of p1(mu) in cm frame
235  double r0 = eb + q0;
236  double w = sqrt(w2);
237  double rin2w = 0.5 / w;
238  double rinr0w = 1.0 / (r0 + w);
239  double eta = -(sy + 2 * w * q0 + t) * rin2w * rinr0w;
240  double phat1 = -q[0] * (1 + eta);
241  double phat2 = -q[1] * (1 + eta);
242  double phat3 = pb * eta - ql * (1 + eta);
243  double phatl = rlam * rin2w;
244  double phatt = sqrt(phat1 * phat1 + phat2 * phat2);
245  double sfhat = phat1 / phatt;
246  double cfhat = phat2 / phatt;
247  double sthat = phatt / phatl;
248  double vthat;
249  if (phat3 > 0.0) {
250  vthat = sthat * sthat / (1 - sqrt(1 - sthat * sthat));
251  } else {
252  vthat = sthat * sthat / (1 + sqrt(1 - sthat * sthat));
253  }
254  double cthat = vthat - 1.0;
255 
256  //Rotate using these euler angles to get the qk direction in the cm
257  double sfg = sin(phig);
258  double cfg = cos(phig);
259  temp1 = sgam * sfg;
260  temp2 = cthat * sgam * cfg + sthat * cgam;
261  double veg = vthat + vgam - vthat * vgam - sthat * sgam * cfg;
262  double qkhat[4];
263  qkhat[3] = sy * rin2w;
264  qkhat[0] = qkhat[3] * (cfhat * temp1 + sfhat * temp2);
265  qkhat[1] = qkhat[3] * (-sfhat * temp1 + cfhat * temp2);
266  qkhat[2] = qkhat[3] * (veg - 1.0);
267 
268  //Boost the photon momentum to the lab frame
269  temp1 = pb * qkhat[2];
270  if (temp1 > 0.0) {
271  temp2 = (rme2 * qkhat[3] * qkhat[3] + pb * pb * (qkhat[0] * qkhat[0] + qkhat[1] * qkhat[1])) / (eb * qkhat[3] + temp1);
272  } else {
273  temp2 = eb * qkhat[3] - temp1;
274  }
275 
276  qk[3] = (temp2 + qkhat[3] * q[3] + qkhat[0] * q[0] + qkhat[1] * q[1] + qkhat[2] * q[2]) / w;
277  temp1 = (qk[3] + qkhat[3]) * rinr0w;
278  qk[0] = qkhat[0] + temp1 * q[0];
279  qk[1] = qkhat[1] + temp1 * q[1];
280  qk[2] = qkhat[2] + temp1 * (-pb + ql);
281 
282  //Construct p2 by momentum conservation
283  p2[0] = -q2[0] - qk[0];
284  p2[1] = -q2[1] - qk[1];
285  p2[2] = -q2[2] - qk[2];
286  p2[3] = -q2[3] - qk[3] + m_cmsEnergy;
287 
288  //Impose cut on the photon energy: qk[3]>eb*rk0
289  if (qk[3] < eb * m_photonEFrac) {
290  weight = 0.0;
291  } else {
292  //The event is now accepted: compute matrix element and weight
293  //Compute fudge factor c1
294 // double c1 = log(1 + z) / log((2 + eps) / eps);
295 // Expression 'log(1 + x)' is replaced by 'log1p(x)' to avoid loss of precision.
296  double c1 = log1p(z) / log((2.0 + eps) / eps);
297 
298  //Compute fudge factor c2
299  temp1 = sy - tmax;
300  double vnumx = sqrt(temp1 * temp1 - 4.0 * rme2 * tmax) + temp1;
301  temp1 = sy + tmax;
302 
303  double vdenx;
304  if (temp1 < 0.0) {
305  vdenx = sqrt(temp1 * temp1 - 4.0 * w2 * tmax) - temp1;
306  } else {
307  vdenx = -4.0 * w2 * tmax / (sqrt(temp1 * temp1 - 4.0 * w2 * tmax) + temp1);
308  }
309  temp1 = sy - tmin;
310  double vnumn = sqrt(temp1 * temp1 - 4.0 * rme2 * tmin) + temp1;
311  temp1 = sy + tmin;
312 
313  double vdenn;
314  if (temp1 < 0.0) {
315  vdenn = sqrt(temp1 * temp1 - 4.0 * w2 * tmin) - temp1;
316  } else {
317  vdenn = -4.0 * w2 * tmin / (sqrt(temp1 * temp1 - 4.0 * w2 * tmin) + temp1);
318  }
319  double c2 = 2.0 * rls / log((vnumx * vdenn) / (vdenx * vnumn));
320 
321  //Compute vector (small) r in cm frame, and (big) z
322  double rlabl = (t - 2.0 * rme2 * y) * rin2pb;
323  double rhat4 = -(2.0 * rme2 * y + (1 - y) * t) * rin2w;
324  double etar = rhat4 * rinr0w;
325  double rhat1 = -q[0] * (1 + etar);
326  double rhat2 = -q[1] * (1 + etar);
327  double rhat3 = rlabl + (pb - ql) * etar;
328  double zz = s * (rhat4 * qkhat[3] - rhat1 * qkhat[0] - rhat2 * qkhat[1] - rhat3 * qkhat[2]);
329 
330  //The other invariants
331  double s1 = 4.0 * eb * (eb - qk[3]);
332  double d1 = sy * rlam * (eps + vgam) * rin2w * rin2w;
333  double d2 = 0.5 * sy;
334 
335  //The exact matrix element
336  //Kleiss-burkhardt cross section multiplied by t^2
337  double rind1 = 1.0 / d1;
338  double rind12 = rind1 * rind1;
339  double rind2 = 1.0 / d2;
340  double rind22 = rind2 * rind2;
341  temp1 = s + t - 2 * d2;
342  temp2 = s1 + t + 2 * d1;
343  double aa0 = (s * s + s1 * s1 + temp1 * temp1 + temp2 * temp2) * rind1 * rind2 * (-t);
344  double aa1 = -4.0 * rme2 * zz * zz * rind12 * rind22;
345  double aa2 = -8.0 * rme2 * (d1 * d1 + d2 * d2) * rind1 * rind2;
346  double aa3 = 16.0 * rme2 * rme2 * (d1 - d2) * zz * rind12 * rind22;
347  double aa4 = -16.0 * rme2 * rme2 * rme2 * (d1 - d2) * (d1 - d2) * rind12 * rind22;
348  double rmex = aa0 + aa1 + aa2 + aa3 + aa4;
349 
350  //The approximate matrix element without c1,2, multiplied by t^2
351  double rmap = 4.0 * s * s * rind1 * rind2 * (-t) * c1 * c2;
352 
353  //The weight
354  weight = rmex / rmap * sigapp;
355 
356  //Isnan check (not sure if this is ok)
357  if (std::isnan(weight)) {
358  B2WARNING("BBBrem: Weight is nan! Setting the weight to zero.");
359  weight = 0.0;
360  }
361 
362 
363  //========================================================
364  // beam size effect (or density effect)
365  // ref: arxiv:hep-ph/9401333
366 
367  // tc = (hbarc/simga_y)^2
368 // double tc = 1.68e-17; //SuperKEKB LER (sigma_y*=48nm)
369  //double tc = 9.81e-18; //SuperKEKB HER (sigma_y*=63nm)
370  double tc = m_densityCorrectionParameter;
371 // int cutflag = 0 ; // 0: no cut, 1: hard cut, 2: soft cut
372  if (m_densityCorrectionMode == 1) {
373  if (abs(t) < tc) weight = 0.0;
374  } else if (m_densityCorrectionMode == 2) {
375  if (t != tc) weight *= t * t / (t - tc) / (t - tc); // t<0<tc, always t!=tc
376  }
377  //========================================================
378 
379  }
380  }
381 }

◆ generateEvent()

double generateEvent ( MCParticleGraph mcGraph,
TVector3  vertex,
TLorentzRotation  boost 
)

Generates one single event.

Parameters
mcGraphReference to the MonteCarlo graph into which the generated particles will be stored.
Returns
Returns the weight of the event.

Definition at line 82 of file BBBrem.cc.

◆ getCrossSection()

double getCrossSection ( )
inline

Returns the total cross section of the generated process in millibarn.

Returns
The total cross section.

Definition at line 106 of file BBBrem.h.

108 { return m_crossSectionOver; }

◆ getCrossSectionError()

double getCrossSectionError ( )
inline

Returns the error on the total cross section of the generated process in millibarn.

Returns
The error on the total cross section.

Definition at line 111 of file BBBrem.h.

◆ getCrossSectionErrorOver()

double getCrossSectionErrorOver ( )
inline

Returns the error on the total overweight bias cross section of the generated process in millibarn.

Returns
The error on the total overweight bias cross section.

Definition at line 121 of file BBBrem.h.

◆ getCrossSectionOver()

double getCrossSectionOver ( )
inline

Returns the total overweight bias cross section of the generated process in millibarn.

Returns
The total overweight bias cross section.

Definition at line 116 of file BBBrem.h.

◆ getMaxWeightDelivered()

double getMaxWeightDelivered ( )
inline

Returns the maximum weight given by the BBBrem generation.

Returns
The maximum weight given by the BBBrem generation.

Definition at line 126 of file BBBrem.h.

◆ getSumWeightDelivered()

double getSumWeightDelivered ( )
inline

Returns the sum of all weights returned by the BBBrem generation.

Returns
The sum of all weights returned by the BBBrem generation.

Definition at line 131 of file BBBrem.h.

◆ init()

void init ( double  cmsEnergy,
double  minPhotonEFrac,
bool  unweighted = true,
double  maxWeight = 2000.0,
int  densitymode = 1,
double  densityparameter = 1.68e-17 
)

Initializes the generator.

@cmsEnergy The center of mass energy in [GeV]. @minPhotonEFrac The minimum photon energy fraction. The min. photon energy is this fraction * beam energy. @unweighted Set to true to generate unweighted events (e.g. for detector simulation), set to false for weighted events. @maxWeight The maximum weight. Only required in the case of unweighted events.

Definition at line 23 of file BBBrem.cc.

◆ storeParticle()

void storeParticle ( MCParticleGraph mcGraph,
const double *  mom,
int  pdg,
TVector3  vertex,
TLorentzRotation  boost,
bool  isVirtual = false,
bool  isInitial = false 
)
protected

Store a single generated particle into the MonteCarlo graph.

Parameters
mcGraphReference to the MonteCarlo graph into which the particle should be stored.
momThe 3-momentum of the particle in [GeV].
vtxThe vertex of the particle in [mm].
pdgThe PDG code of the particle.
isVirtualIf the particle is a virtual particle, such as the incoming particles, set this to true.
isInitialIf the particle is a initial particle for ISR, set this to true.

Definition at line 384 of file BBBrem.cc.

Member Data Documentation

◆ m_eventCount

int m_eventCount
protected

Internal event counter.

Used to calculate the cross-section.

Definition at line 141 of file BBBrem.h.

◆ m_maxWeight

double m_maxWeight
protected

The maximum weight.

Used for the event rejection procedure to produce unweighted events.

Definition at line 145 of file BBBrem.h.

◆ m_weightCount

long m_weightCount
protected

Internal weighted event counter.

Used to calculate the cross-section.

Definition at line 143 of file BBBrem.h.

◆ m_weightCountOver

long m_weightCountOver
protected

Internal overweighted event counter.

Used to calculate the cross-section.

Definition at line 144 of file BBBrem.h.

◆ twopi

constexpr double twopi = 2.0 * M_PI
staticconstexprprivate

2*pi.

To keep things short.

Definition at line 182 of file BBBrem.h.


The documentation for this class was generated from the following files:
Belle2::BBBrem::ac
double ac
variable
Definition: BBBrem.h:194
Belle2::BBBrem::m_photonEFrac
double m_photonEFrac
Minimum photon energy fraction.
Definition: BBBrem.h:152
Belle2::BBBrem::pb
double pb
variable
Definition: BBBrem.h:197
Belle2::BBBrem::m_densityCorrectionParameter
double m_densityCorrectionParameter
Density correction parameter tc.
Definition: BBBrem.h:160
Belle2::BBBrem::rme2s
double rme2s
variable
Definition: BBBrem.h:189
Belle2::BBBrem::m_crossSectionOver
double m_crossSectionOver
The overweight bias cross-section in millibarns.
Definition: BBBrem.h:156
Belle2::BBBrem::a1
double a1
variable
Definition: BBBrem.h:192
Belle2::BBBrem::q2
double q2[4]
variable
Definition: BBBrem.h:202
Belle2::BBBrem::m_densityCorrectionMode
int m_densityCorrectionMode
Mode for bunch density correction.
Definition: BBBrem.h:159
Belle2::BBBrem::q1
double q1[4]
variable
Definition: BBBrem.h:201
Belle2::BBBrem::z0
double z0
variable
Definition: BBBrem.h:191
Belle2::BBBrem::eb
double eb
variable
Definition: BBBrem.h:196
Belle2::BBBrem::p2
double p2[4]
variable
Definition: BBBrem.h:200
Belle2::BBBrem::rin2pb
double rin2pb
variable
Definition: BBBrem.h:198
Belle2::BBBrem::rme2
double rme2
variable
Definition: BBBrem.h:188
Belle2::BBBrem::rls
double rls
variable
Definition: BBBrem.h:190
Belle2::BBBrem::s
double s
variable
Definition: BBBrem.h:187
Belle2::BBBrem::weight
double weight
variable
Definition: BBBrem.h:204
Belle2::BBBrem::twopi
static constexpr double twopi
2*pi.
Definition: BBBrem.h:182
Belle2::BBBrem::m_cmsEnergy
double m_cmsEnergy
Center of mass energy (sqrt(s)).
Definition: BBBrem.h:151
Belle2::BBBrem::qk
double qk[4]
variable
Definition: BBBrem.h:203
Belle2::BBBrem::sigapp
double sigapp
variable
Definition: BBBrem.h:195