2
c Sample analysis for leptonic final states
4
C----------------------------------------------------------------------
6
C DUMMY IF HBOOK IS USED
7
C----------------------------------------------------------------------
11
C----------------------------------------------------------------------
13
C USER''S ROUTINE FOR INITIALIZATION
14
C----------------------------------------------------------------------
16
include 'reweight0.inc'
17
integer nwgt,max_weight,nwgt_analysis
19
common/c_analysis/nwgt_analysis
20
parameter (max_weight=maxscales*maxscales+maxpdfs+1)
21
character*15 weights_info(max_weight)
22
common/cwgtsinfo/weights_info
23
integer nsingle,ncorr,nlepton,nplots,ncuts
24
common/cplots/nsingle,ncorr,nlepton,nplots,ncuts
25
integer MAXELM,MAXELP,MAXMUM,MAXMUP
26
common/cmaxlep/MAXELM,MAXELP,MAXMUM,MAXMUP
27
character*60 tmpstr1,tmpstr2,tmpstr3
30
character*5 cc(maxcuts)
33
PARAMETER (PI=3.14159265358979312D0)
34
real*8 sbin(100),smin(100),smax(100)
35
real*8 cbin(100),cmin(100),cmax(100)
37
integer l0,ilep1,ilep2,io,ipair
40
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
43
weights_info(nwgt)="central value "
44
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
46
c The analysis will consider:
51
c Set these variables here and only here
56
nlepton=MAXELM+MAXELP+MAXMUM+MAXMUP
57
c For each weight and cut configuration, there will be:
58
c nsingle single-inclusive plots (e.g., pt and y)
59
c ncorr correlation plots (e.g., invM, ptpair, dphi, Deltay)
60
c to be repeated for each of the nlepton leptons and
61
c nlepton*(nlepton-1)/2 lepton pairs respectively
63
if(ncuts.gt.maxcuts)then
64
WRITE(*,*)ncuts,maxcuts
65
CALL HWWARN('HWABEG',500)
69
nplots=nlepton * nsingle +
70
# nlepton*(nlepton-1)/2 * ncorr
104
do kk=1,nwgt_analysis
106
l0=(kk-1)*ncuts*nplots+(icuts-1)*nplots
109
l=l0+nsingle*(ilep1-1)+io
110
write(tmpstr1,'(i3)')ilep1
111
write(tmpstr3,'(i3)')io
112
call mbook(l,'sing '//tmpstr1(1:3)//
113
& ' '//tmpstr3(1:3)//' '
114
& //weights_info(kk)//cc(icuts),sbin(io),smin(io),smax(io))
119
do ilep2=ilep1+1,nlepton
122
l=l0+nlepton*nsingle+ncorr*(ipair-1)+io
123
write(tmpstr1,'(i3)')ilep1
124
write(tmpstr2,'(i3)')ilep2
125
write(tmpstr3,'(i3)')io
126
call mbook(l,'corr '//tmpstr1(1:3)//' '//
127
& tmpstr2(1:3)//' '//tmpstr3(1:3)//
128
& ' '//weights_info(kk)//cc(icuts),cbin(io),cmin(io),cmax(io))
136
C----------------------------------------------------------------------
138
C USER''S ROUTINE FOR TERMINAL CALCULATIONS, HISTOGRAM OUTPUT, ETC
139
C----------------------------------------------------------------------
142
integer nsingle,ncorr,nlepton,nplots,ncuts
143
common/cplots/nsingle,ncorr,nlepton,nplots,ncuts
144
INTEGER I,J,kk,l,nwgt_analysis
145
integer l0,ilep1,ilep2,io,ipair,icuts
148
common/c_analysis/nwgt_analysis
149
OPEN(UNIT=99,FILE='HERWIG.top',STATUS='UNKNOWN')
150
C XNORM IS SUCH THAT THE CROSS SECTION PER BIN IS IN PB, SINCE THE HERWIG
151
C WEIGHT IS IN NB, AND CORRESPONDS TO THE AVERAGE CROSS SECTION
152
XNORM=1.D3/DFLOAT(NEVHEP)
156
CALL MOPERA(I+NPL,'F',I+NPL,I+NPL,(XNORM),0.D0)
160
do kk=1,nwgt_analysis
162
l0=(kk-1)*ncuts*nplots+(icuts-1)*nplots
165
l=l0+nsingle*(ilep1-1)+io
166
call multitop(NPL+l,NPL-1,3,2,'sing ',' ','LOG')
171
do ilep2=ilep1+1,nlepton
174
l=l0+nlepton*nsingle+ncorr*(ipair-1)+io
175
call multitop(NPL+l,NPL-1,3,2,'corr ',' ','LOG')
184
C----------------------------------------------------------------------
186
C USER''S ROUTINE TO ANALYSE DATA FROM EVENT
187
C----------------------------------------------------------------------
189
include 'reweight0.inc'
190
DOUBLE PRECISION HWVDOT,PSUM(4)
191
INTEGER ICHSUM,ICHINI,IHEP,IST,ID
193
integer nwgt_analysis,max_weight
194
common/c_analysis/nwgt_analysis
195
parameter (max_weight=maxscales*maxscales+maxpdfs+1)
196
double precision ww(max_weight),www(max_weight)
199
integer nsingle,ncorr,nlepton,nplots,ncuts
200
common/cplots/nsingle,ncorr,nlepton,nplots,ncuts
201
integer MAXELM,MAXELP,MAXMUM,MAXMUP
202
common/cmaxlep/MAXELM,MAXELP,MAXMUM,MAXMUP
204
integer i,j,ilep,ilep1,ilep2,io,NELP,NELM,NMUP,NMUM,
205
# IPAIR,kk,L,L0,ICUTS
206
real*8 GETPTV4,GETRAPIDITYV4,GETINVMV4,GETDELPHIV4,PPAIR(4),
207
# PELM(4,25),PELP(4,25),PMUM(4,25),PMUP(4,25),PLEP(4,25),
210
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
213
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
214
IF(MOD(NEVHEP,10000).EQ.0)RETURN
215
IF (WW(1).EQ.0D0) THEN
216
WRITE(*,*)'WW(1) = 0. Stopping'
219
C INCOMING PARTONS MAY TRAVEL IN THE SAME DIRECTION: IT''S A POWER-SUPPRESSED
220
C EFFECT, SO THROW THE EVENT AWAY
221
IF(SIGN(1.D0,PHEP(3,1)).EQ.SIGN(1.D0,PHEP(3,2)))THEN
222
CALL HWWARN('HWANAL',111)
226
WWW(I)=EVWGT*ww(i)/ww(1)
237
IF(ID.EQ.11.AND.IST.EQ.1) THEN
240
PELM(I,NELM)=PHEP(I,IHEP)
243
ELSEIF(ID.EQ.-11.AND.IST.EQ.1) THEN
246
PELP(I,NELP)=PHEP(I,IHEP)
249
ELSEIF(ID.EQ.13.AND.IST.EQ.1) THEN
252
PMUM(I,NMUM)=PHEP(I,IHEP)
255
ELSEIF(ID.EQ.-13.AND.IST.EQ.1) THEN
258
PMUP(I,NMUP)=PHEP(I,IHEP)
262
IF( NELM.LT.MAXELM .OR. NELP.LT.MAXELP .OR.
263
# NMUM.LT.MAXMUM .OR. NMUP.LT.MAXMUP )THEN
265
WRITE(*,*)NELM,NELP,NMUM,NMUP
266
WRITE(*,*)MAXELM,MAXELP,MAXMUM,MAXMUP
267
CALL HWWARN('HWANAL',500)
269
c Keep the first MAX** leptons of the species **
274
PLEP(I,ILEP)=PELM(I,J)
280
PLEP(I,ILEP)=PELP(I,J)
286
PLEP(I,ILEP)=PMUM(I,J)
292
PLEP(I,ILEP)=PMUP(I,J)
295
IF( ILEP.NE.nlepton )THEN
297
WRITE(*,*)ILEP,nlepton
298
CALL HWWARN('HWANAL',501)
302
OBS(1)=GETPTV4(PLEP(1,ILEP1))
303
OBS(2)=GETRAPIDITYV4(PLEP(1,ILEP1))
304
DO KK=1,NWGT_ANALYSIS
306
L0=(KK-1)*NCUTS*NPLOTS+(ICUTS-1)*NPLOTS
308
L=L0+NSINGLE*(ILEP1-1)+IO
309
CALL MFILL(L,OBS(IO),WWW(KK))
317
DO ILEP2=ILEP1+1,NLEPTON
320
PPAIR(I)=PLEP(I,ILEP1)+PLEP(I,ILEP2)
322
OBS(1)=GETINVMV4(PPAIR)
323
OBS(2)=GETPTV4(PPAIR)
324
OBS(3)=GETDELPHIV4(PLEP(1,ILEP1),PLEP(1,ILEP2))
325
OBS(4)=GETRAPIDITYV4(PLEP(1,ILEP1))-
326
# GETRAPIDITYV4(PLEP(1,ILEP2))
327
DO KK=1,NWGT_ANALYSIS
329
L0=(KK-1)*NCUTS*NPLOTS+(ICUTS-1)*NPLOTS
331
L=L0+NLEPTON*NSINGLE+NCORR*(IPAIR-1)+IO
332
CALL MFILL(L,OBS(IO),WWW(KK))
343
* Ref.: K. Park and K.W. Miller, Comm. of the ACM 31 (1988) p.1192
344
* Use seed = 1 as first value.
346
IMPLICIT INTEGER(A-Z)
347
DOUBLE PRECISION MINV,RANDA
349
PARAMETER(M=2147483647,A=16807,Q=127773,R=2836)
350
PARAMETER(MINV=0.46566128752458d-09)
354
IF(SEED.LE.0) SEED = SEED + M
361
function getrapidity(en,pl)
363
real*8 getrapidity,en,pl,tiny,xplus,xminus,y
364
parameter (tiny=1.d-8)
368
if(xplus.gt.tiny.and.xminus.gt.tiny)then
369
if( (xplus/xminus).gt.tiny.and.(xminus/xplus).gt.tiny )then
370
y=0.5d0*log( xplus/xminus )
382
function getpseudorap(en,ptx,pty,pl)
384
real*8 getpseudorap,en,ptx,pty,pl,tiny,pt,eta,th
385
parameter (tiny=1.d-5)
387
pt=sqrt(ptx**2+pty**2)
388
if(pt.lt.tiny.and.abs(pl).lt.tiny)then
389
eta=sign(1.d0,pl)*1.d8
392
eta=-log(tan(th/2.d0))
399
function getinvm(en,ptx,pty,pl)
401
real*8 getinvm,en,ptx,pty,pl,tiny,tmp
402
parameter (tiny=1.d-5)
404
tmp=en**2-ptx**2-pty**2-pl**2
407
elseif(tmp.gt.-tiny)then
410
write(*,*)'Attempt to compute a negative mass'
418
function getdelphi(ptx1,pty1,ptx2,pty2)
420
real*8 getdelphi,ptx1,pty1,ptx2,pty2,tiny,pt1,pt2,tmp
421
parameter (tiny=1.d-5)
423
pt1=sqrt(ptx1**2+pty1**2)
424
pt2=sqrt(ptx2**2+pty2**2)
425
if(pt1.ne.0.d0.and.pt2.ne.0.d0)then
426
tmp=ptx1*ptx2+pty1*pty2
428
if(abs(tmp).gt.1.d0+tiny)then
429
write(*,*)'Cosine larger than 1'
431
elseif(abs(tmp).ge.1.d0)then
443
function getdr(en1,ptx1,pty1,pl1,en2,ptx2,pty2,pl2)
445
real*8 getdr,en1,ptx1,pty1,pl1,en2,ptx2,pty2,pl2,deta,dphi,
446
# getpseudorap,getdelphi
448
deta=getpseudorap(en1,ptx1,pty1,pl1)-
449
# getpseudorap(en2,ptx2,pty2,pl2)
450
dphi=getdelphi(ptx1,pty1,ptx2,pty2)
451
getdr=sqrt(dphi**2+deta**2)
456
function getdry(en1,ptx1,pty1,pl1,en2,ptx2,pty2,pl2)
458
real*8 getdry,en1,ptx1,pty1,pl1,en2,ptx2,pty2,pl2,deta,dphi,
459
# getrapidity,getdelphi
461
deta=getrapidity(en1,pl1)-
462
# getrapidity(en2,pl2)
463
dphi=getdelphi(ptx1,pty1,ptx2,pty2)
464
getdry=sqrt(dphi**2+deta**2)
473
getptv=sqrt(p(1)**2+p(2)**2)
478
function getpseudorapv(p)
480
real*8 getpseudorapv,p(5)
483
getpseudorapv=getpseudorap(p(4),p(1),p(2),p(3))
488
function getrapidityv(p)
490
real*8 getrapidityv,p(5)
493
getrapidityv=getrapidity(p(4),p(3))
498
function getdrv(p1,p2)
500
real*8 getdrv,p1(5),p2(5)
503
getdrv=getdr(p1(4),p1(1),p1(2),p1(3),
504
# p2(4),p2(1),p2(2),p2(3))
514
getinvmv=getinvm(p(4),p(1),p(2),p(3))
519
function getdelphiv(p1,p2)
521
real*8 getdelphiv,p1(5),p2(5)
524
getdelphiv=getdelphi(p1(1),p1(2),
534
getptv4=sqrt(p(1)**2+p(2)**2)
539
function getpseudorapv4(p)
541
real*8 getpseudorapv4,p(4)
544
getpseudorapv4=getpseudorap(p(4),p(1),p(2),p(3))
549
function getrapidityv4(p)
551
real*8 getrapidityv4,p(4)
554
getrapidityv4=getrapidity(p(4),p(3))
559
function getdrv4(p1,p2)
561
real*8 getdrv4,p1(4),p2(4)
564
getdrv4=getdr(p1(4),p1(1),p1(2),p1(3),
565
# p2(4),p2(1),p2(2),p2(3))
570
function getinvmv4(p)
572
real*8 getinvmv4,p(4)
575
getinvmv4=getinvm(p(4),p(1),p(2),p(3))
580
function getdelphiv4(p1,p2)
582
real*8 getdelphiv4,p1(4),p2(4)
585
getdelphiv4=getdelphi(p1(1),p1(2),
591
function getcosv4(q1,q2)
593
real*8 getcosv4,q1(4),q2(4)
594
real*8 xnorm1,xnorm2,tmp
596
if(q1(4).lt.0.d0.or.q2(4).lt.0.d0)then
600
xnorm1=sqrt(q1(1)**2+q1(2)**2+q1(3)**2)
601
xnorm2=sqrt(q2(1)**2+q2(2)**2+q2(3)**2)
602
if(xnorm1.lt.1.d-6.or.xnorm2.lt.1.d-6)then
605
tmp=q1(1)*q2(1)+q1(2)*q2(2)+q1(3)*q2(3)
606
tmp=tmp/(xnorm1*xnorm2)
607
if(abs(tmp).gt.1.d0.and.abs(tmp).le.1.001d0)then
609
elseif(abs(tmp).gt.1.001d0)then
610
write(*,*)'Error in getcosv4',tmp
622
double precision p(4),getmod
624
getmod=sqrt(p(1)**2+p(2)**2+p(3)**2)
631
subroutine getperpenv4(q1,q2,qperp)
632
c Normal to the plane defined by \vec{q1},\vec{q2}
634
real*8 q1(4),q2(4),qperp(4)
638
xnorm1=sqrt(q1(1)**2+q1(2)**2+q1(3)**2)
639
xnorm2=sqrt(q2(1)**2+q2(2)**2+q2(3)**2)
640
if(xnorm1.lt.1.d-6.or.xnorm2.lt.1.d-6)then
645
qperp(1)=q1(2)*q2(3)-q1(3)*q2(2)
646
qperp(2)=q1(3)*q2(1)-q1(1)*q2(3)
647
qperp(3)=q1(1)*q2(2)-q1(2)*q2(1)
649
qperp(i)=qperp(i)/(xnorm1*xnorm2)
660
subroutine boostwdir2(chybst,shybst,chybstmo,xd,xin,xout)
661
c chybstmo = chybst-1; if it can be computed analytically it improves
662
c the numerical accuracy
664
real*8 chybst,shybst,chybstmo,xd(1:3),xin(0:3),xout(0:3)
668
if(abs(xd(1)**2+xd(2)**2+xd(3)**2-1).gt.1.d-6)then
669
write(*,*)'Error #1 in boostwdir2',xd
674
pz=xin(1)*xd(1)+xin(2)*xd(2)+xin(3)*xd(3)
675
xout(0)=en*chybst-pz*shybst
677
xout(i)=xin(i)+xd(i)*(pz*chybstmo-en*shybst)
686
subroutine boostwdir3(chybst,shybst,chybstmo,xd,xxin,xxout)
688
real*8 chybst,shybst,chybstmo,xd(1:3),xxin(4),xxout(4)
689
real*8 xin(0:3),xout(0:3)
693
xin(mod(i,4))=xxin(i)
695
call boostwdir2(chybst,shybst,chybstmo,xd,xin,xout)
697
xxout(i)=xout(mod(i,4))
706
subroutine getwedge(p1,p2,pout)
708
real*8 p1(4),p2(4),pout(4)
710
pout(1)=p1(2)*p2(3)-p1(3)*p2(2)
711
pout(2)=p1(3)*p2(1)-p1(1)*p2(3)
712
pout(3)=p1(1)*p2(2)-p1(2)*p2(1)
718
C-----------------------------------------------------------------------
719
SUBROUTINE HWWARN(SUBRTN,ICODE)
720
C-----------------------------------------------------------------------
721
C DEALS WITH ERRORS DURING EXECUTION
722
C SUBRTN = NAME OF CALLING SUBROUTINE
723
C ICODE = ERROR CODE: - -1 NONFATAL, KILL EVENT & PRINT NOTHING
724
C 0- 49 NONFATAL, PRINT WARNING & CONTINUE
725
C 50- 99 NONFATAL, PRINT WARNING & JUMP
726
C 100-199 NONFATAL, DUMP & KILL EVENT
727
C 200-299 FATAL, TERMINATE RUN
728
C 300-399 FATAL, DUMP EVENT & TERMINATE RUN
729
C 400-499 FATAL, DUMP EVENT & STOP DEAD
730
C 500- FATAL, STOP DEAD WITH NO DUMP
731
C-----------------------------------------------------------------------
733
INTEGER ICODE,NRN,IERROR
735
IF (ICODE.GE.0) WRITE (6,10) SUBRTN,ICODE
736
10 FORMAT(/' HWWARN CALLED FROM SUBPROGRAM ',A6,': CODE =',I4)
740
ELSEIF (ICODE.LT.100) THEN
741
WRITE (6,20) NEVHEP,NRN,EVWGT
742
20 FORMAT(' EVENT',I8,': SEEDS =',I11,' &',I11,
743
&' WEIGHT =',E11.4/' EVENT SURVIVES. EXECUTION CONTINUES')
744
IF (ICODE.GT.49) RETURN
745
ELSEIF (ICODE.LT.200) THEN
746
WRITE (6,30) NEVHEP,NRN,EVWGT
747
30 FORMAT(' EVENT',I8,': SEEDS =',I11,' &',I11,
748
&' WEIGHT =',E11.4/' EVENT KILLED. EXECUTION CONTINUES')
751
ELSEIF (ICODE.LT.300) THEN
753
40 FORMAT(' EVENT SURVIVES. RUN ENDS GRACEFULLY')
757
ELSEIF (ICODE.LT.400) THEN
759
50 FORMAT(' EVENT KILLED: DUMP FOLLOWS. RUN ENDS GRACEFULLY')
766
ELSEIF (ICODE.LT.500) THEN
768
60 FORMAT(' EVENT KILLED: DUMP FOLLOWS. RUN STOPS DEAD')
775
70 FORMAT(' RUN CANNOT CONTINUE')
783
PRINT *,' EVENT ',NEVHEP
785
PRINT '(I4,I8,I4,4I4,1P,5D11.3)',IP,IDHEP(IP),ISTHEP(IP),
786
& JMOHEP(1,IP),JMOHEP(2,IP),JDAHEP(1,IP),JDAHEP(2,IP),