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)
16 real mcfixedweight, mcextraweight, dilut, gendilut
17 real epx, epy, epz, eprim, ept, eptheta, epphi
18 double precision fdilut, f1,
f2,
r, da1, da2
19 DOUBLE PRECISION radgame, radgamp, radgamenucl, etheta, temp
20 DOUBLE PRECISION pbeame, pbeta, pgamma, ebeame, epznucl
21 DOUBLE PRECISION depol, gamma2,
d, eta,
eps, chi
22 DOUBLE PRECISION gendepol, gengamma2, gend, geneta, geneps
23 double precision genf1, genf2, genr, gena1, gena2, genchi
24 DOUBLE PRECISION dbrack, dxsec, depolweight
26 logical uselut, genlut
29 c---------------------------------------------------------------------
31 c ---------------------------------------------------------------------
34 CHARACTER*256 outputfilename
68 c init all the parameters and
read them
in
79 READ(*,*) pbeam, ebeam
83 READ(*,*) mcset_xmin, mcset_xmax
85 READ(*,*) mcset_ymin, mcset_ymax
87 READ(*,*) mcset_q2min, mcset_q2max
89 READ(*,*) genset_fstruct, genset_r
90 c...
Read switch
for rad-corrections
93 READ(*,*) mcset_w2min,mcset_w2max
95 READ(*,*) mcset_numin,mcset_numax
97 READ(*,*) mcset_pbvalue, mcset_ptvalue
98 c...
Read beam and
Target polarisation
99 READ(*,*) mcset_pbeam, mcset_ptarget
100 c...
Read all the pepsi/
lepto parameters
101 100
READ(*,*,
end=200)
param, j, rval
102 if (
param.eq.
'LST')
then
104 write(*,*)
'LST(',j,
')=',rval
106 if (
param.eq.
'PARL')
then
108 write(*,*)
'PARL(',j,
')=',rval
110 if (
param.eq.
'PARJ')
then
112 write(*,*)
'PARJ(',j,
')=',rval
114 if (
param.eq.
'MSTJ')
then
116 write(*,*)
'MSTJ(',j,
')=',rval
118 if (
param.eq.
'MSTU')
then
120 write(*,*)
'MSTU(',j,
')=',rval
122 if (
param.eq.
'PARU')
then
124 write(*,*)
'PARU(',j,
')=',rval
127 200
write(*,*)
'*********************************************'
128 write(*,*)
'NOW all parameters are read by PEPSI'
129 write(*,*)
'*********************************************'
131 c ... pepsi polarization
132 if (mcset_pbvalue*mcset_ptvalue.lt.0.)
then
134 elseif (mcset_pbvalue*mcset_ptvalue.gt.0.)
then
140 c ... polarization
for helium 3
141 c use lst(39)=1
for ideal helium 3 (no
s prime and
d state)
142 c use lst(39)=3 or (02 should work too ?)
for a real helium 3.
144 if (lst(40).ne.0.and.parl(1).eq.3.and.parl(2).eq.2)
then
163 c cut(10)=mcset_numax
173 initseed = today(1) + 10*today(2) + today(3) +
now(1) + 5*
now(3)
174 write(6,*)
'SEED = ', initseed
175 call
rndmq(idum1,idum2,initseed,
' ')
177 if (abs(ltype).eq.11)
then
180 write(*,*)
"Only positron and electron beam supported"
183 if ((parl(1).eq.1).and.(parl(2).eq.1))
then
185 elseif ((parl(1).eq.1).and.(parl(2).eq.0))
then
187 elseif ((parl(1).eq.2).and.(parl(2).eq.1))
then
190 write(*,*)
"Currently only p,n,d as target supported"
193 pbeame=sqrt(pbeam**2+massp**2)
196 ebeame=sqrt(ebeam**2+masse**2)
197 ebeamenucl=pgamma*ebeame-pgamma*pbeta*(-ebeam)
198 epznucl=-pgamma*pbeta*ebeame+pgamma*(-ebeam)
199 write(*,*)
"proton-Beam: ", pbeame
200 write(*,*)
"lepton-beam: ", -ebeame, ebeamenucl, epznucl
202 mcset_enebeam=sngl(ebeamenucl)
204 write(*,*)
"Ymax=",mcset_ymax,
" Ebeam=",ebeamenucl,
205 +
" set Q2Max=",mcset_q2max,
206 +
"kinematic Q2Max=", 2*massp*ebeamenucl*mcset_ymax
210 call
linit(0,ltype,(-ebeam),pbeam,lst(23))
213 if (qedrad.eq.1)
then
217 write(*,*)
'I have initialized radgen'
218 elseif (qedrad.eq.2)
then
219 write(*,*)
'radgen lookup table will be generated'
226 c ---------------------------------------------------------------------
228 c ---------------------------------------------------------------------
229 outputfilename=outname
230 open(asciilun, file=outputfilename)
231 write(*,*)
'the outputfile will be named: ', outname
234 if (qedrad.eq.1)
then
235 mcfixedweight=(mcset_q2max-mcset_q2min)*(mcset_ymax-mcset_ymin)
240 c the total integrated xsec,
in pbarns
241 mcextraweight = parl(23)
247 write(29,*)
' PEPSI EVENT FILE '
248 write(29,*)
'============================================'
250 30
format(
'I, ievent, genevent, process, subprocess, nucleon,
251 & struckparton, partontrck, trueY, trueQ2, trueX, trueW2,
252 & trueNu, FixedWeight, weight, dxsec, depolWeight, Extraweight,
253 & dilut, F1, F2, A1, A2, R, Depol, d, eta, eps, chi,
254 & gendilut, genF1, genF2, genA1, genA2, genR, genDepol, gend,
255 & geneta, geneps, genchi, Sigcor, radgamEnucl, nrTracks')
257 write(29,*)
'============================================'
258 write(29,*)
' I K(I,1) K(I,2) K(I,3) K(I,4) K(I,5)
259 & P(I,1) P(I,2) P(I,3) P(I,4) P(I,5) V(I,1) V(I,2) V(I,3)'
260 write(29,*)
'============================================'
268 if (qedrad.eq.0)
then
270 write(*,*)
'Generating full event with LEPTO/PEPSI.'
284 if (lst(21).ne.0)
then
285 write(*,*)
'PEPSI failed, trying again,
286 & no rad-corrections'
309 if (qedrad.eq.1)
then
311 write(*,*)
'Generating only hadrons with LEPTO/PEPSI.'
314 geny=mcset_ymin*(mcset_ymax/mcset_ymin)**
rlu(1)
315 genq2=mcset_q2min*(mcset_q2max/mcset_q2min)**
rlu(2)
316 gennu=geny*ebeamenucl
317 genx = genq2/(2.*massp*gennu)
318 genw2 = massp**2.+(genq2*(1./genx-1.))
319 geneprim = ebeamenucl - gennu
320 c write(*,*) genq2,mcset_q2min,(genq2.lt.mcset_q2min)
321 c write(*,*) genq2,2*gennu*massp,(genq2.gt.(2.*gennu*massp))
322 c write(*,*) genw2,mcset_w2min,(genw2.lt.mcset_w2min)
323 c write(*,*) (genq2/(2.*ebeamenucl*geneprim))-1.
324 if ((genq2.lt.mcset_q2min).or.(genq2.gt.(2.*gennu*massp))
325 & .or.(genw2.lt.mcset_w2min))
then
328 temp=(genq2/(2.*ebeamenucl*geneprim))-1.
329 if ((temp.le.1.).and.(temp.ge.-1.))
then
331 genthe = sngl(etheta)
354 ept=sqrt(epx**2+epy**2+epz**2)
355 eptheta=acos(epz/ept)
356 epphi=atan(
p(4,2)/
p(4,1))
365 c write(*,*)
'0:', geny, genq2, genx, genw2, gennu
366 c write(*,*)
'after radgen', mcradcor_ytrue,
367 c & mcradcor_q2true, mcradcor_xtrue, mcradcor_w2true,
368 c & mcradcor_nutrue, mcradcor_ebrems, mcradcor_sigcor
370 if (mcradcor_ebrems.gt.0.)
then
376 if ((q2 .lt. cut(5)) .or. (w2 .lt. cut(7)))
then
377 write(*,*)
'WARNING:Radiated event beyond PEPSI range'
378 write (*,*)
' Q2 ', q2, cut(5)
379 write (*,*)
' W2 ', w2, cut(7)
382 elseif (mcradcor_ebrems.eq.0.)
then
388 if ((q2 .lt. cut(5)) .or. (w2 .lt. cut(7)))
then
389 write(*,*)
'WARNING: Radiated event beyond PEPSI range'
390 write (*,*)
' Q2 ', q2, cut(5)
391 write (*,*)
' W2 ', w2, cut(7)
396 weight = weight * mcradcor_sigcor * mcfixedweight
414 if (lst(21).ne.0)
then
415 write(*,*)
'Gen Hadrons: PEPSI failed, trying again'
422 if ((
k(i,1).eq.0).and.(
k(i,2).eq.0).and.(
k(i,3).eq.0).and.
423 & (
k(i,4).eq.0).and.(
k(i,5).eq.0))
then
425 if (mcradcor_ebrems.gt.0.)
then
436 call
mkasym(dble(q2), dble(
x), mcset_tara, mcset_tarz, da1, da2)
437 call
mkasym(dble(genq2), dble(genx), mcset_tara, mcset_tarz,
439 call
mkf2(dble(q2), dble(
x), mcset_tara, mcset_tarz,
f2, f1)
440 call
mkf2(dble(genq2), dble(genx), mcset_tara, mcset_tarz,
442 call
mkr(dble(q2), dble(
x),
r)
443 call
mkr(dble(genq2), dble(genx), genr)
444 dilut =
real(fdilut(dble(Q2), dble(X), mcset_tara))
445 gendilut =
real(fdilut(dble(genQ2), dble(genX), mcset_tara))
448 gengamma2=genq2/gennu**2
451 gendepol=(geny*(1.+gengamma2*geny/2.)*(2.-geny)-2*geny**2*
452 & masse**2/genq2)/(geny**2*(1.-2.*masse**2/genq2)*
453 & (1.+gengamma2)+2.*(1.+genr)*
454 & (1.-geny-gengamma2*geny**2/4.))
455 depol=(
y*(1.+gamma2*
y/2.)*(2.-
y)-2*
y**2*masse**2/q2)/
456 & (
y**2*(1.-2.*masse**2/q2)*(1.+gamma2)+2.*(1.+
r)*
457 & (1.-
y-gamma2*
y**2/4.))
459 gend=gendepol*((sqrt(1.-geny-gengamma2*
y**2/4.)*
460 & (1+gengamma2*geny/2.))/(1.-geny/2.)*(1+gengamma2*geny/2.)-
461 & geny**2*masse**2/genq2)
462 d=depol*((sqrt(1.-
y-gamma2*
y**2/4.)*(1+gamma2*
y/2.)) /
463 & (1.-
y/2.)*(1+gamma2*
y/2.)-
y**2*masse**2/q2)
465 geneta=(sqrt(gengamma2)*(1.-geny-gengamma2*geny**2/4.-
466 & geny**2*masse**2/genq2)) / ((1.+gengamma2**2*geny/2.)*
467 & (1-geny/2.)-geny**2*masse**2/genq2)
468 eta=(sqrt(gamma2)*(1.-
y-gamma2*
y**2/4.-
y**2*masse**2/q2)) /
469 & ((1.+gamma2**2*
y/2.)*(1-
y/2.)-
y**2*masse**2/q2)
471 genchi=(sqrt(gengamma2)*(1.-geny/2.-geny**2.*masse**2/genq2))/
472 & (1.+gengamma2*geny/2.)
473 chi=(sqrt(gamma2)*(1.-
y/2.-
y**2.*masse**2/q2))/(1.+gamma2*
y/2.)
475 geneps=1./(1.+1./2.*(1.-2.*masse**2/genq2)*
476 & ((geny**2+gengamma2*geny**2)/
477 & (1.-geny-gengamma2*geny**2/4.)))
478 eps=1./(1.+1./2.*(1.-2.*masse**2/q2)*((
y**2+gamma2*
y**2)/
479 & (1.-
y-gamma2*
y**2/4.)))
481 dbrack = (4.*paru(1)*alpha**2)/genq2**2
482 c cross section
in hbar^2
c^2/gev^2/dq^2/
dx
483 dxsec = dbrack*((1.-geny-(massp*genx*geny/2./ebeame))*
484 & genf2/genx+geny**2*genf1)
485 c cross sectin
in mbarn/dq^2/
dx
486 dxsec = dxsec * 0.389379292
488 depolweight = (1.- gendilut*(mcset_pbvalue*mcset_ptvalue)*
489 & (gendepol*(gena1+geneta*gena2)))
491 if (qedrad.eq.1) weight = weight*dxsec*depolweight
493 c write(*,*)
'rad:', genq2, parl(23), parl(24), weight,
494 c & mcradcor_sigcor, dxsec
496 if (mcradcor_ebrems.gt.0.)
then
497 radgamenucl=sqrt(dplabg(1)**2+dplabg(2)**2+dplabg(3)**2)
498 radgame=pgamma*radgamenucl+pgamma*pbeta*(-dplabg(3))
499 radgamp=+pgamma*pbeta*radgamenucl+pgamma*(-dplabg(3))
500 c write(*,*)
'photon:', radgamenucl, radgame, dplabg(3), radgamp
507 write(29,32) 0, iev,
genevent, lst(23), lst(24), lst(22),
508 & lst(25), lst(26),
y, q2,
x, w2, u, mcfixedweight, weight,
509 & dxsec, mcextraweight, dilut,
real(F1),
real(F2),
510 &
real(dA1),
real(dA2),
real(R),
real(Depol),
real(d),
511 &
real(eta),
real(eps),
real(chi), gendilut,
real(genF1),
512 &
real(genF2),
real(genA1),
real(genA2),
real(genR),
513 &
real(genDepol),
real(gend),
real(geneta),
real(geneps),
514 &
real(genchi), mcradcor_sigcor, radgamenucl, nrtrack
515 32
format((i4,1
x,$),(i10,1
x,$),6(i6,1
x,$),
516 & 34(e18.10,1
x,$),i12,/)
517 write(29,*)
'============================================'
520 write(29,34) i,
k(i,1),
k(i,2),
k(i,3),
k(i,4),
k(i,5),
521 &
p(i,1),
p(i,2),
p(i,3),
p(i,4),
p(i,5),
522 &
v(i,1),
v(i,2),
v(i,3)
524 if (mcradcor_ebrems.gt.0.)
then
525 write(29,34) nrtrack, 55, 22, 1, 0, 0,
526 & sngl(dplabg(1)),sngl(dplabg(2)),sngl(radgamp),
527 & sngl(radgame), 0., 0., 0., 0.
528 34
format(2(i6,1
x,$),i10,1
x,$,3(i6,1
x,$),8(f15.6,1
x,$),/)
530 write(29,*)
'=============== Event finished ==============='
536 500
if (qedrad.eq.2)
then
537 write(*,*)
'lookup table is generated;'
538 write(*,*)
'to run now PEPSI change parameter qedrad to 1'
541 c...
print the pepsi cross section which
is needed
to get an absolut
542 c normalisation the number
is in pbarns
543 write(*,*)
'==================================================='
544 write(*,*)
'Pepsi total cross section in pb from numerical',
545 &
' integration', parl(23)
546 write(*,*)
'Pepsi total cross section in pb from MC simulation',
548 write(*,*)
'Total Number of generated events', nev
549 write(*,*)
'Total Number of trials', nevgen
550 write(*,*)
'==================================================='