8 using namespace boost::math::tools;
20 m_p_m=std::sqrt(2/(m_A*m_A)*(1+std::sqrt(1+m_A*m_A)));
22 double pmax=std::sqrt(2+2*std::sqrt(1+m_A*m_A))/m_A;
27 m_lambda_plus = -
f(m_p_plus)/
fp(m_p_plus);
28 m_lambda_minus =
f(m_p_minus)/
fp(m_p_minus);
29 m_q_plus = m_lambda_plus / (m_p_plus - m_p_minus);
30 m_q_minus = m_lambda_minus / (m_p_plus - m_p_minus);
31 m_q_m = 1- (m_q_plus + m_q_minus);
37 return p*
p*
exp(-m_A*
p*
p/(1+std::sqrt(1+
p*
p)));
42 return exp(-m_A*
p*
p/(1+std::sqrt(1+
p*
p)))*
p*(2-m_A*
p*
p/std::sqrt(1+
p*
p));
47 return log(
f(
p)/
f(m_p_m))+1.0;
54 double en, phi, theta,
p;
57 double U(0.0), V(0.0),
X(0.0),
Y(0.0),
E(0.0);
61 U = m_rndmEngine->flat();
62 V = m_rndmEngine->flat();
70 X=( 1 -
Y )*( m_p_minus + m_lambda_minus )+
Y*( m_p_plus - m_lambda_plus );
71 if(V <
f(
X) /
f(m_p_m) &&
X>0){
75 else{
if(U < m_q_m + m_q_plus){
76 E = -
log((U-m_q_m)/m_q_plus);
77 X = m_p_plus - m_lambda_plus*(1-
E);
83 E = -
log((U-(m_q_m+m_q_plus))/m_q_minus);
84 X = m_p_minus + m_lambda_minus * (1 -
E);
95 phi = 2.0*
M_PI*(m_rndmEngine->flat());
96 theta = acos(2.0*m_rndmEngine->flat()-1.0);
99 theta = acos(2.0*((
double)
rand() / RAND_MAX)-1.0);
103 en = std::sqrt(
p*
p+(this->m_m)*(this->m_m));
115 for(
unsigned n = 0;
n<
event.size();
n++){
116 p2 =
event[
n].px()*
event[
n].px() +
event[
n].py()*
event[
n].py() +
event[
n].pz()*
event[
n].pz();
117 result += std::sqrt(
a*
a*
p2 + (this->m_m)* (this->m_m));
119 return result - (this->m_Etot);
125 vector< Vec4 >
event;
129 while(sum_E<(this->m_Etot)){
130 event.push_back(this->generateFourVector());
131 sum_E += (
event.back()).
e();
135 int len =
event.size();
137 for(
int i = 1;
i<4;
i++){
140 for(
int n=0;
n<len;
n++){
145 for(
int n=0;
n<len;
n++){
164 std::cout <<
"[SUEP_SHOWER] WARNING: Failed to rebalance the following event; Printing for debug and throw exception" << std::endl;
165 std::cout <<
e.what() << std::endl;
166 std::cout <<
"N. Particle, px, py, pz, E" << std::endl;
167 for (
size_t jj=0; jj <
event.size(); jj++) {
169 std::cout << jj <<
": " <<
event[jj].px() <<
", " <<
event[jj].py() <<
", " <<
event[jj].pz() <<
", " <<
event[jj].e() << std::endl;
174 for(
int n=0;
n<len;
n++){