Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508

c*******************************************************
c*******************************************************
      subroutine evntinit
      implicit double precision(a-h, o-z)
	implicit integer(i-n)

#include "invegas.h"
#include "bcvegpy_set_par.inc"

c...three pythia functions return integers, so need declaring.
      integer pycomp
c...external statement.
      external pydata,totfun

c****************************************************
c*************** define most of the common block used
c****************************************************

c...pythia common block.
      common/pyjets/n,npad,k(4000,5),p(4000,5),v(4000,5)
      parameter (maxnup=500)
      common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
     &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
     &vtimup(maxnup),spinup(maxnup)
      save /hepeup/

      parameter (maxpup=100)
      integer pdfgup,pdfsup,lprup
      common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
     &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
     &lprup(maxpup)
      save /heprup/

c...user process event common block.
      common/pypars/mstp(200),parp(200),msti(200),pari(200)
      common/pydat1/mstu(200),paru(200),mstj(200),parj(200)
      common/pydat3/mdcy(500,3),mdme(8000,2),brat(8000),kfdp(8000,5)
	double complex colmat,bundamp
      common/upcom/ecm,pmbc,pmb,pmc,fbcc,pmomup(5,8),
     & 	colmat(10,64),bundamp(4),pmomzero(5,8)
	common/counter/ibcstate,nev
	common/grade/xi(NVEGBIN,10)
	common/vegcross/vegsec,vegerr,iveggrade
	common/colflow/amp2cf(10),smatval

c...transform of running information.
	common/ptpass/ptmin,ptmax,crossmax,etamin,etamax,
     &	smin,smax,ymin,ymax,psetamin,psetamax
	common/confine/ptcut,etacut
	common/histcol/inx

c...generate---switch for full events. vegasopen---switch for using
c...vegas.
	logical generate,vegasopen,usegrade
	common/genefull/generate

c...parameters transformtion.
      common/funtrans/nq2,npdfu
	common/usertran/ishower,idpp

c...transform of the vegas information
      common/vegasinf/number,nitmx

c...to get the subprocess cross-section.
      common/subopen/subfactor,subenergy,isubonly

c...to get the distribution of an extra factor z=(2(k1+k2).p_bc)/shat.
      common/extraz/zfactor,zmin,zmax
	common/outpdf/ioutpdf,ipdfnum

c...used in grv98l
	common/intinip/iinip
	common/intinif/iinif

c...transform some variables
      common/loggrade/ievntdis,igenerate,ivegasopen,igrade

c...for transform the subprocess information, i.e.,  whether using
c...the subprocess q\bar{q}->bc+b+\bar{c} to generate events.
      common/qqbar/iqqbar,iqcode

	dimension nfin(20),alamin(20)
      common/coloct/ioctet
	common/octmatrix/coeoct
c...transform the first derivative of the wavefunction at the zero or the
c...wavefunction at the zero.
	common/wavezero/fbc

c...data:lambda and n_f values for parton distributions. this is obtained
c...from pythia and used for vegas running.
      data alamin/0.177d0,0.239d0,0.247d0,0.2322d0,0.248d0,0.248d0,
     &0.192d0,0.326d0,2*0.2d0,0.2d0,0.2d0,0.29d0,0.2d0,0.4d0,5*0.2d0/,
     &nfin/20*4/

c...xbcsec(8) records the total differential cross-sections for different
c...states: 1---singlet 1s0; 2---singlet 3s1; 7---octet 1s0; 8---octet 3s1;
c...3---singlet 1p1; 4---singlet 3p0; 5---singlet 3p1; 6---singlet 3p2.
	common/mixevnt/xbcsec(8),imix,imixtype
	common/mixevnt2/xbcsum,ibclimit
	character*1 pfile

c************************************************
c... open recording files.--record mainly the 
c... vegas running information
c************************************************
	call upopenfile(imix,imixtype,ibcstate,ioctet)

c************************************************

	generate =.false.
	if(igenerate.eq.1) generate =.true.

	vegasopen=.false.
	if(ivegasopen.eq.1) vegasopen=.true.

	usegrade=.false.
	if(igrade.eq.1) usegrade=.true.

	if(isubonly.eq.1) subfactor=subenergy/ecm

c--------------------------------------------
c...reference light-like momentum, which can be choosing arbitrarily.
c...this can be used to check tht rightness of the program.
c...--used only for s-wave gluon fusion mechanism.
	pmomup(1,8)=3.0d0
      pmomup(2,8)=4.0d0
	pmomup(3,8)=5.0d0
	pmomup(4,8)=dsqrt(pmomup(1,8)**2+pmomup(2,8)**2+pmomup(3,8)**2)
	pmomup(5,8)=0.0d0

c--------------------------------------------
c...output program logo.
      call uplogo

c--------------------------------------------
c...setting the alphas.
c   mstu(111)=0---fixed; d=1---fir order; =2---sec order
	mstp(2)  =mstu(111)

c---------------------------------------------------------
c...choose lambda value to be used in case of using vegas.
	if(vegasopen) then
	   if(ioutpdf.eq.0) then
c...this part is from the inner part of pythia.
	      if(mstp(51).ge.1 .and. mstp(51).le.20) then
              paru(112)=alamin(mstp(51))
              mstu(112)=nfin(mstp(51))
            end if
	   else
	      if(ipdfnum.eq.100) then
			 paru(112)=0.1750d0    !grv98l
		     mstu(112)=4
	      end if
		  if(ipdfnum.eq.200) then
			 paru(112)=0.220d0     !msrt2001l
	         mstu(112)=4
	      end if
		  if(ipdfnum.eq.300) then
			 paru(112)=0.215d0     !cteq6l1
	         mstu(112)=4
	      end if
	   end if
	end if

c---------------------------------
c...logo for vegas.
	call vegaslogo(vegasopen)

c******************************************************************
c...using vegas to get the importance function and then the 
c...sampling stratage: xi(), which will be stored in grade files.
c******************************************************************

      if(vegasopen) then
	  if(isubonly.eq.0) then
          if(imix.eq.0) then
c--------------------------------------
c... using existed grade to generate more precise grade.
c... this way is only used for imix=0 (preferable); 
c... for imix=1, the way is the same,
c... but is tedious to write all of them here.
c--------------------------------------
		 if(iveggrade.eq.1) then
	       write(*,'(a)')'existed grade to gene. more precise grade.'
		   write(3,'(a)')'existed grade to gene. more precise grade.'
		   do i=1,NVEGBIN
	          read(11,*) (xi(i,j),j=1,7)
	       end do
c	       open(unit=29,file='data/newgrade.grid',status='unknown')
	       open(unit=29,file='newgrade.grid',status='unknown')
	     end if
		 call vegas(totfun,7,number,nitmx,2)
		 do i=1,NVEGBIN
	       if(iveggrade.eq.1) then
			  write(29,*) (xi(i,j),j=1,7)
	       else
	          write(11,*) (xi(i,j),j=1,7)
		   end if
		 end do
		end if

c******************************************************

          if(imix.eq.1) then
	      if(imixtype.eq.1.or.imixtype.eq.2) then
		   ibcstate=1                         !1s0 and singlet
             write(*,'(a)') '...generating cross-sec and grade (1s0)...'
             write(3,'(a)') '...generating cross-sec and grade (1s0)...'
		   call paraswave(ibcstate)
		   call vegas(totfun,7,number,nitmx,2)
             xbcsec(1)=vegsec
		   do i=1,NVEGBIN
	           write(36,*) (xi(i,j),j=1,7)
		   end do
	       write(36,*) '+'
             write(36,*) vegsec,crossmax
		   rewind(36)
	      end if

c********************************
	      if(imixtype.eq.1.or.imixtype.eq.2) then
		   ibcstate=2                         !3s1 and singlet
             write(*,'(a)') '...generating cross-sec and grade (3s1)...'
             write(3,'(a)') '...generating cross-sec and grade (3s1)...'
             call paraswave(ibcstate)
             call vegas(totfun,7,number,nitmx,2)
             xbcsec(2)=vegsec
             do i=1,NVEGBIN
	           write(37,*) (xi(i,j),j=1,7)
		   end do
	       write(37,*) '+'
             write(37,*) vegsec,crossmax
	       rewind(37)
            end if

c********************************
	      if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=3
             write(*,'(a)') '...generating cross-sec and grade (1p1)...'
             write(3,'(a)') '...generating cross-sec and grade (1p1)...'
             call parapwave
             call vegas(totfun,7,number,nitmx,2)
             xbcsec(3)=vegsec
             do i=1,NVEGBIN
	           write(38,*) (xi(i,j),j=1,7)
		   end do
	       write(38,*) '+'
             write(38,*) vegsec,crossmax
	       rewind(38)
	      end if

c********************************
    	      if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=4
             write(*,'(a)') '...generating cross-sec and grade (3p0)...'
             write(3,'(a)') '...generating cross-sec and grade (3p0)...'
             call parapwave
             call vegas(totfun,7,number,nitmx,2)
             xbcsec(4)=vegsec
             do i=1,NVEGBIN
	           write(39,*) (xi(i,j),j=1,7)
		   end do
	       write(39,*) '+'
             write(39,*) vegsec,crossmax
	       rewind(39)
	     end if

c********************************
	     if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=5
             write(*,'(a)') '...generating cross-sec and grade (3p1)...'
             write(3,'(a)') '...generating cross-sec and grade (3p1)...'
             call parapwave
             call vegas(totfun,7,number,nitmx,2)
             xbcsec(5)=vegsec
             do i=1,NVEGBIN
	           write(46,*) (xi(i,j),j=1,7)
		   end do
	       write(46,*) '+'
             write(46,*) vegsec,crossmax
	       rewind(46)
	      end if

c********************************
	      if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=6
             write(*,'(a)') '...generating cross-sec and grade (3p2)...'
             write(3,'(a)') '...generating cross-sec and grade (3p2)...'
             call parapwave
             call vegas(totfun,7,number,nitmx,2)
             xbcsec(6)=vegsec
             do i=1,NVEGBIN
	           write(47,*) (xi(i,j),j=1,7)
		   end do
	       write(47,*) '+'
             write(47,*) vegsec,crossmax
	       rewind(47)
	      end if

c********************************
	      if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=7                         !1s0 and octet
             write(*,'(a)') '.generating cross-sec and grade (1s0)_8...'
             write(3,'(a)') '.generating cross-sec and grade (1s0)_8...'
             call paraswave(ibcstate)
             ibcstate=1                   !return to original definition
		   call vegas(totfun,7,number,nitmx,2)
             xbcsec(7)=vegsec
             do i=1,NVEGBIN
	           write(48,*) (xi(i,j),j=1,7)
		   end do
	       write(48,*) '+'
             write(48,*) vegsec,crossmax
	       rewind(48)
	      end if

c********************************
	      if(imixtype.eq.1.or.imixtype.eq.3) then
		   ibcstate=8                         !3s1 and octet
             write(*,'(a)') '.generating cross-sec and grade (3s1)_8...'
             write(3,'(a)') '.generating cross-sec and grade (3s1)_8...'
             call paraswave(ibcstate)
             ibcstate=2                   !return to original definition
             call vegas(totfun,7,number,nitmx,2)
             do i=1,NVEGBIN
	           write(49,*) (xi(i,j),j=1,7)
		   end do
             xbcsec(8)=vegsec
	       write(49,*) '+'
             write(49,*) vegsec,crossmax
	       rewind(49)
	      end if
		end if
	  else
	   write(*,'(a,a,1x,g12.5)')'getting subprocess info....',
     &		 'at c.m. energy(gev)',subenergy
	   write(3,'(a,a,1x,g12.5)')'getting subprocess info....',
     &		 'at c.m. energy(gev)',subenergy
	   write(*,'(a)') 'the info. of hadron collider is no use!!!'
	   write(3,'(a)') 'the info. of hadron collider is no use!!!'
          if(iveggrade.eq.1) then
	   write(*,'(a)')'using existed grade to gene. precise grade.'
	   write(3,'(a)')'using existed grade to gene. precise grade.'
		   do i=1,NVEGBIN
	          read(11,*) (xi(i,j),j=1,7)
	       end do
c	       open(unit=29,file='data/newgrade.grid',status='unknown')
	       open(unit=29,file='newgrade.grid',status='unknown')
	    end if	   
		ndim=5
		call vegas(totfun,ndim,number,nitmx,2)
c...record the (new) generated grade.
	    do i=1,NVEGBIN
	       if(iveggrade.eq.1) then
			    write(29,*) (xi(i,j),j=1,ndim)
	       else
	            write(11,*) (xi(i,j),j=1,ndim)
		   end if
		end do
	  end if
	  call vegasend(vegasopen,ievntdis,usegrade)
      else
	  call vegasend(vegasopen,ievntdis,usegrade)
	  if(isubonly.eq.0) then
	     ndim=7
	  else
	     ndim=5
	     write(*,'(a)')'getting the info. of the subporcess....'
		 write(3,'(a)')'getting the info. of the subporcess....'
	  end if

c...initialize the grade.
	  rc=1.0d0/NVEGBIN
        do 77 j=1,ndim
           xi(NVEGBIN,j)=1.0d0
           dr=0.0d0
        do 77 i=1,NVEGBIN-1
           dr=dr+rc
           xi(i,j)=dr
77      continue

c*****************************************************************
c...using the existed grade. one thing should be care here is that
c...the existed grade should be formed under the same parameters.
        if(imix.eq.0) then
	    if(usegrade) then
	     write(*,'(a)') 'using the existed vegas grade.'
		 write(3,'(a)') 'using the existed vegas grade.'
		 do i=1,NVEGBIN
	        read(11,*) (xi(i,j),j=1,7)
	     end do
	    end if
	  end if
      end if

c********************************************
c***  find the total-corssection for each state 
c***  from the previous generated grade, used
c***  when vegas not used.
c********************************************

      if(imix.eq.1 .and. (.not.vegasopen)) then

	 if(imixtype.eq.1) then
	  do i=1,4
	   do
	     read(36+i-1,*) pfile
	     if(pfile.eq.'+') exit
	   enddo
	   read(36+i-1,*) xbcsec(i)
	   rewind(36+i-1)
	  enddo
	  do i=1,4
	   do
	     read(46+i-1,*) pfile
	     if(pfile.eq.'+') exit
	   enddo
	   read(46+i-1,*) xbcsec(4+i)
	   rewind(46+i-1)
	  enddo
	 end if
c---------------------------------------
	 if(imixtype.eq.2) then
	  do i=1,2
	   do
	     read(36+i-1,*) pfile
	     if(pfile.eq.'+') exit
	   enddo
	   read(36+i-1,*) xbcsec(i)
	   rewind(36+i-1)
	  enddo
	 end if
c----------------------------------------
	 if(imixtype.eq.3) then
	  do i=3,4
	   do
	     read(36+i-1,*) pfile
	     if(pfile.eq.'+') exit
	   enddo
	   read(36+i-1,*) xbcsec(i)
	   rewind(36+i-1)
	  enddo
	  do i=1,4
	   do
	     read(46+i-1,*) pfile
	     if(pfile.eq.'+') exit
	   enddo
	   read(46+i-1,*) xbcsec(4+i)
	   rewind(46+i-1)
	  enddo
	 end if
	end if

c*******************************************
	
	if(imix.eq.1) then
	 if(imixtype.eq.1) then 
	  xbcsum=0.0d0
	  do i=1,8
	   xbcsum=xbcsum+xbcsec(i)
	  end do
	  ibclimit=8
	 end if

	 if(imixtype.eq.2) then 
	  xbcsum=0.0d0
	  do i=1,2
	   xbcsum=xbcsum+xbcsec(i)
	  end do
	  ibclimit=2
	 end if

	 if(imixtype.eq.3) then 
	  xbcsum=0.0d0
	  do i=3,8
	   xbcsum=xbcsum+xbcsec(i)
	  end do
	  ibclimit=8
	 end if
	end if

	crossmax=0.0d0

c***************************************************
c***    some switches for event generation     *****
c***************************************************
c...switch off aspects: initial and final state
c...showers, multiple interactions, hadronization.
      if(ishower.eq.0) then
	  mstp(61) =0
        mstp(71) =0
        mstp(81) =0
        mstp(111)=0
	end if

c...expanded event listing (required for histogramming).
      mstp(125)=2

c...pyinit--->to initialize the generation procedure.
      call pyinit('user',' ',' ',0d0)

c...set bc+ stable.
      mdcy(pycomp(541),1)=0
c***************************************************

      return
	end