9 #include "PH_HEPEVT_Interface.h"
10 #include "PhotosUtilities.h"
15 using namespace Photospp;
16 using namespace PhotosUtilities;
21 // Declaration of structs defined in f_Init.h
22 struct PHOSTA phosta_;
23 struct PHLUPY phlupy_;
24 struct TOFROM tofrom_;
26 struct PHOLUN pholun_;
27 struct PHOREST phorest_;
28 struct PHOCMS phocms_;
29 struct PHOMOM phomom_;
30 struct PHOPHS phophs_;
31 struct PHOCORWT phocorwt_;
32 struct PHOPRO phopro_;
33 struct PHOCOP phocop_;
35 struct PHOKEY phokey_;
36 struct PHOEXP phoexp_;
42 /** Logical function used deep inside algorithm to check if emitted
43 particles are to emit. For mother it blocks the vertex,
44 but for daughters individually: bad sisters will not prevent electron to emit.
45 top quark has further exception method. */
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;
56 // --- can be used with VARIANT A. For B use PHINT1 or 2 --------------
57 //----------------------------------------------------------------------
59 // PHINT: PHotos universal INTerference correction weight
61 // Purpose: calculates correction weight as expressed by
62 // formula (17) from CPC 79 (1994), 291.
64 // Input Parameters: Common /PHOEVT/, with photon added.
66 // Output Parameters: correction weight
68 // Author(s): Z. Was, P.Golonka Created at: 19/01/05
69 // Last Update: 23/06/13
71 //----------------------------------------------------------------------
73 double PHINT(int IDUM){
76 double EPS1[4],EPS2[4],PH[4],PL[4];
79 // DOUBLE PRECISION EMU,MCHREN,BETA,phophs_.costhg,MPASQR,XPH, XC1, XC2
80 double XNUM1,XNUM2,XDENO,XC1,XC2;
85 // Calculate polarimetric vector: ph, eps1, eps2 are orthogonal
88 PH[K-i]= pho.phep[pho.nhep-i][K-i];
101 for( K=pho.jdahep[1-i][1-i]; K<=pho.nhep-1;K++){ //! or jdahep[1-i][2-i]
103 // momenta of charged particle in PL
105 for( L=1;L<=4;L++) PL[L-i]=pho.phep[K-i][L-i];
107 // scalar products: epsilon*p/k*p
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] );
118 // accumulate the currents
122 XDENO = XDENO + XC1*XC1 + XC2*XC2;
125 PHINT2=(XNUM1*XNUM1 + XNUM2*XNUM2) / XDENO;
126 return (XNUM1*XNUM1 + XNUM2*XNUM2) / XDENO;
132 //----------------------------------------------------------------------
134 // PHINT: PHotos INTerference (Old version kept for tests only.
136 // Purpose: Calculates interference between emission of photons from
137 // different possible chaged daughters stored in
138 // the HEP common /PHOEVT/.
140 // Input Parameter: commons /PHOEVT/ /PHOMOM/ /PHOPHS/
143 // Output Parameters:
146 // Author(s): Z. Was, Created at: 10/08/93
147 // Last Update: 15/03/99
149 //----------------------------------------------------------------------
151 double PHINT1(int IDUM){
156 DOUBLE PRECISION phomom_.mchsqr,phomom_.mnesqr
158 COMMON/PHOMOM/phomom_.mchsqr,phomom_.mnesqr,PNEUTR(5)
159 DOUBLE PRECISION phophs_.costhg,SINTHG
160 REAL*8 XPHMAX,phophs_.xphoto
161 COMMON/PHOPHS/XPHMAX,phophs_.xphoto,phophs_.costhg,SINTHG
164 double MPASQR,XX,BETA;
170 for(K=pho.jdahep[1-i][2-i]; K>=pho.jdahep[1-i][1-i];K--){
171 if(pho.idhep[K-i]!=22){
177 // check if there is a photon
178 IFINT= pho.nhep>IDENT;
179 // check if it is two body + gammas reaction
180 IFINT= IFINT && (IDENT-pho.jdahep[1-i][1-i])==1;
181 // check if two body was particle antiparticle
182 IFINT= IFINT && pho.idhep[pho.jdahep[1-i][1-i]-i] == -pho.idhep[IDENT-i];
183 // check if particles were charged
184 IFINT= IFINT && PHOCHA(pho.idhep[IDENT-i]) != 0;
185 // calculates interference weight contribution
187 MPASQR = pho.phep[1-i][5-i]*pho.phep[1-i][5-i];
188 XX=4.0*phomom_.mchsqr/MPASQR*(1.0-phophs_.xphoto)/(1.0-phophs_.xphoto+(phomom_.mchsqr-phomom_.mnesqr)/MPASQR)/(1.0-phophs_.xphoto+(phomom_.mchsqr-phomom_.mnesqr)/MPASQR);
190 PHINT = 2.0/(1.0+phophs_.costhg*phophs_.costhg*BETA*BETA);
200 //----------------------------------------------------------------------
202 // PHINT: PHotos INTerference
204 // Purpose: Calculates interference between emission of photons from
205 // different possible chaged daughters stored in
206 // the HEP common /PHOEVT/.
208 // Input Parameter: commons /PHOEVT/ /PHOMOM/ /PHOPHS/
211 // Output Parameters:
214 // Author(s): Z. Was, Created at: 10/08/93
217 //----------------------------------------------------------------------
219 double PHINT2(int IDUM){
223 DOUBLE PRECISION phomom_.mchsqr,phomom_.mnesqr
225 COMMON/PHOMOM/phomom_.mchsqr,phomom_.mnesqr,PNEUTR(5)
226 DOUBLE PRECISION phophs_.costhg,SINTHG
227 REAL*8 XPHMAX,phophs_.xphoto
228 COMMON/PHOPHS/XPHMAX,phophs_.xphoto,phophs_.costhg,SINTHG
230 double MPASQR,XX,BETA,pq1[4],pq2[4],pphot[4];
231 double SS,PP2,PP,E1,E2,q1,q2,costhe,PHINT;
237 for(K=pho.jdahep[1-i][2-i]; K>=pho.jdahep[1-i][1-i];K--){
238 if(pho.idhep[K-i]!=22){
244 // check if there is a photon
245 IFINT= pho.nhep>IDENT;
246 // check if it is two body + gammas reaction
247 IFINT= IFINT&&(IDENT-pho.jdahep[1-i][1-i])==1;
248 // check if two body was particle antiparticle (we improve on it !
249 // IFINT= IFINT.AND.pho.idhep(JDAPHO(1,1)).EQ.-pho.idhep(IDENT)
250 // check if particles were charged
251 IFINT= IFINT&&fabs(PHOCHA(pho.idhep[IDENT-i]))>0.01;
252 // check if they have both charge
253 IFINT= IFINT&&fabs(PHOCHA(pho.idhep[pho.jdahep[1-i][1-i]-i]))>0.01;
254 // calculates interference weight contribution
256 MPASQR = pho.phep[1-i][5-i]*pho.phep[1-i][5-i];
257 XX=4.0*phomom_.mchsqr/MPASQR*(1.0-phophs_.xphoto)/pow(1.-phophs_.xphoto+(phomom_.mchsqr-phomom_.mnesqr)/MPASQR,2);
259 PHINT = 2.0/(1.0+phophs_.costhg*phophs_.costhg*BETA*BETA);
260 SS =MPASQR*(1.0-phophs_.xphoto);
261 PP2=((SS-phomom_.mchsqr-phomom_.mnesqr)*(SS-phomom_.mchsqr-phomom_.mnesqr)-4*phomom_.mchsqr*phomom_.mnesqr)/SS/4;
263 E1 =sqrt(PP2+phomom_.mchsqr);
264 E2 =sqrt(PP2+phomom_.mnesqr);
265 PHINT= (E1+E2)*(E1+E2)/((E2+phophs_.costhg*PP)*(E2+phophs_.costhg*PP)+(E1-phophs_.costhg*PP)*(E1-phophs_.costhg*PP));
268 q1=PHOCHA(pho.idhep[pho.jdahep[1-i][1-i]-i]);
269 q2=PHOCHA(pho.idhep[IDENT-i]);
271 pq1[k-i]=pho.phep[pho.jdahep[1-i][1-i]-i][k-i];
272 pq2[k-i]=pho.phep[pho.jdahep[1-i][1-i]+1-i][k-i];
273 pphot[k-i]=pho.phep[pho.nhep-i][k-i];
275 costhe=(pphot[1-i]*pq1[1-i]+pphot[2-i]*pq1[2-i]+pphot[3-i]*pq1[3-i]);
276 costhe=costhe/sqrt(pq1[1-i]*pq1[1-i]+pq1[2-i]*pq1[2-i]+pq1[3-i]*pq1[3-i]);
277 costhe=costhe/sqrt(pphot[1-i]*pphot[1-i]+pphot[2-i]*pphot[2-i]+pphot[3-i]*pphot[3-i]);
279 // --- this IF checks whether JDAPHO(1,1) was MCH or MNE.
280 // --- phophs_.costhg angle (and in-generation variables) may be better choice
281 // --- than costhe. note that in the formulae below amplitudes were
282 // --- multiplied by (E2+phophs_.costhg*PP)*(E1-phophs_.costhg*PP).
283 if(phophs_.costhg*costhe>0){
285 PHINT= pow(q1*(E2+phophs_.costhg*PP)-q2*(E1-phophs_.costhg*PP),2)/(q1*q1*(E2+phophs_.costhg*PP)*(E2+phophs_.costhg*PP)+q2*q2*(E1-phophs_.costhg*PP)*(E1-phophs_.costhg*PP));
289 PHINT= pow(q1*(E1-phophs_.costhg*PP)-q2*(E2+phophs_.costhg*PP),2)/(q1*q1*(E1-phophs_.costhg*PP)*(E1-phophs_.costhg*PP)+q2*q2*(E2+phophs_.costhg*PP)*(E2+phophs_.costhg*PP));
299 //*****************************************************************
300 //*****************************************************************
301 //*****************************************************************
302 // beginning of the class of methods reading from PH_HEPEVT
303 //*****************************************************************
304 //*****************************************************************
305 //*****************************************************************
308 //----------------------------------------------------------------------
310 // PHOTOS: PHOton radiation in decays event DuMP routine
312 // Purpose: Print event record.
314 // Input Parameters: Common /PH_HEPEVT/
316 // Output Parameters: None
318 // Author(s): B. van Eijk Created at: 05/06/90
319 // Last Update: 20/06/13
321 //----------------------------------------------------------------------
327 const char eq80[81] = "================================================================================";
328 const char X29[30] = " ";
329 const char X23[24 ]= " ";
330 const char X1[2] = " ";
331 const char X2[3] = " ";
332 const char X3[4] = " ";
333 const char X4[5] = " ";
334 const char X6[7] = " ";
335 const char X7[8] = " ";
336 FILE *PHLUN = stdout;
338 for(I=0;I<5;I++) SUMVEC[I]=0.0;
340 //-- Print event number...
341 fprintf(PHLUN,"%s",eq80);
342 fprintf(PHLUN,"%s Event No.: %10i\n",X29,hep.nevhep);
343 fprintf(PHLUN,"%s Particle Parameters\n",X6);
344 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);
345 for(I=1;I<=hep.nhep;I++){
347 //-- For 'stable particle' calculate vector momentum sum
348 if (hep.jdahep[I-i][1-i]==0){
350 SUMVEC[J-i]=SUMVEC[J-i]+hep.phep[I-i][J-i];
352 if (hep.jmohep[I-i][2-i]==0){
353 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]);
356 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]);
360 if(hep.jmohep[I-i][2-i]==0){
361 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]);
364 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]);
368 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]);
369 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]);
374 // 9030 FORMAT(1H ,I4,I7,3X,I4,9X,'Stable',2X,5F9.2)
375 //"%4i %7i %s %4i %s Stable %s %9.2f %9.2f %9.2f %9.2f %9.2f " X3,9X,X2
377 // 9050 FORMAT(1H ,I4,I7,3X,I4,6X,I4,' - ',I4,5F9.2)
378 //"%4i %7i %s %4i %s %4i - %4i %9.2f %9.2f %9.2f %9.2f %9.2f " X3,X6
383 //"%4i %7i %4i - %4i %s Stable %s %9.2f %9.2f %9.2f %9.2f %9.2f " X5,X2
386 //9060 FORMAT(1H ,I4,I7,I4,' - ',I4,2X,I4,' - ',I4,5F9.2)
387 //"%4i %7i %4i - %4i %s %4i - %4i %9.2f %9.2f %9.2f %9.2f %9.2f " X2,
392 //----------------------------------------------------------------------
394 // PHLUPAB: debugging tool
396 // Purpose: NONE, eventually may printout content of the
397 // /PH_HEPEVT/ common
399 // Input Parameters: Common /PH_HEPEVT/ and /PHNUM/
400 // latter may have number of the event.
402 // Output Parameters: None
404 // Author(s): Z. Was Created at: 30/05/93
405 // Last Update: 20/06/13
407 //----------------------------------------------------------------------
409 void PHLUPAB(int IPOINT){
410 char name[12] = "/PH_HEPEVT/";
412 static int IPOIN0=-5;
415 FILE *PHLUN = stdout;
418 IPOIN0=400000; // ! maximal no-print point
419 phlupy_.ipoin =IPOIN0;
420 phlupy_.ipoinm=400001; // ! minimal no-print point
423 if (IPOINT<=phlupy_.ipoinm||IPOINT>=phlupy_.ipoin ) return;
424 if ((int)phnum_.iev<1000){
425 for(I=1; I<=5;I++) SUM[I-i]=0.0;
427 fprintf(PHLUN,"EVENT NR= %i WE ARE TESTING %s at IPOINT=%i \n",(int)phnum_.iev,name,IPOINT);
428 fprintf(PHLUN," ID p_x p_y p_z E m ID-MO_DA1 ID-MO_DA2\n");
430 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[1-i][I-i],hep.phep[2-i][I-i],hep.phep[3-i][I-i],hep.phep[4-i][I-i],hep.phep[5-i][I-i],hep.jdahep[1-i][I-i],hep.jdahep[2-i][I-i]);
432 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[1-i][I-i],hep.phep[2-i][I-i],hep.phep[3-i][I-i],hep.phep[4-i][I-i],hep.phep[5-i][I-i],hep.jdahep[1-i][I-i],hep.jdahep[2-i][I-i]);
433 fprintf(PHLUN," \n");
434 for(I=3;I<=hep.nhep;I++){
435 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", hep.idhep[I-i],hep.phep[1-i][I-i],hep.phep[2-i][I-i],hep.phep[3-i][I-i],hep.phep[4-i][I-i],hep.phep[5-i][I-i],hep.jmohep[1-i][I-i],hep.jmohep[2-i][I-i]);
436 for(J=1;J<=4;J++) SUM[J-i]=SUM[J-i]+hep.phep[J-i][I-i];
440 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]));
441 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]);
446 // 10 FORMAT(1X,' ID ','p_x ','p_y ','p_z ',
448 //$ 'ID-MO_DA1','ID-MO DA2' )
449 // 20 FORMAT(1X,I4,5(F14.9),2I9)
450 //"%i4 %14.9f %14.9f %14.9f %14.9f %i9 i9"
451 // 30 FORMAT(1X,' SUM',5(F14.9))
462 //----------------------------------------------------------------------
464 // PHLUPA: debugging tool
466 // Purpose: NONE, eventually may printout content of the
469 // Input Parameters: Common /PHOEVT/ and /PHNUM/
470 // latter may have number of the event.
472 // Output Parameters: None
474 // Author(s): Z. Was Created at: 30/05/93
475 // Last Update: 21/06/13
477 //----------------------------------------------------------------------
479 void PHLUPA(int IPOINT){
480 char name[9] = "/PHOEVT/";
482 static int IPOIN0=-5;
485 FILE *PHLUN = stdout;
488 IPOIN0=400000; // ! maximal no-print point
489 phlupy_.ipoin =IPOIN0;
490 phlupy_.ipoinm=400001; // ! minimal no-print point
493 if (IPOINT<=phlupy_.ipoinm||IPOINT>=phlupy_.ipoin ) return;
494 if ((int)phnum_.iev<1000){
495 for(I=1; I<=5;I++) SUM[I-i]=0.0;
497 fprintf(PHLUN,"EVENT NR= %i WE ARE TESTING %s at IPOINT=%i \n",(int)phnum_.iev,name,IPOINT);
498 fprintf(PHLUN," ID p_x p_y p_z E m ID-MO_DA1 ID-MO_DA2\n");
500 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[1-i][I-i],pho.phep[2-i][I-i],pho.phep[3-i][I-i],pho.phep[4-i][I-i],pho.phep[5-i][I-i],pho.jdahep[1-i][I-i],pho.jdahep[2-i][I-i]);
502 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[1-i][I-i],pho.phep[2-i][I-i],pho.phep[3-i][I-i],pho.phep[4-i][I-i],pho.phep[5-i][I-i],pho.jdahep[1-i][I-i],pho.jdahep[2-i][I-i]);
503 fprintf(PHLUN," \n");
504 for(I=3;I<=pho.nhep;I++){
505 fprintf(PHLUN,"%4i %14.9f %14.9f %14.9f %14.9f %14.9f %9i %9i\n", pho.idhep[I-i],pho.phep[1-i][I-i],pho.phep[2-i][I-i],pho.phep[3-i][I-i],pho.phep[4-i][I-i],pho.phep[5-i][I-i],pho.jmohep[1-i][I-i],pho.jmohep[2-i][I-i]);
506 for(J=1;J<=4;J++) SUM[J-i]=SUM[J-i]+pho.phep[J-i][I-i];
510 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]));
511 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]);
516 // 10 FORMAT(1X,' ID ','p_x ','p_y ','p_z ',
518 //$ 'ID-MO_DA1','ID-MO DA2' )
519 // 20 FORMAT(1X,I4,5(F14.9),2I9)
520 //"%4i %14.9f %14.9f %14.9f %14.9f %9i %9i"
521 // 30 FORMAT(1X,' SUM',5(F14.9))
528 // COMMON /PH_TOFROM/ QQ[4],XM,th1,fi1
537 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++){
539 tofrom_.QQ[K-i]=tofrom_.QQ[K-i]+hep.phep[L-i][K-i];
542 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];
543 if(tofrom_.XM>0.0) tofrom_.XM=sqrt(tofrom_.XM);
544 if(tofrom_.XM<=0.0) return;
546 for(L=1;L<=hep.nhep;L++){
548 PP[K-i]=hep.phep[L-i][K-i];
550 bostdq(1,tofrom_.QQ,PP,RR);
552 hep.phep[L-i][K-i]=RR[K-i];
558 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]);
559 if(fabs(hep.phep[1-i][1-i])+fabs(hep.phep[1-i][2-i])+fabs(hep.phep[1-i][3-i])>0.0)
560 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]));
562 for(L=1;L<=hep.nhep;L++){
564 RR[K-i]=hep.phep[L-i][K-i];
567 PHORO3(-tofrom_.fi1,RR);
568 PHORO2(-tofrom_.th1,RR);
570 hep.phep[L-i][K-i]=RR[K-i];
579 // // REAL*8 QQ(4),XM,th1,fi1
580 // COMMON /PH_TOFROM/ QQ,XM,th1,fi1
585 if(tofrom_.XM<=0.0) return;
588 for(L=1;L<=hep.nhep;L++){
590 PP[K-i]=hep.phep[L-i][K-i];
593 PHORO2( tofrom_.th1,PP);
594 PHORO3( tofrom_.fi1,PP);
595 bostdq(-1,tofrom_.QQ,PP,RR);
598 hep.phep[L-i][K-i]=RR[K-i];
608 // 2) GENERAL INTERFACE:
614 // NAME USED IN SECT. # OF OC// Comment
615 // PHOQED 1) 2) 3 Flags whether emisson to be gen.
616 // PHOLUN 1) 4) 6 Output device number
617 // PHOCOP 1) 3) 4 photon coupling & min energy
618 // PHPICO 1) 3) 4) 5 PI & 2*PI
619 // PHSEED 1) 4) 3 RN seed
620 // PHOSTA 1) 4) 3 Status information
621 // PHOKEY 1) 2) 3) 7 Keys for nonstandard application
622 // PHOVER 1) 1 Version info for outside
623 // HEPEVT 2) 2 PDG common
624 // PH_HEPEVT2) 8 PDG common internal
625 // PHOEVT 2) 3) 10 PDG branch
626 // PHOIF 2) 3) 2 emission flags for PDG branch
627 // PHOMOM 3) 5 param of char-neutr system
628 // PHOPHS 3) 5 photon momentum parameters
629 // PHOPRO 3) 4 var. for photon rep. (in branch)
630 // PHOCMS 2) 3 parameters of boost to branch CMS
631 // PHNUM 4) 1 event number from outside
632 //----------------------------------------------------------------------
635 //----------------------------------------------------------------------
637 // PHOTOS_MAKE: General search routine
639 // Purpose: Search through the /PH_HEPEVT/ standard HEP common, sta-
640 // rting from the IPPAR-th particle. Whenevr branching
641 // point is found routine PHTYPE(IP) is called.
642 // Finally if calls on PHTYPE(IP) modified entries, common
643 // /PH_HEPEVT/ is ordered.
645 // Input Parameter: IPPAR: Pointer to decaying particle in
646 // /PH_HEPEVT/ and the common itself,
648 // Output Parameters: Common /PH_HEPEVT/, either with or without
649 // new particles added.
651 // Author(s): Z. Was, B. van Eijk Created at: 26/11/89
652 // Last Update: 30/08/93
654 //----------------------------------------------------------------------
656 void PHOTOS_MAKE_C(int IPARR){
658 int IPPAR,I,J,NLAST,MOTHER;
663 // write(*,*) 'at poczatek'
666 //-- Store pointers for cascade treatement...
671 //-- Check decay multiplicity and minimum of correctness..
672 if ((hep.jdahep[IPPAR-i][1-i]==0)||(hep.jmohep[hep.jdahep[IPPAR-i][1-i]-i][1-i]!=IPPAR)) return;
676 // write(*,*) 'at przygotowany'
680 //-- single branch mode
681 //-- IPPAR is original position where the program was called
683 //-- let-s do generation
687 //-- rearrange /PH_HEPEVT/ for added particles.
688 //-- at present this may be not needed as information
689 //-- is set at HepMC level.
691 for(I=NLAST+1;I<=hep.nhep;I++){
693 //-- Photon mother and vertex...
694 MOTHER=hep.jmohep[I-i][1-i];
695 hep.jdahep[MOTHER-i][2-i]=I;
697 hep.vhep[I-i][J-i]=hep.vhep[I-1-i][J-i];
701 // write(*,*) 'at po dzialaniu '
704 // write(*,*) 'at koniec'
712 //----------------------------------------------------------------------
714 // PHCORK: corrects kinmatics of subbranch needed if host program
715 // produces events with the shaky momentum conservation
717 // Input Parameters: Common /PHOEVT/, MODCOR
718 // MODCOR >0 type of action
720 // =2 corrects energy from mass
721 // =3 corrects mass from energy
722 // =4 corrects energy from mass for
723 // particles up to .4 GeV mass,
724 // for heavier ones corrects mass,
725 // =5 most complete correct also of mother
726 // often necessary for exponentiation.
729 // Output Parameters: corrected /PHOEVT/
731 // Author(s): P.Golonka, Z. Was Created at: 01/02/99
732 // Modified : 07/07/13
733 //----------------------------------------------------------------------
735 void PHCORK(int MODCOR){
737 double M,P2,PX,PY,PZ,E,EN,XMS;
739 FILE *PHLUN = stdout;
744 static double MCUT=0.4;
751 fprintf(PHLUN,"Message from PHCORK(MODCOR):: initialization\n");
752 if(MODOP==1) fprintf(PHLUN,"MODOP=1 -- no corrections on event: DEFAULT\n");
753 else if(MODOP==2) fprintf(PHLUN,"MODOP=2 -- corrects Energy from mass\n");
754 else if(MODOP==3) fprintf(PHLUN,"MODOP=3 -- corrects mass from Energy\n");
756 fprintf(PHLUN,"MODOP=4 -- corrects Energy from mass to Mcut\n");
757 fprintf(PHLUN," and mass from energy above Mcut\n");
758 fprintf(PHLUN," Mcut=%6.3f GeV",MCUT);
760 else if(MODOP==5) fprintf(PHLUN,"MODOP=5 -- corrects Energy from mass+flow\n");
763 fprintf(PHLUN,"PHCORK wrong MODCOR=%4i\n",MODCOR);
769 if(MODOP==0&&MODCOR==0){
770 fprintf(PHLUN,"PHCORK lack of initialization\n");
785 // -----------------------
786 // In this case we do nothing
790 // -----------------------
791 // lets loop thru all daughters and correct their energies
792 // according to E^2=p^2+m^2
794 for( I=3;I<=pho.nhep;I++){
796 PX=PX+pho.phep[I-i][1-i];
797 PY=PY+pho.phep[I-i][2-i];
798 PZ=PZ+pho.phep[I-i][3-i];
800 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];
802 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
804 if (IPRINT==1)fprintf(PHLUN,"CORRECTING ENERGY OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][4-i],EN);
806 pho.phep[I-i][4-i]=EN;
807 E = E+pho.phep[I-i][4-i];
813 // -----------------------
814 //C lets loop thru all daughters and correct their energies
815 //C according to E^2=p^2+m^2
817 for( I=3;I<=pho.nhep;I++){
818 PX=PX+pho.phep[I-i][1-i];
819 PY=PY+pho.phep[I-i][2-i];
820 PZ=PZ+pho.phep[I-i][3-i];
822 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];
824 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
826 if (IPRINT==1)fprintf(PHLUN,"CORRECTING ENERGY OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][4-i],EN);
828 pho.phep[I-i][4-i]=EN;
829 E = E+pho.phep[I-i][4-i];
833 pho.phep[1-i][K-i]=0.0;
834 for( I=3;I<=pho.nhep;I++){
835 pho.phep[1-i][K-i]=pho.phep[1-i][K-i]+pho.phep[I-i][K-i];
838 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]);
839 pho.phep[1-i][5-i]=XMS;
842 // -----------------------
844 // lets loop thru all daughters and correct their masses
845 // according to E^2=p^2+m^2
847 for (I=3;I<=pho.nhep;I++){
849 PX=PX+pho.phep[I-i][1-i];
850 PY=PY+pho.phep[I-i][2-i];
851 PZ=PZ+pho.phep[I-i][3-i];
852 E = E+pho.phep[I-i][4-i];
854 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];
856 M=sqrt(fabs( pho.phep[I-i][4-i]*pho.phep[I-i][4-i] - P2));
858 if (IPRINT==1) fprintf(PHLUN,"CORRECTING MASS OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][5-i],M);
860 pho.phep[I-i][5-i]=M;
866 // -----------------------
868 // lets loop thru all daughters and correct their masses
869 // or energies according to E^2=p^2+m^2
871 for (I=3;I<=pho.nhep;I++){
873 PX=PX+pho.phep[I-i][1-i];
874 PY=PY+pho.phep[I-i][2-i];
875 PZ=PZ+pho.phep[I-i][3-i];
876 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];
877 M=sqrt(fabs( pho.phep[I-i][4-i]*pho.phep[I-i][4-i] - P2));
881 if(IPRINT==1) fprintf(PHLUN,"CORRECTING MASS OF %6i: %14.9f => %14.9f\n",I,pho.phep[I-i][5-i],M);
882 pho.phep[I-i][5-i]=M;
883 E = E+pho.phep[I-i][4-i];
887 EN=sqrt( pho.phep[I-i][5-i]*pho.phep[I-i][5-i] + P2);
888 if(IPRINT==1) fprintf(PHLUN,"CORRECTING ENERGY OF %6i: %14.9f =>% 14.9f\n",I ,pho.phep[I-i][4-i],EN);
890 pho.phep[I-i][4-i]=EN;
891 E = E+pho.phep[I-i][4-i];
901 fprintf(PHLUN,"CORRECTING MOTHER");
902 fprintf(PHLUN,"PX:%14.9f =>%14.9f",pho.phep[1-i][1-i],PX-pho.phep[2-i][1-i]);
903 fprintf(PHLUN,"PY:%14.9f =>%14.9f",pho.phep[1-i][2-i],PY-pho.phep[2-i][2-i]);
904 fprintf(PHLUN,"PZ:%14.9f =>%14.9f",pho.phep[1-i][3-i],PZ-pho.phep[2-i][3-i]);
905 fprintf(PHLUN," E:%14.9f =>%14.9f",pho.phep[1-i][4-i], E-pho.phep[2-i][4-i]);
908 pho.phep[1-i][1-i]=PX-pho.phep[2-i][1-i];
909 pho.phep[1-i][2-i]=PY-pho.phep[2-i][2-i];
910 pho.phep[1-i][3-i]=PZ-pho.phep[2-i][3-i];
911 pho.phep[1-i][4-i]=E -pho.phep[2-i][4-i];
914 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];
915 if(pho.phep[1-i][4-i]*pho.phep[1-i][4-i]>P2){
916 M=sqrt(pho.phep[1-i][4-i]*pho.phep[1-i][4-i] - P2 );
917 if(IPRINT==1)fprintf(PHLUN," M: %14.9f => %14.9f\n",pho.phep[1-i][5-i],M);
918 pho.phep[1-i][5-i]=M;
930 //----------------------------------------------------------------------
932 // PHOTOS: PHOton radiation in decays DOing of KINematics
934 // Purpose: Starting from the charged particle energy/momentum,
935 // PNEUTR, photon energy fraction and photon angle with
936 // respect to the axis formed by charged particle energy/
937 // momentum vector and PNEUTR, scale the energy/momentum,
938 // keeping the original direction of the neutral system in
939 // the lab. frame untouched.
941 // Input Parameters: IP: Pointer to decaying particle in
942 // /PHOEVT/ and the common itself
943 // NCHARB: pointer to the charged radiating
944 // daughter in /PHOEVT/.
945 // NEUDAU: pointer to the first neutral daughter
946 // Output Parameters: Common /PHOEVT/, with photon added.
948 // Author(s): Z. Was, B. van Eijk Created at: 26/11/89
949 // Last Update: 27/05/93
951 //----------------------------------------------------------------------
953 void PHODO(int IP,int NCHARB,int NEUDAU){
955 double QNEW,QOLD,EPHOTO,PMAVIR;
957 double CCOSTH,SSINTH,PVEC[4],PARNE;
958 double TH3,FI3,TH4,FI4,FI5,ANGLE;
962 EPHOTO=phophs_.xphoto*pho.phep[IP-i][5-i]/2.0;
963 PMAVIR=sqrt(pho.phep[IP-i][5-i]*(pho.phep[IP-i][5-i]-2.0*EPHOTO));
965 //-- Reconstruct kinematics of charged particle and neutral system
966 phorest_.fi1=PHOAN1(phomom_.pneutr[1-i],phomom_.pneutr[2-i]);
968 //-- Choose axis along z of PNEUTR, calculate angle between x and y
969 //-- components and z and x-y plane and perform Lorentz transform...
970 phorest_.th1=PHOAN2(phomom_.pneutr[3-i],sqrt(phomom_.pneutr[1-i]*phomom_.pneutr[1-i]+phomom_.pneutr[2-i]*phomom_.pneutr[2-i]));
971 PHORO3(-phorest_.fi1,phomom_.pneutr);
972 PHORO2(-phorest_.th1,phomom_.pneutr);
974 //-- Take away photon energy from charged particle and PNEUTR ! Thus
975 //-- the onshell charged particle decays into virtual charged particle
976 //-- and photon. The virtual charged particle mass becomes:
977 //-- SQRT(pho.phep[5,IP)*(pho.phep[5,IP)-2*EPHOTO)). Construct new PNEUTR mo-
978 //-- mentum in the rest frame of the parent:
979 //-- 1) Scaling parameters...
980 QNEW=PHOTRI(PMAVIR,phomom_.pneutr[5-i],pho.phep[NCHARB-i][5-i]);
981 QOLD=phomom_.pneutr[3-i];
982 GNEUT=(QNEW*QNEW+QOLD*QOLD+phomom_.mnesqr)/(QNEW*QOLD+sqrt((QNEW*QNEW+phomom_.mnesqr)*(QOLD*QOLD+phomom_.mnesqr)));
985 PHOERR(4,"PHOKIN",DATA);
987 PARNE=GNEUT-sqrt(max(GNEUT*GNEUT-1.0,0.0));
989 //-- 2) ...reductive boost...
990 PHOBO3(PARNE,phomom_.pneutr);
992 //-- ...calculate photon energy in the reduced system...
994 pho.isthep[pho.nhep-i]=1;
995 pho.idhep[pho.nhep-i] =22;
996 //-- Photon mother and daughter pointers !
997 pho.jmohep[pho.nhep-i][1]=IP;
998 pho.jmohep[pho.nhep-i][2]=0;
999 pho.jdahep[pho.nhep-i][1]=0;
1000 pho.jdahep[pho.nhep-i][2]=0;
1001 pho.phep[pho.nhep-i][4-i]=EPHOTO*pho.phep[IP-i][5-i]/PMAVIR;
1003 //-- ...and photon momenta
1004 CCOSTH=-phophs_.costhg;
1005 SSINTH=phophs_.sinthg;
1006 TH3=PHOAN2(CCOSTH,SSINTH);
1007 FI3=TWOPI*Photos::randomDouble();
1008 pho.phep[pho.nhep-i][1-i]=pho.phep[pho.nhep-i][4-i]*phophs_.sinthg*cos(FI3);
1009 pho.phep[pho.nhep-i][2-i]=pho.phep[pho.nhep-i][4-i]*phophs_.sinthg*sin(FI3);
1011 //-- Minus sign because axis opposite direction of charged particle !
1012 pho.phep[pho.nhep-i][3-i]=-pho.phep[pho.nhep-i][4-i]*phophs_.costhg;
1013 pho.phep[pho.nhep-i][5-i]=0.0;
1015 //-- Rotate in order to get photon along z-axis
1016 PHORO3(-FI3,phomom_.pneutr);
1017 PHORO3(-FI3,pho.phep[pho.nhep-i]);
1018 PHORO2(-TH3,phomom_.pneutr);
1019 PHORO2(-TH3,pho.phep[pho.nhep-i]);
1020 ANGLE=EPHOTO/pho.phep[pho.nhep-i][4-i];
1022 //-- Boost to the rest frame of decaying particle
1023 PHOBO3(ANGLE,phomom_.pneutr);
1024 PHOBO3(ANGLE,pho.phep[pho.nhep-i]);
1026 //-- Back in the parent rest frame but PNEUTR not yet oriented !
1027 FI4=PHOAN1(phomom_.pneutr[1-i],phomom_.pneutr[2-i]);
1028 TH4=PHOAN2(phomom_.pneutr[3-i],sqrt(phomom_.pneutr[1-i]*phomom_.pneutr[1-i]+phomom_.pneutr[2-i]*phomom_.pneutr[2-i]));
1029 PHORO3(FI4,phomom_.pneutr);
1030 PHORO3(FI4,pho.phep[pho.nhep-i]);
1032 for(I=2; I<=4;I++) PVEC[I-i]=0.0;
1039 PHORO2(-TH4,phomom_.pneutr);
1040 PHORO2(-TH4,pho.phep[pho.nhep-i]);
1042 FI5=PHOAN1(PVEC[1-i],PVEC[2-i]);
1044 //-- Charged particle restores original direction
1045 PHORO3(-FI5,phomom_.pneutr);
1046 PHORO3(-FI5,pho.phep[pho.nhep-i]);
1047 PHORO2(phorest_.th1,phomom_.pneutr);
1048 PHORO2(phorest_.th1,pho.phep[pho.nhep-i]);
1049 PHORO3(phorest_.fi1,phomom_.pneutr);
1050 PHORO3(phorest_.fi1,pho.phep[pho.nhep-i]);
1051 //-- See whether neutral system has multiplicity larger than 1...
1053 if((pho.jdahep[IP-i][2-i]-pho.jdahep[IP-i][1-i])>1){
1054 //-- Find pointers to components of 'neutral' system
1057 LAST=pho.jdahep[IP-i][2-i];
1058 for(I=FIRST;I<=LAST;I++){
1059 if(I!=NCHARB && ( pho.jmohep[I-i][1-i]==IP)){
1061 //-- Reconstruct kinematics...
1062 PHORO3(-phorest_.fi1,pho.phep[I-i]);
1063 PHORO2(-phorest_.th1,pho.phep[I-i]);
1065 //-- ...reductive boost
1066 PHOBO3(PARNE,pho.phep[I-i]);
1068 //-- Rotate in order to get photon along z-axis
1069 PHORO3(-FI3,pho.phep[I-i]);
1070 PHORO2(-TH3,pho.phep[I-i]);
1072 //-- Boost to the rest frame of decaying particle
1073 PHOBO3(ANGLE,pho.phep[I-i]);
1075 //-- Back in the parent rest-frame but PNEUTR not yet oriented.
1076 PHORO3(FI4,pho.phep[I-i]);
1077 PHORO2(-TH4,pho.phep[I-i]);
1079 //-- Charged particle restores original direction
1080 PHORO3(-FI5,pho.phep[I-i]);
1081 PHORO2(phorest_.th1,pho.phep[I-i]);
1082 PHORO3(phorest_.fi1,pho.phep[I-i]);
1088 // ...only one 'neutral' particle in addition to photon!
1089 for(J=1;J<=4;J++) pho.phep[NEUDAU-i][J-i]=phomom_.pneutr[J-i];
1092 //-- All 'neutrals' treated, fill /PHOEVT/ for charged particle...
1093 for (J=1;J<=3;J++) pho.phep[NCHARB-i][J-i]=-(pho.phep[pho.nhep-i][J-i]+phomom_.pneutr[J-i]);
1094 pho.phep[NCHARB-i][4-i]=pho.phep[IP-i][5-i]-(pho.phep[pho.nhep-i][4-i]+phomom_.pneutr[4-i]);
1099 //----------------------------------------------------------------------
1101 // PHOTOS: PHOtos Boson W correction weight
1103 // Purpose: calculates correction weight due to amplitudes of
1104 // emission from W boson.
1110 // Input Parameters: Common /PHOEVT/, with photon added.
1111 // wt to be corrected
1115 // Output Parameters: wt
1117 // Author(s): G. Nanava, Z. Was Created at: 13/03/03
1118 // Last Update: 08/07/13
1120 //----------------------------------------------------------------------
1122 void PHOBW(double *WT){
1125 double EMU,MCHREN,BETA,COSTHG,MPASQR,XPH;
1127 if(abs(pho.idhep[1-i])==24 &&
1128 abs(pho.idhep[pho.jdahep[1-i][1-i]-i]) >=11 &&
1129 abs(pho.idhep[pho.jdahep[1-i][1-i]-i]) <=16 &&
1130 abs(pho.idhep[pho.jdahep[1-i][1-i]+1-i])>=11 &&
1131 abs(pho.idhep[pho.jdahep[1-i][1-i]+1-i])<=16 ){
1134 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==11 ||
1135 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==13 ||
1136 abs(pho.idhep[pho.jdahep[1-i][1-i]-i])==15 ){
1137 I=pho.jdahep[1-i][1-i];
1140 I=pho.jdahep[1-i][1-i]+1;
1143 EMU=pho.phep[I-i][4-i];
1144 MCHREN=fabs(pow(pho.phep[I-i][4-i],2)-pow(pho.phep[I-i][3-i],2)
1145 -pow(pho.phep[I-i][2-i],2)-pow(pho.phep[I-i][1-i],2));
1146 BETA=sqrt(1.0- MCHREN/ pho.phep[I-i][4-i]/pho.phep[I-i][4-i]);
1147 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]
1148 +pho.phep[I-i][1-i]*pho.phep[pho.nhep-i][1-i])/
1149 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])/
1150 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]);
1151 MPASQR=pho.phep[1-i][4-i]*pho.phep[1-i][4-i];
1152 XPH=pho.phep[pho.nhep-i][4-i];
1153 *WT=(*WT)*(1-8*EMU*XPH*(1-COSTHG*BETA)*
1154 (MCHREN+2*XPH*sqrt(MPASQR))/
1155 (MPASQR*MPASQR)/(1-MCHREN/MPASQR)/(4-MCHREN/MPASQR));
1157 // write(*,*) pho.idhep[1),pho.idhep[pho.jdahep[1,1)),pho.idhep[pho.jdahep[1,1)+1)
1158 // write(*,*) emu,xph,costhg,beta,mpasqr,mchren
1164 //----------------------------------------------------------------------
1166 // PHOTOS: PHOton radiation in decays control FACtor
1168 // Purpose: This is the control function for the photon spectrum and
1169 // final weighting. It is called from PHOENE for genera-
1170 // ting the raw photon energy spectrum (MODE=0) and in PHO-
1171 // COR to scale the final weight (MODE=1). The factor con-
1172 // sists of 3 terms. Addition of the factor FF which mul-
1173 // tiplies PHOFAC for MODE=0 and divides PHOFAC for MODE=1,
1174 // does not affect the results for the MC generation. An
1175 // appropriate choice for FF can speed up the calculation.
1176 // Note that a too small value of FF may cause weight over-
1177 // flow in PHOCOR and will generate a warning, halting the
1178 // execution. PRX should be included for repeated calls
1179 // for the same event, allowing more particles to radiate
1180 // photons. At the first call IREP=0, for more than 1
1181 // charged decay products, IREP >= 1. Thus, PRSOFT (no
1182 // photon radiation probability in the previous calls)
1183 // appropriately scales the strength of the bremsstrahlung.
1185 // Input Parameters: MODE, PROBH, XF
1187 // Output Parameter: Function value
1189 // Author(s): S. Jadach, Z. Was Created at: 01/01/89
1190 // B. van Eijk, P.Golonka Last Update: 09/07/13
1192 //----------------------------------------------------------------------
1194 double PHOFAC(int MODE){
1195 static double FF=0.0,PRX=0.0;
1197 if(phokey_.iexp) return 1.0; // In case of exponentiation this routine is useles
1205 if(phopro_.irep==0) PRX=1.0;
1206 PRX=PRX/(1.0-phopro_.probh);
1209 //-- Following options are not considered for the time being...
1210 //-- (1) Good choice, but does not save very much time:
1211 //-- FF=(1.0-sqrt(phopro_.xf)/2.0)/(1.0+sqrt(phopro_.xf)/2.0)
1212 //-- (2) Taken from the blue, but works without weight overflows...
1213 //-- FF=(1.0-phopro_.xf/(1-pow((1-sqrt(phopro_.xf)),2)))*(1+(1-sqrt(phopro_.xf))/sqrt(1-phopro_.xf))/2.0
1229 //----------------------------------------------------------------------
1231 // PHOTOS: PHOton radiation in decays CORrection weight from
1232 // matrix elements This version for spin 1/2 is verified for
1234 // Purpose: Calculate photon angle. The reshaping functions will
1235 // have to depend on the spin S of the charged particle.
1236 // We define: ME = 2 * S + 1 !
1237 // THIS IS POSSIBLY ALWAYS BETTER THAN PHOCOR()
1239 // Input Parameters: MPASQR: Parent mass squared,
1240 // MCHREN: Renormalised mass of charged system,
1241 // ME: 2 * spin + 1 determines matrix element
1243 // Output Parameter: Function value.
1245 // Author(s): Z. Was, B. van Eijk, G. Nanava Created at: 26/11/89
1246 // Last Update: 01/11/12
1248 //----------------------------------------------------------------------
1250 double PHOCORN(double MPASQR,double MCHREN,int ME){
1252 double beta0,beta1,XX,YY,DATA;
1258 //-- Shaping (modified by ZW)...
1259 XX=4.0*phomom_.mchsqr/MPASQR*(1.0-phophs_.xphoto)/pow(1.0-phophs_.xphoto+(phomom_.mchsqr-phomom_.mnesqr)/MPASQR,2);
1261 S1=MPASQR * (1.0-phophs_.xphoto);
1262 beta0=2*PHOTRI(1.0,sqrt(phomom_.mchsqr/MPASQR),sqrt(phomom_.mnesqr/MPASQR));
1263 beta1=2*PHOTRI(1.0,sqrt(phomom_.mchsqr/S1),sqrt(phomom_.mnesqr/S1));
1264 wt1= (1.0-phophs_.costhg*sqrt(1.0-MCHREN))
1265 /((1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2))/2.0)*phophs_.xphoto; // de-presampler
1267 wt2= beta1/beta0*phophs_.xphoto; //phase space jacobians
1268 wt3= beta1*beta1* (1.0-phophs_.costhg*phophs_.costhg) * (1.0-phophs_.xphoto)/phophs_.xphoto/phophs_.xphoto
1269 /pow(1.0 +phomom_.mchsqr/S1-phomom_.mnesqr/S1-beta1*phophs_.costhg,2)/2.0; // matrix element
1272 S1=MPASQR * (1.0-phophs_.xphoto);
1273 beta0=2*PHOTRI(1.0,sqrt(phomom_.mchsqr/MPASQR),sqrt(phomom_.mnesqr/MPASQR));
1274 beta1=2*PHOTRI(1.0,sqrt(phomom_.mchsqr/S1),sqrt(phomom_.mnesqr/S1));
1275 wt1= (1.0-phophs_.costhg*sqrt(1.0-MCHREN))
1276 /((1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2))/2.0)*phophs_.xphoto; // de-presampler
1278 wt2= beta1/beta0*phophs_.xphoto; // phase space jacobians
1280 wt3= beta1*beta1* (1.0-phophs_.costhg*phophs_.costhg) * (1.0-phophs_.xphoto)/phophs_.xphoto/phophs_.xphoto // matrix element
1281 /pow(1.0 +phomom_.mchsqr/S1-phomom_.mnesqr/S1-beta1*phophs_.costhg,2)/2.0 ;
1282 wt3=wt3*(1-phophs_.xphoto/phophs_.xphmax+0.5*pow(phophs_.xphoto/phophs_.xphmax,2))/(1-phophs_.xphoto/phophs_.xphmax);
1283 // print*,"wt3=",wt3
1284 phocorwt_.phocorwt3=wt3;
1285 phocorwt_.phocorwt2=wt2;
1286 phocorwt_.phocorwt1=wt1;
1288 // YY=0.5D0*(1.D0-phophs_.xphoto/phophs_.xphmax+1.D0/(1.D0-phophs_.xphoto/phophs_.xphmax))
1289 // phwt_.beta=SQRT(1.D0-XX)
1290 // wt1=(1.D0-phophs_.costhg*SQRT(1.D0-MCHREN))/(1.D0-phophs_.costhg*phwt_.beta)
1291 // wt2=(1.D0-XX/YY/(1.D0-phwt_.beta**2*phophs_.costhg**2))*(1.D0+phophs_.costhg*phwt_.beta)/2.D0
1294 else if ((ME==3) || (ME==4) || (ME==5)){
1296 phwt_.beta=sqrt(1.0-XX);
1297 wt1=(1.0-phophs_.costhg*sqrt(1.0-MCHREN))/(1.0-phophs_.costhg*phwt_.beta);
1298 wt2=(1.0-XX/YY/(1.0-phwt_.beta*phwt_.beta*phophs_.costhg*phophs_.costhg))*(1.0+phophs_.costhg*phwt_.beta)/2.0;
1299 wt3=(1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2)-pow(phophs_.xphoto/phophs_.xphmax,3))/
1300 (1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2));
1304 PHOERR(6,"PHOCORN",DATA);
1306 phwt_.beta=sqrt(1.0-XX);
1307 wt1=(1.0-phophs_.costhg*sqrt(1.0-MCHREN))/(1.0-phophs_.costhg*phwt_.beta);
1308 wt2=(1.0-XX/YY/(1.0-phwt_.beta*phwt_.beta*phophs_.costhg*phophs_.costhg))*(1.0+phophs_.costhg*phwt_.beta)/2.0;
1314 phopro_.corwt=PHOCOR;
1317 PHOERR(3,"PHOCOR",DATA);
1326 //----------------------------------------------------------------------
1328 // PHOTOS: PHOton radiation in decays CORrection weight from
1331 // Purpose: Calculate photon angle. The reshaping functions will
1332 // have to depend on the spin S of the charged particle.
1333 // We define: ME = 2 * S + 1 !
1335 // Input Parameters: MPASQR: Parent mass squared,
1336 // MCHREN: Renormalised mass of charged system,
1337 // ME: 2 * spin + 1 determines matrix element
1339 // Output Parameter: Function value.
1341 // Author(s): Z. Was, B. van Eijk Created at: 26/11/89
1342 // Last Update: 21/03/93
1344 //----------------------------------------------------------------------
1346 double PHOCOR(double MPASQR,double MCHREN,int ME){
1352 //-- Shaping (modified by ZW)...
1353 XX=4.0*phomom_.mchsqr/MPASQR*(1.0-phophs_.xphoto)/pow((1.0-phophs_.xphoto+(phomom_.mchsqr-phomom_.mnesqr)/MPASQR),2);
1356 phwt_.wt3=(1.0-phophs_.xphoto/phophs_.xphmax)/((1.0+pow((1.0-phophs_.xphoto/phophs_.xphmax),2))/2.0);
1359 YY=0.5*(1.0-phophs_.xphoto/phophs_.xphmax+1.0/(1.0-phophs_.xphoto/phophs_.xphmax));
1362 else if((ME==3)||(ME==4)||(ME==5)){
1364 phwt_.wt3=(1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2)-pow(phophs_.xphoto/phophs_.xphmax,3))/
1365 (1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2) );
1369 PHOERR(6,"PHOCOR",DATA);
1375 phwt_.beta=sqrt(1.0-XX);
1376 phwt_.wt1=(1.0-phophs_.costhg*sqrt(1.0-MCHREN))/(1.0-phophs_.costhg*phwt_.beta);
1377 phwt_.wt2=(1.0-XX/YY/(1.0-phwt_.beta*phwt_.beta*phophs_.costhg*phophs_.costhg))*(1.0+phophs_.costhg*phwt_.beta)/2.0;
1380 IscaNLO=Photos::meCorrectionWtForScalar; ///// @@@@@
1381 if(ME==1 && IscaNLO ==1){ // this switch NLO in scalar decays.
1382 // overrules default calculation.
1383 // Need tests including basic ones
1384 PHOC=PHOCORN(MPASQR,MCHREN,ME);
1390 phwt_.wt2=phwt_.wt2*PHOFAC(1);
1392 PHOC=phwt_.wt1*phwt_.wt2*phwt_.wt3;
1397 PHOERR(3,"PHOCOR",DATA);
1403 //----------------------------------------------------------------------
1405 // PHOTWO: PHOtos but TWO mothers allowed
1407 // Purpose: Combines two mothers into one in /PHOEVT/
1408 // necessary eg in case of g g (q qbar) --> t tbar
1410 // Input Parameters: Common /PHOEVT/ (/PHOCMS/)
1412 // Output Parameters: Common /PHOEVT/, (stored mothers)
1414 // Author(s): Z. Was Created at: 5/08/93
1415 // Last Update:10/08/93
1417 //----------------------------------------------------------------------
1419 void PHOTWO(int MODE){
1425 // logical IFRAD is used to tag cases when two mothers may be
1426 // merged to the sole one.
1427 // So far used in case:
1428 // 1) of t tbar production
1432 IFRAD=(pho.idhep[1-i]==21) && (pho.idhep[2-i]==21);
1433 IFRAD=IFRAD || (pho.idhep[1-i]==-pho.idhep[2-i] && abs(pho.idhep[1-i])<=6);
1434 IFRAD=IFRAD && (abs(pho.idhep[3-i])==6) && (abs(pho.idhep[4-i])==6);
1435 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)
1436 -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);
1437 IFRAD=IFRAD && (MPASQR>0.0);
1439 //.....combining first and second mother
1441 pho.phep[1-i][I-i]=pho.phep[1-i][I-i]+pho.phep[2-i][I-i];
1443 pho.phep[1-i][5-i]=sqrt(MPASQR);
1444 //.....removing second mother,
1446 pho.phep[2-i][I-i]=0.0;
1451 // boosting of the mothers to the reaction frame not implemented yet.
1452 // to do it in mode 0 original mothers have to be stored in new comon (?)
1453 // and in mode 1 boosted to cms.
1459 //----------------------------------------------------------------------
1461 // PHOTOS: PHOtos CDE-s
1463 // Purpose: Keep definitions for PHOTOS QED correction Monte Carlo.
1465 // Input Parameters: None
1467 // Output Parameters: None
1469 // Author(s): Z. Was, B. van Eijk Created at: 29/11/89
1470 // Last Update: 10/08/93
1472 // =========================================================
1473 // General Structure Information: =
1474 // =========================================================
1476 // 1) INITIALIZATION (all in C++ now)
1477 // 2) GENERAL INTERFACE:
1480 // PHOTWO (specific interface
1483 // PHTYPE (specific interface
1484 // PHOMAK (specific interface
1485 // 3) QED PHOTON GENERATION:
1510 // NAME USED IN SECT. # OF OC// Comment
1511 // PHOQED 1) 2) 3 Flags whether emisson to be gen.
1512 // PHOLUN 1) 4) 6 Output device number
1513 // PHOCOP 1) 3) 4 photon coupling & min energy
1514 // PHPICO 1) 3) 4) 5 PI & 2*PI
1515 // PHOSTA 1) 4) 3 Status information
1516 // PHOKEY 1) 2) 3) 7 Keys for nonstandard application
1517 // PHOVER 1) 1 Version info for outside
1518 // HEPEVT 2) 2 PDG common
1519 // PH_HEPEVT2) 8 PDG common internal
1520 // PHOEVT 2) 3) 10 PDG branch
1521 // PHOIF 2) 3) 2 emission flags for PDG branch
1522 // PHOMOM 3) 5 param of char-neutr system
1523 // PHOPHS 3) 5 photon momentum parameters
1524 // PHOPRO 3) 4 var. for photon rep. (in branch)
1525 // PHOCMS 2) 3 parameters of boost to branch CMS
1526 // PHNUM 4) 1 event number from outside
1527 //----------------------------------------------------------------------
1530 //----------------------------------------------------------------------
1532 // PHOIN: PHOtos INput
1534 // Purpose: copies IP branch of the common /PH_HEPEVT/ into /PHOEVT/
1535 // moves branch into its CMS system.
1537 // Input Parameters: IP: pointer of particle starting branch
1539 // BOOST: Flag whether boost to CMS was or was
1540 // . replace stri not performed.
1542 // Output Parameters: Commons: /PHOEVT/, /PHOCMS/
1544 // Author(s): Z. Was Created at: 24/05/93
1545 // Last Update: 16/11/93
1547 //----------------------------------------------------------------------
1548 void PHOIN(int IP,bool *BOOST,int nhep0){
1549 int FIRST,LAST,I,LL,IP2,J,NA;
1554 // let-s calculate size of the little common entry
1555 FIRST=hep.jdahep[IP-i][1-i];
1556 LAST =hep.jdahep[IP-i][2-i];
1557 pho.nhep=3+LAST-FIRST+hep.nhep-nhep0;
1558 pho.nevhep=pho.nhep;
1560 // let-s take in decaying particle
1561 pho.idhep[1-i]=hep.idhep[IP-i];
1562 pho.jdahep[1-i][1-i]=3;
1563 pho.jdahep[1-i][2-i]=3+LAST-FIRST;
1564 for(I=1;I<=5;I++) pho.phep[1-i][I-i]=hep.phep[IP-i][I-i];
1566 // let-s take in eventual second mother
1567 IP2=hep.jmohep[hep.jdahep[IP-i][1-i]-i][2-i];
1568 if((IP2!=0) && (IP2!=IP)){
1569 pho.idhep[2-i]=hep.idhep[IP2-i];
1570 pho.jdahep[2-i][1-i]=3;
1571 pho.jdahep[2-i][2-i]=3+LAST-FIRST;
1573 pho.phep[2-i][I-i]=hep.phep[IP2-i][I-i];
1577 for(I=1;I<=5;I++) pho.phep[2-i][I-i]=0.0;
1580 // let-s take in daughters
1581 for(LL=0;LL<=LAST-FIRST;LL++){
1582 pho.idhep[3+LL-i]=hep.idhep[FIRST+LL-i];
1583 pho.jmohep[3+LL-i][1-i]=hep.jmohep[FIRST+LL-i][1-i];
1584 if(hep.jmohep[FIRST+LL-i][1-i]==IP) pho.jmohep[3+LL-i][1-i]=1;
1585 for(I=1;I<=5;I++) pho.phep[3+LL-i][I-i]=hep.phep[FIRST+LL-i][I-i];
1589 // let-s take in illegitimate daughters
1591 for(LL=1;LL<=hep.nhep-nhep0;LL++){
1592 pho.idhep[NA+LL-i]=hep.idhep[nhep0+LL-i];
1593 pho.jmohep[NA+LL-i][1-i]=hep.jmohep[nhep0+LL-i][1-i];
1594 if(hep.jmohep[nhep0+LL-i][1-i]==IP) pho.jmohep[NA+LL-i][1-i]=1;
1595 for(I=1;I<=5;I++) pho.phep[NA+LL-i][I-i]=hep.phep[nhep0+LL-i][I-i];
1598 //-- there is hep.nhep-nhep0 daugters more.
1599 pho.jdahep[1-i][2-i]=3+LAST-FIRST+hep.nhep-nhep0;
1601 if (pho.idhep[pho.nhep-i]==22) PHLUPA(100001);
1602 // if (pho.idhep[pho.nhep-i]==22) exit(0);
1604 if(pho.idhep[pho.nhep-i]==22) PHLUPA(100002);
1606 // special case of t tbar production process
1607 if(phokey_.iftop) PHOTWO(0);
1610 //-- Check whether parent is in its rest frame...
1611 // ZBW ND 27.07.2009:
1612 // bug reported by Vladimir Savinov localized and fixed.
1613 // protection against rounding error was back-firing if soft
1614 // momentum of mother was physical. Consequence was that PHCORK was
1615 // messing up masses of final state particles in vertex of the decay.
1616 // Only configurations with previously generated photons of energy fraction
1617 // smaller than 0.0001 were affected. Effect was numerically insignificant.
1619 // IF ( (ABS(pho.phep[4,1)-pho.phep[5,1)).GT.pho.phep[5,1)*1.D-8)
1620 // $ .AND.(pho.phep[5,1).NE.0)) THEN
1622 if((fabs(pho.phep[1-i][1-i]+fabs(pho.phep[1-i][2-i])+fabs(pho.phep[1-i][3-i]))>
1623 pho.phep[1-i][5-i]*1.E-8) && (pho.phep[1-i][5-i]!=0)){
1626 //PHOERR(404,"PHOIN",1.0); // we need to improve this warning: program should never
1630 //-- Boost daughter particles to rest frame of parent...
1631 //-- Resultant neutral system already calculated in rest frame !
1632 for(J=1;J<=3;J++) phocms_.bet[J-i]=-pho.phep[1-i][J-i]/pho.phep[1-i][5-i];
1633 phocms_.gam=pho.phep[1-i][4-i]/pho.phep[1-i][5-i];
1634 for(I=pho.jdahep[1-i][1-i];I<=pho.jdahep[1-i][2-i];I++){
1635 PB=phocms_.bet[1-i]*pho.phep[I-i][1-i]+phocms_.bet[2-i]*pho.phep[I-i][2-i]+phocms_.bet[3-i]*pho.phep[I-i][3-i];
1636 for(J=1;J<=3;J++) pho.phep[I-i][J-i]=pho.phep[I-i][J-i]+phocms_.bet[J-i]*(pho.phep[I-i][4-i]+PB/(phocms_.gam+1.0));
1637 pho.phep[I-i][4-i]=phocms_.gam*pho.phep[I-i][4-i]+PB;
1639 //-- Finally boost mother as well
1641 PB=phocms_.bet[1-i]*pho.phep[I-i][1-i]+phocms_.bet[2-i]*pho.phep[I-i][2-i]+phocms_.bet[3-i]*pho.phep[I-i][3-i];
1642 for(J=1;J<=3;J++) pho.phep[I-i][J-i]=pho.phep[I-i][J-i]+phocms_.bet[J-i]*(pho.phep[I-i][4-i]+PB/(phocms_.gam+1.0));
1644 pho.phep[I-i][4-i]=phocms_.gam*pho.phep[I-i][4-i]+PB;
1648 // special case of t tbar production process
1649 if(phokey_.iftop) PHOTWO(1);
1651 if(pho.idhep[pho.nhep-i]==22) PHLUPA(10000);
1652 //if (pho.idhep[pho.nhep-1-i]==22) exit(0); // this is probably form very old times ...
1657 //----------------------------------------------------------------------
1659 // PHOOUT: PHOtos OUTput
1661 // Purpose: copies back IP branch of the common /PH_HEPEVT/ from
1662 // /PHOEVT/ moves branch back from its CMS system.
1664 // Input Parameters: IP: pointer of particle starting branch
1665 // to be given back.
1666 // BOOST: Flag whether boost to CMS was or was
1669 // Output Parameters: Common /PHOEVT/,
1671 // Author(s): Z. Was Created at: 24/05/93
1674 //----------------------------------------------------------------------
1675 void PHOOUT(int IP, bool BOOST, int nhep0){
1676 int LL,FIRST,LAST,I;
1680 if(pho.nhep==pho.nevhep) return;
1681 //-- When parent was not in its rest-frame, boost back...
1684 PHOERR(404,"PHOOUT",1.0); // we need to improve this warning: program should never
1687 for (J=pho.jdahep[1-i][1-i];J<=pho.jdahep[1-i][2-i];J++){
1688 PB=-phocms_.bet[1-i]*pho.phep[J-i][1-i]-phocms_.bet[2-i]*pho.phep[J-i][2-i]-phocms_.bet[3-i]*pho.phep[J-i][3-i];
1689 for(K=1;K<=3;K++) pho.phep[J-i][K-i]=pho.phep[J-i][K-i]-phocms_.bet[K-i]*(pho.phep[J-i][4-i]+PB/(phocms_.gam+1.0));
1690 pho.phep[J-i][4-i]=phocms_.gam*pho.phep[J-i][4-i]+PB;
1693 //-- ...boost photon, or whatever else has shown up
1694 for(NN=pho.nevhep+1;NN<=pho.nhep;NN++){
1695 PB=-phocms_.bet[1-i]*pho.phep[NN-i][1-i]-phocms_.bet[2-i]*pho.phep[NN-i][2-i]-phocms_.bet[3-i]*pho.phep[NN-i][3-i];
1696 for(K=1;K<=3;K++) pho.phep[NN-i][K-i]=pho.phep[NN-i][K-i]-phocms_.bet[K-i]*(pho.phep[NN-i][4-i]+PB/(phocms_.gam+1.0));
1697 pho.phep[NN-i][4-i]=phocms_.gam*pho.phep[NN][4-i]+PB;
1700 PHCORK(0); // we have to use it because it clears input
1701 // for grandaughters modified in C++
1702 FIRST=hep.jdahep[IP-i][1-i];
1703 LAST =hep.jdahep[IP-i][2-i];
1704 // let-s take in original daughters
1705 for(LL=0;LL<=LAST-FIRST;LL++){
1706 hep.idhep[FIRST+LL-i] = pho.idhep[3+LL-i];
1707 for(I=1;I<=5;I++) hep.phep[FIRST+LL-i][I-i] = pho.phep[3+LL-i][I-i];
1710 // let-s take newcomers to the end of HEPEVT.
1712 for (LL=1;LL<=pho.nhep-NA;LL++){
1713 hep.idhep[nhep0+LL-i] = pho.idhep[NA+LL-i];
1714 hep.isthep[nhep0+LL-i]=pho.isthep[NA+LL-i];
1715 hep.jmohep[nhep0+LL-i][1-i]=IP;
1716 hep.jmohep[nhep0+LL-i][2-i]=hep.jmohep[hep.jdahep[IP-i][1-i]-i][2-i];
1717 hep.jdahep[nhep0+LL-i][1-i]=0;
1718 hep.jdahep[nhep0+LL-i][2-i]=0;
1719 for(I=1;I<=5;I++) hep.phep[nhep0+LL-i][I-i] = pho.phep[NA+LL-i][I-i];
1721 hep.nhep=hep.nhep+pho.nhep-pho.nevhep;
1726 //----------------------------------------------------------------------
1728 // PHOCHK: checking branch.
1730 // Purpose: checks whether particles in the common block /PHOEVT/
1731 // can be served by PHOMAK.
1732 // JFIRST is the position in /PH_HEPEVT/ (!) of the first
1733 // daughter of sub-branch under action.
1736 // Author(s): Z. Was Created at: 22/10/92
1737 // Last Update: 11/12/00
1739 //----------------------------------------------------------------------
1740 // ********************
1742 void PHOCHK(int JFIRST){
1747 static int i=1, IPPAR=1;
1752 for (I=IPPAR;I<=NLAST;I++){
1753 IDABS = abs(pho.idhep[I-i]);
1754 // possibly call on PHZODE is a dead (to be omitted) code.
1755 pho.qedrad[I-i]= F(0,IDABS) && F(0,abs(pho.idhep[1-i]))
1756 && (pho.idhep[2-i]==0);
1758 if(I>2) pho.qedrad[I-i]=pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i];
1762 // now we go to special cases, where pho.qedrad[I) will be overwritten
1766 // special case of top pair production
1767 for(K=pho.jdahep[1-i][2-i];K>=pho.jdahep[1-i][1-i];K--){
1768 if(pho.idhep[K-i]!=22){
1770 break; // from loop over K
1774 IFRAD=((pho.idhep[1-i]==21) && (pho.idhep[2-i]== 21))
1775 || ((abs(pho.idhep[1-i])<=6) && (pho.idhep[2-i]==(-pho.idhep[1-i])));
1777 && (abs(pho.idhep[3-i])==6)&& (pho.idhep[4-i]==(-pho.idhep[3-i]))
1780 for(I=IPPAR;I<=NLAST;I++){
1781 pho.qedrad[I-i]= true;
1782 if(I>2) pho.qedrad[I-i]=pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i];
1789 // special case of top decay
1790 for (K=pho.jdahep[1-i][2-i];K>=pho.jdahep[1-i][1-i];K--){
1791 if(pho.idhep[K-i]!=22){
1796 IFRAD=((abs(pho.idhep[1-i])==6) && (pho.idhep[2-i]==0));
1798 && ((abs(pho.idhep[3-i])==24) &&(abs(pho.idhep[4-i])== 5)
1799 || (abs(pho.idhep[3-i])== 5) &&(abs(pho.idhep[4-i])==24) )
1803 for(I=IPPAR;I<=NLAST;I++){
1804 pho.qedrad[I-i]= true;
1805 if(I>2) pho.qedrad[I-i] = (pho.qedrad[I-i] && hep.qedrad[JFIRST+I-IPPAR-2-i]);
1816 //----------------------------------------------------------------------
1818 // PHOTOS: PHOton radiation in decays calculation of photon ENErgy
1821 // Purpose: Subroutine returns photon energy fraction (in (parent
1822 // mass)/2 units) for the decay bremsstrahlung.
1824 // Input Parameters: MPASQR: Mass of decaying system squared,
1825 // XPHCUT: Minimum energy fraction of photon,
1826 // XPHMAX: Maximum energy fraction of photon.
1828 // Output Parameter: MCHREN: Renormalised mass squared,
1829 // BETA: Beta factor due to renormalisation,
1830 // XPHOTO: Photon energy fraction,
1831 // XF: Correction factor for PHOFA//
1833 // Author(s): S. Jadach, Z. Was Created at: 01/01/89
1834 // B. van Eijk, P.Golonka Last Update: 11/07/13
1836 //----------------------------------------------------------------------
1838 void PHOENE(double MPASQR,double *pMCHREN,double *pBETA,double *pBIGLOG,int IDENT){
1840 double PRSOFT,PRHARD;
1845 double &MCHREN = *pMCHREN;
1846 double &BETA = *pBETA;
1847 double &BIGLOG = *pBIGLOG;
1849 if(phophs_.xphmax<=phocop_.xphcut){
1850 BETA=PHOFAC(-1); // to zero counter, here beta is dummy
1854 //-- Probabilities for hard and soft bremstrahlung...
1855 MCHREN=4.0* phomom_.mchsqr/MPASQR/pow(1.0+ phomom_.mchsqr/MPASQR,2);
1856 BETA=sqrt(1.0-MCHREN);
1859 // ----------- VARIANT B ------------------
1860 // we replace 1D0/BETA*BIGLOG with (1.0/BETA*BIGLOG+2*phokey_.fint)
1861 // for integral of new crude
1862 BIGLOG=log(MPASQR/ phomom_.mchsqr*(1.0+BETA)*(1.0+BETA)/4.0*
1863 pow(1.0+ phomom_.mchsqr/MPASQR,2));
1864 PRHARD=phocop_.alpha/PI*(1.0/BETA*BIGLOG+2*phokey_.fint)
1865 *(log(phophs_.xphmax/phocop_.xphcut)-.75+phocop_.xphcut/phophs_.xphmax-.25*phocop_.xphcut*phocop_.xphcut/phophs_.xphmax/phophs_.xphmax);
1866 PRHARD=PRHARD*PHOCHA(IDENT)*PHOCHA(IDENT)*phokey_.fsec;
1867 // ----------- END OF VARIANT B ------------------
1869 // ----------- VARIANT A ------------------
1870 BIGLOG=log(MPASQR/ phomom_.mchsqr*(1.0+BETA)*(1.0+BETA)/4.0*
1871 pow(1.0+ phomom_.mchsqr/MPASQR,2));
1872 PRHARD=phocop_.alpha/PI*(1.0/BETA*BIGLOG)*
1873 (log(phophs_.xphmax/phocop_.xphcut)-.75+phocop_.xphcut/phophs_.xphmax-.25*phocop_.xphcut*phocop_.xphcut/phophs_.xphmax/phophs_.xphmax);
1874 PRHARD=PRHARD*PHOCHA(IDENT)*PHOCHA(IDENT)*phokey_.fsec*phokey_.fint;
1875 //me_channel_(&IDME);
1876 IDME=PH_HEPEVT_Interface::ME_channel;
1877 // write(*,*) 'KANALIK IDME=',IDME
1883 PRHARD=PRHARD/(1.0+0.75*phocop_.alpha/PI); // NLO
1886 // work on virtual crrections in W decay to be done.
1889 cout << "problem with ME_CHANNEL IDME= " << IDME << endl;
1893 //----------- END OF VARIANT A ------------------
1895 if(phopro_.irep==0) phopro_.probh=0.0;
1897 if(phokey_.iexp){ // IEXP
1898 phoexp_.nchan=phoexp_.nchan+1;
1899 if(phoexp_.expini){ // EXPINI
1900 phoexp_.pro[phoexp_.nchan-i]=PRHARD+0.05*(1.0+phokey_.fint); // we store hard photon emission prob
1901 //for leg phoexp_.nchan
1902 PRHARD=0.0; // to kill emission at initialization call
1903 phopro_.probh=PRHARD;
1907 for(K=phoexp_.nchan;K<=phoexp_.NX;K++) PRSUM=PRSUM+phoexp_.pro[K-i];
1908 PRHARD=PRHARD/PRSUM; // note that PRHARD may be smaller than
1909 //phoexp_.pro[phoexp_.nchan) because it is calculated
1910 // for kinematical configuartion as is
1911 // (with effects of previous photons)
1912 PRKILL=phoexp_.pro[phoexp_.nchan-i]/PRSUM-PRHARD;
1918 PRHARD=PRHARD*PHOFAC(0); // PHOFAC is used to control eikonal
1919 // formfactors for non exp version only
1920 // here PHOFAC(0)=1 at least now.
1921 phopro_.probh=PRHARD;
1925 //-- Check on kinematical bounds
1929 PHOERR(2,"PHOENE",DATA);
1935 PHOERR(2,"PHOENE",DATA);
1939 RRR=Photos::randomDouble();
1942 //-- No photon... (ie. photon too soft)
1944 if (RRR<PRKILL) phophs_.xphoto=-5.0; //No photon...no further trials
1948 //-- Hard photon... (ie. photon hard enough).
1949 //-- Calculate Altarelli-Parisi Kernel
1951 phophs_.xphoto=exp(Photos::randomDouble()*log(phocop_.xphcut/phophs_.xphmax));
1952 phophs_.xphoto=phophs_.xphoto*phophs_.xphmax;}
1953 while(Photos::randomDouble()>((1.0+pow(1.0-phophs_.xphoto/phophs_.xphmax,2))/2.0));
1957 //-- Calculate parameter for PHOFAC function
1958 phopro_.xf=4.0* phomom_.mchsqr*MPASQR/pow(MPASQR+ phomom_.mchsqr-phomom_.mnesqr,2);
1963 //----------------------------------------------------------------------
1965 // PHOTOS: Photon radiation in decays
1967 // Purpose: Order (alpha) radiative corrections are generated in
1968 // the decay of the IPPAR-th particle in the HEP-like
1969 // common /PHOEVT/. Photon radiation takes place from one
1970 // of the charged daughters of the decaying particle IPPAR
1971 // WT is calculated, eventual rejection will be performed
1972 // later after inclusion of interference weight.
1974 // Input Parameter: IPPAR: Pointer to decaying particle in
1975 // /PHOEVT/ and the common itself,
1977 // Output Parameters: Common /PHOEVT/, either with or without a
1979 // WT weight of the configuration
1981 // Author(s): Z. Was, B. van Eijk Created at: 26/11/89
1982 // Last Update: 12/07/13
1984 //----------------------------------------------------------------------
1986 void PHOPRE(int IPARR,double *pWT,int *pNEUDAU,int *pNCHARB){
1987 int CHAPOI[pho.nmxhep];
1988 double MINMAS,MPASQR,MCHREN;
1989 double EPS,DEL1,DEL2,DATA,BIGLOG;
1991 int IP,IPPAR,I,J,ME,NCHARG,NEUPOI,NLAST;
1997 int &NEUDAU = *pNEUDAU;
1998 int &NCHARB = *pNCHARB;
2004 //-- Store pointers for cascade treatement...
2009 //-- Check decay multiplicity..
2010 if (pho.jdahep[IP-i][1-i]==0) return;
2013 //-- Loop over daughters, determine charge multiplicity
2019 for (I=pho.jdahep[IP-i][1-i];I<=pho.jdahep[IP-i][2-i];I++){
2022 //-- Exclude marked particles, quarks and gluons etc...
2023 IDABS=abs(pho.idhep[I-i]);
2024 if (pho.qedrad[I-pho.jdahep[IP-i][1-i]+3-i]){
2025 if(PHOCHA(pho.idhep[I-i])!=0){
2027 if(NCHARG>pho.nmxhep){
2029 PHOERR(1,"PHOTOS",DATA);
2033 MINMAS=MINMAS+pho.phep[I-i][5-i]*pho.phep[I-i][5-i];
2035 MASSUM=MASSUM+pho.phep[I-i][5-i];
2040 //-- Check that sum of daughter masses does not exceed parent mass
2041 if ((pho.phep[IP-i][5-i]-MASSUM)/pho.phep[IP-i][5-i]>2.0*phocop_.xphcut){
2047 for (J=1;J<=3;J++) phomom_.pneutr[J-i] =-pho.phep[CHAPOI[NCHARG-i]-i][J-i];
2048 phomom_.pneutr[4-i]=pho.phep[IP-i][5-i]-pho.phep[CHAPOI[NCHARG-i]-i][4-i];
2050 //-- Calculate invariant mass of 'neutral' etc. systems
2051 MPASQR=pho.phep[IP-i][5-i]*pho.phep[IP-i][5-i];
2052 phomom_.mchsqr=pow(pho.phep[CHAPOI[NCHARG-i]-i][5-i],2);
2053 if((pho.jdahep[IP-i][2-i]-pho.jdahep[IP-i][1-i])==1){
2054 NEUPOI=pho.jdahep[IP-i][1-i];
2055 if(NEUPOI==CHAPOI[NCHARG-i]) NEUPOI=pho.jdahep[IP-i][2-i];
2056 phomom_.mnesqr=pho.phep[NEUPOI-i][5-i]*pho.phep[NEUPOI-i][5-i];
2057 phomom_.pneutr[5-i]=pho.phep[NEUPOI-i][5-i];
2060 phomom_.mnesqr=pow(phomom_.pneutr[4-i],2)-pow(phomom_.pneutr[1-i],2)-pow(phomom_.pneutr[2-i],2)-pow(phomom_.pneutr[3-i],2);
2061 phomom_.mnesqr=max(phomom_.mnesqr,MINMAS-phomom_.mchsqr);
2062 phomom_.pneutr[5-i]=sqrt(phomom_.mnesqr);
2066 //-- Determine kinematical limit...
2067 phophs_.xphmax=(MPASQR-pow(phomom_.pneutr[5-i]+pho.phep[CHAPOI[NCHARG-i]-i][5-i],2))/MPASQR;
2070 //-- Photon energy fraction...
2071 PHOENE(MPASQR,&MCHREN,&phwt_.beta,&BIGLOG,pho.idhep[CHAPOI[NCHARG-i]-i]);
2074 if (phophs_.xphoto<-4.0) {
2075 NCHARG=0; // we really stop trials
2076 phophs_.xphoto=0.0; // in this case !!
2077 //-- Energy fraction not too large (very seldom) ? Define angle.
2079 else if ((phophs_.xphoto<phocop_.xphcut) || (phophs_.xphoto > phophs_.xphmax)){
2081 //-- No radiation was accepted, check for more daughters that may ra-
2082 //-- diate and correct radiation probability...
2084 if(NCHARG>0) phopro_.irep=phopro_.irep+1;
2085 if(NCHARG>0) goto label30;
2089 //-- Angle is generated in the frame defined by charged vector and
2090 //-- PNEUTR, distribution is taken in the infrared limit...
2091 EPS=MCHREN/(1.0+phwt_.beta);
2093 //-- Calculate sin(theta) and cos(theta) from interval variables
2094 DEL1=(2.0-EPS)*pow(EPS/(2.0-EPS),Photos::randomDouble());
2098 // ----------- VARIANT B ------------------
2099 // corrections for more efiicient interference correction,
2100 // instead of doubling crude distribution, we add flat parallel channel
2101 if(Photos::randomDouble()<BIGLOG/phwt_.beta/(BIGLOG/phwt_.beta+2*phokey_.fint)){
2102 phophs_.costhg=(1.0-DEL1)/phwt_.beta;
2103 phophs_.sinthg=sqrt(DEL1*DEL2-MCHREN)/phwt_.beta;
2106 phophs_.costhg=-1.0+2*Photos::randomDouble();
2107 phophs_.sinthg= sqrt(1.0-phophs_.costhg*phophs_.costhg);
2110 if (phokey_.fint>1.0){
2112 WGT=1.0/(1.0-phwt_.beta*phophs_.costhg);
2113 WGT=WGT/(WGT+phokey_.fint);
2120 // ----------- END OF VARIANT B ------------------
2122 // ----------- VARIANT A ------------------
2123 phophs_.costhg=(1.0-DEL1)/phwt_.beta;
2124 phophs_.sinthg=sqrt(DEL1*DEL2-MCHREN)/phwt_.beta;
2126 // ----------- END OF VARIANT A ------------------
2129 //-- Determine spin of particle and construct code for matrix element
2130 ME=(int) (2.0*PHOSPI(pho.idhep[CHAPOI[NCHARG-i]-i])+1.0);
2132 //-- Weighting procedure with 'exact' matrix element, reconstruct kine-
2133 //-- matics for photon, neutral and charged system and update /PHOEVT/.
2134 //-- Find pointer to the first component of 'neutral' system
2135 for (I=pho.jdahep[IP-i][1-i];I<=pho.jdahep[IP-i][2-i];I++){
2136 if(I!=CHAPOI[NCHARG-i]){
2138 goto label51; //break; // to 51
2142 //-- Pointer not found...
2144 PHOERR(5,"PHOKIN",DATA);
2147 NCHARB=CHAPOI[NCHARG-i];
2148 NCHARB=NCHARB-pho.jdahep[IP-i][1-i]+3;
2149 NEUDAU=NEUDAU-pho.jdahep[IP-i][1-i]+3;
2151 IDME=PH_HEPEVT_Interface::ME_channel;
2152 // two options introduced temporarily.
2153 // In future always PHOCOR-->PHOCORN
2154 // Tests and adjustment of wts for Znlo needed.
2155 // otherwise simple change. PHOCORN implements
2156 // exact ME for scalar to 2 scalar decays.
2158 b=PHOCORN(MPASQR,MCHREN,ME);
2160 WT=WT/(1-phophs_.xphoto/phophs_.xphmax+0.5*pow(phophs_.xphoto/phophs_.xphmax,2))*(1-phophs_.xphoto/phophs_.xphmax)/2; // factor to go to WnloWT
2164 a=PHOCOR(MPASQR,MCHREN,ME);
2165 b=PHOCORN(MPASQR,MCHREN,ME);
2167 WT=WT*phwt_.wt1*phwt_.wt2*phwt_.wt3/phocorwt_.phocorwt1/phocorwt_.phocorwt2/phocorwt_.phocorwt3; // factor to go to ZnloWT
2168 // write(*,*) ' -----------'
2169 // write(*,*) phwt_.wt1,' ',phwt_.wt2,' ',phwt_.wt3
2170 // write(*,*) phocorwt_.phocorwt1,' ',phocorwt_.phocorwt2,' ',phocorwt_.phocorwt3
2173 a=PHOCOR(MPASQR,MCHREN,ME);
2175 // WT=b*WGT; // /(1-phophs_.xphoto/phophs_.xphmax+0.5*pow(phophs_.xphoto/phophs_.xphmax,2))*(1-phophs_.xphoto/phophs_.xphmax)/2;
2183 DATA=pho.phep[IP-i][5-i]-MASSUM;
2184 PHOERR(10,"PHOTOS",DATA);
2193 //----------------------------------------------------------------------
2195 // PHOMAK: PHOtos MAKe
2197 // Purpose: Single or double bremstrahlung radiative corrections
2198 // are generated in the decay of the IPPAR-th particle in
2199 // the HEP common /PH_HEPEVT/. Example of the use of
2202 // Input Parameter: IPPAR: Pointer to decaying particle in
2203 // /PH_HEPEVT/ and the common itself
2205 // Output Parameters: Common /PH_HEPEVT/, either with or without
2208 // Author(s): Z. Was, Created at: 26/05/93
2209 // Last Update: 29/01/05
2211 //----------------------------------------------------------------------
2213 void PHOMAK(int IPPAR,int NHEP0){
2227 PHOIN(IP,&BOOST,NHEP0);
2228 PHOCHK(hep.jdahep[IP-i][1-i]);
2230 PHOPRE(1,&WT,&NEUDAU,&NCHARB);
2233 RN=Photos::randomDouble();
2234 // PHODO is caling randomDouble(), thus change of series if it is moved before if
2235 PHODO(1,NCHARB,NEUDAU);
2238 // we eliminate divisions /phokey_.fint in variant B. ???
2240 // get ID of channel dependent ME, ID=0 means no
2242 IDME=PH_HEPEVT_Interface::ME_channel;
2243 // corrections for matrix elements
2244 // controlled by IDME
2245 // write(*,*) 'KANALIK IDME=',IDME
2247 if( IDME==0) { // default
2249 if(phokey_.interf) WT=WT*PHINT(IDUM);
2250 if(phokey_.ifw) PHOBW(&WT); // extra weight for leptonic W decay
2252 else if (IDME==2){ // ME weight for leptonic W decay
2254 PhotosMEforW::PHOBWnlo(&WT);
2257 else if (IDME==1){ // ME weight for leptonic Z decay
2259 WT=WT*PhotosMEforZ::phwtnlo();
2262 cout << "problem with ME_CHANNEL IDME= " << IDME << endl;
2267 WT = WT/phokey_.fint; // FINT must be in variant A
2271 if (WT>1.0) PHOERR(3,"WT_INT",DATA);
2274 PHOOUT(IP,BOOST,NHEP0);
2279 //----------------------------------------------------------------------
2281 // PHTYPE: Central manadgement routine.
2283 // Purpose: defines what kind of the
2284 // actions will be performed at point ID.
2286 // Input Parameters: ID: pointer of particle starting branch
2287 // in /PH_HEPEVT/ to be treated.
2289 // Output Parameters: Common /PH_HEPEVT/.
2291 // Author(s): Z. Was Created at: 24/05/93
2292 // P. Golonka Last Update: 27/06/04
2294 //----------------------------------------------------------------------
2295 void PHTYPE(int ID){
2306 IFOUR= phokey_.itre; // we can make internal choice whether
2307 // we want 3 or four photons at most.
2309 //-- Check decay multiplicity..
2310 if(hep.jdahep[ID-i][1-i]==0) return;
2311 // if (hep.jdahep[ID-i][1-i]==hep.jdahep[ID-i][2-i]) return;
2316 phoexp_.expini=true; // Initialization/cleaning
2317 for(phoexp_.nchan=1;phoexp_.nchan<=phoexp_.NX;phoexp_.nchan++)
2318 phoexp_.pro[phoexp_.nchan-i]=0.0;
2322 PHOMAK(ID,NHEP0); // Initialization/crude formfactors into
2323 // phoexp_.pro[phoexp_.nchan)
2324 phoexp_.expini=false;
2325 RN=Photos::randomDouble();
2327 for(K=1;K<=phoexp_.NX;K++)PRSUM=PRSUM+phoexp_.pro[K-i];
2330 // exponent for crude Poissonian multiplicity
2331 // distribution, will be later overwritten
2332 // to give probability for k
2334 // distribuant for the crude Poissonian
2336 for(K=1;K<=100;K++){ // hard coded max (photon) multiplicity is 100
2338 ESU=ESU*PRSUM/K; // we get at K ESU=EXP(-PRSUM)*PRSUM**K/K!
2339 SUM=SUM+ESU; // thus we get distribuant at K.
2341 PHOMAK(ID,NHEP0); // LOOPING
2342 if(SUM>1.0-phokey_.expeps) break;
2347 //-- quatro photon emission
2349 RN=Photos::randomDouble();
2356 else if (RN>=17.0/24.0){
2360 else if(RN>=9.0/24.0){
2366 else if(phokey_.itre){
2367 //-- triple photon emission
2369 RN=Photos::randomDouble();
2375 else if (RN>=2.0/6.0){
2379 else if(phokey_.isec){
2380 //-- double photon emission
2382 RN=Photos::randomDouble();
2389 //-- single photon emission
2394 //-- electron positron pair (coomented out for a while
2395 // if (IPAIR) PHOPAR(ID,NHEP0);
2398 } // namespace Photospp