10 #include "HEPEVT_struct.h"
11 #include "PhotosUtilities.h"
15 using namespace Photospp;
48 return Photos::IPHQRK_setQarknoEmission(0,i) && (i<= 41 || i>100)
50 && i != 2101 && i !=3101 && i !=3201
51 && i != 1103 && i !=2103 && i !=2203
52 && i != 3103 && i !=3203 && i !=3303;
73 double PHINT(
int IDUM){
76 double EPS1[4],EPS2[4],PH[4],PL[4];
80 double XNUM1,XNUM2,XDENO,XC1,XC2;
88 PH[K-i]= pho.phep[pho.nhep-i][K-i];
101 for( K=pho.jdahep[1-i][1-i]; K<=pho.nhep-i;K++){
105 for( L=1;L<=4;L++) PL[L-i]=pho.phep[K-i][L-i];
109 XC1 = - PHOCHA(pho.idhep[K-i]) *
110 ( PL[1-i]*EPS1[1-i] + PL[2-i]*EPS1[2-i] + PL[3-i]*EPS1[3-i] ) /
111 ( PH[4-i]*PL[4-i] - PH[1-i]*PL[1-i] - PH[2-i]*PL[2-i] - PH[3-i]*PL[3-i] );
113 XC2 = - PHOCHA(pho.idhep[K-i]) *
114 ( PL[1-i]*EPS2[1-i] + PL[2-i]*EPS2[2-i] + PL[3-i]*EPS2[3-i] ) /
115 ( PH[4-i]*PL[4-i] - PH[1-i]*PL[1-i] - PH[2-i]*PL[2-i] - PH[3-i]*PL[3-i] );
122 XDENO = XDENO + XC1*XC1 + XC2*XC2;
125 PHINT2=(XNUM1*XNUM1 + XNUM2*XNUM2) / XDENO;
151 double PHINT1(
int IDUM){
164 double MPASQR,XX,BETA;
167 double &COSTHG =phophs.costhg;
168 double &XPHOTO =phophs.xphoto;
170 double &MCHSQR = phomom.mchsqr;
171 double &MNESQR = phomom.mnesqr;
176 for(K=pho.jdahep[1-i][2-i]; K>=pho.jdahep[1-i][1-i];K--){
177 if(pho.idhep[K-i]!=22){
184 IFINT= pho.nhep>IDENT;
186 IFINT= IFINT && (IDENT-pho.jdahep[1-i][1-i])==1;
188 IFINT= IFINT && pho.idhep[pho.jdahep[1-i][1-i]-i] == -pho.idhep[IDENT-i];
190 IFINT= IFINT && PHOCHA(pho.idhep[IDENT-i]) != 0;
193 MPASQR = pho.phep[1-i][5-i]*pho.phep[1-i][5-i];
194 XX=4.0*MCHSQR/MPASQR*(1.0-XPHOTO)/(1.0-XPHOTO+(MCHSQR-MNESQR)/MPASQR)/(1.0-XPHOTO+(MCHSQR-MNESQR)/MPASQR);
196 PHINT = 2.0/(1.0+COSTHG*COSTHG*BETA*BETA);
225 double PHINT2(
int IDUM){
236 double &COSTHG =phophs.costhg;
237 double &XPHOTO =phophs.xphoto;
238 double &MCHSQR = phomom.mchsqr;
239 double &MNESQR = phomom.mnesqr;
242 double MPASQR,XX,BETA,pq1[4],pq2[4],pphot[4];
243 double SS,PP2,PP,E1,E2,q1,q2,costhe,PHINT;
249 for(K=pho.jdahep[1-i][2-i]; K>=pho.jdahep[1-i][1-i];K--){
250 if(pho.idhep[K-i]!=22){
257 IFINT= pho.nhep>IDENT;
259 IFINT= IFINT&&(IDENT-pho.jdahep[1-i][1-i])==1;
263 IFINT= IFINT&&fabs(PHOCHA(pho.idhep[IDENT-i]))>0.01;
265 IFINT= IFINT&&fabs(PHOCHA(pho.idhep[pho.jdahep[1-i][1-i]-i]))>0.01;
268 MPASQR = pho.phep[1-i][5-i]*pho.phep[1-i][5-i];
269 XX=4.0*MCHSQR/MPASQR*(1.0-XPHOTO)/pow(1.-XPHOTO+(MCHSQR-MNESQR)/MPASQR,2);
271 PHINT = 2.0/(1.0+COSTHG*COSTHG*BETA*BETA);
272 SS =MPASQR*(1.0-XPHOTO);
273 PP2=((SS-MCHSQR-MNESQR)*(SS-MCHSQR-MNESQR)-4*MCHSQR*MNESQR)/SS/4;
275 E1 =sqrt(PP2+MCHSQR);
276 E2 =sqrt(PP2+MNESQR);
277 PHINT= (E1+E2)*(E1+E2)/((E2+COSTHG*PP)*(E2+COSTHG*PP)+(E1-COSTHG*PP)*(E1-COSTHG*PP));
280 q1=PHOCHA(pho.idhep[pho.jdahep[1-i][1-i]-i]);
281 q2=PHOCHA(pho.idhep[IDENT-i]);
283 pq1[k-i]=pho.phep[pho.jdahep[1-i][1-i]-i][k-i];
284 pq2[k-i]=pho.phep[pho.jdahep[1-i][1-i]+1-i][k-i];
285 pphot[k-i]=pho.phep[pho.nhep-i][k-i];
287 costhe=(pphot[1-i]*pq1[1-i]+pphot[2-i]*pq1[2-i]+pphot[3-i]*pq1[3-i]);
288 costhe=costhe/sqrt(pq1[1-i]*pq1[1-i]+pq1[2-i]*pq1[2-i]+pq1[3-i]*pq1[3-i]);
289 costhe=costhe/sqrt(pphot[1-i]*pphot[1-i]+pphot[2-i]*pphot[2-i]+pphot[3-i]*pphot[3-i]);
297 PHINT= pow(q1*(E2+COSTHG*PP)-q2*(E1-COSTHG*PP),2)/(q1*q1*(E2+COSTHG*PP)*(E2+COSTHG*PP)+q2*q2*(E1-COSTHG*PP)*(E1-COSTHG*PP));
301 PHINT= pow(q1*(E1-COSTHG*PP)-q2*(E2+COSTHG*PP),2)/(q1*q1*(E1-COSTHG*PP)*(E1-COSTHG*PP)+q2*q2*(E2+COSTHG*PP)*(E2+COSTHG*PP));
339 const char eq80[81] =
"================================================================================";
340 const char X29[30] =
" ";
341 const char X23[24 ]=
" ";
342 const char X1[2] =
" ";
343 const char X2[3] =
" ";
344 const char X3[4] =
" ";
345 const char X4[5] =
" ";
346 const char X6[7] =
" ";
347 const char X7[8] =
" ";
348 FILE *PHLUN = stdout;
350 for(I=0;I<5;I++) SUMVEC[I]=0.0;
353 fprintf(PHLUN,
"%s",eq80);
354 fprintf(PHLUN,
"%s Event No.: %10i\n",X29,hep.nevhep);
355 fprintf(PHLUN,
"%s Particle Parameters\n",X6);
356 fprintf(PHLUN,
"%s Nr %s Type %s Parent(s) %s Daughter(s) %s Px %s Py %s Pz %s E %s Inv. M.\n",X1,X3,X3,X2,X6,X7,X7,X7,X4);
357 for(I=1;I<=hep.nhep;I++){
360 if (hep.jdahep[I-i][1-i]==0){
362 SUMVEC[J-i]=SUMVEC[J-i]+hep.phep[I-i][J-i];
364 if (hep.jmohep[I-i][2-i]==0){
365 fprintf(PHLUN,
"%4i %7i %s %4i %s Stable %9.2f %9.2f %9.2f %9.2f %9.2f\n" , I,hep.idhep[I-i],X3,hep.jmohep[I-i][1-i],X7,hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i]);
368 fprintf(PHLUN,
"%4i %7i %4i - %4i %s Stable %9.2f %9.2f %9.2f %9.2f %9.2f\n",I,hep.idhep[I-i],hep.jmohep[I-i][1-i],hep.jmohep[I-i][2-i], X4,hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i]);
372 if(hep.jmohep[I-i][2-i]==0){
373 fprintf(PHLUN,
"%4i %7i %s %4i %s %4i - %4i %9.2f %9.2f %9.2f %9.2f %9.2f\n" , I,hep.idhep[I-i],X3,hep.jmohep[I-i][1-i],X2,hep.jdahep[I-i][1-i],hep.jdahep[I-i][2-i],hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i]);
376 fprintf(PHLUN,
"%4i %7i %4i - %4i %4i - %4i %9.2f %9.2f %9.2f %9.2f %9.2f\n", I,hep.idhep[I-i],hep.jmohep[I-i][1-i],hep.jmohep[I-i][2-i],hep.jdahep[I-i][1-i],hep.jdahep[I-i][2-i],hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i]);
380 SUMVEC[5-i]=sqrt(SUMVEC[4-i]*SUMVEC[4-i]-SUMVEC[1-i]*SUMVEC[1-i]-SUMVEC[2-i]*SUMVEC[2-i]-SUMVEC[3-i]*SUMVEC[3-i]);
381 fprintf(PHLUN,
"%s Vector Sum: %9.2f %9.2f %9.2f %9.2f %9.2f\n",X23,SUMVEC[1-i],SUMVEC[2-i],SUMVEC[3-i],SUMVEC[4-i],SUMVEC[5-i]);
421 void PHLUPAB(
int IPOINT){
422 char name[12] =
"/PH_HEPEVT/";
424 static int IPOIN0=-5;
427 FILE *PHLUN = stdout;
431 phlupy.ipoin =IPOIN0;
432 phlupy.ipoinm=400001;
435 if (IPOINT<=phlupy.ipoinm||IPOINT>=phlupy.ipoin )
return;
436 if ((
int)phnum.iev<1000){
437 for(I=1; I<=5;I++) SUM[I-i]=0.0;
439 fprintf(PHLUN,
"EVENT NR= %i WE ARE TESTING %s at IPOINT=%i \n",(
int)phnum.iev,name,IPOINT);
440 fprintf(PHLUN,
" ID p_x p_y p_z E m ID-MO_DA1 ID-MO_DA2\n");
442 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i],hep.jdahep[I-i][1-i],hep.jdahep[I-i][2-i]);
444 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i],hep.jdahep[I-i][1-i],hep.jdahep[I-i][2-i]);
445 fprintf(PHLUN,
" \n");
446 for(I=3;I<=hep.nhep;I++){
447 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[I-i][1-i],hep.phep[I-i][2-i],hep.phep[I-i][3-i],hep.phep[I-i][4-i],hep.phep[I-i][5-i],hep.jmohep[I-i][1-i],hep.jmohep[I-i][2-i]);
448 for(J=1;J<=4;J++) SUM[J-i]=SUM[J-i]+hep.phep[I-i][J-i];
452 SUM[5-i]=sqrt(fabs(SUM[4-i]*SUM[4-i]-SUM[1-i]*SUM[1-i]-SUM[2-i]*SUM[2-i]-SUM[3-i]*SUM[3-i]));
453 fprintf(PHLUN,
" SUM %14.9f %14.9f %14.9f %14.9f %14.9f\n",SUM[1-i],SUM[2-i],SUM[3-i],SUM[4-i],SUM[5-i]);
491 void PHLUPA(
int IPOINT){
492 char name[9] =
"/PHOEVT/";
494 static int IPOIN0=-5;
497 FILE *PHLUN = stdout;
501 phlupy.ipoin =IPOIN0;
502 phlupy.ipoinm=400001;
505 if (IPOINT<=phlupy.ipoinm||IPOINT>=phlupy.ipoin )
return;
506 if ((
int)phnum.iev<1000){
507 for(I=1; I<=5;I++) SUM[I-i]=0.0;
509 fprintf(PHLUN,
"EVENT NR= %i WE ARE TESTING %s at IPOINT=%i \n",(
int)phnum.iev,name,IPOINT);
510 fprintf(PHLUN,
" ID p_x p_y p_z E m ID-MO_DA1 ID-MO_DA2\n");
512 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[I-i][1-i],pho.phep[I-i][2-i],pho.phep[I-i][3-i],pho.phep[I-i][4-i],pho.phep[I-i][5-i],pho.jdahep[I-i][1-i],pho.jdahep[I-i][2-i]);
514 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[I-i][1-i],pho.phep[I-i][2-i],pho.phep[I-i][3-i],pho.phep[I-i][4-i],pho.phep[I-i][5-i],pho.jdahep[I-i][1-i],pho.jdahep[I-i][2-i]);
515 fprintf(PHLUN,
" \n");
516 for(I=3;I<=pho.nhep;I++){
517 fprintf(PHLUN,
"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[I-i][1-i],pho.phep[I-i][2-i],pho.phep[I-i][3-i],pho.phep[I-i][4-i],pho.phep[I-i][5-i],pho.jmohep[I-i][1-i],pho.jmohep[I-i][2-i]);
518 for(J=1;J<=4;J++) SUM[J-i]=SUM[J-i]+pho.phep[I-i][J-i];
522 SUM[5-i]=sqrt(fabs(SUM[4-i]*SUM[4-i]-SUM[1-i]*SUM[1-i]-SUM[2-i]*SUM[2-i]-SUM[3-i]*SUM[3-i]));
523 fprintf(PHLUN,
" SUM %14.9f %14.9f %14.9f %14.9f %14.9f\n",SUM[1-i],SUM[2-i],SUM[3-i],SUM[4-i],SUM[5-i]);
549 for( L=hep.jdahep[hep.jmohep[hep.nhep-i][1-i]-i][1-i];L<=hep.jdahep[hep.jmohep[hep.nhep-i][1-i]-i][2-i];L++){
551 tofrom.QQ[K-i]=tofrom.QQ[K-i]+hep.phep[L-i][K-i];
554 tofrom.XM =tofrom.QQ[4-i]*tofrom.QQ[4-i]-tofrom.QQ[3-i]*tofrom.QQ[3-i]-tofrom.QQ[2-i]*tofrom.QQ[2-i]-tofrom.QQ[1-i]*tofrom.QQ[1-i];
555 if(tofrom.XM>0.0) tofrom.XM=sqrt(tofrom.XM);
556 if(tofrom.XM<=0.0)
return;
558 for(L=1;L<=hep.nhep;L++){
560 PP[K-i]=hep.phep[L-i][K-i];
562 bostdq(1,tofrom.QQ,PP,RR);
564 hep.phep[L-i][K-i]=RR[K-i];
570 if(fabs(hep.phep[1-i][1-i])+fabs(hep.phep[1-i][2-i])>0.0) tofrom.fi1=PHOAN1(hep.phep[1-i][1-i],hep.phep[1-i][2-i]);
571 if(fabs(hep.phep[1-i][1-i])+fabs(hep.phep[1-i][2-i])+fabs(hep.phep[1-i][3-i])>0.0)
572 tofrom.th1=PHOAN2(hep.phep[1-i][3-i],sqrt(hep.phep[1-i][1-i]*hep.phep[1-i][1-i]+hep.phep[1-i][2-i]*hep.phep[1-i][2-i]));
574 for(L=1;L<=hep.nhep;L++){
576 RR[K-i]=hep.phep[L-i][K-i];
579 PHORO3(-tofrom.fi1,RR);
580 PHORO2(-tofrom.th1,RR);
582 hep.phep[L-i][K-i]=RR[K-i];
597 if(tofrom.XM<=0.0)
return;
600 for(L=1;L<=hep.nhep;L++){
602 PP[K-i]=hep.phep[L-i][K-i];
605 PHORO2( tofrom.th1,PP);
606 PHORO3( tofrom.fi1,PP);
607 bostdq(-1,tofrom.QQ,PP,RR);
610 hep.phep[L-i][K-i]=RR[K-i];
668 void PHOTOS_MAKE_C(
int IPARR){
670 int IPPAR,I,J,NLAST,MOTHER;
683 if ((hep.jdahep[IPPAR-i][1-i]==0)||(hep.jmohep[hep.jdahep[IPPAR-i][1-i]-i][1-i]!=IPPAR))
return;
702 for(I=NLAST+1;I<=hep.nhep;I++){
705 MOTHER=hep.jmohep[I-i][1-i];
706 hep.jdahep[MOTHER-i][2-i]=I;
708 hep.vhep[I-i][J-i]=hep.vhep[I-1-i][J-i];
746 void PHCORK(
int MODCOR){
748 double M,P2,PX,PY,PZ,E,EN,XMS;
750 FILE *PHLUN = stdout;
755 static double MCUT=0.4;
762 fprintf(PHLUN,
"Message from PHCORK(MODCOR):: initialization\n");
763 if(MODOP==1) fprintf(PHLUN,
"MODOP=1 -- no corrections on event: DEFAULT\n");
764 else if(MODOP==2) fprintf(PHLUN,
"MODOP=2 -- corrects Energy from mass\n");
765 else if(MODOP==3) fprintf(PHLUN,
"MODOP=3 -- corrects mass from Energy\n");
767 fprintf(PHLUN,
"MODOP=4 -- corrects Energy from mass to Mcut\n");
768 fprintf(PHLUN,
" and mass from energy above Mcut\n");
769 fprintf(PHLUN,
" Mcut=%6.3f GeV",MCUT);
771 else if(MODOP==5) fprintf(PHLUN,
"MODOP=5 -- corrects Energy from mass+flow\n");
774 fprintf(PHLUN,
"PHCORK wrong MODCOR=%4i\n",MODCOR);
780 if(MODOP==0&&MODCOR==0){
781 fprintf(PHLUN,
"PHCORK lack of initialization\n");
805 for( I=3;I<=pho.nhep;I++){
807 PX=PX+pho.phep[I-i][1-i];
808 PY=PY+pho.phep[I-i][2-i];
809 PZ=PZ+pho.phep[I-i][3-i];
811 P2=pho.phep[I-i][1-i]*pho.phep[I-i][1-i]+pho.phep[I-i][2-i]*pho.phep[I-i][2-i]+pho.phep[I-i][3-i]*pho.phep[I-i][3-i];
813 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
815 if (IPRINT==1)fprintf(PHLUN,
"CORRECTING ENERGY OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][4-i],EN);
817 pho.phep[I-i][4-i]=EN;
818 E = E+pho.phep[I-i][4-i];
828 for( I=3;I<=pho.nhep;I++){
829 PX=PX+pho.phep[I-i][1-i];
830 PY=PY+pho.phep[I-i][2-i];
831 PZ=PZ+pho.phep[I-i][3-i];
833 P2=pho.phep[I-i][1-i]*pho.phep[I-i][1-i]+pho.phep[I-i][2-i]*pho.phep[I-i][2-i]+pho.phep[I-i][3-i]*pho.phep[I-i][3-i];
835 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
837 if (IPRINT==1)fprintf(PHLUN,
"CORRECTING ENERGY OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][4-i],EN);
839 pho.phep[I-i][4-i]=EN;
840 E = E+pho.phep[I-i][4-i];
844 pho.phep[1-i][K-i]=0.0;
845 for( I=3;I<=pho.nhep;I++){
846 pho.phep[1-i][K-i]=pho.phep[1-i][K-i]+pho.phep[I-i][K-i];
849 XMS=sqrt(pho.phep[1-i][4-i]*pho.phep[1-i][4-i]-pho.phep[1-i][3-i]*pho.phep[1-i][3-i]-pho.phep[1-i][2-i]*pho.phep[1-i][2-i]-pho.phep[1-i][1-i]*pho.phep[1-i][1-i]);
850 pho.phep[1-i][5-i]=XMS;
858 for (I=3;I<=pho.nhep;I++){
860 PX=PX+pho.phep[I-i][1-i];
861 PY=PY+pho.phep[I-i][2-i];
862 PZ=PZ+pho.phep[I-i][3-i];
863 E = E+pho.phep[I-i][4-i];
865 P2=pho.phep[I-i][1-i]*pho.phep[I-i][1-i]+pho.phep[I-i][2-i]*pho.phep[I-i][2-i]+pho.phep[I-i][3-i]*pho.phep[I-i][3-i];
867 M=sqrt(fabs( pho.phep[I-i][4-i]*pho.phep[I-i][4-i] - P2));
869 if (IPRINT==1) fprintf(PHLUN,
"CORRECTING MASS OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][5-i],M);
871 pho.phep[I-i][5-i]=M;
882 for (I=3;I<=pho.nhep;I++){
884 PX=PX+pho.phep[I-i][1-i];
885 PY=PY+pho.phep[I-i][2-i];
886 PZ=PZ+pho.phep[I-i][3-i];
887 P2=pho.phep[I-i][1-i]*pho.phep[I-i][1-i]+pho.phep[I-i][2-i]*pho.phep[I-i][2-i]+pho.phep[I-i][3-i]*pho.phep[I-i][3-i];
888 M=sqrt(fabs( pho.phep[I-i][4-i]*pho.phep[I-i][4-i] - P2));
892 if(IPRINT==1) fprintf(PHLUN,
"CORRECTING MASS OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][5-i],M);
893 pho.phep[I-i][5-i]=M;
894 E = E+pho.phep[I-i][4-i];
898 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
899 if(IPRINT==1) fprintf(PHLUN,
"CORRECTING ENERGY OF %6i: %14.9f =>% 14.9f\n",I ,pho.phep[I-i][4-i],EN);
901 pho.phep[I-i][4-i]=EN;
902 E = E+pho.phep[I-i][4-i];
912 fprintf(PHLUN,
"CORRECTING MOTHER");
913 fprintf(PHLUN,
"PX:%14.9f =>%14.9f",pho.phep[1-i][1-i],PX-pho.phep[2-i][1-i]);
914 fprintf(PHLUN,
"PY:%14.9f =>%14.9f",pho.phep[1-i][2-i],PY-pho.phep[2-i][2-i]);
915 fprintf(PHLUN,
"PZ:%14.9f =>%14.9f",pho.phep[1-i][3-i],PZ-pho.phep[2-i][3-i]);
916 fprintf(PHLUN,
" E:%14.9f =>%14.9f",pho.phep[1-i][4-i], E-pho.phep[2-i][4-i]);
919 pho.phep[1-i][1-i]=PX-pho.phep[2-i][1-i];
920 pho.phep[1-i][2-i]=PY-pho.phep[2-i][2-i];
921 pho.phep[1-i][3-i]=PZ-pho.phep[2-i][3-i];
922 pho.phep[1-i][4-i]=E -pho.phep[2-i][4-i];
925 P2=pho.phep[1-i][1-i]*pho.phep[1-i][1-i]+pho.phep[1-i][2-i]*pho.phep[1-i][2-i]+pho.phep[1-i][3-i]*pho.phep[1-i][3-i];
926 if(pho.phep[1-i][4-i]*pho.phep[1-i][4-i]>P2){
927 M=sqrt(pho.phep[1-i][4-i]*pho.phep[1-i][4-i] - P2 );
928 if(IPRINT==1)fprintf(PHLUN,
" M: %14.9f => %14.9f\n",pho.phep[1-i][5-i],M);
929 pho.phep[1-i][5-i]=M;
964 void PHODO(
int IP,
int NCHARB,
int NEUDAU){
966 double QNEW,QOLD,EPHOTO,PMAVIR;
968 double CCOSTH,SSINTH,PVEC[4],PARNE;
969 double TH3,FI3,TH4,FI4,FI5,ANGLE;
971 double &COSTHG =phophs.costhg;
972 double &SINTHG =phophs.sinthg;
973 double &XPHOTO =phophs.xphoto;
974 double *PNEUTR = phomom.pneutr;
975 double &MNESQR = phomom.mnesqr;
978 EPHOTO=XPHOTO*pho.phep[IP-i][5-i]/2.0;
979 PMAVIR=sqrt(pho.phep[IP-i][5-i]*(pho.phep[IP-i][5-i]-2.0*EPHOTO));
982 phorest.fi1=PHOAN1(PNEUTR[1-i],PNEUTR[2-i]);
986 phorest.th1=PHOAN2(PNEUTR[3-i],sqrt(PNEUTR[1-i]*PNEUTR[1-i]+PNEUTR[2-i]*PNEUTR[2-i]));
987 PHORO3(-phorest.fi1,PNEUTR);
988 PHORO2(-phorest.th1,PNEUTR);
996 QNEW=PHOTRI(PMAVIR,PNEUTR[5-i],pho.phep[NCHARB-i][5-i]);
998 GNEUT=(QNEW*QNEW+QOLD*QOLD+MNESQR)/(QNEW*QOLD+sqrt((QNEW*QNEW+MNESQR)*(QOLD*QOLD+MNESQR)));
1001 PHOERR(4,
"PHOKIN",DATA);
1003 PARNE=GNEUT-sqrt(max(GNEUT*GNEUT-1.0,0.0));
1006 PHOBO3(PARNE,PNEUTR);
1009 pho.nhep=pho.nhep+1;
1010 pho.isthep[pho.nhep-i]=1;
1011 pho.idhep[pho.nhep-i] =22;
1013 pho.jmohep[pho.nhep-i][1-i]=IP;
1014 pho.jmohep[pho.nhep-i][2-i]=0;
1015 pho.jdahep[pho.nhep-i][1-i]=0;
1016 pho.jdahep[pho.nhep-i][2-i]=0;
1017 pho.phep[pho.nhep-i][4-i]=EPHOTO*pho.phep[IP-i][5-i]/PMAVIR;
1022 TH3=PHOAN2(CCOSTH,SSINTH);
1024 pho.phep[pho.nhep-i][1-i]=pho.phep[pho.nhep-i][4-i]*SINTHG*cos(FI3);
1025 pho.phep[pho.nhep-i][2-i]=pho.phep[pho.nhep-i][4-i]*SINTHG*sin(FI3);
1028 pho.phep[pho.nhep-i][3-i]=-pho.phep[pho.nhep-i][4-i]*COSTHG;
1029 pho.phep[pho.nhep-i][5-i]=0.0;
1032 PHORO3(-FI3,PNEUTR);
1033 PHORO3(-FI3,pho.phep[pho.nhep-i]);
1034 PHORO2(-TH3,PNEUTR);
1035 PHORO2(-TH3,pho.phep[pho.nhep-i]);
1036 ANGLE=EPHOTO/pho.phep[pho.nhep-i][4-i];
1039 PHOBO3(ANGLE,PNEUTR);
1040 PHOBO3(ANGLE,pho.phep[pho.nhep-i]);
1043 FI4=PHOAN1(PNEUTR[1-i],PNEUTR[2-i]);
1044 TH4=PHOAN2(PNEUTR[3-i],sqrt(PNEUTR[1-i]*PNEUTR[1-i]+PNEUTR[2-i]*PNEUTR[2-i]));
1046 PHORO3(FI4,pho.phep[pho.nhep-i]);
1048 for(I=2; I<=4;I++) PVEC[I-i]=0.0;
1055 PHORO2(-TH4,PNEUTR);
1056 PHORO2(-TH4,pho.phep[pho.nhep-i]);
1058 FI5=PHOAN1(PVEC[1-i],PVEC[2-i]);
1061 PHORO3(-FI5,PNEUTR);
1062 PHORO3(-FI5,pho.phep[pho.nhep-i]);
1063 PHORO2(phorest.th1,PNEUTR);
1064 PHORO2(phorest.th1,pho.phep[pho.nhep-i]);
1065 PHORO3(phorest.fi1,PNEUTR);
1066 PHORO3(phorest.fi1,pho.phep[pho.nhep-i]);
1069 if((pho.jdahep[IP-i][2-i]-pho.jdahep[IP-i][1-i])>1){
1073 LAST=pho.jdahep[IP-i][2-i];
1074 for(I=FIRST;I<=LAST;I++){
1075 if(I!=NCHARB && ( pho.jmohep[I-i][1-i]==IP)){
1078 PHORO3(-phorest.fi1,pho.phep[I-i]);
1079 PHORO2(-phorest.th1,pho.phep[I-i]);
1082 PHOBO3(PARNE,pho.phep[I-i]);
1085 PHORO3(-FI3,pho.phep[I-i]);
1086 PHORO2(-TH3,pho.phep[I-i]);
1089 PHOBO3(ANGLE,pho.phep[I-i]);
1092 PHORO3(FI4,pho.phep[I-i]);
1093 PHORO2(-TH4,pho.phep[I-i]);
1096 PHORO3(-FI5,pho.phep[I-i]);
1097 PHORO2(phorest.th1,pho.phep[I-i]);
1098 PHORO3(phorest.fi1,pho.phep[I-i]);
1105 for(J=1;J<=4;J++) pho.phep[NEUDAU-i][J-i]=PNEUTR[J-i];
1109 for (J=1;J<=3;J++) pho.phep[NCHARB-i][J-i]=-(pho.phep[pho.nhep-i][J-i]+PNEUTR[J-i]);
1110 pho.phep[NCHARB-i][4-i]=pho.phep[IP-i][5-i]-(pho.phep[pho.nhep-i][4-i]+PNEUTR[4-i]);
1138 void PHOBW(
double *WT){
1141 double EMU,MCHREN,BETA,COSTHG,MPASQR,XPH;
1143 if(abs(pho.idhep[1-i])==24 &&
1144 abs(pho.idhep[pho.jdahep[1-i][1-i]-i]) >=11 &&
1145 abs(pho.idhep[pho.jdahep[1-i][1-i]-i]) <=16 &&
1146 abs(pho.idhep[pho.jdahep[1-i][1-i]+1-i])>=11 &&
1147 abs(pho.idhep[pho.jdahep[1-i][1-i]+1-i])<=16 ){
1150 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==11 ||
1151 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==13 ||
1152 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==15 ){
1153 I=pho.jdahep[1-i][1-i];
1156 I=pho.jdahep[1-i][1-i]+1;
1159 EMU=pho.phep[I-i][4-i];
1160 MCHREN=fabs(pow(pho.phep[I-i][4-i],2)-pow(pho.phep[I-i][3-i],2)
1161 -pow(pho.phep[I-i][2-i],2)-pow(pho.phep[I-i][1-i],2));
1162 BETA=sqrt(1.0- MCHREN/ pho.phep[I-i][4-i]/pho.phep[I-i][4-i]);
1163 COSTHG=(pho.phep[I-i][3-i]*pho.phep[pho.nhep-i][3-i]+pho.phep[I-i][2-i]*pho.phep[pho.nhep-i][2-i]
1164 +pho.phep[I-i][1-i]*pho.phep[pho.nhep-i][1-i])/
1165 sqrt(pho.phep[I-i][3-i]*pho.phep[I-i][3-i]+pho.phep[I-i][2-i]*pho.phep[I-i][2-i]+pho.phep[I-i][1-i]*pho.phep[I-i][1-i])/
1166 sqrt(pho.phep[pho.nhep-i][3-i]*pho.phep[pho.nhep-i][3-i]+pho.phep[pho.nhep-i][2-i]*pho.phep[pho.nhep-i][2-i]+pho.phep[pho.nhep-i][1-i]*pho.phep[pho.nhep-i][1-i]);
1167 MPASQR=pho.phep[1-i][4-i]*pho.phep[1-i][4-i];
1168 XPH=pho.phep[pho.nhep-i][4-i];
1169 *WT=(*WT)*(1-8*EMU*XPH*(1-COSTHG*BETA)*
1170 (MCHREN+2*XPH*sqrt(MPASQR))/
1171 (MPASQR*MPASQR)/(1-MCHREN/MPASQR)/(4-MCHREN/MPASQR));
1210 double PHOFAC(
int MODE){
1211 static double FF=0.0,PRX=0.0;
1213 if(phokey.iexp)
return 1.0;
1221 if(phopro.irep==0) PRX=1.0;
1222 PRX=PRX/(1.0-phopro.probh);
1266 double PHOCORN(
double MPASQR,
double MCHREN,
int ME){
1268 double beta0,beta1,XX,YY,DATA;
1270 double &COSTHG =phophs.costhg;
1271 double &XPHMAX =phophs.xphmax;
1272 double &XPHOTO =phophs.xphoto;
1273 double &MCHSQR = phomom.mchsqr;
1274 double &MNESQR = phomom.mnesqr;
1280 XX=4.0*MCHSQR/MPASQR*(1.0-XPHOTO)/pow(1.0-XPHOTO+(MCHSQR-MNESQR)/MPASQR,2);
1282 S1=MPASQR * (1.0-XPHOTO);
1283 beta0=2*PHOTRI(1.0,sqrt(MCHSQR/MPASQR),sqrt(MNESQR/MPASQR));
1284 beta1=2*PHOTRI(1.0,sqrt(MCHSQR/S1),sqrt(MNESQR/S1));
1285 wt1= (1.0-COSTHG*sqrt(1.0-MCHREN))
1286 /((1.0+pow(1.0-XPHOTO/XPHMAX,2))/2.0)*XPHOTO;
1288 wt2= beta1/beta0*XPHOTO;
1289 wt3= beta1*beta1* (1.0-COSTHG*COSTHG) * (1.0-XPHOTO)/XPHOTO/XPHOTO
1290 /pow(1.0 +MCHSQR/S1-MNESQR/S1-beta1*COSTHG,2)/2.0;
1293 S1=MPASQR * (1.0-XPHOTO);
1294 beta0=2*PHOTRI(1.0,sqrt(MCHSQR/MPASQR),sqrt(MNESQR/MPASQR));
1295 beta1=2*PHOTRI(1.0,sqrt(MCHSQR/S1),sqrt(MNESQR/S1));
1296 wt1= (1.0-COSTHG*sqrt(1.0-MCHREN))
1297 /((1.0+pow(1.0-XPHOTO/XPHMAX,2))/2.0)*XPHOTO;
1299 wt2= beta1/beta0*XPHOTO;
1301 wt3= beta1*beta1* (1.0-COSTHG*COSTHG) * (1.0-XPHOTO)/XPHOTO/XPHOTO
1302 /pow(1.0 +MCHSQR/S1-MNESQR/S1-beta1*COSTHG,2)/2.0 ;
1303 wt3=wt3*(1-XPHOTO/XPHMAX+0.5*pow(XPHOTO/XPHMAX,2))/(1-XPHOTO/XPHMAX);
1305 phocorwt.phocorwt3=wt3;
1306 phocorwt.phocorwt2=wt2;
1307 phocorwt.phocorwt1=wt1;
1315 else if ((ME==3) || (ME==4) || (ME==5)){
1317 phwt.beta=sqrt(1.0-XX);
1318 wt1=(1.0-COSTHG*sqrt(1.0-MCHREN))/(1.0-COSTHG*phwt.beta);
1319 wt2=(1.0-XX/YY/(1.0-phwt.beta*phwt.beta*COSTHG*COSTHG))*(1.0+COSTHG*phwt.beta)/2.0;
1320 wt3=(1.0+pow(1.0-XPHOTO/XPHMAX,2)-pow(XPHOTO/XPHMAX,3))/
1321 (1.0+pow(1.0-XPHOTO/XPHMAX,2));
1325 PHOERR(6,
"PHOCORN",DATA);
1327 phwt.beta=sqrt(1.0-XX);
1328 wt1=(1.0-COSTHG*sqrt(1.0-MCHREN))/(1.0-COSTHG*phwt.beta);
1329 wt2=(1.0-XX/YY/(1.0-phwt.beta*phwt.beta*COSTHG*COSTHG))*(1.0+COSTHG*phwt.beta)/2.0;
1335 phopro.corwt=PHOCOR;
1338 PHOERR(3,
"PHOCOR",DATA);
1367 double PHOCOR(
double MPASQR,
double MCHREN,
int ME){
1371 double &COSTHG =phophs.costhg;
1372 double &XPHMAX =phophs.xphmax;
1373 double &XPHOTO =phophs.xphoto;
1374 double &MCHSQR = phomom.mchsqr;
1375 double &MNESQR = phomom.mnesqr;
1380 XX=4.0*MCHSQR/MPASQR*(1.0-XPHOTO)/pow((1.0-XPHOTO+(MCHSQR-MNESQR)/MPASQR),2);
1383 phwt.wt3=(1.0-XPHOTO/XPHMAX)/((1.0+pow((1.0-XPHOTO/XPHMAX),2))/2.0);
1386 YY=0.5*(1.0-XPHOTO/XPHMAX+1.0/(1.0-XPHOTO/XPHMAX));
1389 else if((ME==3)||(ME==4)||(ME==5)){
1391 phwt.wt3=(1.0+pow(1.0-XPHOTO/XPHMAX,2)-pow(XPHOTO/XPHMAX,3))/
1392 (1.0+pow(1.0-XPHOTO/XPHMAX,2) );
1396 PHOERR(6,
"PHOCOR",DATA);
1402 phwt.beta=sqrt(1.0-XX);
1403 phwt.wt1=(1.0-COSTHG*sqrt(1.0-MCHREN))/(1.0-COSTHG*phwt.beta);
1404 phwt.wt2=(1.0-XX/YY/(1.0-phwt.beta*phwt.beta*COSTHG*COSTHG))*(1.0+COSTHG*phwt.beta)/2.0;
1408 if(ME==1 && IscaNLO ==1){
1411 PHOC=PHOCORN(MPASQR,MCHREN,ME);
1417 phwt.wt2=phwt.wt2*PHOFAC(1);
1419 PHOC=phwt.wt1*phwt.wt2*phwt.wt3;
1424 PHOERR(3,
"PHOCOR",DATA);
1446 void PHOTWO(
int MODE){
1459 IFRAD=(pho.idhep[1-i]==21) && (pho.idhep[2-i]==21);
1460 IFRAD=IFRAD || (pho.idhep[1-i]==-pho.idhep[2-i] && abs(pho.idhep[1-i])<=6);
1461 IFRAD=IFRAD && (abs(pho.idhep[3-i])==6) && (abs(pho.idhep[4-i])==6);
1462 MPASQR= pow(pho.phep[1-i][4-i]+pho.phep[2-i][4-i],2)-pow(pho.phep[1-i][3-i]+pho.phep[2-i][3-i],2)
1463 -pow(pho.phep[1-i][2-i]+pho.phep[2-i][2-i],2)-pow(pho.phep[1-i][1-i]+pho.phep[2-i][1-i],2);
1464 IFRAD=IFRAD && (MPASQR>0.0);
1468 pho.phep[1-i][I-i]=pho.phep[1-i][I-i]+pho.phep[2-i][I-i];
1470 pho.phep[1-i][5-i]=sqrt(MPASQR);
1473 pho.phep[2-i][I-i]=0.0;
1575 void PHOIN(
int IP,
bool *BOOST,
int *NHEP0){
1576 int FIRST,LAST,I,LL,IP2,J,NA;
1579 int &nhep0 = *NHEP0;
1581 double &GAM =phocms.gam;
1582 double *BET = phocms.bet;
1586 FIRST=hep.jdahep[IP-i][1-i];
1587 LAST =hep.jdahep[IP-i][2-i];
1588 pho.nhep=3+LAST-FIRST+hep.nhep-nhep0;
1589 pho.nevhep=pho.nhep;
1592 pho.idhep[1-i]=hep.idhep[IP-i];
1593 pho.jdahep[1-i][1-i]=3;
1594 pho.jdahep[1-i][2-i]=3+LAST-FIRST;
1595 for(I=1;I<=5;I++) pho.phep[1-i][I-i]=hep.phep[IP-i][I-i];
1598 IP2=hep.jmohep[hep.jdahep[IP-i][1-i]-i][2-i];
1599 if((IP2!=0) && (IP2!=IP)){
1600 pho.idhep[2-i]=hep.idhep[IP2-i];
1601 pho.jdahep[2-i][1-i]=3;
1602 pho.jdahep[2-i][2-i]=3+LAST-FIRST;
1604 pho.phep[2-i][I-i]=hep.phep[IP2-i][I-i];
1608 for(I=1;I<=5;I++) pho.phep[2-i][I-i]=0.0;
1612 for(LL=0;LL<=LAST-FIRST;LL++){
1613 pho.idhep[3+LL-i]=hep.idhep[FIRST+LL-i];
1614 pho.jmohep[3+LL-i][1-i]=hep.jmohep[FIRST+LL-i][1-i];
1615 if(hep.jmohep[FIRST+LL-i][1-i]==IP) pho.jmohep[3+LL-i][1-i]=1;
1616 for(I=1;I<=5;I++) pho.phep[3+LL-i][I-i]=hep.phep[FIRST+LL-i][I-i];
1622 for(LL=1;LL<=hep.nhep-nhep0;LL++){
1623 pho.idhep[NA+LL-i]=hep.idhep[nhep0+LL-i];
1624 pho.jmohep[NA+LL-i][1-i]=hep.jmohep[nhep0+LL-i][1-i];
1625 if(hep.jmohep[nhep0+LL-i][1-i]==IP) pho.jmohep[NA+LL-i][1-i]=1;
1626 for(I=1;I<=5;I++) pho.phep[NA+LL-i][I-i]=hep.phep[nhep0+LL-i][I-i];
1630 pho.jdahep[1-i][2-i]=3+LAST-FIRST+hep.nhep-nhep0;
1632 if (pho.idhep[pho.nhep-i]==22) PHLUPA(100001);
1635 if(pho.idhep[pho.nhep-i]==22) PHLUPA(100002);
1638 if(phokey.iftop) PHOTWO(0);
1653 if((fabs(pho.phep[1-i][1-i]+fabs(pho.phep[1-i][2-i])+fabs(pho.phep[1-i][3-i]))>
1654 pho.phep[1-i][5-i]*1.E-8) && (pho.phep[1-i][5-i]!=0)){
1663 for(J=1;J<=3;J++) BET[J-i]=-pho.phep[1-i][J-i]/pho.phep[1-i][5-i];
1664 GAM=pho.phep[1-i][4-i]/pho.phep[1-i][5-i];
1665 for(I=pho.jdahep[1-i][1-i];I<=pho.jdahep[1-i][2-i];I++){
1666 PB=BET[1-i]*pho.phep[I-i][1-i]+BET[2-i]*pho.phep[I-i][2-i]+BET[3-i]*pho.phep[I-i][3-i];
1667 for(J=1;J<=3;J++) pho.phep[I-i][J-i]=pho.phep[I-i][J-i]+BET[J-i]*(pho.phep[I-i][4-i]+PB/(GAM+1.0));
1668 pho.phep[I-i][4-i]=GAM*pho.phep[I-i][4-i]+PB;
1672 PB=BET[1-i]*pho.phep[I-i][1-i]+BET[2-i]*pho.phep[I-i][2-i]+BET[3-i]*pho.phep[I-i][3-i];
1673 for(J=1;J<=3;J++) pho.phep[I-i][J-i]=pho.phep[I-i][J-i]+BET[J-i]*(pho.phep[I-i][4-i]+PB/(GAM+1.0));
1675 pho.phep[I-i][4-i]=GAM*pho.phep[I-i][4-i]+PB;
1680 if(phokey.iftop) PHOTWO(1);
1682 if(pho.idhep[pho.nhep-i]==22) PHLUPA(10000);
1706 void PHOOUT(
int IP,
bool BOOST,
int nhep0){
1707 int LL,FIRST,LAST,I;
1710 double &GAM =phocms.gam;
1711 double *BET = phocms.bet;
1714 if(pho.nhep==pho.nevhep)
return;
1721 double phocms_check = fabs(1 - GAM) + fabs(BET[1-i]) + fabs(BET[2-i]) + fabs(BET[3-i]);
1722 if( phocms_check > 0.001 ) {
1723 Log::Error() <<
"Msg. from PHOOUT: possible problems with boosting due to the rounding errors." << endl
1724 <<
"Boost parameters: ("<< GAM <<
","
1725 << BET[1-i] <<
"," << BET[2-i] <<
"," << BET[3-i] <<
")"<<endl
1726 <<
"should be equal to: (1,0,0,0) up to at least several digits." << endl;
1729 Log::Warning() <<
"Msg. from PHOOUT: possible problems with boosting due to the rounding errors." << endl
1730 <<
"Boost parameters: ("<< GAM <<
","
1731 << BET[1-i] <<
"," << BET[2-i] <<
"," << BET[3-i] <<
")"<<endl
1732 <<
"should be equal to: (1,0,0,0) up to at least several digits." << endl;
1735 for (J=pho.jdahep[1-i][1-i];J<=pho.jdahep[1-i][2-i];J++){
1736 PB=-BET[1-i]*pho.phep[J-i][1-i]-BET[2-i]*pho.phep[J-i][2-i]-BET[3-i]*pho.phep[J-i][3-i];
1737 for(K=1;K<=3;K++) pho.phep[J-i][K-i]=pho.phep[J-i][K-i]-BET[K-i]*(pho.phep[J-i][4-i]+PB/(GAM+1.0));
1738 pho.phep[J-i][4-i]=GAM*pho.phep[J-i][4-i]+PB;
1742 for(NN=pho.nevhep+1;NN<=pho.nhep;NN++){
1743 PB=-BET[1-i]*pho.phep[NN-i][1-i]-BET[2-i]*pho.phep[NN-i][2-i]-BET[3-i]*pho.phep[NN-i][3-i];
1744 for(K=1;K<=3;K++) pho.phep[NN-i][K-i]=pho.phep[NN-i][K-i]-BET[K-i]*(pho.phep[NN-i][4-i]+PB/(GAM+1.0));
1745 pho.phep[NN-i][4-i]=GAM*pho.phep[NN][4-i]+PB;
1750 FIRST=hep.jdahep[IP-i][1-i];
1751 LAST =hep.jdahep[IP-i][2-i];
1753 for(LL=0;LL<=LAST-FIRST;LL++){
1754 hep.idhep[FIRST+LL-i] = pho.idhep[3+LL-i];
1755 for(I=1;I<=5;I++) hep.phep[FIRST+LL-i][I-i] = pho.phep[3+LL-i][I-i];
1760 for (LL=1;LL<=pho.nhep-NA;LL++){
1761 hep.idhep[nhep0+LL-i] = pho.idhep[NA+LL-i];
1762 hep.isthep[nhep0+LL-i]=pho.isthep[NA+LL-i];
1763 hep.jmohep[nhep0+LL-i][1-i]=IP;
1764 hep.jmohep[nhep0+LL-i][2-i]=hep.jmohep[hep.jdahep[IP-i][1-i]-i][2-i];
1765 hep.jdahep[nhep0+LL-i][1-i]=0;
1766 hep.jdahep[nhep0+LL-i][2-i]=0;
1767 for(I=1;I<=5;I++) hep.phep[nhep0+LL-i][I-i] = pho.phep[NA+LL-i][I-i];
1769 hep.nhep=hep.nhep+pho.nhep-pho.nevhep;
1790 void PHOCHK(
int JFIRST){
1795 static int i=1, IPPAR=1;
1800 for (I=IPPAR;I<=NLAST;I++){
1801 IDABS = abs(pho.idhep[I-i]);
1803 pho.qedrad[I-i]= pho.qedrad[I-i] &&F(0,IDABS) && F(0,abs(pho.idhep[1-i]))
1804 && (pho.idhep[2-i]==0);
1806 if(I>2) pho.qedrad[I-i]=pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i];
1815 for(K=pho.jdahep[1-i][2-i];K>=pho.jdahep[1-i][1-i];K--){
1816 if(pho.idhep[K-i]!=22){
1822 IFRAD=((pho.idhep[1-i]==21) && (pho.idhep[2-i]== 21))
1823 || ((abs(pho.idhep[1-i])<=6) && (pho.idhep[2-i]==(-pho.idhep[1-i])));
1825 && (abs(pho.idhep[3-i])==6)&& (pho.idhep[4-i]==(-pho.idhep[3-i]))
1828 for(I=IPPAR;I<=NLAST;I++){
1829 pho.qedrad[I-i]=
true;
1830 if(I>2) pho.qedrad[I-i]=pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i];
1838 for (K=pho.jdahep[1-i][2-i];K>=pho.jdahep[1-i][1-i];K--){
1839 if(pho.idhep[K-i]!=22){
1844 IFRAD=((abs(pho.idhep[1-i])==6) && (pho.idhep[2-i]==0));
1846 && ( ((abs(pho.idhep[3-i])==24) && (abs(pho.idhep[4-i])== 5))
1847 || ((abs(pho.idhep[3-i])== 5) && (abs(pho.idhep[4-i])==24)) )
1851 for(I=IPPAR;I<=NLAST;I++){
1852 pho.qedrad[I-i]=
true;
1853 if(I>2) pho.qedrad[I-i] = (pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i]);
1886 void PHOENE(
double MPASQR,
double *pMCHREN,
double *pBETA,
double *pBIGLOG,
int IDENT){
1888 double PRSOFT,PRHARD;
1893 double &MCHREN = *pMCHREN;
1894 double &BETA = *pBETA;
1895 double &BIGLOG = *pBIGLOG;
1896 int &NCHAN =phoexp.nchan;
1897 double &XPHMAX =phophs.xphmax;
1898 double &XPHOTO =phophs.xphoto;
1899 double &MCHSQR = phomom.mchsqr;
1900 double &MNESQR = phomom.mnesqr;
1903 if(XPHMAX<=phocop.xphcut){
1909 MCHREN=4.0* MCHSQR/MPASQR/pow(1.0+ MCHSQR/MPASQR,2);
1910 BETA=sqrt(1.0-MCHREN);
1916 BIGLOG=log(MPASQR/ MCHSQR*(1.0+BETA)*(1.0+BETA)/4.0*
1917 pow(1.0+ MCHSQR/MPASQR,2));
1918 PRHARD=phocop.alpha/PI*(1.0/BETA*BIGLOG+2*phokey.fint)
1919 *(log(XPHMAX/phocop.xphcut)-.75+phocop.xphcut/XPHMAX-.25*phocop.xphcut*phocop.xphcut/XPHMAX/XPHMAX);
1920 PRHARD=PRHARD*PHOCHA(IDENT)*PHOCHA(IDENT)*phokey.fsec;
1924 BIGLOG=log(MPASQR/ MCHSQR*(1.0+BETA)*(1.0+BETA)/4.0*
1925 pow(1.0+ MCHSQR/MPASQR,2));
1926 PRHARD=phocop.alpha/PI*(1.0/BETA*BIGLOG)*
1927 (log(XPHMAX/phocop.xphcut)-.75+phocop.xphcut/XPHMAX-.25*phocop.xphcut*phocop.xphcut/XPHMAX/XPHMAX);
1928 PRHARD=PRHARD*PHOCHA(IDENT)*PHOCHA(IDENT)*phokey.fsec*phokey.fint;
1937 PRHARD=PRHARD/(1.0+0.75*phocop.alpha/PI);
1943 cout <<
"problem with ME_CHANNEL IDME= " << IDME << endl;
1949 if(phopro.irep==0) phopro.probh=0.0;
1954 phoexp.pro[NCHAN-i]=PRHARD+0.05*(1.0+phokey.fint);
1957 phopro.probh=PRHARD;
1961 for(K=NCHAN;K<=phoexp.NX;K++) PRSUM=PRSUM+phoexp.pro[K-i];
1962 PRHARD=PRHARD/PRSUM;
1966 PRKILL=phoexp.pro[NCHAN-i]/PRSUM-PRHARD;
1972 PRHARD=PRHARD*PHOFAC(0);
1975 phopro.probh=PRHARD;
1983 PHOERR(2,
"PHOENE",DATA);
1989 PHOERR(2,
"PHOENE",DATA);
1998 if (RRR<PRKILL) XPHOTO=-5.0;
2006 XPHOTO=XPHOTO*XPHMAX;}
2012 phopro.xf=4.0* MCHSQR*MPASQR/pow(MPASQR+ MCHSQR-MNESQR,2);
2040 void PHOPRE(
int IPARR,
double *pWT,
int *pNEUDAU,
int *pNCHARB){
2041 int CHAPOI[pho.nmxhep];
2042 double MINMAS,MPASQR,MCHREN;
2043 double EPS,DEL1,DEL2,DATA,BIGLOG;
2045 int IP,IPPAR,I,J,ME,NCHARG,NEUPOI,NLAST;
2051 int &NEUDAU = *pNEUDAU;
2052 int &NCHARB = *pNCHARB;
2053 double &COSTHG =phophs.costhg;
2054 double &SINTHG =phophs.sinthg;
2055 double &XPHOTO =phophs.xphoto;
2056 double &XPHMAX =phophs.xphmax;
2057 double *PNEUTR = phomom.pneutr;
2058 double &MCHSQR = phomom.mchsqr;
2059 double &MNESQR = phomom.mnesqr;
2071 if (pho.jdahep[IP-i][1-i]==0)
return;
2080 for (I=pho.jdahep[IP-i][1-i];I<=pho.jdahep[IP-i][2-i];I++){
2084 IDABS=abs(pho.idhep[I-i]);
2085 if (pho.qedrad[I-pho.jdahep[IP-i][1-i]+3-i]){
2086 if(PHOCHA(pho.idhep[I-i])!=0){
2088 if(NCHARG>pho.nmxhep){
2090 PHOERR(1,
"PHOTOS",DATA);
2094 MINMAS=MINMAS+pho.phep[I-i][5-i]*pho.phep[I-i][5-i];
2096 MASSUM=MASSUM+pho.phep[I-i][5-i];
2102 if ((pho.phep[IP-i][5-i]-MASSUM)/pho.phep[IP-i][5-i]>2.0*phocop.xphcut){
2108 for (J=1;J<=3;J++) PNEUTR[J-i] =-pho.phep[CHAPOI[NCHARG-i]-i][J-i];
2109 PNEUTR[4-i]=pho.phep[IP-i][5-i]-pho.phep[CHAPOI[NCHARG-i]-i][4-i];
2112 MPASQR=pho.phep[IP-i][5-i]*pho.phep[IP-i][5-i];
2113 MCHSQR=pow(pho.phep[CHAPOI[NCHARG-i]-i][5-i],2);
2114 if((pho.jdahep[IP-i][2-i]-pho.jdahep[IP-i][1-i])==1){
2115 NEUPOI=pho.jdahep[IP-i][1-i];
2116 if(NEUPOI==CHAPOI[NCHARG-i]) NEUPOI=pho.jdahep[IP-i][2-i];
2117 MNESQR=pho.phep[NEUPOI-i][5-i]*pho.phep[NEUPOI-i][5-i];
2118 PNEUTR[5-i]=pho.phep[NEUPOI-i][5-i];
2121 MNESQR=pow(PNEUTR[4-i],2)-pow(PNEUTR[1-i],2)-pow(PNEUTR[2-i],2)-pow(PNEUTR[3-i],2);
2122 MNESQR=max(MNESQR,MINMAS-MCHSQR);
2123 PNEUTR[5-i]=sqrt(MNESQR);
2128 XPHMAX=(MPASQR-pow(PNEUTR[5-i]+pho.phep[CHAPOI[NCHARG-i]-i][5-i],2))/MPASQR;
2132 PHOENE(MPASQR,&MCHREN,&phwt.beta,&BIGLOG,pho.idhep[CHAPOI[NCHARG-i]-i]);
2140 else if ((XPHOTO<phocop.xphcut) || (XPHOTO > XPHMAX)){
2145 if(NCHARG>0) phopro.irep=phopro.irep+1;
2146 if(NCHARG>0)
goto label30;
2152 EPS=MCHREN/(1.0+phwt.beta);
2163 COSTHG=(1.0-DEL1)/phwt.beta;
2164 SINTHG=sqrt(DEL1*DEL2-MCHREN)/phwt.beta;
2168 SINTHG= sqrt(1.0-COSTHG*COSTHG);
2171 if (phokey.fint>1.0){
2173 WGT=1.0/(1.0-phwt.beta*COSTHG);
2174 WGT=WGT/(WGT+phokey.fint);
2184 COSTHG=(1.0-DEL1)/phwt.beta;
2185 SINTHG=sqrt(DEL1*DEL2-MCHREN)/phwt.beta;
2191 ME=(int) (2.0*PHOSPI(pho.idhep[CHAPOI[NCHARG-i]-i])+1.0);
2196 for (I=pho.jdahep[IP-i][1-i];I<=pho.jdahep[IP-i][2-i];I++){
2197 if(I!=CHAPOI[NCHARG-i]){
2205 PHOERR(5,
"PHOKIN",DATA);
2208 NCHARB=CHAPOI[NCHARG-i];
2209 NCHARB=NCHARB-pho.jdahep[IP-i][1-i]+3;
2210 NEUDAU=NEUDAU-pho.jdahep[IP-i][1-i]+3;
2219 b=PHOCORN(MPASQR,MCHREN,ME);
2221 WT=WT/(1-XPHOTO/XPHMAX+0.5*pow(XPHOTO/XPHMAX,2))*(1-XPHOTO/XPHMAX)/2;
2225 a=PHOCOR(MPASQR,MCHREN,ME);
2226 b=PHOCORN(MPASQR,MCHREN,ME);
2228 WT=WT*phwt.wt1*phwt.wt2*phwt.wt3/phocorwt.phocorwt1/phocorwt.phocorwt2/phocorwt.phocorwt3;
2234 a=PHOCOR(MPASQR,MCHREN,ME);
2244 DATA=pho.phep[IP-i][5-i]-MASSUM;
2245 PHOERR(10,
"PHOTOS",DATA);
2274 void PHOMAK(
int IPPAR,
int NHEP0){
2288 PHOIN(IP,&BOOST,&NHEP0);
2289 PHOCHK(hep.jdahep[IP-i][1-i]);
2291 PHOPRE(1,&WT,&NEUDAU,&NCHARB);
2296 PHODO(1,NCHARB,NEUDAU);
2310 if(phokey.interf) WT=WT*PHINT(IDUM);
2311 if(phokey.ifw) PHOBW(&WT);
2320 WT=WT*PhotosMEforZ::phwtnlo();
2323 cout <<
"problem with ME_CHANNEL IDME= " << IDME << endl;
2328 WT = WT/phokey.fint;
2332 if (WT>1.0) PHOERR(3,
"WT_INT",DATA);
2335 PHOOUT(IP,BOOST,NHEP0);
2356 void PHTYPE(
int ID){
2365 int &NCHAN =phoexp.nchan;
2378 if(hep.jdahep[ID-i][1-i]==0)
return;
2396 int pho_size = max(NHEP0,(hep.jdahep[ID-i][2-i] - hep.jdahep[ID-i][1-i] + 1) +2);
2398 for(
int I = 0; I < pho_size; ++I) {
2402 double elMass=0.000511;
2403 double muMass=0.1057;
2408 switch(Photos::momentumUnit) {
2418 Log::Error()<<
"GEV or MEV unit must be set for pair emission"<<endl;
2421 PHOPAR(ID,NHEP0,11,elMass,&STRENG);
2422 PHOPAR(ID,NHEP0,13,muMass,&STRENG);
2428 for(NCHAN=1;NCHAN<=phoexp.NX;NCHAN++)
2429 phoexp.pro[NCHAN-i]=0.0;
2435 phoexp.expini=
false;
2438 for(K=1;K<=phoexp.NX;K++)PRSUM=PRSUM+phoexp.pro[K-i];
2447 for(K=1;K<=100;K++){
2453 if(SUM>1.0-phokey.expeps)
break;
2467 else if (RN>=17.0/24.0){
2471 else if(RN>=9.0/24.0){
2477 else if(phokey.itre){
2486 else if (RN>=2.0/6.0){
2490 else if(phokey.isec){
2510 PHOPAR(ID,NHEP0,11,elMass,&STRENG);
2511 PHOPAR(ID,NHEP0,13,muMass,&STRENG);
2543 void PHOPAR(
int IPARR,
int NHEP0,
int idlep,
double masslep,
double *pSTRENG) {
2544 double PCHAR[4],PNEU[4],PELE[4],PPOZ[4],BUF[4];
2550 double &STRENG = *pSTRENG;
2556 PHOIN(IPPAR,&BOOST,&NHEP0);
2557 PHOCHK(pho.jdahep[IP][0]);
2560 if(pho.jdahep[IP][0] == 0)
return;
2561 if(pho.jdahep[IP][0] == pho.jdahep[IP][1])
return;
2564 for(
int I=pho.jdahep[IP][0]-i; I <= pho.jdahep[IP][1]-i; ++I) {
2568 if( PHOCHA(pho.idhep[I]) == 0 )
continue;
2570 int IDABS = abs(pho.idhep[I]);
2575 pho.qedrad[I]= pho.qedrad[I] && F(0,IDABS) && F(0,abs(pho.idhep[1-i]))
2576 && (pho.idhep[2-i]==0);
2578 if(!pho.qedrad[I])
continue;
2582 for(
int J = 0; J < 3; ++J) {
2583 PCHAR[J] = pho.phep[I][J];
2584 PNEU [J] =-pho.phep[I][J];
2588 PNEU[3] = pho.phep[IP][3] - pho.phep[I][3];
2589 PCHAR[3] = pho.phep[I][3];
2591 double AMCH = pho.phep[I][4];
2615 bool sameflav=abs(idlep)==abs(pho.idhep[I]);
2617 if(pho.idhep[I]<0) idsign=-1;
2620 trypar(&JESLI,&STRENG,AMCH,masslep,PCHAR,PNEU,PELE,PPOZ,&sameflav);
2650 for(
int J = pho.jdahep[IP][0]-i; J <= pho.jdahep[IP][1]-i; ++J) {
2651 for(
int K = 0; K<4; ++K) {
2652 BUF[K] = pho.phep[J][K];
2654 if (J == I) partra( 1,BUF);
2655 else partra(-1,BUF);
2657 for(
int K = 0; K<4; ++K) {
2658 pho.phep[J][K] = BUF[K];
2672 pho.nhep = pho.nhep+1;
2673 pho.isthep[pho.nhep-i] = 1;
2674 pho.idhep [pho.nhep-i] = idlep*idsign;
2675 pho.jmohep[pho.nhep-i][0] = IP;
2676 pho.jmohep[pho.nhep-i][1] = 0;
2677 pho.jdahep[pho.nhep-i][0] = 0;
2678 pho.jdahep[pho.nhep-i][1] = 0;
2679 pho.qedrad[pho.nhep-i]=
false;
2682 for(
int K = 1; K<=4; ++K) {
2683 pho.phep[pho.nhep-i][K-i] = PELE[K-i];
2686 pho.phep[pho.nhep-i][4] = masslep;
2689 pho.nhep = pho.nhep+1;
2690 pho.isthep[pho.nhep-i] = 1;
2691 pho.idhep [pho.nhep-i] =-idlep*idsign;
2692 pho.jmohep[pho.nhep-i][0] = IP;
2693 pho.jmohep[pho.nhep-i][1] = 0;
2694 pho.jdahep[pho.nhep-i][0] = 0;
2695 pho.jdahep[pho.nhep-i][1] = 0;
2696 pho.qedrad[pho.nhep-i]=
false;
2698 for(
int K = 1; K<=4; ++K) {
2699 pho.phep[pho.nhep-i][K-i] = PPOZ[K-i];
2734 pho.phep[pho.nhep-i][4] = masslep;
2738 PHOOUT(IPPAR, BOOST, NHEP0);
2739 PHOIN (IPPAR,&BOOST,&NHEP0);
static bool meCorrectionWtForScalar
static double(* randomDouble)()
static void PHOBWnlo(double *WT)