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
c 15.02.2004 Link routines between SIBYLL2.1 and EPOS.
c author T. Pierog


c-----------------------------------------------------------------------
      subroutine IniSibyll
c-----------------------------------------------------------------------
c Primary initialization for Sibyll
c-----------------------------------------------------------------------
      include 'epos.inc'
      COMMON /S_DEBUG/ Ncall, Ndebug
      COMMON /S_CSYDEC/ CBR(102), KDEC(612), LBARP(49), IDB(49)

      call utpri('inisib',ish,ishini,6)
      write(ifmt,'(a,i6)')'initialize Sibyll ...'

      Ndebug=0
      if(ish.ge.3)Ndebug=ish-2

C... SIBYLL initialization
      CALL SIBYLL_INI

C...Cross sections for nucleus-nucleus and hadron nucleus
      CALL NUC_NUC_INI

C...define all particles as unstable
      do i=1,49
        IDB(i) = abs(IDB(i))   ! >0 means unstable
      enddo


      egymin=10.1
      egymax=1e7
      irescl=0
      

      call utprix('inisib',ish,ishini,6)
      end

c-----------------------------------------------------------------------
      subroutine IniEvtSib
c-----------------------------------------------------------------------
c Initialization for each type of event (for given proj, targ and egy)
c-----------------------------------------------------------------------
      include 'epos.inc'
      COMMON /S_CSYDEC/ CBR(102), KDEC(612), LBARP(49), IDB(49)
      common/geom/rmproj,rmtarg,bmax,bkmx


      if(matarg.gt.18.or.maproj.gt.64)
     &  call utstop('Mass too big for Sibyll (Mtrg<18, Mprj<64) !&')
      id=idtrafo('nxs','sib',idproj)
      ida=abs(id)
      if(ida.lt.6.or.ida.gt.14)
     &  call utstop('projectile no allowed in Sibyll !&')
      if(idtarg.ne.0.and.idtarg.ne.1120)
     &  call utstop('target no allowed in Sibyll !&')
      if(bminim.gt.0.or.bmaxim.lt.1000)
     &  write(ifmt,*)'Only min bias event in Sibyll ... no b !'
      call iclass(idproj,iclpro)
      bminim=0.
      bmaxim=10000.
      bmax=10.+maproj+matarg
      sibincs=fsibcrse(engy,maproj,matarg)
      if(engy.lt.egymin)sibincs=0.          !below egymin, no interaction
      call xsigma


c Epos syntax to allow (or not) particle decay in Sibyll
c (part taken from epos-dky: hdecas)

      if(idecay.eq.1.and.ctaumin.le.0.)then

      if(ndecay.eq.1.or.mod(ndecay/10,10).eq.1)then          !Kshort, Klong
        IDB(11) = -abs(IDB(11))   ! <0 means stable
        IDB(12) = -abs(IDB(12))
      endif
      if(ndecay.eq.1.or.mod(ndecay/100,10).eq.1)then         !Lambda
        IDB(39) = -abs(IDB(39))
      endif
      if(ndecay.eq.1.or.mod(ndecay/1000,10).eq.1)then        !sigma+
        IDB(34) = -abs(IDB(34))
      endif
      if(ndecay.eq.1.or.mod(ndecay/1000,10).eq.1)then        !sigma-
        IDB(36) = -abs(IDB(36))
      endif
      if(ndecay.eq.1.or.mod(ndecay/10000,10).eq.1)then       !Xi+/-
        IDB(38) = -abs(IDB(38))
      endif
      if(ndecay.eq.1.or.mod(ndecay/10000,10).eq.1)then       !Xi0
        IDB(37) = -abs(IDB(37))
      endif
      if(ndecay.eq.1.or.mod(ndecay/100000 ,10).eq.1)then     !omega
        IDB(49) = -abs(IDB(49))
      endif
      if(ndecay.eq.1.or.mod(ndecay/1000000,10).eq.1)then     !pi0
        IDB(6) = -abs(IDB(6))
      endif

      if(nrnody.gt.0)then                      !all other particle
        do nod=1,nrnody
          idd=abs(idtrafo('nxs','sib',nody(nod)))
          if(idd.lt.50)IDB(idd) = -abs(IDB(idd))
        enddo
      endif

      else

C...define all particles as stable
      do i=1,49
        IDB(i) = -abs(IDB(i))   ! <0 means stable
      enddo

      endif

      if(ish.ge.2)write(ifch,*)
     &  'Sibyll used with (E,proj,maproj,matarg)',engy,id,maproj
     &  ,matarg

      return
      end

c-----------------------------------------------------------------------
      subroutine emssib(iret)
c-----------------------------------------------------------------------
c  call Sibyll to simulate interaction
c-----------------------------------------------------------------------
      include 'epos.inc'
      common/geom/rmproj,rmtarg,bmax,bkmx
C  SIBYLL
      COMMON /S_PLIST/ P(8000,5), LLIST(8000), NP
      COMMON /S_PLNUC/ PA(5,40000), LLA(40000), NPA
      PARAMETER (NW_max = 20)
      PARAMETER (NS_max = 20, NH_max = 50)
      PARAMETER (NJ_max = (NS_max+NH_max)*NW_max)
      COMMON /S_CHIST/ X1J(NJ_max),X2J(NJ_max),
     &    X1JSUM(NW_max),X2JSUM(NW_max),PTJET(NJ_max),PHIJET(NJ_max),
     &    NNPJET(NJ_max),NNPSTR(2*NW_max),NNSOF(NW_max),NNJET(NW_max),
     &    JDIF(NW_max),NW,NJET,NSOF

      iret=0
      b1=bminim
      b2=min(bmax,bmaxim)
      a=pi*(b2**2-b1**2)

      if(a.gt.0..and.rangen().gt.sibincs/10./a)goto 1001   !no interaction
      if(ish.ge.3)call alist('Determine Sibyll Production&',0,0)

      nptl=0
      NP=0
      NPA=0
      
      nevt=1
      kolevt=-1
      koievt=-1
      kohevt=-1
      npjevt=maproj
      ntgevt=matarg
      pmxevt=pnll
      egyevt=engy
      bimevt=0.
      bimp=0.
      phievt=0.
      phi=0.
      anintine=anintine+1.
      ns=0                      !number of projectile spectators
      npps=0
      npns=0

      call conre
      call conwr

      itrg=matarg
      if(idtargin.eq.0)itrg=0
      if(maproj.eq.1)then             !hadronic projectile
        L0=idtrafo('nxs','sib',idproj)
        CALL SIBYLL (L0, itrg, engy)
        CALL DECSIB
        if(ish.ge.5)write(ifch,'(a,i5)')
     $         ' number of particles from Sibyll :',NP
c save interaction type
        if(JDIF(1).eq.0)then
          typevt=1                !ND
        elseif(JDIF(1).eq.3)then
          typevt=2                !DD
        else
          typevt=4                !SD
        endif
        do k=1,NP

c LLIST is the code of final particle, P - its 4-momentum and mass.
          ic=LLIST(k)
            
          if(ish.ge.7)write(ifch,'(a,i5,a,i5,2a,4(e10.4,1x))')
     $       ' Sibyll particle ',k,' id :',ic,' before conversion'
     $     , ' momentum :',(P(k,i),i=1,5)

          nptl=nptl+1
          if(nptl.gt.mxptl)call utstop('Sibyll: mxptl too small&')

          if(abs(ic).ge.10000)then
            ic=ic-sign(10000,ic)
            istptl(nptl)=1
          else
            istptl(nptl)=0
          endif

          id=idtrafo('sib','nxs',ic)
          if(ish.ge.7)write(ifch,'(a,i5,a,i5,a)')
     $         ' epos particle ',nptl,' id :',id,' after conversion'
            

          pptl(1,nptl)=P(k,1)   !P_x
          pptl(2,nptl)=P(k,2)   !P_y
          pptl(3,nptl)=P(k,3)   !P_z
          pptl(4,nptl)=abs(P(k,4))   !E
          pptl(5,nptl)=P(k,5)   !mass
          ityptl(nptl)=0
          iorptl(nptl)=1
          jorptl(nptl)=maproj+matarg
          ifrptl(1,nptl)=0
          ifrptl(2,nptl)=0
          xorptl(1,nptl)=0.
          xorptl(2,nptl)=0.
          xorptl(3,nptl)=0.
          xorptl(4,nptl)=0.
          tivptl(1,nptl)=0.
          tivptl(2,nptl)=0.
          idptl(nptl)=id
          
            
          if(ish.ge.5)write(ifch,'(a,i5,a,i5,a,4(e10.4,1x),f6.3)')
     $         ' particle from Sibyll ',nptl,' id :',idptl(nptl)
     $         , ' momentum :',(pptl(i,nptl),i=1,5)


        enddo
        if(NW.lt.matarg)then
          ntgevt=NW
          do is=maproj+1+NW,maproj+matarg !make the ns last target nucleon final
            iorptl(is)=0
            istptl(is)=0
          enddo
        endif
      else                          !for nucleus projectile
        nbar=0
        IAP = maproj
        CALL SIBNUC (IAP, itrg, engy)
        if(ish.ge.5)write(ifch,'(a,i5)')
     $         ' number of particles from Sibyll :',NPA
        do 100 k=1,NPA

c LLIST is the code of final particle, P - its 4-momentum and mass.
          ic=LLA(k)
            
          if(ish.ge.7)write(ifch,'(a,i5,a,i5,2a,4(e10.4,1x))')
     $       ' Sibyll particle ',k,' id :',ic,' before conversion'
     $     , ' momentum :',(PA(i,k),i=1,5)


          nNuc=0
          if(ic.ge.1001) then                !count spectators
            nNuc=ic-1000
            if(infragm.le.1
     &         .or.PA(4,k).lt.0.5*egymin)then   !nuclear interaction only above min energy, otherwise : fragmentation
              ns=ns+nNuc
              goto 100
            elseif(ic.eq.1001)then
              if(drangen(dummy).lt.0.45d0) then
                ic = 13
                npps=npps+1
              else
                ic = 14
                npns=npns+1
               endif
              nNuc=0
            else
              ptm=sqrt(PA(1,k)*PA(1,k)+PA(2,k)*PA(2,k)+PA(5,k)*PA(5,k))
              PA(4,k)=PA(4,k)*float(nNuc)            !energy by nucleon
              PA(3,k)=sign(sqrt((PA(4,k)+ptm)*(PA(4,k)-ptm)),PA(3,k))
              npps=npps+nNuc/2
              npns=npns+nNuc-nNuc/2
            endif
          endif
          nptl=nptl+1
          if(nptl.gt.mxptl)call utstop('Sibyll: mxptl too small&')
          id=idtrafo('sib','nxs',ic)
          if(ish.ge.7)write(ifch,'(a,i5,a,i10,a)')
     $         ' epos particle ',nptl,' id :',id,' after conversion'
            

          nbar=nbar+nNuc
          if(abs(id).gt.1000.and.nNuc.eq.0)nbar=nbar+sign(1,id)
          pptl(1,nptl)=PA(1,k)  !P_x
          pptl(2,nptl)=PA(2,k)  !P_y
          pptl(3,nptl)=PA(3,k)  !P_z
          pptl(4,nptl)=PA(4,k)  !E
          pptl(5,nptl)=PA(5,k)  !mass
          istptl(nptl)=0
          ityptl(nptl)=0
          iorptl(nptl)=1
          jorptl(nptl)=maproj+matarg
          ifrptl(1,nptl)=0
          ifrptl(2,nptl)=0
          xorptl(1,nptl)=0.
          xorptl(2,nptl)=0.
          xorptl(3,nptl)=0.
          xorptl(4,nptl)=0.
          tivptl(1,nptl)=0.
          tivptl(2,nptl)=0.
          idptl(nptl)=id
          
            
          if(ish.ge.5)write(ifch,'(a,i5,a,i10,a,4(e10.4,1x),f6.3)')
     $         ' particle from Sibyll ',nptl,' id :',idptl(nptl)
     $         , ' momentum :',(pptl(i,nptl),i=1,5)

 100    continue

        ntw=nbar-(maproj-ns)
        nsf=0
        if(ntw.lt.matarg)then
          ntgevt=ntw
          do is=maproj+1+ntw,maproj+matarg !make the nts last target nucleon final (not wounded)
            iorptl(is)=0
            istptl(is)=0
          enddo
        else
          nsf=maproj+matarg-nbar
        endif
          if(ish.ge.5)write(ifch,'(a,i3,a,i3,a,i2,a)')
     $         ' target spectators :',matarg-ntw
     $        ,' projectile spectators (ns) :',nsf,' (',ns,')'
        if((infragm.le.1.or.ns.gt.0).and.nsf.le.maproj)then
          if(infragm.eq.2)ns=ns-nsf
          if(infragm.eq.1.and.ns.gt.0)then
c  remaining nucleus is one fragment
            nptl=nptl+1
            istptl(nptl)=0
            pptl(1,nptl)=0.d0
            pptl(2,nptl)=0.d0
            pptl(4,nptl)=0.d0
            inucl=0
            do is=1,ns
              inucl=inucl+1
              pptl(4,nptl)=pptl(4,nptl)+pptl(4,is)
            enddo
            iprot= int(dble(inucl) / 2.15d0 + 0.7d0)
            idnucl=1000000000+iprot*10000+inucl*10 !code for nuclei
            npps=npps+iprot
            npns=npns+inucl-iprot
            call idmass(idnucl,am)
            pptl(5,nptl)=am  !mass
            ptot=(pptl(4,nptl)+am)*(pptl(4,nptl)-am)
            pptl(3,nptl)=sqrt(ptot)
            ityptl(nptl)=0
            istptl(nptl)=0
            iorptl(nptl)=1
            jorptl(nptl)=maproj
            ifrptl(1,nptl)=0
            ifrptl(2,nptl)=0
            xorptl(1,nptl)=xorptl(1,1)
            xorptl(2,nptl)=xorptl(2,1)
            xorptl(3,nptl)=xorptl(3,1)
            xorptl(4,nptl)=xorptl(4,1)
            tivptl(1,nptl)=tivptl(1,1)
            tivptl(2,nptl)=tivptl(2,1)
            idptl(nptl)=idnucl
          else
            do is=maproj-ns+1,maproj         !make the nsf first projectile nucleon final (not wounded)
              if(infragm.eq.2)istptl(is)=0
              if(idptl(is).eq.1120)npps=npps+1
              if(idptl(is).eq.1220)npns=npns+1
            enddo
          endif
        endif
c number of participants
        if(laproj.gt.1)then
        npjevt=maproj-npps-npns
        npppar=max(0,laproj-npps)
        npnpar=npjevt-npppar
c set participant projectile as non spectators
        do i=1,maproj
          if(idptl(i).eq.1120)then
            if(npppar.gt.0)then
              npppar=npppar-1
            else                !restore spectators
              iorptl(i)=0
              if(infragm.eq.0)istptl(i)=0
            endif
          endif
          if(idptl(i).eq.1220)then
            if(npnpar.gt.0)then
              npnpar=npnpar-1
            else                !restore spectators
              iorptl(i)=0
              if(infragm.eq.0)istptl(i)=0
            endif
          endif
        enddo
      endif

      endif


1000  return

1001  iret=-1 
      goto 1000 

      end


c------------------------------------------------------------------------------
      function fsibcrse(egy,mapro,matar)
c------------------------------------------------------------------------------
c hadron-proton particle production cross section with Sibyll.
c egy - center of mass energy
c------------------------------------------------------------------------------
      include 'epos.inc'
      dimension SDIF(3)

      if(iclpro.eq.1)then
        L=2
      elseif(iclpro.eq.2)then
        L=1
      else
        L=3
      endif
      call SIB_SIGMA_HP(L,egy,ST,SEL,SINEL,SDIF,SL,RHO)
      if(matar.gt.1)then
C  calculate hadron-A(matar) cross section
        CALL GLAUBER(matar,ST,SL,RHO,SIGTA,SIGELAdum,SIGQEA)
        fsibcrse=SIGTA-SIGQEA
      else
        fsibcrse=SINEL
      endif

      if(mapro.gt.1)fsibcrse=ainfin !???????? temporary

      return
      end

c------------------------------------------------------------------------------
      double precision function sibcrse(ek,mapro,matar,id)
c------------------------------------------------------------------------------
c inelastic cross section of Sibyll 
c if id=0, target = air
c ek - kinetic energy in GeV
c maproj - projec mass number     (1<maproj<64)
c matarg - projec mass number
c id - proj id (sibyll code)
c------------------------------------------------------------------------------
      include 'epos.inc'
      double precision egy
      COMMON /CLENNN/ SSIGNUC(60), ALNUC(60)

      sibcrse=0.d0
      call idmass(1120,amt1)
      call idmass(1220,amt2)
      amtar=0.5*(amt1+amt2)
      if(mapro.eq.1)call idmass(idproj,ampro)
      if(matar.eq.1)call idmass(idtarg,amtar)
      egy=dble(ek+ampro)
      if(id.eq.0)then
        if(maproj.eq.1)then
          sqs=sqrt( 2*real(egy)*amtar+amtar**2+ampro**2 )
          if(iclpro.eq.1)then
            L=2
          elseif(iclpro.eq.2)then
            L=1
          else
            L=3
          endif
          call SIB_SIGMA_HAIR (L,sqs,sibcr)
          sibcrse=dble(sibcr)
        else
          EO=real(egy)*1.e-3         !e0 in TeV
          CALL  SIGNUC_INI(mapro,E0) !  fills SSIGNUC and ALNUC
          sibcrse  = dble(SSIGNUC(mapro))
        endif
      else
        sqs=sqrt( 2*real(egy)*amtar+amtar**2+ampro**2 )
        sibcrse=dble(fsibcrse(sqs,mapro,matar))
      endif

      return
      end

c--------------------------------------------------------------------
      function S_RNDM(idum)
c--------------------------------------------------------------------
c random number generator
c--------------------------------------------------------------------
      include 'epos.inc'

      S_RNDM=rangen()
      if(irandm.eq.1)write(ifch,*)'S_RNDM()= ',S_RNDM,idum

      return
      end