96 const double r_04_00 = 0.674;
97 const double cos_delta = 0.925;
98 for(
int ii = 0; ii < 100; ++ii){
100 const double R = (1./
epsilon)*r_04_00/(1.-r_04_00);
101 for(
int jj = 0; jj < 200; ++jj){
104 for(
int kk = 0; kk < 200; ++kk){
107 double this_test = std::pow(std::sin(theta),2.)*(1+epsilon*
cos(2.*psi)) + 2.*epsilon*R*std::pow(
std::cos(theta),2.)
108 +std::sqrt(2.*epsilon*(1+epsilon))*cos_delta*std::sin(2.*theta)*
std::cos(psi);
109 if(this_test > max_bin)
131 double dW,
dY, xw,xy,xtest;
165 double px0,
double py0,
double pz0,
167 double& px1,
double& py1,
double& pz1,
168 double& px2,
double& py2,
double& pz2,
175 double betax,betay,betaz;
176 double mdec1=0.0,mdec2=0.0;
177 double E1=0.0,E2=0.0;
185 cout<<
" ERROR: W="<<W<<endl;
190 pmag = (W*W - mdec2*mdec2)/(2.0*W);
194 cout<<
" ERROR: W="<<W<<endl;
199 pmag = sqrt(W*W/4. - mdec2*mdec2);
212 px1 = sin(theta)*
cos(phi)*pmag;
213 py1 = sin(theta)*sin(phi)*pmag;
214 pz1 =
cos(theta)*pmag;
219 Ecm = sqrt(W*W+px0*px0+py0*py0+pz0*pz0);
220 E1 = sqrt(mdec1*mdec1+px1*px1+py1*py1+pz1*pz1);
221 E2 = sqrt(mdec2*mdec2+px2*px2+py2*py2+pz2*pz2);
230 transform (betax,betay,betaz,E1,px1,py1,pz1,iFbadevent);
231 transform (betax,betay,betaz,E2,px2,py2,pz2,iFbadevent);
249 const double parentMass = W;
252 const double daughterMass = getDaughterMass(ipid);
253 if (parentMass < 4 * daughterMass){
254 cout <<
" ERROR: W=" << parentMass <<
" GeV too small" << endl;
260 const double parentEnergy = sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]
261 + parentMass * parentMass);
262 const lorentzVector parentVec(p[0], p[1], p[2], parentEnergy);
265 assert(_phaseSpaceGen);
266 static bool firstCall =
true;
268 const double m[4] = {daughterMass, daughterMass, daughterMass, daughterMass};
269 _phaseSpaceGen->setDecay(4, m);
271 _phaseSpaceGen->setMaxWeight(1.01 * _phaseSpaceGen->estimateMaxWeight(_VMWmax));
276 if (!_phaseSpaceGen->generateDecayAccepted(parentVec))
280 for (
unsigned int i = 0; i < 4; ++i)
281 decayVecs[i] = _phaseSpaceGen->daughter(i);
287 double& e_g1,
double& px_g1,
double& py_g1,
double& pz_g1,
288 double& e_g2,
double& px_g2,
double& py_g2,
double& pz_g2,
293 double betax,betay,betaz;
294 double E1=0.0,E2=0.0;
300 pmag = sqrt(m_pi0*m_pi0/4.);
311 px_g1 = sin(theta)*
cos(phi)*pmag;
312 py_g1 = sin(theta)*sin(phi)*pmag;
313 pz_g1 =
cos(theta)*pmag;
318 Ecm = sqrt(m_pi0*m_pi0+px_pi0*px_pi0+py_pi0*py_pi0+pz_pi0*pz_pi0);
319 E1 = sqrt(px_g1*px_g1+py_g1*py_g1+pz_g1*pz_g1);
320 E2 = sqrt(px_g2*px_g2+py_g2*py_g2+pz_g2*pz_g2);
322 betax = -(px_pi0/Ecm);
323 betay = -(py_pi0/Ecm);
324 betaz = -(pz_pi0/Ecm);
326 transform (betax,betay,betaz,E1,px_g1,py_g1,pz_g1,iFbadevent);
327 transform (betax,betay,betaz,E2,px_g2,py_g2,pz_g2,iFbadevent);
399 default: cout<<
"No daughtermass defined, gammaavectormeson::getdaughtermass"<<endl;
416 while(xtest > dndtheta){
430 dndtheta = sin(theta)*(1 + r_04_00+( 1-3.*r_04_00 )*
cos(theta)*
cos(theta));
436 dndtheta= sin(theta)*(1 - r_04_00+( 3.*r_04_00-1 )*
cos(theta)*
cos(theta));
439 default:
if(!
_backwardsProduction) cout<<
"No proper theta dependence defined, check gammaavectormeson::gettheta"<<endl;
444 dndtheta = sin(theta);
455 double m2 = 0.6*(W*W);
461 R = (Q2+
m2)*(Q2+m2)*R*R/
m2;
462 return epsilon*R/(1+epsilon*
R);
488 double &Y,
double &E,
double &px,
double &py,
double &pz,
489 double &t_px,
double &t_py,
double &t_pz,
double &t_E,
490 double &e_phi,
int &tcheck)
495 double Epom,Pom_pz,tmin,
pt2,phi1,phi2;
497 double xt,xtest,ytest;
500 double target_px, target_py, target_pz, target_E;
507 px1 = gamma_pt*
cos(phi1);
508 py1 = gamma_pt*sin(phi1);
510 double betax_cm = ((px1+target_px)/(Egam+target_E));
511 double betay_cm = ((py1+target_py)/(Egam+target_E));
512 double betaz_cm = ((gamma_pz+target_pz)/(Egam+target_E));
513 transform (betax_cm,betay_cm,betaz_cm,target_E,target_px,target_py,target_pz,isbadevent);
514 transform (betax_cm,betay_cm,betaz_cm,Egam, px1, py1, gamma_pz, isbadevent);
520 Epom = 0.5*(W*W+Q2)/(Egam + target_E);
531 double ttest = xtest*xtest;
535 if( ytest > yprob )
goto L613vm;
541 double Wgammap = 0.0;
550 if(
N0 <= 1 )cout<<
" ATTENTION: Using user defined value of bslope = "<<
_bslopeVal<<endl;
554 Wgammap = sqrt(4.*Egam*_pEnergy);
555 bslope_tdist = 4.63 + 4.*0.164*log(Wgammap/90.0);
556 if(
N0 <= 1 )cout<<
" ATTENTION: Using energy dependent value of bslope!"<<endl;
559 cout<<
" Undefined setting for BSLOPE_DEFINITION "<<endl;
564 t2 = (-1./bslope_tdist)*log(xtest);
572 cout<<
" WARNING: tmin= "<<tmin<<endl;
573 cout<<
" Y = "<<Y<<
" W = "<<W<<
" Epom = "<<Epom<<
" gamma = "<<
_VMgamma_em<<endl;
574 cout<<
" Will pick a new W,Y "<<endl;
584 std::cout<<
"Can't find the electron for eX"<<std::endl;
595 std::cout<<
"Can't find the electron for eX"<<std::endl;
596 if( xtest > comp )
goto L663vm;
602 t_px = pt2*
cos(phi2);
603 t_py = pt2*sin(phi2);
606 double newion_E = target_E-Epom;
607 double newion_px = target_px - t_px;
608 double newion_py = target_py - t_py;
610 if(newion_pz_squared<0)
goto L522vm;
611 double newion_pz = -sqrt( newion_pz_squared );
612 Pom_pz = target_pz - newion_pz;
621 pz = gamma_pz + t_pz;
623 transform (-betax_cm,-betay_cm,-betaz_cm,target_E,target_px,target_py,target_pz,isbadevent);
624 transform (-betax_cm,-betay_cm,-betaz_cm,newion_E,newion_px,newion_py,newion_pz,isbadevent);
625 transform (-betax_cm,-betay_cm,-betaz_cm,Egam, px1, py1, gamma_pz, isbadevent);
626 transform (-betax_cm,-betay_cm,-betaz_cm,E, px, py, pz, isbadevent);
627 t_px = target_px-newion_px;
628 t_py = target_py-newion_py;
629 t_pz = target_pz-newion_pz;
630 t_E = target_E-newion_E;
631 Y = 0.5*std::log( (E+fabs(pz))/(E-fabs(pz)) );
637 double is_proton_E = target_E;
638 double is_proton_px = target_px;
639 double is_proton_py = target_py;
640 double is_proton_pz = target_pz;
641 double is_gamma_E = Egam;
642 double is_gamma_px = px1;
643 double is_gamma_py = py1;
644 double is_gamma_pz = gamma_pz;
645 double is_tot_E = is_proton_E + is_gamma_E;
646 double is_tot_px = is_proton_px + is_gamma_px;
647 double is_tot_py = is_proton_py + is_gamma_py;
648 double is_tot_pz = is_proton_pz + is_gamma_pz;
650 double fs_proton_E = newion_E;
651 double fs_proton_px = newion_px;
652 double fs_proton_py = newion_py;
653 double fs_proton_pz = newion_pz;
656 double fs_vm_px = px;
657 double fs_vm_py = py;
658 double fs_vm_pz = pz;
661 double betax_cm = (is_tot_px/is_tot_E);
662 double betay_cm = (is_tot_py/is_tot_E);
663 double betaz_cm = (is_tot_pz/is_tot_E);
664 transform (betax_cm,betay_cm,betaz_cm,is_proton_E,is_proton_px,is_proton_py,is_proton_pz,isbadevent);
665 transform (betax_cm,betay_cm,betaz_cm,is_gamma_E, is_gamma_px, is_gamma_py, is_gamma_pz, isbadevent);
666 transform (betax_cm,betay_cm,betaz_cm,fs_proton_E,fs_proton_px,fs_proton_py,fs_proton_pz,isbadevent);
667 transform (betax_cm,betay_cm,betaz_cm,fs_vm_E, fs_vm_px, fs_vm_py, fs_vm_pz, isbadevent);
669 double u_fs_proton_px = -1.0*fs_proton_px;
670 double u_fs_proton_py = -1.0*fs_proton_py;
671 double u_fs_proton_pz = -1.0*fs_proton_pz;
672 double u_fs_proton_E = fs_proton_E;
674 double u_fs_vm_px = -1.0*fs_vm_px;
675 double u_fs_vm_py = -1.0*fs_vm_py;
676 double u_fs_vm_pz = -1.0*fs_vm_pz;
677 double u_fs_vm_E = fs_vm_E;
679 betax_cm = -1.0*betax_cm;
680 betay_cm = -1.0*betay_cm;
681 betaz_cm = -1.0*betaz_cm;
682 transform (betax_cm,betay_cm,betaz_cm,is_proton_E, is_proton_px, is_proton_py, is_proton_pz, isbadevent);
683 transform (betax_cm,betay_cm,betaz_cm,is_gamma_E, is_gamma_px, is_gamma_py, is_gamma_pz, isbadevent);
684 transform (betax_cm,betay_cm,betaz_cm,u_fs_proton_E,u_fs_proton_px,u_fs_proton_py,u_fs_proton_pz,isbadevent);
685 transform (betax_cm,betay_cm,betaz_cm,u_fs_vm_E, u_fs_vm_px, u_fs_vm_py, u_fs_vm_pz, isbadevent);
692 t_px=-u_fs_proton_px;
693 t_py=-u_fs_proton_py;
694 t_pz=is_proton_pz-u_fs_proton_pz;
695 t_E =is_proton_E-u_fs_proton_E;
704 Y = 0.5*std::log( (E+fabs(pz))/(E-fabs(pz)) );
720 double ereds =0.,Cm=0.,Coef=0.,
x=0.,pp=0.,test=0.,
u=0.;
721 double singleformfactorCm=0.,singleformfactorpp1=0.,singleformfactorpp2=0.;
730 if( E < 0.0005 )
return Cm;
829 double dY=0.,yleft=0.,yfract=0.,xpt=0.,
pt1=0.,ptfract=0.,pt=0.,
pt2=0.,
theta=0.;
875 for(j=0;j<_VMNPT+1;j++){
896 pt=yfract*
pt2+(1-yfract)*
pt1;
904 E = sqrt(W*W+pt*pt)*cosh(Y);
905 pz = sqrt(W*W+pt*pt)*sinh(Y);
915 double pT = sqrt(px*px + py*py);
916 double p = sqrt(pz*pz + pT*pT);
917 double eta = -99.9;
if((p-pz) != 0){eta = 0.5*log((p+pz)/(p-pz));}
924 cout<<
"Reading in luminosity tables. Gammaanarrowvm()"<<endl;
926 cout<<
"Creating and calculating crosssection. Gammaanarrowvm()"<<endl;
942 cout<<
"Reading in luminosity tables. Gammaainkoherentvm()"<<endl;
944 cout<<
"Creating and calculating crosssection. Gammaaincoherentvm()"<<endl;
960 cout<<
"Reading in luminosity tables. Gammaawidevm()"<<endl;
962 cout<<
"Creating and calculating crosssection. Gammaawidevm()"<<endl;
978 cout<<
"Reading in luminosity tables. e_Gammaanarrowvm()"<<endl;
980 cout<<
"Creating and calculating crosssection. e_Gammaanarrowvm()"<<endl;
996 cout<<
"Reading in luminosity tables. e_Gammaawidevm()"<<endl;
998 cout<<
"Creating and calculating crosssection. e_Gammaawidevm()"<<endl;
1013 double &Q2,
double &gamma_pz,
double &gamma_pt,
1014 double &E_prime,
double &theta_e
1018 double xw,xEgamma, xQ2, xtest, q2test;
1026 bool pick_state =
false;
1028 while( pick_state ==
false ){
1042 std::pair< double, std::vector<double> > this_energy =
_g_EQ2array->operator[](IGamma);
1043 double intgrated_q2 = this_energy.first;
1046 if( xtest > intgrated_q2 ){
1053 std::vector<double> photon_flux = this_energy.second;
1054 double VMQ2min = photon_flux[0];
1055 double VMQ2max = photon_flux[1];
1057 double ratio = std::log(VMQ2max/VMQ2min);
1058 double ln_min = std::log(VMQ2min);
1061 Q2 = std::exp(ln_min+xQ2*ratio);
1064 double Q2_bin_0_1 = std::exp(ln_min+1*ratio/
_VMnumQ2) - (std::exp(ln_min+0*ratio/
_VMnumQ2));
1065 double x_1 = std::exp(ln_min+IQ2*ratio/
_VMnumQ2);
1066 double x_2 = std::exp(ln_min+(1+IQ2)*ratio/
_VMnumQ2);
1067 double x_3 = std::exp(ln_min+(2+IQ2)*ratio/
_VMnumQ2);
1068 double scale_max = 0.0001;
1069 for(
int ii = 0; ii <
_VMnumQ2; ii++){
1070 double x_2_ii = std::exp(ln_min+(1+ii)*ratio/_VMnumQ2);
1071 double x_1_ii = std::exp(ln_min+ii*ratio/_VMnumQ2);
1072 if((photon_flux[ii+2]*(x_2_ii-x_1_ii)/Q2_bin_0_1 )>scale_max){
1073 scale_max = (photon_flux[ii+2]*(x_2_ii-x_1_ii)/Q2_bin_0_1);
1076 double y_1 = photon_flux[IQ2+2] *(x_2-x_1)/Q2_bin_0_1/scale_max;
1077 double y_2 = photon_flux[IQ2+3] *(x_3-x_2)/Q2_bin_0_1/scale_max;
1078 double m = (y_2 - y_1)/(x_2 - x_1);
1079 double c = y_1-m*x_1;
1089 double cos_theta_e = 1. - Q2/(2.*
_eEnergy*E_prime);
1090 theta_e = acos(cos_theta_e);
1092 else {theta_e = sqrt(Q2/(
_eEnergy*E_prime));}
1094 gamma_pt = E_prime*sin(theta_e);
1096 double pz_squared = targetEgamma*targetEgamma + Q2 - gamma_pt*gamma_pt;
1097 if( pz_squared < 0 )
1099 double temp_pz = sqrt(pz_squared);
1101 gamma_pz = temp_pz*cosh(beam_y) - targetEgamma*sinh(beam_y);
1102 cmsEgamma = targetEgamma*cosh(beam_y) - temp_pz*sinh(beam_y);
1129 double comenergy = 0.;
1130 double rapidity = 0.;
1133 double momx=0.,momy=0.,momz=0.;
1134 double targetEgamma = 0, cmsEgamma = 0 ;
1135 double gamma_pz = 0 , gamma_pt = 0, e_theta = 0;
1136 double px2=0.,px1=0.,py2=0.,py1=0.,pz2=0.,pz1=0.;
1137 double e_E=0., e_phi=0;
1138 double t_px =0, t_py=0., t_pz=0, t_E;
1139 bool accepted =
false;
1142 Q2, gamma_pz, gamma_pt,
1145 momenta(comenergy,cmsEgamma, Q2, gamma_pz, gamma_pt,
1146 rapidity, E, momx, momy, momz,
1147 t_px, t_py, t_pz, t_E,
1152 double col_polarization = (1 - col_y)/(1-col_y+col_y*col_y/2.);
1158 twoBodyDecay(ipid,comenergy,momx,momy,momz,spin_element,
1159 px1,py1,pz1,px2,py2,pz2,iFbadevent);
1160 double pt1chk = sqrt(px1*px1+py1*py1);
1161 double pt2chk = sqrt(px2*px2+py2*py2);
1189 if (iFbadevent==0&&tcheck==0) {
1204 if ( ipid == 11 || ipid == 13 ){
1207 }
else if (ipid == 22){
1217 double e_px = e_ptot*sin(e_theta)*
cos(e_phi);
1218 double e_py = e_ptot*sin(e_theta)*sin(e_phi);
1219 double e_pz = e_ptot*
cos(e_theta);
1221 event.addSourceElectron(electron);
1227 (
gamma).Boost(boostVector);
1228 event.addGamma(gamma, targetEgamma, Q2);
1232 if(isOmegaNeutralDecay){
1234 double e_gamma1,px_gamma1,py_gamma1,pz_gamma1,e_gamma2,px_gamma2,py_gamma2,pz_gamma2;
1235 double Ed1 = sqrt(px1*px1+py1*py1+pz1*pz1);
1237 event.addParticle(particle1);
1239 pi0Decay(px2,py2,pz2,e_gamma1,px_gamma1,py_gamma1,pz_gamma1,e_gamma2,px_gamma2,py_gamma2,pz_gamma2,iFbadevent);
1242 event.addParticle(particle2);
1243 event.addParticle(particle3);
1246 double Ed1 = sqrt(md*md+px1*px1+py1*py1+pz1*pz1);
1248 event.addParticle(particle1);
1250 double Ed2 = sqrt(md*md+px2*px2+py2*py2+pz2*pz2);
1252 event.addParticle(particle2);
1259 double t_var = t_E*t_E - t_px*t_px - t_py*t_py - t_pz*t_pz;
1260 event.addScatteredTarget(target, t_var);
1267 ostringstream tag1, tag2;
1270 string to_ret = tag1.str()+
","+tag2.str();