7 using namespace Photospp;
12 inline double xlam(
double A,
double B,
double C){
return sqrt((A-B-C)*(A-B-C)-4.0*B*C);}
14 inline double max(
double a,
double b)
16 return (a > b) ? a : b;
20 double angfi(
double X,
double Y){
22 const double PI=3.141592653589793238462643;
24 if(X==0.0 && Y==0.0)
return 0.0;
25 if(fabs(Y) < fabs(X)){
27 if(X<=0.0) THE=PI-THE;}
29 THE=acos(X/sqrt(X*X +Y*Y));
31 if(Y<0.0) THE=2*PI-THE;
35 double angxy(
double X,
double Y){
37 const double PI=3.141592653589793238462643;
39 if(X==0.0 && Y==0.0)
return 0.0;
41 if(fabs(Y) < fabs(X)){
43 if(X<=0.0) THE=PI-THE;}
45 THE=acos(X/sqrt(X*X +Y*Y));
50 void bostd3(
double EXE,
double PVEC[4],
double QVEC[4]){
57 double RPL,RMI,QPL,QMI;
65 RPL=RVEC[4-j]+RVEC[3-j];
66 RMI=RVEC[4-j]-RVEC[3-j];
71 QVEC[3-j]=(QPL-QMI)/2;
72 QVEC[4-j]=(QPL+QMI)/2;
78 void rotod3(
double ANGLE,
double PVEC[4],
double QVEC[4]){
84 CS=cos(ANGLE)*PVEC[1-j]-sin(ANGLE)*PVEC[2-j];
85 SN=sin(ANGLE)*PVEC[1-j]+cos(ANGLE)*PVEC[2-j];
95 void rotod2(
double PHI,
double PVEC[4],
double QVEC[4]){
109 QVEC[1-j]= CS*RVEC[1-j]+SN*RVEC[3-j];
111 QVEC[3-j]=-SN*RVEC[1-j]+CS*RVEC[3-j];
117 void lortra(
int KEY,
double PRM,
double PNEUTR[4],
double PNU[4],
double PAA[4],
double PP[4],
double PE[4]){
128 bostd3(PRM,PNEUTR,PNEUTR);
129 bostd3(PRM,PNU ,PNU );
130 bostd3(PRM,PAA ,PAA );
135 rotod2(PRM,PNEUTR,PNEUTR);
136 rotod2(PRM,PNU ,PNU );
137 rotod2(PRM,PAA ,PAA );
142 rotod3(PRM,PNEUTR,PNEUTR);
143 rotod3(PRM,PNU ,PNU );
144 rotod3(PRM,PAA ,PAA );
149 printf (
" STOP IN LOTRA. WRONG KEYTRA");
154 double amast(
double VEC[4]){
156 double ama= VEC[4-i]*VEC[4-i]-VEC[1-i]*VEC[1-i]-VEC[2-i]*VEC[2-i]-VEC[3-i]*VEC[3-i];
161 void spaj(
int KUDA,
double P2[4],
double Q2[4],
double PP[4],
double PE[4]){
168 if (KLUCZ==0)
return;
170 printf (
" %10i =====================SPAJ==================== \n", KUDA);
171 printf (
" P2 %18.13f %18.13f %18.13f %18.13f \n",P2[0],P2[1],P2[2],P2[3]);
172 printf (
" Q2 %18.13f %18.13f %18.13f %18.13f \n",Q2[0],Q2[1],Q2[2],Q2[3]);
173 printf (
" PE %18.13f %18.13f %18.13f %18.13f \n",PE[0],PE[1],PE[2],PE[3]);
174 printf (
" PP %18.13f %18.13f %18.13f %18.13f \n",PP[0],PP[1],PP[2],PP[3]);
176 for(
int k=0;k<=3;k++) SUM[k]=P2[k]+Q2[k]+PE[k]+PP[k];
178 printf (
"SUM %18.13f %18.13f %18.13f %18.13f \n",SUM[0],SUM[1],SUM[2],SUM[3]);
203 void partra(
int IBRAN,
double PHOT[4]){
207 rotod3(-parkin.fi0,PHOT,PHOT);
208 rotod2(-parkin.th0,PHOT,PHOT);
209 bostd3(parkin.bsta,PHOT,PHOT);
210 rotod3(-parkin.fi1,PHOT,PHOT);
211 rotod2(-parkin.th1,PHOT,PHOT);
212 rotod3(-parkin.fi2,PHOT,PHOT);
215 bostd3(parkin.parneu,PHOT,PHOT);
218 bostd3(parkin.parch,PHOT,PHOT);
221 rotod3(-parkin.fi3,PHOT,PHOT);
222 rotod2(-parkin.th3,PHOT,PHOT);
223 bostd3(parkin.bpar,PHOT,PHOT);
224 rotod3( parkin.fi4,PHOT,PHOT);
225 rotod2(-parkin.th4,PHOT,PHOT);
226 rotod3(-parkin.fi5,PHOT,PHOT);
227 rotod3( parkin.fi2,PHOT,PHOT);
228 rotod2( parkin.th1,PHOT,PHOT);
229 rotod3( parkin.fi1,PHOT,PHOT);
230 bostd3(parkin.bstb,PHOT,PHOT);
231 rotod2( parkin.th0,PHOT,PHOT);
232 rotod3( parkin.fi0,PHOT,PHOT);
237 void trypar(
bool *JESLI,
double *pSTRENG,
double AMCH,
double AMEL,
double PA[4],
double PB[4],
double PE[4],
double PP[4],
bool *sameflav){
238 double &STRENG = *pSTRENG;
240 double &FI0=parkin.fi0;
241 double &FI1=parkin.fi1;
242 double &FI2=parkin.fi2;
243 double &FI3=parkin.fi3;
244 double &FI4=parkin.fi4;
245 double &FI5=parkin.fi5;
246 double &TH0=parkin.th0;
247 double &TH1=parkin.th1;
248 double &TH3=parkin.th3;
249 double &TH4=parkin.th4;
250 double &PARNEU=parkin.parneu;
251 double &PARCH=parkin.parch;
252 double &BPAR=parkin.bpar;
253 double &BSTA=parkin.bsta;
254 double &BSTB=parkin.bstb;
256 double PNEUTR[4],PAA[4],PHOT[4],PSUM[4];
260 const double PI=3.141592653589793238462643;
261 const double ALFINV= 137.01;
264 PA[4-j]=max(PA[4-j],sqrt(PA[1-j]*PA[1-j]+PA[2-j]*PA[2-j]+PA[3-j]*PA[3-j]));
265 PB[4-j]=max(PB[4-j],sqrt(PB[1-j]*PB[1-j]+PB[2-j]*PB[2-j]+PB[3-j]*PB[3-j]));
268 for(
int k=0;k<=3;k++){
271 PSUM[k] =PA[k]+PB[k];
275 if((PAA[4-j]+PNEUTR[4-j])< 0.01 ){
276 printf (
" too small energy to emit %10.7f\n",PAA[4-j]+PNEUTR[4-j]);
285 double X1 = PSUM[1-j];
286 double X2 = PSUM[2-j];
289 X2 = sqrt(PSUM[1-j]*PSUM[1-j]+PSUM[2-j]*PSUM[2-j]);
291 spaj(-2,PNEUTR,PAA,PP,PE);
292 lortra(3,-FI0,PNEUTR,VEC,PAA,PP,PE);
293 lortra(2,-TH0,PNEUTR,VEC,PAA,PP,PE);
294 rotod3(-FI0,PSUM,PSUM);
295 rotod2(-TH0,PSUM,PSUM);
296 BSTA=(PSUM[4-j]-PSUM[3-j])/sqrt(PSUM[4-j]*PSUM[4-j]-PSUM[3-j]*PSUM[3-j]);
297 BSTB=(PSUM[4-j]+PSUM[3-j])/sqrt(PSUM[4-j]*PSUM[4-j]-PSUM[3-j]*PSUM[3-j]);
298 lortra(1,BSTA,PNEUTR,VEC,PAA,PP,PE);
299 spaj(-1,PNEUTR,PAA,PP,PE);
300 double AMNE=amast(PNEUTR);
302 if(AMCH<0.0) AMCH=AMEL;
303 if (AMNE<0.0) AMNE=0.0;
304 double AMTO =PAA[4-j]+PNEUTR[4-j];
309 if(STRENG==0.0) {*JESLI=
false;
return;}
313 *0.5*(1.0/PI/ALFINV)*(1.0/PI/ALFINV)
319 *2*log(AMTO/AMEL/2.0)
321 *log((AMTO*AMTO+2*AMCH*AMCH)/2.0/AMCH/AMCH);
323 PRHARD=PRHARD*FREJECT;
331 printf(
" stop from Photos pairs.cxx PRHARD= %18.13f \n",PRHARD);
338 if (RRR[7-j]>PRHARD){
339 STRENG=STRENG/(1.0-PRHARD);
352 double XMP=2.0*AMEL*exp(RRR[1-j]*log(AMTO/2.0/AMEL));
357 double XPmin=2.0*AMEL;
358 double XPdelta=AMTO-XPmin;
359 double XP= XPmin*exp(RRR[2-j]*log((XPdelta+XPmin)/XPmin));
361 double XMK2=(AMTO*AMTO+XMP*XMP)-2.0*AMTO*XP;
364 double eps=4.0*AMCH*AMCH/AMTO/AMTO;
365 double C1 =1.0+eps -eps*exp(RRR[3-j]*log((2+eps)/eps));
367 double FIX1=2.0*PI*RRR[4-j];
370 double C2 =1.0-2.0*RRR[5-j];
371 double FIX2=2.0*PI*RRR[6-j];
376 JESLIK= (XP <((AMTO*AMTO+XMP*XMP-(AMCH+AMNE)*(AMCH+AMNE))/2.0/AMTO));
381 JESLIK= (XMP<(AMTO-AMNE-AMCH));
385 JESLIK= (XMP<(AMTO-AMNE-AMCH))&& (XP >XMP);
391 (XMP<(AMTO-AMNE-AMCH))&&
393 (XP <((AMTO*AMTO+XMP*XMP-(AMCH+AMNE)*(AMCH+AMNE))/2.0/AMTO));
400 *JESLI=(RRR[7-j]<PRHARD) &&
401 (XMP<(AMTO-AMNE-AMCH)) &&
403 (XP <((AMTO*AMTO+XMP*XMP-(AMCH+AMNE)*(AMCH+AMNE))/2.0/AMTO));
407 *JESLI= *JESLI && XP< delta;
413 double F= (AMTO*AMTO-4.0*AMEL*AMEL)
414 /(AMTO*AMTO-4.0*AMEL*AMEL) *XMP*XMP;
418 double G= 2*AMTO*XPdelta
419 /(2*AMTO*XPdelta) *2*AMTO*XP;
424 /2.0 *(1.0+eps-C1)/2.0;
430 H=1./(0.5/H1+0.5/H2);
434 double XPMAX=(AMTO*AMTO+XMP*XMP-(AMCH+AMNE)*(AMCH+AMNE))/2.0/AMTO;
438 xlam(1.0,AMEL*AMEL/XMP/XMP, AMEL*AMEL/XMP/XMP)*
439 xlam(1.0,XMK2/AMTO/AMTO,XMP*XMP/AMTO/AMTO)*
440 xlam(1.0,AMCH*AMCH/XMK2,AMNE*AMNE/XMK2)
441 / xlam(1.0,AMCH*AMCH/AMTO/AMTO,AMNE*AMNE/AMTO/AMTO);
462 X2 = sqrt(PNEUTR[1-j]*PNEUTR[1-j]+PNEUTR[2-j]*PNEUTR[2-j]) ;
464 spaj(0,PNEUTR,PAA,PP,PE);
465 lortra(3,-FI1,PNEUTR,VEC,PAA,PP,PE);
466 lortra(2,-TH1,PNEUTR,VEC,PAA,PP,PE);
471 FI2=angfi(VEC[1-j],VEC[2-j]);
472 lortra(3,-FI2,PNEUTR,VEC,PAA,PP,PE);
473 spaj(1,PNEUTR,PAA,PP,PE);
479 double AMCH2=AMCH*AMCH;
480 double AMNE2=AMNE*AMNE;
482 double QNEW=xlam(AMTOST,AMNE2,AMCH2)/sqrt(AMTOST)/2.0;
483 double QOLD=PNEUTR[3-j];
484 double GCHAR=(QNEW*QNEW+QOLD*QOLD+AMCH*AMCH)/
485 (QNEW*QOLD+sqrt((QNEW*QNEW+AMCH*AMCH)*(QOLD*QOLD+AMCH*AMCH)));
486 double GNEU= (QNEW*QNEW+QOLD*QOLD+AMNE*AMNE)/
487 (QNEW*QOLD+sqrt((QNEW*QNEW+AMNE*AMNE)*(QOLD*QOLD+AMNE*AMNE)));
497 if(GNEU<1.||GCHAR<1.){
498 printf(
" PHOTOS TRYPAR GBOOST LT 1., LIMIT OF PHASE SPACE %18.13f %18.13f %18.13f %18.13f %18.13f %18.13f %18.13f %18.13f \n"
499 ,GNEU,GCHAR,QNEW,QOLD,AMTO,AMTOST,AMNE,AMCH);
502 PARCH =GCHAR+sqrt(GCHAR*GCHAR-1.0);
503 PARNEU=GNEU -sqrt(GNEU*GNEU -1.0);
506 bostd3(PARNEU,VEC ,VEC );
507 bostd3(PARNEU,PNEUTR,PNEUTR);
508 bostd3(PARCH,PAA ,PAA );
509 spaj(2,PNEUTR,PAA,PP,PE);
512 double PMOD=xlam(XMP*XMP,AMEL*AMEL,AMEL*AMEL)/XMP/2.0;
513 double S2=sqrt(1.0-C2*C2);
516 PP[2-j]=PMOD*S2*cos(FIX2);
517 PP[1-j]=PMOD*S2*sin(FIX2);
523 double PENE=(AMTO*AMTO-XMP*XMP-XMK2)/2.0/sqrt(XMK2);
524 double PPED=sqrt(PENE*PENE-XMP*XMP);
527 double SINTHG=sqrt(1.0-C1*C1);
531 PHOT[1-j]=PMOD*SINTHG*cos(FI3);
532 PHOT[2-j]=PMOD*SINTHG*sin(FI3);
534 PHOT[3-j]=-PMOD*COSTHG;
539 lortra(3,-FI3,PNEUTR,VEC,PAA,PP,PE);
540 rotod3(-FI3,PHOT,PHOT);
541 lortra(2,-TH3,PNEUTR,VEC,PAA,PP,PE);
542 rotod2(-TH3,PHOT,PHOT);
543 spaj(21,PNEUTR,PAA,PP,PE);
545 double PAIRB=PENE/XMP+PPED/XMP;
548 spaj(3,PNEUTR,PAA,PP,PE);
549 double GAMM=(PNEUTR[4-j]+PAA[4-j]+PP[4-j]+PE[4-j])/AMTO;
555 if( GAMM > 0.9999999 ) GAMM = 1.0;
557 printf(
"Photos::partra: GAMM = %20.18e\n",GAMM);
558 printf(
" BELOW 0.9999999 THRESHOLD!\n");
563 BPAR=GAMM-sqrt(GAMM*GAMM-1.0);
564 lortra(1, BPAR,PNEUTR,VEC,PAA,PP,PE);
565 bostd3( BPAR,PHOT,PHOT);
566 spaj(4,PNEUTR,PAA,PP,PE);
572 X2 = sqrt(PNEUTR[1-j]*PNEUTR[1-j]+PNEUTR[2-j]*PNEUTR[2-j]);
574 lortra(3, FI4,PNEUTR,VEC,PAA,PP,PE);
575 rotod3( FI4,PHOT,PHOT);
576 lortra(2,-TH4,PNEUTR,VEC,PAA,PP,PE);
577 rotod2(-TH4,PHOT,PHOT);
581 lortra(3,-FI5,PNEUTR,VEC,PAA,PP,PE);
582 rotod3(-FI5,PHOT,PHOT);
584 lortra(3, FI2,PNEUTR,VEC,PAA,PP,PE);
585 rotod3( FI2,PHOT,PHOT);
586 lortra(2, TH1,PNEUTR,VEC,PAA,PP,PE);
587 rotod2( TH1,PHOT,PHOT);
588 lortra(3, FI1,PNEUTR,VEC,PAA,PP,PE);
589 rotod3( FI1,PHOT,PHOT);
590 spaj(10,PNEUTR,PAA,PP,PE);
591 lortra(1,BSTB,PNEUTR,VEC,PAA,PP,PE);
592 lortra(2,TH0,PNEUTR,VEC,PAA,PP,PE);
593 lortra(3,FI0,PNEUTR,VEC,PAA,PP,PE);
594 spaj(11,PNEUTR,PAA,PP,PE);
599 double pq= PAA[3]*PP[3]-PAA[2]*PP[2]-PAA[1]*PP[1]-PAA[0]*PP[0];
600 pq=pq +PAA[3]*PE[3]-PAA[2]*PE[2]-PAA[1]*PE[1]-PAA[0]*PE[0];
602 double ppq= PNEUTR[3]*PP[3]-PNEUTR[2]*PP[2]-PNEUTR[1]*PP[1]-PNEUTR[0]*PP[0];
603 ppq=ppq+ PNEUTR[3]*PE[3]-PNEUTR[2]*PE[2]-PNEUTR[1]*PE[1]-PNEUTR[0]*PE[0];
604 double pq1 =PAA[3]*PP[3]-PAA[2]*PP[2]-PAA[1]*PP[1]-PAA[0]*PP[0];
605 double pq2 =PAA[3]*PE[3]-PAA[2]*PE[2]-PAA[1]*PE[1]-PAA[0]*PE[0];
607 double ppq1=PNEUTR[3]*PP[3]-PNEUTR[2]*PP[2]-PNEUTR[1]*PP[1]-PNEUTR[0]*PP[0];
608 double ppq2=PNEUTR[3]*PE[3]-PNEUTR[2]*PE[2]-PNEUTR[1]*PE[1]-PNEUTR[0]*PE[0];
610 double ppp=PNEUTR[3]*PAA[3]-PNEUTR[2]*PAA[2]-PNEUTR[1]*PAA[1]-PNEUTR[0]*PAA[0];
612 double YOT1=1./2./XMP/XMP/XMP/XMP*
613 ( 4*(pq1/pq-ppq1/ppq)*(pq2/pq-ppq2/ppq)
614 -XMP*XMP*(AMCH2/pq/pq+AMNE2/ppq/ppq-ppp/pq/ppq-ppp/pq/ppq) );
622 for(
int k=0;k<=3;k++){
623 double stored=PAA[k];
628 pq= PAA[3]*PP[3]-PAA[2]*PP[2]-PAA[1]*PP[1]-PAA[0]*PP[0];
629 pq=pq +PAA[3]*PE[3]-PAA[2]*PE[2]-PAA[1]*PE[1]-PAA[0]*PE[0];
631 ppq= PNEUTR[3]*PP[3]-PNEUTR[2]*PP[2]-PNEUTR[1]*PP[1]-PNEUTR[0]*PP[0];
632 ppq=ppq+ PNEUTR[3]*PE[3]-PNEUTR[2]*PE[2]-PNEUTR[1]*PE[1]-PNEUTR[0]*PE[0];
633 pq1 =PAA[3]*PP[3]-PAA[2]*PP[2]-PAA[1]*PP[1]-PAA[0]*PP[0];
634 pq2 =PAA[3]*PE[3]-PAA[2]*PE[2]-PAA[1]*PE[1]-PAA[0]*PE[0];
636 ppq1=PNEUTR[3]*PP[3]-PNEUTR[2]*PP[2]-PNEUTR[1]*PP[1]-PNEUTR[0]*PP[0];
637 ppq2=PNEUTR[3]*PE[3]-PNEUTR[2]*PE[2]-PNEUTR[1]*PE[1]-PNEUTR[0]*PE[0];
639 ppp=PNEUTR[3]*PAA[3]-PNEUTR[2]*PAA[2]-PNEUTR[1]*PAA[1]-PNEUTR[0]*PAA[0];
641 XMP=-(PP[0]+PE[0])*(PP[0]+PE[0])-(PP[1]+PE[1])*(PP[1]+PE[1])
642 -(PP[2]+PE[2])*(PP[2]+PE[2])+(PP[3]+PE[3])*(PP[3]+PE[3]);
646 double YOT1p=1./2./XMP/XMP/XMP/XMP*
647 ( 4*(pq1/pq-ppq1/ppq)*(pq2/pq-ppq2/ppq)
648 -XMP*XMP*(AMCH2/pq/pq+AMNE2/ppq/ppq-ppp/pq/ppq-ppp/pq/ppq) );
655 for(
int k=0;k<=3;k++){
656 double stored=PAA[k];
662 double WT=YOT1*YOT2*YOT3;
667 printf (
" from Photos pairs.cxx WT= %15.8f \n",WT);
static double(* randomDouble)()