10 integer nevgen, i, j, lastgenevent,
genevent
11 integer iev, nev, nprt
12 integer idum1, idum2, initseed
13 integer ltype, tracknr, nrtrack,
t1,
t2
14 integer*4 today(3),
now(3)
15 real rval, alpha, alpha2
16 real mcfixedweight, mcextraweight, dilut, gendilut
17 real truey, trueq2, truex, truenu, truew2
18 real epx, epy, epz, eprim, ept, eptheta, epphi
19 double precision fdilut, f1,
f2,
r, da1, da2
20 DOUBLE PRECISION radgame, radgamp, radgamenucl, etheta, temp
21 DOUBLE PRECISION pbeame, pbeta, pgamma, ebeame, epznucl
22 DOUBLE PRECISION depol, gamma2,
d, eta,
eps, chi
23 DOUBLE PRECISION gendepol, gengamma2, gend, geneta, geneps
24 double precision genf1, genf2, genr, gena1, gena2, genchi
25 DOUBLE PRECISION dbrack, dxsec
27 logical uselut, genlut
30 c---------------------------------------------------------------------
32 c ---------------------------------------------------------------------
35 CHARACTER*256 outputfilename
55 c init all the parameters and
read them
in
66 READ(*,*) pbeam, ebeam
70 READ(*,*) mcset_xmin, mcset_xmax
72 READ(*,*) mcset_ymin, mcset_ymax
74 READ(*,*) mcset_q2min, mcset_q2max
76 READ(*,*) genset_fstruct, genset_r
77 c...
Read switch
for rad-corrections
80 READ(*,*) mcset_w2min,mcset_w2max
82 READ(*,*) mcset_numin,mcset_numax
84 READ(*,*) mcset_pbvalue, mcset_ptvalue
85 c...
Read beam and
Target polarisation
86 READ(*,*) mcset_pbeam, mcset_ptarget
87 c...
Read all the pepsi/
lepto parameters
88 100
READ(*,*,
end=200)
param, j, rval
89 if (
param.eq.
'LST')
then
91 write(*,*)
'LST(',j,
')=',rval
93 if (
param.eq.
'PARL')
then
95 write(*,*)
'PARL(',j,
')=',rval
97 if (
param.eq.
'PARJ')
then
99 write(*,*)
'PARJ(',j,
')=',rval
101 if (
param.eq.
'MSTJ')
then
103 write(*,*)
'MSTJ(',j,
')=',rval
105 if (
param.eq.
'MSTU')
then
107 write(*,*)
'MSTU(',j,
')=',rval
109 if (
param.eq.
'PARU')
then
111 write(*,*)
'PARU(',j,
')=',rval
114 200
write(*,*)
'*********************************************'
115 write(*,*)
'NOW all parameters are read by PEPSI'
116 write(*,*)
'*********************************************'
118 c ... pepsi polarization
119 if (mcset_pbvalue*mcset_ptvalue.lt.0.)
then
121 elseif (mcset_pbvalue*mcset_ptvalue.gt.0.)
then
127 c ... polarization
for helium 3
128 c use lst(39)=1
for ideal helium 3 (no
s prime and
d state)
129 c use lst(39)=3 or (02 should work too ?)
for a real helium 3.
131 if (lst(40).ne.0.and.parl(1).eq.3.and.parl(2).eq.2)
then
150 c cut(10)=mcset_numax
160 initseed = today(1) + 10*today(2) + today(3) +
now(1) + 5*
now(3)
161 write(6,*)
'SEED = ', initseed
162 call
rndmq(idum1,idum2,initseed,
' ')
164 if (abs(ltype).eq.11)
then
167 write(*,*)
"Only positron and electron beam supported"
170 if ((parl(1).eq.1).and.(parl(2).eq.1))
then
172 elseif ((parl(1).eq.1).and.(parl(2).eq.0))
then
174 elseif ((parl(2).eq.2).and.(parl(2).eq.1))
then
177 write(*,*)
"Currently only p,n,d as target supported"
180 pbeame=sqrt(pbeam**2+massp**2)
183 ebeame=sqrt(ebeam**2+masse**2)
184 ebeamenucl=pgamma*ebeame-pgamma*pbeta*(-ebeam)
185 epznucl=-pgamma*pbeta*ebeame+pgamma*(-ebeam)
186 c write(*,*) ebeamenucl, ebeame, epznucl, -ebeam
187 mcset_enebeam=sngl(ebeamenucl)
191 call
linit(0,ltype,(-ebeam),pbeam,lst(23))
194 if (qedrad.eq.1)
then
198 write(*,*)
'I have initialized radgen'
199 elseif (qedrad.eq.2)
then
200 write(*,*)
'radgen lookup table will be generated'
207 c ---------------------------------------------------------------------
209 c ---------------------------------------------------------------------
210 outputfilename=outname
211 open(asciilun, file=outputfilename)
212 write(*,*)
'the outputfile will be named: ', outname
214 c the total integrated xsec,
in pbarns
215 if (qedrad.eq.1)
then
216 mcfixedweight=(mcset_q2max-mcset_q2min)*(mcset_ymax-mcset_ymin)
225 write(29,*)
' PEPSI EVENT FILE '
226 write(29,*)
'============================================'
228 30
format(
'I, ievent, genevent, process, subprocess, nucleon,
229 & struckparton, partontrck, trueY, trueQ2, trueX, trueW2,
230 & trueNu, FixedWeight, weight, Extraweight, Sigcor, dilut, F1,
231 & F2, A1, A2, R, Depol, d, eta, eps, chi, radgamEnucl, nrTracks')
233 write(29,*)
'============================================'
234 write(29,*)
' I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5)
235 & P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)'
236 write(29,*)
'============================================'
244 if (qedrad.eq.0)
then
246 write(*,*)
'Generating full event with LEPTO/PEPSI.'
260 if (lst(21).ne.0)
then
261 write(*,*)
'PEPSI failed, trying again,
262 & no rad-corrections'
285 if (qedrad.eq.1)
then
287 write(*,*)
'Generating only hadrons with LEPTO/PEPSI.'
290 geny=mcset_ymin*(mcset_ymax/mcset_ymin)**
rlu(1)
291 genq2=mcset_q2min*(mcset_q2max/mcset_q2min)**
rlu(2)
292 c geny = (mcset_ymax-mcset_ymin)*
rlu(1) + mcset_ymin
293 c genq2 = (mcset_q2max-mcset_q2min)*
rlu(2) + mcset_q2min
294 gennu=geny*ebeamenucl
295 genx = genq2/(2.*massp*gennu)
296 genw2 = massp**2.+(genq2*(1./genx-1.))
297 geneprim = ebeamenucl - gennu
298 if ((genq2.lt.mcset_q2min).or.(genq2.gt.(2.*gennu*massp))
299 & .or.(genw2.lt.mcset_w2min))
then
302 temp=(genq2/(2.*ebeamenucl*geneprim))-1.
303 if ((temp.le.1.).and.(temp.ge.-1.))
then
305 genthe = sngl(etheta)
327 ept=sqrt(epx**2+epy**2+epz**2)
328 eptheta=acos(epz/ept)
329 epphi=atan(
p(4,2)/
p(4,1))
338 c write(*,*)
'0:', geny, genq2, genx, genw2, gennu
339 c write(*,*)
'after radgen', mcradcor_ytrue,
340 c & mcradcor_q2true, mcradcor_xtrue, mcradcor_w2true,
341 c & mcradcor_nutrue, mcradcor_ebrems, mcradcor_sigcor
343 if (mcradcor_ebrems.gt.0.)
then
349 weight = weight * mcradcor_sigcor
350 if ((q2 .lt. cut(5)) .or. (w2 .lt. cut(7)))
then
351 write(*,*)
'WARNING:Radiated event beyond PEPSI range'
352 write (*,*)
' Q2 ', q2, cut(5)
353 write (*,*)
' W2 ', w2, cut(7)
356 elseif (mcradcor_ebrems.eq.0.)
then
362 weight = weight * mcradcor_sigcor
363 if ((q2 .lt. cut(5)) .or. (w2 .lt. cut(7)))
then
364 write(*,*)
'WARNING: Radiated event beyond PEPSI range'
365 write (*,*)
' Q2 ', q2, cut(5)
366 write (*,*)
' W2 ', w2, cut(7)
387 if (lst(21).ne.0)
then
388 write(*,*)
'Gen Hadrons: PEPSI failed, trying again'
395 if ((
k(i,1).eq.0).and.(
k(i,2).eq.0).and.(
k(i,3).eq.0).and.
396 & (
k(i,4).eq.0).and.(
k(i,5).eq.0))
then
398 if (mcradcor_ebrems.gt.0.)
then
409 call
mkasym(dble(q2), dble(
x), mcset_tara, mcset_tarz, da1, da2)
410 call
mkasym(dble(genq2), dble(genx), mcset_tara, mcset_tarz,
412 call
mkf2(dble(q2), dble(
x), mcset_tara, mcset_tarz,
f2, f1)
413 call
mkf2(dble(genq2), dble(genx), mcset_tara, mcset_tarz,
415 call
mkr(dble(q2), dble(
x),
r)
416 call
mkr(dble(genq2), dble(genx), genr)
417 dilut =
real(fdilut(dble(Q2), dble(X), mcset_tara))
418 gendilut =
real(fdilut(dble(genQ2), dble(genX), mcset_tara))
421 gengamma2=genq2/gennu**2
424 gendepol=(geny*(1.+gengamma2*geny/2.)*(2.-geny)-2*geny**2*
425 & masse**2/genq2)/(geny**2*(1.-2.*masse**2/genq2)*
426 & (1.+gengamma2)+2.*(1.+genr)*
427 & (1.-geny-gengamma2*geny**2/4.))
428 depol=(
y*(1.+gamma2*
y/2.)*(2.-
y)-2*
y**2*masse**2/q2)/
429 & (
y**2*(1.-2.*masse**2/q2)*(1.+gamma2)+2.*(1.+
r)*
430 & (1.-
y-gamma2*
y**2/4.))
432 gend=gendepol*((sqrt(1.-geny-gengamma2*
y**2/4.)*
433 & (1+gengamma2*geny/2.))/(1.-geny/2.)*(1+gengamma2*geny/2.)-
434 & geny**2*masse**2/genq2)
435 d=depol*((sqrt(1.-
y-gamma2*
y**2/4.)*(1+gamma2*
y/2.)) /
436 & (1.-
y/2.)*(1+gamma2*
y/2.)-
y**2*masse**2/q2)
438 geneta=(sqrt(gengamma2)*(1.-geny-gengamma2*geny**2/4.-
439 & geny**2*masse**2/genq2)) / ((1.+gengamma2**2*geny/2.)*
440 & (1-geny/2.)-geny**2*masse**2/genq2)
441 eta=(sqrt(gamma2)*(1.-
y-gamma2*
y**2/4.-
y**2*masse**2/q2)) /
442 & ((1.+gamma2**2*
y/2.)*(1-
y/2.)-
y**2*masse**2/q2)
444 genchi=(sqrt(gengamma2)*(1.-geny/2.-geny**2.*masse**2/genq2))/
445 & (1.+gengamma2*geny/2.)
446 chi=(sqrt(gamma2)*(1.-
y/2.-
y**2.*masse**2/q2))/(1.+gamma2*
y/2.)
448 geneps=1./(1.+1./2.*(1.-2.*masse**2/genq2)*
449 & ((geny**2+gengamma2*geny**2)/
450 & (1.-geny-gengamma2*geny**2/4.)))
451 eps=1./(1.+1./2.*(1.-2.*masse**2/q2)*((
y**2+gamma2*
y**2)/
452 & (1.-
y-gamma2*
y**2/4.)))
454 dbrack = (4.*paru(1)*alpha**2)/genq2**2
455 dxsec = dbrack*((1.-geny-(massp*genx*geny/2./ebeame))*
456 & genf2/genx+geny**2*genf1)*genx*genq2
457 dxsec = dxsec*(1.- gendilut*(mcset_pbvalue*mcset_ptvalue)*
458 & (gendepol*(gena1+geneta*gena2)))
460 if (qedrad.eq.1) weight = weight*dxsec
461 c write(*,*)
'rad:', genq2, parl(23), parl(24), weight,
462 c & mcradcor_sigcor, dxsec
464 if (mcradcor_ebrems.gt.0.)
then
465 radgamenucl=sqrt(dplabg(1)**2+dplabg(2)**2+dplabg(3)**2)
466 radgame=pgamma*radgamenucl+pgamma*pbeta*(-dplabg(3))
467 radgamp=+pgamma*pbeta*radgamenucl+pgamma*(-dplabg(3))
468 c write(*,*)
'photon:', radgamenucl, radgame, dplabg(3), radgamp
475 if ((parl(23).gt.0.).and.(parl(24).gt.0.))
then
476 mcextraweight = parl(24)/parl(23)
481 write(29,32) 0, iev,
genevent, lst(23), lst(24), lst(22),
482 & lst(25), lst(26),
y, q2,
x, w2, u, mcfixedweight, weight,
483 & mcextraweight, mcradcor_sigcor, dilut,
real(F1),
real(F2),
484 &
real(dA1),
real(dA2),
real(R),
real(Depol),
real(d),
485 &
real(eta),
real(eps),
real(chi), radgamenucl, nrtrack
486 32
format((i4,1
x,$),(i10,1
x,$),6(i6,1
x,$),5(f12.6,1
x,$),
487 & 2(f18.6,1
x,$), 14(f12.6,1
x,$),i12,/)
488 write(29,*)
'============================================'
491 write(29,34) i,
k(i,1),
k(i,2),
k(i,3),
k(i,4),
k(i,5),
492 &
p(i,1),
p(i,2),
p(i,3),
p(i,4),
p(i,5),
493 &
v(i,1),
v(i,2),
v(i,3)
495 if (mcradcor_ebrems.gt.0.)
then
496 write(29,34) nrtrack, 55, 22, 1, 0, 0,
497 & sngl(dplabg(1)),sngl(dplabg(2)),sngl(radgamp),
498 & sngl(radgame), 0., 0., 0., 0.
499 34
format(2(i6,1
x,$),i10,1
x,$,3(i6,1
x,$),8(f15.6,1
x,$),/)
501 write(29,*)
'=============== Event finished ==============='
507 500
if (qedrad.eq.2)
then
508 write(*,*)
'lookup table is generated;'
509 write(*,*)
'to run now PEPSI change parameter qedrad to 1'
513 c normalisation the number
is in pbarns
514 write(*,*)
'==================================================='
515 write(*,*)
'Pepsi total cross section in pb from numerical',
516 &
' integration', parl(23)
517 write(*,*)
'Pepsi total cross section in pb from MC simulation',
519 write(*,*)
'mcextraweight =', mcextraweight
520 write(*,*)
'Total Number of generated events', nev
521 write(*,*)
'Total Number of trials', nevgen
522 write(*,*)
'==================================================='