JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
mod_Kinematics.F90
Go to the documentation of this file.
2 implicit none
3 save
4 
6 
7 CONTAINS
8 
9 
10 SUBROUTINE shiftmass(p1,p2,m1,m2,p1hat,p2hat,MassWeight)
12 implicit none
13 real(8),intent(in) :: p1(1:4),p2(1:4)
14 real(8) :: m1,m2,p1hat(1:4),p2hat(1:4)
15 real(8),optional :: MassWeight
16 real(8) :: xi,eta,a,b,c,p1sq,p2sq,p1p2
17 real(8) :: p1hatsq, p2hatsq, p12hatsq
18 
19  p1sq = p1(1:4).dot.p1(1:4)
20  p2sq = p2(1:4).dot.p2(1:4)
21  p1p2 = p1(1:4).dot.p2(1:4)
22 
23  a = ( p1sq*p2(1:4) - p2sq*p1(1:4) + p1p2*(p2(1:4)-p1(1:4)) ).dot.( p1sq*p2(1:4) - p2sq*p1(1:4) + p1p2*(p2(1:4)-p1(1:4)) )
24  b = ( p1sq+p2sq+2d0*p1p2+m2**2-m1**2 ) * ( p1p2**2 - p1sq*p2sq )
25  c = 0.25d0*( p1sq+p2sq+2d0*p1p2+m2**2-m1**2 )**2*p1sq - (p1sq+p1p2)**2*m2**2
26  eta = 1d0/2d0/a * ( -b - dsqrt( dabs(b**2 -4d0*a*c) ) )
27  xi = ( p1sq+p2sq+2d0*p1p2 + m2**2 - m1**2 - 2d0*eta*(p2sq+p1p2) )/2d0/( p1sq + p1p2 )
28 
29  p2hat(1:4) = xi*p1(1:4) + eta*p2(1:4)
30  p1hat(1:4) = (1d0-xi)*p1(1:4) + (1d0-eta)*p2(1:4)
31 
32  if( present(massweight) ) then
33  p1hatsq = p1hat(1:4).dot.p1hat(1:4)
34  p2hatsq = p2hat(1:4).dot.p2hat(1:4)
35  p12hatsq = (p1hat(1:4)+p2hat(1:4)).dot.(p1hat(1:4)+p2hat(1:4)) ! Should be p1p2*2d0, but better to avoid un-anticipated uses
36 
37  ! Below is the same as 2d0/pi/g_d(p12hatsq,p1hatsq,p2hatsq)
38  massweight = (p12hatsq**2+p1hatsq**2+p2hatsq**2-2d0*(p1hatsq*p2hatsq+p1hatsq*p12hatsq+p12hatsq*p2hatsq)) ! Writing this way instead of get_MInv should avoid the issue of - vs + invariant masses
39  if(massweight.ge.0d0 .and. p12hatsq.ne.0d0) then
40  massweight = sqrt(massweight/(p12hatsq**2))
41  else
42  massweight = 0d0
43  endif
44  endif
45 
46 ! if( dabs( (p1hat.dot.p1hat)-m1**2 )/m1**2.gt.1d-3 ) then
47 ! print *, "1",p1hat.dot.p1hat , m1**2
48 ! print *, p1
49 ! print *, p1hat
50 ! print *, a,b,c,eta,xi,p1sq + p1p2
51 ! pause
52 ! endif
53 ! if( dabs( (p2hat.dot.p2hat)-m2**2 )/m2**2.gt.1d-3 ) then
54 ! print *, "2",p2hat.dot.p2hat , m2**2
55 ! print *, p2
56 ! print *, p2hat
57 ! print *, a,b,c,eta,xi,p1sq + p1p2
58 ! pause
59 ! endif
60 
61 
62 RETURN
63 END SUBROUTINE
64 
65 
66 
67 
68 FUNCTION zlepbranching(xRnd)
70 implicit none
71 real(8) :: xrnd
72 integer :: zlepbranching
73 
74 
75  if( xrnd .le. brlept_z_ee/(100d0*percent-brlept_z_tt) ) then
77  elseif(xrnd .le. (brlept_z_ee+brlept_z_mm)/(100d0*percent-brlept_z_tt) ) then
79  else
80  print *, "error ",xrnd
81  stop
82  endif
83 
84 !print *, "checker 2",(Brlept_Z_ee)/(100d0*percent-Brlept_Z_tt)
85 !print *, "checker 2",(Brlept_Z_ee+Brlept_Z_mm)/(100d0*percent-Brlept_Z_tt)
86 
87 RETURN
88 END FUNCTION
89 
90 FUNCTION zlepbranching_flat(xRnd)
92 implicit none
93 real(8) :: xrnd
94 integer :: zlepbranching_flat
95 
96 
97  if( xrnd .le. 0.5d0 ) then
99  else
101  endif
102 
103 RETURN
104 END FUNCTION
105 
106 FUNCTION zlepplustaubranching(xRnd)
108 implicit none
109 real(8) :: xrnd
110 integer :: zlepplustaubranching
111 
112  if( xrnd .le. brlept_z_ee ) then
114  elseif(xrnd .le. brlept_z_ee+brlept_z_mm ) then
116  elseif(xrnd .le. brlept_z_ee+brlept_z_mm+brlept_z_tt ) then
118  else
119  print *, "error ",xrnd
120  stop
121  endif
122 
123 ! print *, "checker 3",Brlept_Z_ee
124 ! print *, "checker 3",Brlept_Z_ee+Brlept_Z_mm
125 ! print *, "checker 3",Brlept_Z_ee+Brlept_Z_mm+Brlept_Z_tt
126 
127 RETURN
128 END FUNCTION
129 
130 FUNCTION zlepplustaubranching_flat(xRnd)
132 implicit none
133 real(8) :: xrnd
134 integer :: zlepplustaubranching_flat
135 
136  if( xrnd .le. (1d0/3d0) ) then
138  elseif(xrnd .le. (2d0/3d0) ) then
140  else
142  endif
143 
144 RETURN
145 END FUNCTION
146 
147 FUNCTION znubranching(xRnd)
149 implicit none
150 real(8) :: xrnd
151 integer :: znubranching
152 
153  if( xrnd .le. brlept_z_nn ) then
155  elseif(xrnd .le. brlept_z_nn+brlept_z_nn ) then
157  elseif(xrnd .le. brlept_z_nn+brlept_z_nn+brlept_z_nn ) then
159  else
160  print *, "error ",xrnd
161  stop
162  endif
163 
164 !print *, "checker 4",Brlept_Z_nn
165 !print *, "checker 4",Brlept_Z_nn+Brlept_Z_nn
166 !print *, "checker 4",Brlept_Z_nn+Brlept_Z_nn+Brlept_Z_nn
167 
168 RETURN
169 END FUNCTION
170 
171 FUNCTION znubranching_flat(xRnd)
173 implicit none
174 real(8) :: xrnd
175 integer :: znubranching_flat
176 
177  if( xrnd .le. (1d0/3d0) ) then
179  elseif(xrnd .le. (2d0/3d0) ) then
181  else
183  endif
184 
185 RETURN
186 END FUNCTION
187 
188 FUNCTION zquabranching_flat(xRnd)
190 implicit none
191 real(8) :: xrnd
192 integer :: zquabranching_flat
193 real(8),parameter :: ncol=3d0
194 real(8),parameter :: xxxx=1d0/15d0
195 real(8),parameter :: yyyy=ncol*xxxx
196 
197  if( xrnd .le. yyyy ) then
199  elseif(xrnd .le. yyyy+yyyy) then
201  elseif(xrnd .le. yyyy+yyyy+yyyy) then
203  elseif(xrnd .le. yyyy+yyyy+yyyy+yyyy) then
205  elseif(xrnd .le. yyyy+yyyy+yyyy+yyyy+yyyy) then
207  else
208  print *, "error ",xrnd
209  stop
210  endif
211 
212 !print *, "checker 1",Brhadr_Z_uu,Brhadr_Z_dd
213 !print *, "checker 1",Brhadr_Z_uu+Brhadr_Z_cc+Brhadr_Z_dd+Brhadr_Z_ss+Brhadr_Z_bb
214 
215 RETURN
216 END FUNCTION
217 
218 FUNCTION zquabranching(xRnd)
220 implicit none
221 real(8) :: xrnd
222 integer :: zquabranching
223 real(8),parameter :: ncol=3d0
224 real(8),parameter :: xxxx=1d0/15d0
225 real(8),parameter :: yyyy=ncol*xxxx
226 
227  if( xrnd .le. brhadr_z_uu ) then
229  elseif(xrnd .le. brhadr_z_uu+brhadr_z_cc) then
231  elseif(xrnd .le. brhadr_z_uu+brhadr_z_cc+brhadr_z_dd) then
233  elseif(xrnd .le. brhadr_z_uu+brhadr_z_cc+brhadr_z_dd+brhadr_z_ss) then
237  else
238  print *, "error ",xrnd
239  stop
240  endif
241 
242 
243 RETURN
244 END FUNCTION
245 
246 FUNCTION zanybranching_flat(xRnd)
248 implicit none
249 real(8) :: xrnd
250 integer :: zanybranching_flat
251 real(8),parameter :: ncol=3d0
252 real(8),parameter :: xx=1d0/21d0
253 real(8),parameter :: yy=ncol*xx
254 
255 ! real(8),parameter :: xx=1d0/11d0
256 ! real(8),parameter :: yy=xx
257 
258 
259  if( xrnd .le. yy ) then
261  elseif(xrnd .le. 2d0*yy ) then
263  elseif(xrnd .le. 3d0*yy ) then
265  elseif(xrnd .le. 4d0*yy ) then
267  elseif(xrnd .le. 5d0*yy ) then
269  elseif(xrnd .le. 5d0*yy + xx ) then
271  elseif(xrnd .le. 5d0*yy + 2d0*xx ) then
273  elseif(xrnd .le. 5d0*yy + 3d0*xx ) then
275  elseif(xrnd .le. 5d0*yy + 4d0*xx ) then
277  elseif(xrnd .le. 5d0*yy + 5d0*xx ) then
279  elseif(xrnd .le. 5d0*yy + 6d0*xx ) then
281  else
282  print *, "error ",xrnd
283  stop
284  endif
285 
286 
287 
288 
289 
290 ! if( xRnd .le. yy*scale_alpha_Z_uu ) then
291 ! ZAnyBranching = Up_
292 ! elseif(xRnd .le. 2*yy*scale_alpha_Z_uu ) then
293 ! ZAnyBranching = Chm_
294 ! elseif(xRnd .le. 2*yy*scale_alpha_Z_uu+yy*scale_alpha_Z_dd ) then
295 ! ZAnyBranching = Dn_
296 ! elseif(xRnd .le. 2*yy*scale_alpha_Z_uu+2*yy*scale_alpha_Z_dd ) then
297 ! ZAnyBranching = Str_
298 ! elseif(xRnd .le. 2*yy*scale_alpha_Z_uu+3*yy*scale_alpha_Z_dd ) then
299 ! ZAnyBranching = Bot_
300 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd) + xx*scale_alpha_Z_ll ) then
301 ! ZAnyBranching = ElM_
302 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd) + xx*2*scale_alpha_Z_ll ) then
303 ! ZAnyBranching = MuM_
304 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd) + xx*3*scale_alpha_Z_ll ) then
305 ! ZAnyBranching = TaM_
306 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd)+xx*3*scale_alpha_Z_ll + xx*scale_alpha_Z_nn ) then
307 ! ZAnyBranching = NuE_
308 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd)+xx*3*scale_alpha_Z_ll + xx*2*scale_alpha_Z_nn ) then
309 ! ZAnyBranching = NuM_
310 ! elseif(xRnd .le. yy*(2*scale_alpha_Z_uu+3*scale_alpha_Z_dd)+xx*3*scale_alpha_Z_ll + xx*3*scale_alpha_Z_nn ) then
311 ! ZAnyBranching = NuT_
312 ! else
313 ! print *, "error ",xRnd
314 ! stop
315 ! endif
316 
317 
318 
319 RETURN
320 END FUNCTION
321 
322 FUNCTION zanybranching(xRnd)
324 implicit none
325 real(8) :: xrnd
326 integer :: zanybranching
327 
328 
329  if( xrnd .le. br_z_uu ) then
331  elseif(xrnd .le. br_z_uu+br_z_cc) then
333  elseif(xrnd .le. br_z_uu+br_z_cc+br_z_dd) then
335  elseif(xrnd .le. br_z_uu+br_z_cc+br_z_dd+br_z_ss) then
337  elseif(xrnd .le. br_z_uu+br_z_cc+br_z_dd+br_z_ss+br_z_bb) then
339  elseif(xrnd .le. br_z_uu+br_z_cc+br_z_dd+br_z_ss+br_z_bb+br_z_ee) then
341  elseif(xrnd .le. br_z_uu+br_z_cc+br_z_dd+br_z_ss+br_z_bb+br_z_ee+br_z_mm) then
351  else
352  print *, "error ",xrnd
353  stop
354  endif
355 
356 
357 ! if( xRnd .le. scale_alpha_Z_uu*Br_Z_uu ) then
358 ! ZAnyBranching = Up_
359 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc) then
360 ! ZAnyBranching = Chm_
361 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd) then
362 ! ZAnyBranching = Dn_
363 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss) then
364 ! ZAnyBranching = Str_
365 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb) then
366 ! ZAnyBranching = Bot_
367 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee) then
368 ! ZAnyBranching = ElM_
369 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm) then
370 ! ZAnyBranching = MuM_
371 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm+scale_alpha_Z_ll*Br_Z_tt) then
372 ! ZAnyBranching = TaM_
373 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm+scale_alpha_Z_ll*Br_Z_tt+scale_alpha_Z_nn*Br_Z_nn) then
374 ! ZAnyBranching = NuE_
375 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm+scale_alpha_Z_ll*Br_Z_tt+scale_alpha_Z_nn*Br_Z_nn+scale_alpha_Z_nn*Br_Z_nn) then
376 ! ZAnyBranching = NuM_
377 ! elseif(xRnd .le. scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm+scale_alpha_Z_ll*Br_Z_tt+scale_alpha_Z_nn*Br_Z_nn+scale_alpha_Z_nn*Br_Z_nn+scale_alpha_Z_nn*Br_Z_nn) then
378 ! ZAnyBranching = NuT_
379 ! else
380 ! print *, "error ",xRnd
381 ! stop
382 ! endif
383 
384 
385 ! print *, "checker ",Br_Z_uu+Br_Z_cc+Br_Z_dd+Br_Z_ss+Br_Z_bb+Br_Z_ee+Br_Z_mm+Br_Z_tt+Br_Z_nn+Br_Z_nn+Br_Z_nn
386 ! print *, "checker ",scale_alpha_Z_uu*Br_Z_uu+scale_alpha_Z_uu*Br_Z_cc+scale_alpha_Z_dd*Br_Z_dd+scale_alpha_Z_dd*Br_Z_ss+scale_alpha_Z_dd*Br_Z_bb+scale_alpha_Z_ll*Br_Z_ee+scale_alpha_Z_ll*Br_Z_mm+scale_alpha_Z_ll*Br_Z_tt+scale_alpha_Z_nn*Br_Z_nn+scale_alpha_Z_nn*Br_Z_nn+scale_alpha_Z_nn*Br_Z_nn
387 ! pause
388 
389 
390 RETURN
391 END FUNCTION
392 
393 FUNCTION wlepbranching(xRnd)
395 implicit none
396 real(8) :: xrnd
397 integer :: wlepbranching
398 
399  if( xrnd .le. brlept_w_en /(100d0*percent-brlept_w_tn) ) then
401  elseif(xrnd .le. (brlept_w_en+brlept_w_mn)/(100d0*percent-brlept_w_tn) ) then
403  else
404  print *, "error ",xrnd
405  stop
406  endif
407 
408 !print *, "checker 6",Brlept_W_en /(100d0*percent-Brlept_W_tn)
409 !print *, "checker 6",(Brlept_W_en+Brlept_W_mn)/(100d0*percent-Brlept_W_tn)
410 
411 RETURN
412 END FUNCTION
413 
414 FUNCTION wlepbranching_flat(xRnd)
416 implicit none
417 real(8) :: xrnd
418 integer :: wlepbranching_flat
419 
420  if( xrnd .le. 0.5d0 ) then
422  else
424  endif
425 
426 RETURN
427 END FUNCTION
428 
429 FUNCTION wlepplustaubranching(xRnd)
431 implicit none
432 real(8) :: xrnd
433 integer :: wlepplustaubranching
434 
435  if( xrnd .le. brlept_w_en ) then
437  elseif(xrnd .le. brlept_w_en+brlept_w_mn ) then
439  elseif(xrnd .le. brlept_w_en+brlept_w_mn+brlept_w_tn ) then
441  else
442  print *, "error ",xrnd
443  stop
444  endif
445 
446 ! print *, "checker 7",Brlept_W_en
447 ! print *, "checker 7",Brlept_W_en+Brlept_W_mn
448 ! print *, "checker 7",Brlept_W_en+Brlept_W_mn+Brlept_W_tn
449 
450 RETURN
451 END FUNCTION
452 
453 FUNCTION wlepplustaubranching_flat(xRnd)
455 implicit none
456 real(8) :: xrnd
457 integer :: wlepplustaubranching_flat
458 
459  if( xrnd .le. (1d0/3d0) ) then
461  elseif(xrnd .le. (2d0/3d0) ) then
463  else
465  endif
466 
467 RETURN
468 END FUNCTION
469 
470 FUNCTION wquaupbranching(xRnd)
472 implicit none
473 real(8) :: xrnd
474 integer :: wquaupbranching
475 
476  if( xrnd .le. brhadr_w_ud ) then
478  elseif(xrnd .le. brhadr_w_ud+brhadr_w_cs ) then
480  else
481  print *, "error ",xrnd
482  stop
483  endif
484 
485 
486 !print *, "checker 8",Brhadr_W_ud
487 !print *, "checker 8",Brhadr_W_ud+Brhadr_W_cs
488 
489 RETURN
490 END FUNCTION
491 
492 FUNCTION wquaupbranching_flat(xRnd)
494 implicit none
495 real(8) :: xrnd
496 integer :: wquaupbranching_flat
497 
498  if( xrnd .le. 0.5d0 ) then
500  else
502  endif
503 
504 RETURN
505 END FUNCTION
506 
507 FUNCTION wanybranching_flat(xRnd)
509 implicit none
510 real(8) :: xrnd
511 integer :: wanybranching_flat
512 real(8),parameter :: ncol=3d0
513 real(8),parameter :: xx=1d0/9d0
514 real(8),parameter :: yy=ncol*xx
515 
516 
517  if( xrnd .le. yy ) then
519  elseif(xrnd .le. 2d0*yy ) then
521  elseif(xrnd .le. 2d0*yy + xx ) then
523  elseif(xrnd .le. 2d0*yy + 2d0*xx ) then
525  elseif(xrnd .le. 2d0*yy + 3d0*xx ) then
527  else
528  print *, "error ",xrnd
529  stop
530  endif
531 
532 RETURN
533 END FUNCTION
534 
535 FUNCTION wanybranching(xRnd)
537 implicit none
538 real(8) :: xrnd
539 integer :: wanybranching
540 
541 
542  if( xrnd .le. br_w_ud ) then
544  elseif(xrnd .le. br_w_ud+br_w_cs ) then
546  elseif(xrnd .le. br_w_ud+br_w_cs+br_w_en ) then
548  elseif(xrnd .le. br_w_ud+br_w_cs+br_w_en+br_w_mn ) then
550  elseif(xrnd .le. br_w_ud+br_w_cs+br_w_en+br_w_mn+br_w_tn ) then
552  else
553  print *, "error ",xrnd
554  stop
555  endif
556 
557 
558 ! if( xRnd .le. scale_alpha_W_ud*Br_W_ud ) then
559 ! WAnyBranching = Up_
560 ! elseif(xRnd .le. scale_alpha_W_ud*Br_W_ud+scale_alpha_W_cs*Br_W_cs ) then
561 ! WAnyBranching = Chm_
562 ! elseif(xRnd .le. scale_alpha_W_ud*Br_W_ud+scale_alpha_W_cs*Br_W_cs+scale_alpha_W_ln*Br_W_en ) then
563 ! WAnyBranching = ElM_
564 ! elseif(xRnd .le. scale_alpha_W_ud*Br_W_ud+scale_alpha_W_cs*Br_W_cs+scale_alpha_W_ln*Br_W_en+scale_alpha_W_ln*Br_W_mn ) then
565 ! WAnyBranching = MuM_
566 ! elseif(xRnd .le. scale_alpha_W_ud*Br_W_ud+scale_alpha_W_cs*Br_W_cs+scale_alpha_W_ln*Br_W_en+scale_alpha_W_ln*Br_W_mn+scale_alpha_W_ln*Br_W_tn ) then
567 ! WAnyBranching = TaM_
568 ! else
569 ! print *, "error ",xRnd
570 ! stop
571 ! endif
572 
573 ! print *, "checker 2",Br_W_ud+Br_W_cs+Br_W_en+Br_W_mn+Br_W_tn
574 ! print *, "checker 2",scale_alpha_W_ud*Br_W_ud+scale_alpha_W_cs*Br_W_cs+scale_alpha_W_ln*Br_W_en+scale_alpha_W_ln*Br_W_mn+scale_alpha_W_ln*Br_W_tn
575 ! pause
576 
577 RETURN
578 END FUNCTION
579 
580 ! VBranching and VVBranchings also take into account color multiplicity, so it should be used only when color is not taken into account inside the ME!
581 ! This is why some final states count 3 times instead of just once.
582 ! Rule of thumb for counting final states in this function is e,mu,ta,nus=1, d,u,s,c,b=3
583 ! When a CKM partner is called, since sum(VCKM**@)=1 along a row, counting should not be unaffected.
584 SUBROUTINE vbranching(DecayMode,MY_IDUP,ICOLUP,CombWeight,ColorBase)
586 use modmisc
587 implicit none
588 integer, intent(in) :: DecayMode
589 integer :: MY_IDUP(1:3),ICOLUP(1:2,1:2),DKFlavor,ICOLUP_Base
590 integer, optional ::ColorBase
591 real(8), intent(out) :: CombWeight
592 real(8) :: DKRnd
593 
594 ! particle associations:
595 !
596 ! IDUP(6) --> MomDK(:,2) --> v-spinor
597 ! IDUP(7) --> MomDK(:,1) --> ubar-spinor
598 ! IDUP(8) --> MomDK(:,4) --> v-spinor
599 ! IDUP(9) --> MomDK(:,3) --> ubar-spinor
600 
601  if (present(colorbase)) then
602  icolup_base = colorbase
603  else
604  icolup_base = 800
605  endif
606 
607  icolup(:,:) = 0
608  combweight = 1d0
609  if( decaymode.eq.0 ) then! Z1->2l
610  call random_number(dkrnd)
611  my_idup(1) = z0_
612  dkflavor = zlepbranching_flat( dkrnd )!= ElM or MuM
613  my_idup(2) =-dkflavor
614  my_idup(3) =+dkflavor
615  combweight = combweight*2d0
616  elseif( decaymode.eq.1 ) then! Z1->2q
617  call random_number(dkrnd)
618  my_idup(1) = z0_
619  dkflavor = zquabranching_flat( dkrnd )!= Up,Dn,Chm,Str,Bot
620  my_idup(2) =-dkflavor
621  my_idup(3) =+dkflavor
622  icolup(1:2,1) = (/ 0,icolup_base+3/)
623  icolup(1:2,2) = (/icolup_base+3, 0/)
624  combweight = combweight*5d0*3d0
625  elseif( decaymode.eq.2 ) then! Z1->2tau
626  my_idup(1) = z0_
627  my_idup(2) = tap_
628  my_idup(3) = tam_
629  elseif( decaymode.eq.3 ) then! Z1->2nu
630  call random_number(dkrnd)
631  my_idup(1) = z0_
632  dkflavor = znubranching_flat( dkrnd )!= NuE,NuM,NuT
633  my_idup(2) =-dkflavor
634  my_idup(3) =+dkflavor
635  combweight = combweight*3d0
636  elseif( decaymode.eq.4 ) then! W1(+)->lnu
637  call random_number(dkrnd)
638  my_idup(1) = wp_
639  dkflavor = wlepbranching_flat( dkrnd )!= ElM or MuM
640  my_idup(2) = +abs(dkflavor) ! lepton(+)
641  my_idup(3) = +abs(dkflavor)+7 ! neutrino
642  combweight = combweight*2d0
643  elseif( decaymode.eq.5 ) then! W1(+)->2q
644  call random_number(dkrnd)
645  my_idup(1) = wp_
646  dkflavor = wquaupbranching_flat( dkrnd )!= Up,Chm
647  my_idup(3) = +abs(dkflavor) ! up flavor
648  my_idup(2) = getckmpartner(my_idup(3))! anti-dn flavor
649  icolup(1:2,1) = (/ 0,icolup_base+3/)
650  icolup(1:2,2) = (/icolup_base+3, 0/)
651  combweight = combweight*2d0*3d0
652  elseif( decaymode.eq.6 ) then! W1(+)->taunu
653  my_idup(1) = wp_
654  my_idup(2) = tap_
655  my_idup(3) = nut_
656  elseif( decaymode.eq.7 ) then! photon
657  my_idup(1) = pho_
658  my_idup(2) = not_a_particle_
659  my_idup(3) = not_a_particle_
660  elseif( decaymode.eq.8 ) then! Z1->2l+2tau
661  call random_number(dkrnd)
662  my_idup(1) = z0_
663  dkflavor = zlepplustaubranching_flat( dkrnd )!= ElM or MuM or TaM
664  my_idup(2) =-dkflavor
665  my_idup(3) =+dkflavor
666  combweight = combweight*3d0
667  elseif( decaymode.eq.9 ) then! Z1-> anything
668  call random_number(dkrnd)
669  my_idup(1) = z0_
670  dkflavor = zanybranching_flat( dkrnd )
671  my_idup(2) =-dkflavor
672  my_idup(3) =+dkflavor
673  if(isaquark(dkflavor)) then
674  icolup(1:2,1) = (/ 0,icolup_base+3/)
675  icolup(1:2,2) = (/icolup_base+3, 0/)
676  endif
677  combweight = combweight*21d0!*(6d0 + 5d0*3d0)
678  elseif( decaymode.eq.10 ) then! W1(+)->l+tau +nu
679  call random_number(dkrnd)
680  my_idup(1) = wp_
681  dkflavor = wlepplustaubranching_flat( dkrnd )!= ElM or MuM or TaM
682  my_idup(2) = +abs(dkflavor) ! lepton(+)
683  my_idup(3) = +abs(dkflavor)+7 ! neutrino
684  combweight = combweight*3d0
685  elseif( decaymode.eq.11 ) then! W1(+)-> anything
686  call random_number(dkrnd)
687  my_idup(1) = wp_
688  dkflavor = wanybranching_flat( dkrnd )
689  if(isaquark(dkflavor)) then
690  my_idup(3) = +abs(dkflavor) ! up flavor
691  my_idup(2) = getckmpartner(my_idup(3))! anti-dn flavor
692  icolup(1:2,1) = (/ 0,icolup_base+3/)
693  icolup(1:2,2) = (/icolup_base+3, 0/)
694  else
695  my_idup(2) = +abs(dkflavor) ! lepton(+)
696  my_idup(3) = +abs(dkflavor)+7 ! neutrino
697  endif
698  combweight = combweight*9d0!*(3d0 + 2d0*3d0)
699  ! Exclusive Z1 decay modes
700  elseif( &
701  decaymode.eq.-2*2 .or. & ! Z->ee
702  decaymode.eq.-3*3 .or. & ! Z->mumu
703  decaymode.eq.-5*5 .or. & ! Z->dd
704  decaymode.eq.-7*7 .or. & ! Z->uu
705  decaymode.eq.-11*11 .or. & ! Z->ss
706  decaymode.eq.-13*13 .or. & ! Z->cc
707  decaymode.eq.-17*17 & ! Z->bb
708  ) then
709  my_idup(1) = z0_
710  dkflavor = ( &
711  elm_*logicaltointeger(decaymode.eq.-2*2) + & ! Z->ee
712  mum_*logicaltointeger(decaymode.eq.-3*3) + & ! Z->mumu
713  dn_*logicaltointeger(decaymode.eq.-5*5) + & ! Z->dd
714  up_*logicaltointeger(decaymode.eq.-7*7) + & ! Z->uu
715  str_*logicaltointeger(decaymode.eq.-11*11) + & ! Z->ss
716  chm_*logicaltointeger(decaymode.eq.-13*13) + & ! Z->cc
717  bot_*logicaltointeger(decaymode.eq.-17*17) & ! Z->bb
718  )
719  my_idup(2) =-dkflavor
720  my_idup(3) =+dkflavor
721  if(isaquark(dkflavor)) then
722  icolup(1:2,1) = (/ 0,icolup_base+3/)
723  icolup(1:2,2) = (/icolup_base+3, 0/)
724  endif
725  ! Exclusive W+ decay modes
726  elseif( &
727  decaymode.eq.-2*1 .or. & ! W->enu
728  decaymode.eq.-3*1 .or. & ! W->munu
729  decaymode.eq.-5*7 .or. & ! W->du
730  decaymode.eq.-5*13 .or. & ! W->dc
731  decaymode.eq.-11*7 .or. & ! W->su
732  decaymode.eq.-11*13 .or. & ! W->sc
733  decaymode.eq.-17*7 .or. & ! W->bu
734  decaymode.eq.-17*13 & ! W->bc
735  ) then
736  my_idup(1) = wp_
737  my_idup(2) = ( &
738  elp_*logicaltointeger(decaymode.eq.-2*1) + & ! W->enu
739  mup_*logicaltointeger(decaymode.eq.-3*1) + & ! W->munu
740  adn_*logicaltointeger(decaymode.eq.-5*7) + & ! W->du
741  adn_*logicaltointeger(decaymode.eq.-5*13) + & ! W->dc
742  astr_*logicaltointeger(decaymode.eq.-11*7) + & ! W->su
743  astr_*logicaltointeger(decaymode.eq.-11*13) + & ! W->sc
744  abot_*logicaltointeger(decaymode.eq.-17*7) + & ! W->bu
745  abot_*logicaltointeger(decaymode.eq.-17*13) & ! W->bc
746  )
747  my_idup(3) = ( &
748  nue_*logicaltointeger(decaymode.eq.-2*1) + & ! W->enu
749  num_*logicaltointeger(decaymode.eq.-3*1) + & ! W->munu
750  up_*logicaltointeger(decaymode.eq.-5*7) + & ! W->du
751  chm_*logicaltointeger(decaymode.eq.-5*13) + & ! W->dc
752  up_*logicaltointeger(decaymode.eq.-11*7) + & ! W->su
753  chm_*logicaltointeger(decaymode.eq.-11*13) + & ! W->sc
754  up_*logicaltointeger(decaymode.eq.-17*7) + & ! W->bu
755  chm_*logicaltointeger(decaymode.eq.-17*13) & ! W->bc
756  )
757  if(isaquark(dkflavor)) then
758  icolup(1:2,1) = (/ 0,icolup_base+3/)
759  icolup(1:2,2) = (/icolup_base+3, 0/)
760  endif
761  endif
762 
763 
764 RETURN
765 END SUBROUTINE
766 
767 SUBROUTINE vvbranchings(MY_IDUP,ICOLUP,CombWeight,ColorBase)
769 use modmisc
770 implicit none
771 integer :: MY_IDUP(4:9),ICOLUP(1:2,6:9),ICOLUP_Base
772 integer, optional ::ColorBase
773 real(8), intent(out) :: CombWeight
774 integer :: tmp_idup(1:3),tmp_icolup(1:2,1:2)
775 real(8) :: tmp_CombWeight
776 real(8) :: DKRnd
777 
778 ! particle associations:
779 !
780 ! IDUP(6) --> MomDK(:,2) --> v-spinor
781 ! IDUP(7) --> MomDK(:,1) --> ubar-spinor
782 ! IDUP(8) --> MomDK(:,4) --> v-spinor
783 ! IDUP(9) --> MomDK(:,3) --> ubar-spinor
784 
785  if (present(colorbase)) then
786  icolup_base = colorbase
787  else
788  icolup_base = 800
789  endif
790 
791  icolup(:,:) = 0
792  combweight = 1d0
793 
794  call vbranching(decaymode1, tmp_idup, tmp_icolup, tmp_combweight, icolup_base)
795  my_idup(4) = tmp_idup(1)
796  my_idup(6) = tmp_idup(2)
797  my_idup(7) = tmp_idup(3)
798  icolup(1:2,6) = tmp_icolup(1:2,1)
799  icolup(1:2,7) = tmp_icolup(1:2,2)
800  combweight = combweight * tmp_combweight
801 
802 
803  icolup_base = icolup_base+1
804  call vbranching(decaymode2, tmp_idup, tmp_icolup, tmp_combweight, icolup_base)
805  my_idup(5) = tmp_idup(1)
806  my_idup(8) = tmp_idup(2)
807  my_idup(9) = tmp_idup(3)
808  icolup(1:2,8) = tmp_icolup(1:2,1)
809  icolup(1:2,9) = tmp_icolup(1:2,2)
810  if (isawdecay(decaymode2)) then
811  my_idup(5) = -my_idup(5)
812  call swap(my_idup(8),my_idup(9))
813  my_idup(8) = -my_idup(8)
814  my_idup(9) = -my_idup(9)
815  endif
816  if( process.lt.110 .or. process.gt.114) then ! for tHq processes only one V branching!
817  combweight = combweight * tmp_combweight
818  endif
819 
820 RETURN
821 END SUBROUTINE
822 
823 FUNCTION getckmpartner( Flavor )
825 use modparameters
826 implicit none
827 integer :: flavor,getckmpartner
828 real(8) :: flavorrnd,sumckm,vsq(1:3)
829 
830  call random_number(flavorrnd)
831 
832 
833  if( abs(flavor).eq.abs(up_) ) then
834  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(dn_)) ))**2
835  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(str_)) ))**2
836  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(bot_)) ))**2
837  vsq(:) = vsq(:)/scale_alpha_w_ud
838 
839  sumckm = vsq(1)+vsq(2)+vsq(3)
840  flavorrnd = flavorrnd*sumckm
841 
842  if( flavorrnd.le.vsq(1) ) then! u-->d
843  getckmpartner = -sign(1,flavor) * abs(dn_)
844  elseif( flavorrnd.le.(vsq(2)+vsq(1)) ) then! u-->s
845  getckmpartner = -sign(1,flavor) * abs(str_)
846  else! u-->b
847  getckmpartner = -sign(1,flavor) * abs(bot_)
848  endif
849 
850  elseif( abs(flavor).eq.abs(chm_) ) then
851  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(dn_)) ))**2
852  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(str_)) ))**2
853  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(bot_)) ))**2
854  vsq(:) = vsq(:)/scale_alpha_w_cs
855 
856  sumckm = vsq(1)+vsq(2)+vsq(3)
857  flavorrnd = flavorrnd*sumckm
858 
859  if( flavorrnd.le.vsq(2) ) then! c-->s
860  getckmpartner = -sign(1,flavor) * abs(str_)
861  elseif( flavorrnd.le.(vsq(1)+vsq(2)) ) then! c-->d
862  getckmpartner = -sign(1,flavor) * abs(dn_)
863  else! c-->b
864  getckmpartner = -sign(1,flavor) * abs(bot_)
865  endif
866 
867  elseif( abs(flavor).eq.abs(top_) ) then
868  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(dn_)) ))**2
869  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(str_)) ))**2
870  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(bot_)) ))**2
871 
872  sumckm = vsq(1)+vsq(2)+vsq(3)
873  flavorrnd = flavorrnd*sumckm
874 
875  if( flavorrnd.le.vsq(3) ) then! t-->b
876  getckmpartner = -sign(1,flavor) * abs(bot_)
877  elseif( flavorrnd.le.(vsq(2)+vsq(3)) ) then! t-->s
878  getckmpartner = -sign(1,flavor) * abs(str_)
879  else! t-->d
880  getckmpartner = -sign(1,flavor) * abs(dn_)
881  endif
882 
883 
884  elseif( abs(flavor).eq.abs(dn_) ) then
885  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(up_)) ))**2
886  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(chm_)) ))**2
887  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(top_)) ))**2
888  vsq(:) = vsq(:)/scale_alpha_w_ud
889 
890  sumckm = vsq(1)+vsq(2)+vsq(3)
891  flavorrnd = flavorrnd*sumckm
892 
893  if( flavorrnd.le.vsq(1) ) then! d-->u
894  getckmpartner = -sign(1,flavor) * abs(up_)
895  elseif( flavorrnd.le.(vsq(2)+vsq(1)) ) then! d-->c
896  getckmpartner = -sign(1,flavor) * abs(chm_)
897  else! d-->t
898  getckmpartner = -sign(1,flavor) * abs(top_)
899  endif
900 
901  elseif( abs(flavor).eq.abs(str_) ) then
902  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(up_)) ))**2
903  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(chm_)) ))**2
904  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(top_)) ))**2
905  vsq(:) = vsq(:)/scale_alpha_w_cs
906 
907  sumckm = vsq(1)+vsq(2)+vsq(3)
908  flavorrnd = flavorrnd*sumckm
909 
910  if( flavorrnd.le.vsq(2) ) then! s-->c
911  getckmpartner = -sign(1,flavor) * abs(chm_)
912  elseif( flavorrnd.le.(vsq(1)+vsq(2)) ) then! s-->u
913  getckmpartner = -sign(1,flavor) * abs(up_)
914  else! s-->t
915  getckmpartner = -sign(1,flavor) * abs(top_)
916  endif
917 
918  elseif( abs(flavor).eq.abs(bot_) ) then
919  vsq(1) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(up_)) ))**2
920  vsq(2) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(chm_)) ))**2
921  vsq(3) = (ckm( convertlhereverse(abs(flavor)), convertlhereverse(abs(top_)) ))**2
922 
923  sumckm = vsq(1)+vsq(2)+vsq(3)
924  flavorrnd = flavorrnd*sumckm
925 
926  if( flavorrnd.le.vsq(3) ) then! b-->t
927  getckmpartner = -sign(1,flavor) * abs(top_)
928  elseif( flavorrnd.le.(vsq(2)+vsq(3)) ) then! b-->c
929  getckmpartner = -sign(1,flavor) * abs(chm_)
930  else! b -->u
931  getckmpartner = -sign(1,flavor) * abs(up_)
932  endif
933 
934  else
935  call error("Dn flavor conversion not yet implemented")
936  endif
937 
938 RETURN
939 END FUNCTION
940 
941 FUNCTION getckmpartner_flat( Flavor )
943 use modparameters
944 implicit none
945 integer :: flavor,getckmpartner_flat
946 real(8) :: flavorrnd,sumckm,vsq(1:3)
947 
948  call random_number(flavorrnd)
949  vsq(:) = 1d0
950  sumckm = vsq(1)+vsq(2)+vsq(3)
951  flavorrnd = flavorrnd*sumckm
952 
953  if( abs(flavor).eq.abs(up_) ) then
954  if( flavorrnd.le.vsq(1) ) then! u-->d
955  getckmpartner_flat = -sign(1,flavor) * abs(dn_)
956  elseif( flavorrnd.le.(vsq(2)+vsq(1)) ) then! u-->s
957  getckmpartner_flat = -sign(1,flavor) * abs(str_)
958  else! u-->b
959  getckmpartner_flat = -sign(1,flavor) * abs(bot_)
960  endif
961 
962  elseif( abs(flavor).eq.abs(chm_) ) then
963  if( flavorrnd.le.vsq(2) ) then! c-->s
964  getckmpartner_flat = -sign(1,flavor) * abs(str_)
965  elseif( flavorrnd.le.(vsq(1)+vsq(2)) ) then! c-->d
966  getckmpartner_flat = -sign(1,flavor) * abs(dn_)
967  else! c-->b
968  getckmpartner_flat = -sign(1,flavor) * abs(bot_)
969  endif
970 
971  elseif( abs(flavor).eq.abs(top_) ) then
972  if( flavorrnd.le.vsq(3) ) then! t-->b
973  getckmpartner_flat = -sign(1,flavor) * abs(bot_)
974  elseif( flavorrnd.le.(vsq(2)+vsq(3)) ) then! t-->s
975  getckmpartner_flat = -sign(1,flavor) * abs(str_)
976  else! t-->d
977  getckmpartner_flat = -sign(1,flavor) * abs(dn_)
978  endif
979 
980 
981  elseif( abs(flavor).eq.abs(dn_) ) then
982  if( flavorrnd.le.vsq(1) ) then! d-->u
983  getckmpartner_flat = -sign(1,flavor) * abs(up_)
984  elseif( flavorrnd.le.(vsq(2)+vsq(1)) ) then! d-->c
985  getckmpartner_flat = -sign(1,flavor) * abs(chm_)
986  else! d-->t
987  getckmpartner_flat = -sign(1,flavor) * abs(top_)
988  endif
989 
990  elseif( abs(flavor).eq.abs(str_) ) then
991  if( flavorrnd.le.vsq(2) ) then! s-->c
992  getckmpartner_flat = -sign(1,flavor) * abs(chm_)
993  elseif( flavorrnd.le.(vsq(1)+vsq(2)) ) then! s-->u
994  getckmpartner_flat = -sign(1,flavor) * abs(up_)
995  else! s-->t
996  getckmpartner_flat = -sign(1,flavor) * abs(top_)
997  endif
998 
999  elseif( abs(flavor).eq.abs(bot_) ) then
1000  if( flavorrnd.le.vsq(3) ) then! b-->t
1001  getckmpartner_flat = -sign(1,flavor) * abs(top_)
1002  elseif( flavorrnd.le.(vsq(2)+vsq(3)) ) then! b-->c
1003  getckmpartner_flat = -sign(1,flavor) * abs(chm_)
1004  else! b -->u
1005  getckmpartner_flat = -sign(1,flavor) * abs(up_)
1006  endif
1007 
1008  else
1009  call error("Dn flavor conversion not yet implemented")
1010  endif
1011 
1012 RETURN
1013 END FUNCTION
1014 
1015 
1016 
1017 FUNCTION getbwpropagator(sHat, scheme)
1019 use modparameters
1020 implicit none
1021 real(8) :: getbwpropagator,shat
1022 real(8) :: mhb, ghb, biggamma
1023 integer :: scheme
1024 double precision decaymass, qqq, qqq0
1025 
1026  if( scheme.eq.1 ) then! running width
1027  getbwpropagator = 1d0/( (shat-m_reso**2)**2 + (shat*ga_reso/m_reso)**2 )
1028  elseif( scheme.eq.2 ) then! fixed width
1029  getbwpropagator = 1d0/( (shat-m_reso**2)**2 + (m_reso*ga_reso)**2 )
1030  elseif( scheme.eq.3 ) then! Passarino's CPS
1031  if( mubarh.lt.0d0 .or. gabarh.lt.0d0 ) then
1032  call call_hto(m_reso/gev, m_top/gev, mhb, ghb)
1033  if( isnan(mubarh).or.isnan(gabarh) ) then
1034  print *, "Passarino's CALL_HTO returned a NaN"
1035  print *, "(gabarH,Ehat)",gabarh,dsqrt(dabs(shat))/gev
1036  stop 1
1037  RETURN
1038  endif
1039  mhb = mhb*gev
1040  ghb = ghb*gev
1041 
1042  mubarh = sqrt(mhb**2/(1d0+(ghb/mhb)**2))
1043  gabarh = mubarh/mhb*ghb
1044  endif
1045 
1046  getbwpropagator = 1d0/( (shat-mubarh**2)**2 + (mubarh*gabarh)**2 )
1047 
1048  !call HTO_gridHt(dsqrt(dabs(sHat))/GeV,BigGamma)
1049  !BigGamma = BigGamma*GeV
1050 
1051  !print *, dsqrt(dabs(sHat))/GeV, gabarH/GeV, BigGamma/GeV
1052  elseif( scheme.eq.4) then !alternate running width
1053  if ( m_zprime.ne.-1 ) then !if you're using ZPrime then it will consider the ZPrime mass
1054  decaymass = m_zprime
1055  else
1056  decaymass = m_z !if you're doing Z-ZPrime stuff this scheme won't work anyways so the point is moot
1057  end if
1058  ! PRINT *, decayMass, decayMass**2, sHat, 0.25d0*sHat, M_Reso, 0.25d0*M_Reso**2
1059  if(0.25d0*(shat) < decaymass**2) then !sHat is the mass squared!
1060  qqq = 0
1061  else
1062  qqq = sqrt(0.25d0*(shat) - decaymass**2)
1063  endif
1064  qqq0=sqrt(0.25d0*(m_reso**2) - decaymass**2)
1065  getbwpropagator = 1d0/( (shat-m_reso**2)**2 + (m_reso*ga_reso*qqq/qqq0)**2 ) !new style running width
1066  elseif( scheme.eq.0 ) then !remove the propagator completely
1067  getbwpropagator = 1d0
1068  else
1069  print *, "Invalid scheme: ", scheme
1070  stop 1
1071  endif
1072 
1073 
1074 RETURN
1075 END FUNCTION
1076 
1077 FUNCTION reweightbwpropagator(sHat)! sHat is the resonance inv. mass squared
1079 use modparameters
1080 implicit none
1081 real(8) :: reweightbwpropagator,shat
1082 real(8) :: breitwigner,breitwigner_run
1083 
1084 
1085  reweightbwpropagator = 1d0
1086  breitwigner = getbwpropagator(shat, 2)
1087  breitwigner_run = getbwpropagator(shat, widthscheme)
1088 
1089  reweightbwpropagator = breitwigner_run/breitwigner
1090 
1091 
1092 RETURN
1093 END FUNCTION
1094 
1095 
1096 
1097 
1098 SUBROUTINE boost2lab(x1,x2,NumPart,Mom)
1099 implicit none
1100 real(8) Mom(1:4,1:NumPart)
1101 real(8) x1,x2
1102 real(8) gamma,betagamma,MomTmp1,MomTmp4
1103 integer :: i,NumPart
1104 
1105  gamma = (x1+x2)/2d0/dsqrt(x1*x2)
1106  betagamma = (x2-x1)/2d0/dsqrt(x1*x2)
1107 
1108  do i=1,numpart
1109  momtmp1=mom(1,i)
1110  momtmp4=mom(4,i)
1111  mom(1,i)= gamma*momtmp1 - betagamma*momtmp4
1112  mom(4,i)= gamma*momtmp4 - betagamma*momtmp1
1113  enddo
1114 
1115 RETURN
1116 END SUBROUTINE
1117 
1118 !LORENTZ.F
1119 !VERSION 20130123
1120 !
1121 !A subroutine that performs a general boost to a four vector
1122 !(vector) based on another four vector (boost). The primed and
1123 !unprimed frames have their axes in parallel to one another.
1124 !Rotation is not performed by this subroutine.
1125  subroutine lorentz(vector, boost)
1127  implicit none
1128 
1129  double precision vector(4), boost(4)
1130  double precision lambdaMtrx(4,4), vector_copy(4)
1131  double precision beta(2:4), beta_sq, gamma
1132  integer i,j
1133  double precision, parameter :: epsilon = 1d-13 !a small quantity slightly above machine precision
1134 
1135 ! double precision KRONECKER_DELTA
1136 ! external KRONECKER_DELTA
1137 
1138  do i=2,4
1139  beta(i) = boost(i)/boost(1)
1140  enddo
1141 
1142  beta_sq = beta(2)**2+beta(3)**2+beta(4)**2
1143 
1144  if(beta_sq.ge.epsilon)then
1145 
1146  gamma = 1d0/dsqrt(1d0-beta_sq)
1147 
1148  lambdamtrx(1,1) = gamma
1149 
1150  do i=2,4
1151  lambdamtrx(1,i) = gamma*beta(i)
1152  lambdamtrx(i,1) = lambdamtrx(1,i)
1153  enddo
1154 
1155  do i=2,4
1156  do j=2,4
1157  lambdamtrx(i,j) = (gamma-1d0)*beta(i)*beta(j)/beta_sq + kronecker_delta(i,j)
1158  enddo
1159  enddo
1160 
1161 
1162 !apply boost to vector1
1163  vector_copy = vector
1164  vector = 0d0
1165  do i=1,4
1166  do j=1,4
1167  vector(i) = vector(i) + lambdamtrx(i,j)*vector_copy(j)
1168  enddo
1169  enddo
1170  endif
1171 
1172  return
1173  END subroutine lorentz
1174 ! KRONECKER_DELTA.F
1175 !
1176 ! KRONECKER_DELTA(i,j)
1177 ! A function that returns 1 if i=j, and 0 otherwise.
1178  double precision function kronecker_delta(i,j)
1179  integer i,j
1180  if(i.eq.j)then
1181  kronecker_delta = 1d0
1182  else
1183  kronecker_delta = 0d0
1184  endif
1185 
1186  return
1187  end function kronecker_delta
1188 
1189 
1190 
1191 
1192 
1193 subroutine setrunningscales(p,id) ! p in JHU-GeV, id in JHUGen conventions
1195 use modmisc
1196 implicit none
1197 real(dp), intent(in) :: p(1:4,4:6) ! No need to run the second index from 4 to 7: pH, pJ1, pJ2
1198 integer, intent(in) :: id(4:7) ! id_JJH/id_JJVV, id_J1, id_J2, id_JJ (if applicable)
1199 real(8) :: polemass(3:7) ! mJJH, mH, mJ1, mJ2, mJJ (if applicable)
1200 real(8) :: pjjhstar(4),phstar(4),pj(4,2),pjj(4),pjhstar(4),ptjet(5:6),maxptjet,minptjet
1201 integer idx,ip
1202 
1203  phstar(:) = 0d0
1204  pjj(:) = 0d0
1205  ptjet(:) = 0d0
1206  polemass(3) = getmass(id(4)) ! Pole mass of the JJH system
1207  polemass(4) = m_reso
1208  do idx=4,6
1209  if(idx.eq.4) then
1210  do ip=1,4
1211  phstar(ip) = phstar(ip) + p(ip,idx)
1212  enddo
1213  else
1214  polemass(idx) = getmass(id(idx))
1215  do ip=1,4
1216  pjj(ip) = pjj(ip) + p(ip,idx)
1217  enddo
1218  ptjet(idx) = get_pt(p(1:4,idx))
1219  endif
1220  enddo
1221  maxptjet = maxval(ptjet)
1222  minptjet = minval(ptjet, mask=.not.all(p(1:4,5:6).eq.0d0, 1))
1223  polemass(7) = getmass(id(7)) ! Pole mass of the JJ system
1224 
1225  pjjhstar = pjj + phstar
1226  if(polemass(5).gt.polemass(6)) then
1227  pj(:,1)=p(:,5)
1228  pj(:,2)=p(:,6)
1229  else
1230  pj(:,1)=p(:,6)
1231  pj(:,2)=p(:,5)
1232  call swapr(polemass(5),polemass(6)) ! will use polemass(5) as the greater mass below
1233  endif
1234  pjhstar(1:4) = pj(1:4,1) + phstar(1:4)
1235 
1236  ! Determine the appropriate factorization scale for the chosen scheme from pole and invariant masses
1237  if(facscheme .eq. krenfacscheme_mhstar) then
1238  mu_fact = get_minv(phstar(1:4))
1239 
1240  elseif(facscheme .eq. -krenfacscheme_mhstar) then
1241  mu_fact = polemass(4)
1242 
1243  elseif(facscheme .eq. krenfacscheme_mjjhstar) then
1244  mu_fact = get_minv(pjjhstar(1:4))
1245  elseif(facscheme .eq. -krenfacscheme_mjjhstar) then
1246  mu_fact = polemass(3)
1247 
1248  elseif(facscheme .eq. krenfacscheme_mjj_mhstar) then
1249  mu_fact = get_minv(pjj(1:4))+get_minv(phstar(1:4))
1250  elseif(facscheme .eq. -krenfacscheme_mjj_mhstar) then
1251  mu_fact = polemass(4)+polemass(7)
1252  elseif(facscheme .eq. krenfacscheme_mj_mj_mhstar) then
1253  mu_fact = get_minv(pj(1:4,1))+get_minv(pj(1:4,2))+get_minv(phstar(1:4))
1254  elseif(facscheme .eq. -krenfacscheme_mj_mj_mhstar) then
1255  mu_fact = polemass(4)+polemass(5)+polemass(6)
1256 
1257  elseif(facscheme .eq. krenfacscheme_mjj) then
1258  mu_fact = get_minv(pjj(1:4))
1259  elseif(facscheme .eq. -krenfacscheme_mjj) then
1260  mu_fact = polemass(7)
1261  elseif(facscheme .eq. krenfacscheme_mj_mj) then
1262  mu_fact = get_minv(pjj(1:4))
1263  elseif(facscheme .eq. -krenfacscheme_mj_mj) then
1264  mu_fact = polemass(5)+polemass(6)
1265 
1266  elseif(facscheme .eq. krenfacscheme_mjhstar) then
1267  mu_fact = get_minv(pjhstar(1:4))
1268  elseif(facscheme .eq. krenfacscheme_mj_mhstar) then
1269  mu_fact = get_minv(pj(1:4,1))+get_minv(phstar(1:4))
1270  elseif((facscheme .eq. -krenfacscheme_mjhstar) .or. (facscheme .eq. -krenfacscheme_mj_mhstar)) then
1271  mu_fact = polemass(4)+polemass(5)
1272  elseif(facscheme .eq. krenfacscheme_mj) then
1273  mu_fact = get_minv(pj(1:4,1))
1274  elseif(facscheme .eq. -krenfacscheme_mj) then
1275  mu_fact = polemass(5)
1276  elseif(facscheme .eq. krenfacscheme_maxptj) then
1277  mu_fact = maxptjet
1278  elseif(facscheme .eq. krenfacscheme_minptj) then
1279  mu_fact = minptjet
1280  elseif(facscheme .eq. krenfacscheme_custom_scale) then
1281  call random_number(mu_fact)
1283  mu_fact = mu_fact/100 !correction to make sure that you are operating in single GeVs, not hundreds of GeV
1284  else
1285  call error("This should never be able to happen.")
1286  endif
1287 
1288  ! Do the same for the renormalization scale
1289  if(renscheme .eq. krenfacscheme_mhstar) then
1290  mu_ren = get_minv(phstar(1:4))
1291 
1292  elseif(renscheme .eq. -krenfacscheme_mhstar) then
1293  mu_ren = polemass(4)
1294 
1295  elseif(renscheme .eq. krenfacscheme_mjjhstar) then
1296  mu_ren = get_minv(pjjhstar(1:4))
1297  elseif(renscheme .eq. -krenfacscheme_mjjhstar) then
1298  mu_ren = polemass(3)
1299 
1300  elseif(renscheme .eq. krenfacscheme_mjj_mhstar) then
1301  mu_ren = get_minv(pjj(1:4))+get_minv(phstar(1:4))
1302  elseif(renscheme .eq. -krenfacscheme_mjj_mhstar) then
1303  mu_ren = polemass(4)+polemass(7)
1304  elseif(renscheme .eq. krenfacscheme_mj_mj_mhstar) then
1305  mu_ren = get_minv(pj(1:4,1))+get_minv(pj(1:4,2))+get_minv(phstar(1:4))
1306  elseif(renscheme .eq. -krenfacscheme_mj_mj_mhstar) then
1307  mu_ren = polemass(4)+polemass(5)+polemass(6)
1308 
1309  elseif(renscheme .eq. krenfacscheme_mjj) then
1310  mu_ren = get_minv(pjj(1:4))
1311  elseif(renscheme .eq. -krenfacscheme_mjj) then
1312  mu_ren = polemass(7)
1313  elseif(renscheme .eq. krenfacscheme_mj_mj) then
1314  mu_ren = get_minv(pjj(1:4))
1315  elseif(renscheme .eq. -krenfacscheme_mj_mj) then
1316  mu_ren = polemass(5)+polemass(6)
1317 
1318  elseif(renscheme .eq. krenfacscheme_mjhstar) then
1319  mu_ren = get_minv(pjhstar(1:4))
1320  elseif(renscheme .eq. krenfacscheme_mj_mhstar) then
1321  mu_ren = get_minv(pj(1:4,1))+get_minv(phstar(1:4))
1322  elseif((renscheme .eq. -krenfacscheme_mjhstar) .or. (renscheme .eq. -krenfacscheme_mj_mhstar)) then
1323  mu_ren = polemass(4)+polemass(5)
1324  elseif(renscheme .eq. krenfacscheme_mj) then
1325  mu_ren = get_minv(pj(1:4,1))
1326  elseif(renscheme .eq. -krenfacscheme_mj) then
1327  mu_ren = polemass(5)
1328  elseif(renscheme .eq. krenfacscheme_maxptj) then
1329  mu_ren = maxptjet
1330  elseif(renscheme .eq. krenfacscheme_minptj) then
1331  mu_ren = minptjet
1332  else
1333  call error("This should never be able to happen.")
1334  endif
1335 
1336  ! Never ever allow the scales to go negative
1338  mu_ren = abs(mu_ren) * murenmultiplier
1339 
1340 return
1341 end subroutine setrunningscales
1342 
1343 SUBROUTINE setpdfs(x1,x2,pdf)
1345 implicit none
1346 real(8) :: x1,x2,pdfscale
1347 real(8) :: upv(1:2),dnv(1:2),usea(1:2),dsea(1:2),str(1:2),chm(1:2),bot(1:2),glu(1:2),phot(1:2),sbar(1:2),cbar(1:2),bbar(1:2)
1348 integer,parameter :: swpdf_u=1, swpdf_d=1, swpdf_c=1, swpdf_s=1, swpdf_b=1, swpdf_g=1
1349 real(8) :: pdf(-6:6,1:2),nnpdf(1:2,-6:7)
1350 
1351  pdfscale=mu_fact/gev
1352  pdf(:,:) = 0d0
1353 
1354 #if useLHAPDF==1
1355  call evolvepdf(x1,pdfscale,nnpdf(1,-6:7))
1356  call evolvepdf(x2,pdfscale,nnpdf(2,-6:7))
1357  nnpdf(1,-6:7) = nnpdf(1,-6:7)/x1
1358  nnpdf(2,-6:7) = nnpdf(2,-6:7)/x2
1359 
1360  pdf(up_,1) = nnpdf(1,+2) * swpdf_u
1361  pdf(aup_,1) = nnpdf(1,-2) * swpdf_u
1362  pdf(dn_,1) = nnpdf(1,+1) * swpdf_d
1363  pdf(adn_,1) = nnpdf(1,-1) * swpdf_d
1364  pdf(chm_,1) = nnpdf(1,+4) * swpdf_c
1365  pdf(achm_,1) = nnpdf(1,-4) * swpdf_c
1366  pdf(str_,1) = nnpdf(1,+3) * swpdf_s
1367  pdf(astr_,1) = nnpdf(1,-3) * swpdf_s
1368  pdf(bot_,1) = nnpdf(1,+5) * swpdf_b
1369  pdf(abot_,1) = nnpdf(1,-5) * swpdf_b
1370  pdf(0,1) = nnpdf(1,+0) * swpdf_g
1371 
1372  pdf(up_,2) = nnpdf(2,+2) * swpdf_u
1373  pdf(aup_,2) = nnpdf(2,-2) * swpdf_u
1374  pdf(dn_,2) = nnpdf(2,+1) * swpdf_d
1375  pdf(adn_,2) = nnpdf(2,-1) * swpdf_d
1376  pdf(chm_,2) = nnpdf(2,+4) * swpdf_c
1377  pdf(achm_,2) = nnpdf(2,-4) * swpdf_c
1378  pdf(str_,2) = nnpdf(2,+3) * swpdf_s
1379  pdf(astr_,2) = nnpdf(2,-3) * swpdf_s
1380  pdf(bot_,2) = nnpdf(2,+5) * swpdf_b
1381  pdf(abot_,2) = nnpdf(2,-5) * swpdf_b
1382  pdf(0,2) = nnpdf(2,+0) * swpdf_g
1383 
1384  pdf(:,:) = dabs(pdf(:,:))
1385 
1386  RETURN
1387 
1388 #else
1389  if( pdfset.eq.1 ) then
1390  call cteq6(x1,pdfscale,upv(1),dnv(1),usea(1),dsea(1),str(1),chm(1),bot(1),glu(1))
1391  call cteq6(x2,pdfscale,upv(2),dnv(2),usea(2),dsea(2),str(2),chm(2),bot(2),glu(2))
1392  elseif( pdfset.eq.2 ) then
1393  call getallpdfs("pdfs/mstw2008lo",0,x1,pdfscale,upv(1),dnv(1),usea(1),dsea(1),str(1),sbar(1),chm(1),cbar(1),bot(1),bbar(1),glu(1),phot(1))
1394  str(1)= (str(1)+sbar(1))/2d0
1395  chm(1)= (chm(1)+cbar(1))/2d0
1396  bot(1)= (bot(1)+bbar(1))/2d0
1397  upv(1)=upv(1)/x1
1398  dnv(1)=dnv(1)/x1
1399  usea(1)=usea(1)/x1
1400  dsea(1)=dsea(1)/x1
1401  str(1)=str(1)/x1
1402  chm(1)=chm(1)/x1
1403  bot(1)=bot(1)/x1
1404  glu(1)=glu(1)/x1
1405  phot(1)=phot(1)/x1
1406 
1407  call getallpdfs("pdfs/mstw2008lo",0,x2,pdfscale,upv(2),dnv(2),usea(2),dsea(2),str(2),sbar(2),chm(2),cbar(2),bot(2),bbar(2),glu(2),phot(2))
1408  str(2)= (str(2)+sbar(2))/2d0
1409  chm(2)= (chm(2)+cbar(2))/2d0
1410  bot(2)= (bot(2)+bbar(2))/2d0
1411  upv(2)=upv(2)/x2
1412  dnv(2)=dnv(2)/x2
1413  usea(2)=usea(2)/x2
1414  dsea(2)=dsea(2)/x2
1415  str(2)=str(2)/x2
1416  chm(2)=chm(2)/x2
1417  bot(2)=bot(2)/x2
1418  glu(2)=glu(2)/x2
1419  phot(2)=phot(2)/x2
1420 
1421  elseif( pdfset.ge.201 .and. pdfset.le.240) then
1422  call getallpdfs("pdfs/mstw2008lo.90cl",pdfset-200,x1,pdfscale,upv(1),dnv(1),usea(1),dsea(1),str(1),sbar(1),chm(1),cbar(1),bot(1),bbar(1),glu(1),phot(1))
1423  str(1)= (str(1)+sbar(1))/2d0
1424  chm(1)= (chm(1)+cbar(1))/2d0
1425  bot(1)= (bot(1)+bbar(1))/2d0
1426  upv(1)=upv(1)/x1
1427  dnv(1)=dnv(1)/x1
1428  usea(1)=usea(1)/x1
1429  dsea(1)=dsea(1)/x1
1430  str(1)=str(1)/x1
1431  chm(1)=chm(1)/x1
1432  bot(1)=bot(1)/x1
1433  glu(1)=glu(1)/x1
1434  phot(1)=phot(1)/x1
1435 
1436  call getallpdfs("pdfs/mstw2008lo.90cl",pdfset-200,x2,pdfscale,upv(2),dnv(2),usea(2),dsea(2),str(2),sbar(2),chm(2),cbar(2),bot(2),bbar(2),glu(2),phot(2))
1437  str(2)= (str(2)+sbar(2))/2d0
1438  chm(2)= (chm(2)+cbar(2))/2d0
1439  bot(2)= (bot(2)+bbar(2))/2d0
1440  upv(2)=upv(2)/x2
1441  dnv(2)=dnv(2)/x2
1442  usea(2)=usea(2)/x2
1443  dsea(2)=dsea(2)/x2
1444  str(2)=str(2)/x2
1445  chm(2)=chm(2)/x2
1446  bot(2)=bot(2)/x2
1447  glu(2)=glu(2)/x2
1448  phot(2)=phot(2)/x2
1449  elseif( pdfset.eq.3 ) then
1450 
1451  call nnevolvepdf(x1,pdfscale,nnpdf(1,-6:7))
1452  call nnevolvepdf(x2,pdfscale,nnpdf(2,-6:7))
1453  nnpdf(1,-6:7) = nnpdf(1,-6:7)/x1
1454  nnpdf(2,-6:7) = nnpdf(2,-6:7)/x2
1455 
1456  ! PROTON CONTENT
1457  pdf(up_,1) = nnpdf(1,+2) * swpdf_u
1458  pdf(aup_,1) = nnpdf(1,-2) * swpdf_u
1459  pdf(dn_,1) = nnpdf(1,+1) * swpdf_d
1460  pdf(adn_,1) = nnpdf(1,-1) * swpdf_d
1461  pdf(chm_,1) = nnpdf(1,+4) * swpdf_c
1462  pdf(achm_,1) = nnpdf(1,-4) * swpdf_c
1463  pdf(str_,1) = nnpdf(1,+3) * swpdf_s
1464  pdf(astr_,1) = nnpdf(1,-3) * swpdf_s
1465  pdf(bot_,1) = nnpdf(1,+5) * swpdf_b
1466  pdf(abot_,1) = nnpdf(1,-5) * swpdf_b
1467  pdf(0,1) = nnpdf(1,+0) * swpdf_g
1468 
1469  pdf(up_,2) = nnpdf(2,+2) * swpdf_u
1470  pdf(aup_,2) = nnpdf(2,-2) * swpdf_u
1471  pdf(dn_,2) = nnpdf(2,+1) * swpdf_d
1472  pdf(adn_,2) = nnpdf(2,-1) * swpdf_d
1473  pdf(chm_,2) = nnpdf(2,+4) * swpdf_c
1474  pdf(achm_,2) = nnpdf(2,-4) * swpdf_c
1475  pdf(str_,2) = nnpdf(2,+3) * swpdf_s
1476  pdf(astr_,2) = nnpdf(2,-3) * swpdf_s
1477  pdf(bot_,2) = nnpdf(2,+5) * swpdf_b
1478  pdf(abot_,2) = nnpdf(2,-5) * swpdf_b
1479  pdf(0,2) = nnpdf(2,+0) * swpdf_g
1480 
1481  pdf(:,:) = dabs(pdf(:,:))
1482  RETURN
1483  else
1484  print *, "PDFSet",pdfset,"not available!"
1485  stop
1486  endif
1487 #endif
1488 
1489 IF( collider.EQ.1 ) THEN
1490 ! PROTON CONTENT
1491  pdf(up_,1) = (upv(1) + usea(1)) * swpdf_u
1492  pdf(aup_,1) = usea(1) * swpdf_u
1493  pdf(dn_,1) = (dnv(1) + dsea(1)) * swpdf_d
1494  pdf(adn_,1) = dsea(1) * swpdf_d
1495  pdf(chm_,1) = chm(1) * swpdf_c
1496  pdf(achm_,1) = chm(1) * swpdf_c
1497  pdf(str_,1) = str(1) * swpdf_s
1498  pdf(astr_,1) = str(1) * swpdf_s
1499  pdf(bot_,1) = bot(1) * swpdf_b
1500  pdf(abot_,1) = bot(1) * swpdf_b
1501  pdf(0,1) = glu(1) * swpdf_g
1502 
1503 ! PROTON CONTENT
1504  pdf(up_,2) = (upv(2) + usea(2)) * swpdf_u
1505  pdf(aup_,2) = usea(2) * swpdf_u
1506  pdf(dn_,2) = (dnv(2) + dsea(2)) * swpdf_d
1507  pdf(adn_,2) = dsea(2) * swpdf_d
1508  pdf(chm_,2) = chm(2) * swpdf_c
1509  pdf(achm_,2) = chm(2) * swpdf_c
1510  pdf(str_,2) = str(2) * swpdf_s
1511  pdf(astr_,2) = str(2) * swpdf_s
1512  pdf(bot_,2) = bot(2) * swpdf_b
1513  pdf(abot_,2) = bot(2) * swpdf_b
1514  pdf(0,2) = glu(2) * swpdf_g
1515 
1516 ELSEIF( collider.EQ.2 ) THEN
1517 ! PROTON CONTENT
1518  pdf(up_,1) = (upv(1) + usea(1)) * swpdf_u
1519  pdf(aup_,1) = usea(1) * swpdf_u
1520  pdf(dn_,1) = (dnv(1) + dsea(1)) * swpdf_d
1521  pdf(adn_,1) = dsea(1) * swpdf_d
1522  pdf(chm_,1) = chm(1) * swpdf_c
1523  pdf(achm_,1) = chm(1) * swpdf_c
1524  pdf(str_,1) = str(1) * swpdf_s
1525  pdf(astr_,1) = str(1) * swpdf_s
1526  pdf(bot_,1) = bot(1) * swpdf_b
1527  pdf(abot_,1) = bot(1) * swpdf_b
1528  pdf(0,1) = glu(1) * swpdf_g
1529 
1530 ! ANTI-PROTON CONTENT
1531  pdf(up_,2) = usea(2) * swpdf_u
1532  pdf(aup_,2) = (upv(2)+usea(2)) * swpdf_u
1533  pdf(dn_,2) = dsea(2) * swpdf_d
1534  pdf(adn_,2) = (dnv(2) + dsea(2)) * swpdf_d
1535  pdf(chm_,2) = chm(2) * swpdf_c
1536  pdf(achm_,2) = chm(2) * swpdf_c
1537  pdf(str_,2) = str(2) * swpdf_s
1538  pdf(astr_,2) = str(2) * swpdf_s
1539  pdf(bot_,2) = bot(2) * swpdf_b
1540  pdf(abot_,2) = bot(2) * swpdf_b
1541  pdf(0,2) = glu(2) * swpdf_g
1542 
1543 ENDIF
1544 
1545 pdf(:,:) = dabs(pdf(:,:))
1546 
1547 
1548 RETURN
1549 END SUBROUTINE
1550 
1551 SUBROUTINE cteq6(X,SCALE,UPV,DNV,USEA,DSEA,STR,CHM,BOT,GLU)
1552 implicit none
1553 double precision X,SCALE,UPV,DNV,USEA,DSEA,STR,CHM,BOT,GLU
1554 double precision Q,xsave,qsave,Ctq6Pdf,D,U
1555 
1556  q=scale
1557  xsave=x
1558  qsave=q
1559  u = ctq6pdf(1,x,q)
1560  d = ctq6pdf(2,x,q)
1561  usea = ctq6pdf(-1,x,q)
1562  dsea = ctq6pdf(-2,x,q)
1563  str = ctq6pdf(3,x,q)
1564  chm = ctq6pdf(4,x,q)
1565  bot = ctq6pdf(5,x,q)
1566  glu = ctq6pdf(0,x,q)
1567  upv=u-usea
1568  dnv=d-dsea
1569  x=xsave
1570  q=qsave
1571 RETURN
1572 END SUBROUTINE
1573 
1574 !! QCD scale from MCFM
1575 !! Implementation into JHUGen by Ulascan Sarica, Dec. 2015
1576 !subroutine EvalAlphaS()
1577 ! use ModParameters
1578 ! IMPLICIT NONE
1579 !#if useLHAPDF==1
1580 !!--- This is simply a wrapper to the LHAPDF implementation of the running coupling alphas, in the style of the native MCFM routine
1581 ! DOUBLE PRECISION alphasPDF
1582 ! REAL(DP) :: Q
1583 ! Q = Mu_Ren/GeV
1584 ! alphas=alphasPDF(Q)
1585 !#else
1586 !! Evaluation of strong coupling constant alphas
1587 !! Original Author: R.K. Ellis
1588 !! q -- Scale at which alpha_s is to be evaluated
1589 !! alphas_mz -- ModParameters value of alpha_s at the mass of the Z-boson
1590 !! nloops_pdf -- ModParameters value of the number of loops (1,2, or 3) at which the beta function is evaluated to determine running.
1591 !! If you somehow need a more complete implementation, check everything at or before commit 28472c5bfee128dde458fd4929b4d3ece9519ab8
1592 ! INTEGER, PARAMETER :: NF6=6
1593 ! INTEGER, PARAMETER :: NF5=5
1594 ! INTEGER, PARAMETER :: NF4=4
1595 ! INTEGER, PARAMETER :: NF3=3
1596 ! INTEGER, PARAMETER :: NF2=2
1597 ! INTEGER, PARAMETER :: NF1=1
1598 !
1599 ! IF (Mu_Ren .LE. 0d0) THEN
1600 ! WRITE(6,*) 'ModKinematics::EvalAlphaS: Mu_Ren .le. 0, Mu_Ren (GeV) = ',(Mu_Ren*GeV)
1601 ! stop
1602 ! ENDIF
1603 ! IF (nQflavors_pdf .NE. NF5) THEN
1604 ! WRITE(6,*) 'ModKinematics::EvalAlphaS: nQflavors_pdf invalid, nQflavors_pdf = ',nQflavors_pdf
1605 ! WRITE(6,*) 'ModKinematics::EvalAlphaS: Check 28472c5bfee128dde458fd4929b4d3ece9519ab8'
1606 ! stop
1607 ! ENDIF
1608 ! IF (nloops_pdf .NE. 1) THEN
1609 ! WRITE(6,*) 'ModKinematics::EvalAlphaS: nloops_pdf invalid, nloops_pdf = ',nloops_pdf
1610 ! WRITE(6,*) 'ModKinematics::EvalAlphaS: Check 28472c5bfee128dde458fd4929b4d3ece9519ab8'
1611 ! stop
1612 ! ENDIF
1613 !
1614 ! alphas=alphas_mz/(1.0_dp+alphas_mz*B0_PDF(NF5)*2.0_dp*dlog((Mu_Ren/zmass_pdf)))
1615 !#endif
1616 ! ! Calculate the derived couplings
1617 ! call ComputeQCDVariables()
1618 ! RETURN
1619 !end subroutine EvalAlphaS
1620 
1621 
1622 
1623 
1624 END MODULE
1625 
modparameters::abot_
integer, target, public abot_
Definition: mod_Parameters.F90:1111
getallpdfs
subroutine getallpdfs(prefix, ih, x, q, upv, dnv, usea, dsea, str, sbar, chm, cbar, bot, bbar, glu, phot)
Definition: mstwpdf.f:22
modkinematics::lorentz
subroutine lorentz(vector, boost)
Definition: mod_Kinematics.F90:1126
modparameters::achm_
integer, target, public achm_
Definition: mod_Parameters.F90:1108
modparameters::br_z_nn
real(8), parameter, public br_z_nn
Definition: mod_Parameters.F90:304
modparameters::elm_
integer, target, public elm_
Definition: mod_Parameters.F90:1112
modparameters::krenfacscheme_mj
integer, parameter, public krenfacscheme_mj
Definition: mod_Parameters.F90:41
modparameters::pdfset
integer, public pdfset
Definition: mod_Parameters.F90:69
modparameters::krenfacscheme_mhstar
integer, parameter, public krenfacscheme_mhstar
Definition: mod_Parameters.F90:33
modparameters::brlept_z_mm
real(8), parameter, public brlept_z_mm
Definition: mod_Parameters.F90:312
modkinematics::wlepbranching
integer function wlepbranching(xRnd)
Definition: mod_Kinematics.F90:394
modparameters::krenfacscheme_mj_mj
integer, parameter, public krenfacscheme_mj_mj
Definition: mod_Parameters.F90:38
modparameters::mubarh
real(8), public mubarh
Definition: mod_Parameters.F90:133
modparameters::krenfacscheme_custom_scale
integer, parameter, public krenfacscheme_custom_scale
Definition: mod_Parameters.F90:44
modkinematics::getckmpartner_flat
integer function getckmpartner_flat(Flavor)
Definition: mod_Kinematics.F90:942
modmisc::get_minv
real(8) function get_minv(Mom)
Definition: mod_Misc.F90:172
modparameters::mufacmultiplier
real(8), public mufacmultiplier
Definition: mod_Parameters.F90:21
modparameters::ckm
real(8) function ckm(id1in, id2in)
Definition: mod_Parameters.F90:1593
modparameters::brhadr_z_ss
real(8), parameter, public brhadr_z_ss
Definition: mod_Parameters.F90:322
modparameters::mu_fact
real(8), public mu_fact
Definition: mod_Parameters.F90:267
modparameters::customlowerscalebound
real(8), public customlowerscalebound
Definition: mod_Parameters.F90:21
modparameters::dn_
integer, target, public dn_
Definition: mod_Parameters.F90:1085
modparameters::murenmultiplier
real(8), public murenmultiplier
Definition: mod_Parameters.F90:21
modparameters::brlept_w_mn
real(8), parameter, public brlept_w_mn
Definition: mod_Parameters.F90:316
modmisc::swapr
subroutine swapr(i, j)
Definition: mod_Misc.F90:403
modparameters::krenfacscheme_mjjhstar
integer, parameter, public krenfacscheme_mjjhstar
Definition: mod_Parameters.F90:34
modparameters::convertlhereverse
integer function convertlhereverse(Part)
Definition: mod_Parameters.F90:1711
modkinematics::wlepbranching_flat
integer function wlepbranching_flat(xRnd)
Definition: mod_Kinematics.F90:415
modparameters::brlept_w_en
real(8), parameter, public brlept_w_en
Definition: mod_Parameters.F90:315
modparameters::m_zprime
real(8), public m_zprime
Definition: mod_Parameters.F90:619
modparameters::br_w_en
real(8), parameter, public br_w_en
Definition: mod_Parameters.F90:305
modmisc::error
subroutine error(Message, ErrNum)
Definition: mod_Misc.F90:366
modparameters::getmass
real(8) function getmass(Part)
Definition: mod_Parameters.F90:2021
modkinematics
Definition: mod_Kinematics.F90:1
modkinematics::zlepplustaubranching
integer function zlepplustaubranching(xRnd)
Definition: mod_Kinematics.F90:107
modkinematics::wanybranching
integer function wanybranching(xRnd)
Definition: mod_Kinematics.F90:536
modparameters::brhadr_w_cs
real(8), parameter, public brhadr_w_cs
Definition: mod_Parameters.F90:325
modparameters::adn_
integer, target, public adn_
Definition: mod_Parameters.F90:1107
modparameters::facscheme
integer, public facscheme
Definition: mod_Parameters.F90:20
modkinematics::kronecker_delta
double precision function kronecker_delta(i, j)
Definition: mod_Kinematics.F90:1179
nnevolvepdf
subroutine nnevolvepdf(x, Q, xpdf)
Definition: NNPDFDriver.f:138
modparameters::br_z_ee
real(8), parameter, public br_z_ee
Definition: mod_Parameters.F90:301
modparameters::chm_
integer, target, public chm_
Definition: mod_Parameters.F90:1086
modparameters::up_
integer, target, public up_
Definition: mod_Parameters.F90:1084
modparameters::bot_
integer, target, public bot_
Definition: mod_Parameters.F90:1089
modparameters::krenfacscheme_minptj
integer, parameter, public krenfacscheme_minptj
Definition: mod_Parameters.F90:43
modparameters::krenfacscheme_mjj
integer, parameter, public krenfacscheme_mjj
Definition: mod_Parameters.F90:37
modparameters::brlept_z_tt
real(8), parameter, public brlept_z_tt
Definition: mod_Parameters.F90:313
modparameters::br_w_mn
real(8), parameter, public br_w_mn
Definition: mod_Parameters.F90:306
modparameters::br_z_mm
real(8), parameter, public br_z_mm
Definition: mod_Parameters.F90:302
modparameters::ga_reso
real(8), public ga_reso
Definition: mod_Parameters.F90:231
modmisc::isnan
logical function isnan(x)
Definition: mod_Misc.F90:380
modkinematics::vvbranchings
subroutine vvbranchings(MY_IDUP, ICOLUP, CombWeight, ColorBase)
Definition: mod_Kinematics.F90:768
modparameters::br_z_ss
real(8), parameter, public br_z_ss
Definition: mod_Parameters.F90:294
modparameters::m_top
real(8), public m_top
Definition: mod_Parameters.F90:224
modparameters::br_w_ud
real(8), parameter, public br_w_ud
Definition: mod_Parameters.F90:308
modkinematics::wquaupbranching_flat
integer function wquaupbranching_flat(xRnd)
Definition: mod_Kinematics.F90:493
modparameters::krenfacscheme_mjhstar
integer, parameter, public krenfacscheme_mjhstar
Definition: mod_Parameters.F90:39
modkinematics::boost2lab
subroutine boost2lab(x1, x2, NumPart, Mom)
Definition: mod_Kinematics.F90:1099
modparameters::krenfacscheme_mj_mhstar
integer, parameter, public krenfacscheme_mj_mhstar
Definition: mod_Parameters.F90:40
modkinematics::znubranching_flat
integer function znubranching_flat(xRnd)
Definition: mod_Kinematics.F90:172
modparameters::brhadr_z_bb
real(8), parameter, public brhadr_z_bb
Definition: mod_Parameters.F90:323
modkinematics::zlepbranching_flat
integer function zlepbranching_flat(xRnd)
Definition: mod_Kinematics.F90:91
modkinematics::znubranching
integer function znubranching(xRnd)
Definition: mod_Kinematics.F90:148
modparameters::scale_alpha_w_cs
real(8), public scale_alpha_w_cs
Definition: mod_Parameters.F90:333
modparameters::brlept_w_tn
real(8), parameter, public brlept_w_tn
Definition: mod_Parameters.F90:317
modparameters::tam_
integer, target, public tam_
Definition: mod_Parameters.F90:1114
modparameters::scale_alpha_w_ud
real(8), public scale_alpha_w_ud
Definition: mod_Parameters.F90:332
modmisc::get_pt
real(8) function get_pt(Mom)
Definition: mod_Misc.F90:152
modparameters::brlept_z_ee
real(8), parameter, public brlept_z_ee
Definition: mod_Parameters.F90:311
modkinematics::cteq6
subroutine cteq6(X, SCALE, UPV, DNV, USEA, DSEA, STR, CHM, BOT, GLU)
Definition: mod_Kinematics.F90:1552
modparameters::aup_
integer, target, public aup_
Definition: mod_Parameters.F90:1106
modkinematics::getckmpartner
integer function getckmpartner(Flavor)
Definition: mod_Kinematics.F90:824
modparameters::isawdecay
logical function isawdecay(DKMode)
Definition: mod_Parameters.F90:2278
modparameters::gev
real(8), parameter, public gev
Definition: mod_Parameters.F90:93
modparameters::collider
integer, public collider
Definition: mod_Parameters.F90:17
modparameters::percent
real(8), parameter, public percent
Definition: mod_Parameters.F90:90
modparameters::nue_
integer, target, public nue_
Definition: mod_Parameters.F90:1097
modkinematics::wanybranching_flat
integer function wanybranching_flat(xRnd)
Definition: mod_Kinematics.F90:508
modparameters::renscheme
integer, public renscheme
Definition: mod_Parameters.F90:20
modparameters::brlept_z_nn
real(8), parameter, public brlept_z_nn
Definition: mod_Parameters.F90:314
modparameters::elp_
integer, target, public elp_
Definition: mod_Parameters.F90:1090
call_hto
subroutine call_hto(mhiggs, mtop, mhb, ghb)
Definition: CALLING_cpHTO.f:7656
modparameters::br_z_tt
real(8), parameter, public br_z_tt
Definition: mod_Parameters.F90:303
modkinematics::wlepplustaubranching
integer function wlepplustaubranching(xRnd)
Definition: mod_Kinematics.F90:430
modkinematics::zquabranching
integer function zquabranching(xRnd)
Definition: mod_Kinematics.F90:219
modkinematics::vbranching
subroutine vbranching(DecayMode, MY_IDUP, ICOLUP, CombWeight, ColorBase)
Definition: mod_Kinematics.F90:585
modkinematics::zanybranching
integer function zanybranching(xRnd)
Definition: mod_Kinematics.F90:323
modkinematics::getbwpropagator
real(8) function, public getbwpropagator(sHat, scheme)
Definition: mod_Kinematics.F90:1018
modparameters::brhadr_z_dd
real(8), parameter, public brhadr_z_dd
Definition: mod_Parameters.F90:321
modparameters::br_w_tn
real(8), parameter, public br_w_tn
Definition: mod_Parameters.F90:307
modparameters
Definition: mod_Parameters.F90:1
modkinematics::shiftmass
subroutine shiftmass(p1, p2, m1, m2, p1hat, p2hat, MassWeight)
Definition: mod_Kinematics.F90:11
modmisc
Definition: mod_Misc.F90:1
modkinematics::wlepplustaubranching_flat
integer function wlepplustaubranching_flat(xRnd)
Definition: mod_Kinematics.F90:454
modparameters::brhadr_z_uu
real(8), parameter, public brhadr_z_uu
Definition: mod_Parameters.F90:319
modkinematics::setpdfs
subroutine, public setpdfs(x1, x2, pdf)
Definition: mod_Kinematics.F90:1344
modparameters::krenfacscheme_maxptj
integer, parameter, public krenfacscheme_maxptj
Definition: mod_Parameters.F90:42
modparameters::krenfacscheme_mj_mj_mhstar
integer, parameter, public krenfacscheme_mj_mj_mhstar
Definition: mod_Parameters.F90:36
modparameters::m_z
real(8), public m_z
Definition: mod_Parameters.F90:226
modparameters::nut_
integer, target, public nut_
Definition: mod_Parameters.F90:1099
modparameters::dp
integer, parameter, public dp
Definition: mod_Parameters.F90:11
modparameters::mu_ren
real(8), public mu_ren
Definition: mod_Parameters.F90:268
modparameters::mum_
integer, target, public mum_
Definition: mod_Parameters.F90:1113
modparameters::wp_
integer, target, public wp_
Definition: mod_Parameters.F90:1096
modkinematics::wquaupbranching
integer function wquaupbranching(xRnd)
Definition: mod_Kinematics.F90:471
modkinematics::setrunningscales
subroutine, public setrunningscales(p, id)
Definition: mod_Kinematics.F90:1194
modmisc::logicaltointeger
integer function logicaltointeger(var)
Definition: mod_Misc.F90:97
modparameters::br_w_cs
real(8), parameter, public br_w_cs
Definition: mod_Parameters.F90:309
modparameters::gabarh
real(8), public gabarh
Definition: mod_Parameters.F90:134
modparameters::m_reso
real(8), public m_reso
Definition: mod_Parameters.F90:230
modparameters::str_
integer, target, public str_
Definition: mod_Parameters.F90:1087
modparameters::isaquark
logical function isaquark(PartType)
Definition: mod_Parameters.F90:2369
modparameters::astr_
integer, target, public astr_
Definition: mod_Parameters.F90:1109
modparameters::brhadr_z_cc
real(8), parameter, public brhadr_z_cc
Definition: mod_Parameters.F90:320
modparameters::not_a_particle_
integer, parameter, public not_a_particle_
Definition: mod_Parameters.F90:1121
modparameters::decaymode1
integer, public decaymode1
Definition: mod_Parameters.F90:17
modkinematics::zanybranching_flat
integer function zanybranching_flat(xRnd)
Definition: mod_Kinematics.F90:247
modparameters::num_
integer, target, public num_
Definition: mod_Parameters.F90:1098
modparameters::customupperscalebound
real(8), public customupperscalebound
Definition: mod_Parameters.F90:21
modparameters::tap_
integer, target, public tap_
Definition: mod_Parameters.F90:1092
modkinematics::reweightbwpropagator
real(8) function, public reweightbwpropagator(sHat)
Definition: mod_Kinematics.F90:1078
modparameters::decaymode2
integer, public decaymode2
Definition: mod_Parameters.F90:17
modparameters::krenfacscheme_mjj_mhstar
integer, parameter, public krenfacscheme_mjj_mhstar
Definition: mod_Parameters.F90:35
modparameters::top_
integer, target, public top_
Definition: mod_Parameters.F90:1088
modparameters::pho_
integer, target, public pho_
Definition: mod_Parameters.F90:1094
modparameters::z0_
integer, target, public z0_
Definition: mod_Parameters.F90:1095
modparameters::br_z_cc
real(8), parameter, public br_z_cc
Definition: mod_Parameters.F90:292
modparameters::process
integer, public process
Definition: mod_Parameters.F90:17
modkinematics::zlepbranching
integer function zlepbranching(xRnd)
Definition: mod_Kinematics.F90:69
modparameters::widthscheme
integer, public widthscheme
Definition: mod_Parameters.F90:131
modkinematics::zquabranching_flat
integer function zquabranching_flat(xRnd)
Definition: mod_Kinematics.F90:189
modparameters::br_z_dd
real(8), parameter, public br_z_dd
Definition: mod_Parameters.F90:293
modparameters::br_z_uu
real(8), parameter, public br_z_uu
Definition: mod_Parameters.F90:291
modparameters::br_z_bb
real(8), parameter, public br_z_bb
Definition: mod_Parameters.F90:295
modparameters::brhadr_w_ud
real(8), parameter, public brhadr_w_ud
Definition: mod_Parameters.F90:324
modmisc::swap
Definition: mod_Misc.F90:5
modkinematics::zlepplustaubranching_flat
integer function zlepplustaubranching_flat(xRnd)
Definition: mod_Kinematics.F90:131
modparameters::mup_
integer, target, public mup_
Definition: mod_Parameters.F90:1091