Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pylhef.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pylhef.f
1 
2 
3 C*********************************************************************
4 
5 C...Combine the two old-style Pythia initialization and event files
6 C...into a single Les Houches Event File.
7 
8  SUBROUTINE pylhef
9 
10 C...Double precision and integer declarations.
11  IMPLICIT DOUBLE PRECISION(a-h, o-z)
12  IMPLICIT INTEGER(i-n)
13 
14 C...PYTHIA commonblock: only used to provide read/write units and version.
15  common/pypars/mstp(200),parp(200),msti(200),pari(200)
16  SAVE /pypars/
17 
18 C...User process initialization commonblock.
19  INTEGER maxpup
20  parameter(maxpup=100)
21  INTEGER idbmup,pdfgup,pdfsup,idwtup,nprup,lprup
22  DOUBLE PRECISION ebmup,xsecup,xerrup,xmaxup
23  common/heprup/idbmup(2),ebmup(2),pdfgup(2),pdfsup(2),
24  &idwtup,nprup,xsecup(maxpup),xerrup(maxpup),xmaxup(maxpup),
25  &lprup(maxpup)
26  SAVE /heprup/
27 
28 C...User process event common block.
29  INTEGER maxnup
30  parameter(maxnup=500)
31  INTEGER nup,idprup,idup,istup,mothup,icolup
32  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
33  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
34  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
35  &vtimup(maxnup),spinup(maxnup)
36  SAVE /hepeup/
37 
38 C...Lines to read in assumed never longer than 200 characters.
39  parameter(maxlen=200)
40  CHARACTER*(MAXLEN) string
41 
42 C...Format for reading lines.
43  CHARACTER*6 strfmt
44  strfmt='(A000)'
45  WRITE(strfmt(3:5),'(I3)') maxlen
46 
47 C...Rewind initialization and event files.
48  rewind mstp(161)
49  rewind mstp(162)
50 
51 C...Write header info.
52  WRITE(mstp(163),'(A)') '<LesHouchesEvents version="1.0">'
53  WRITE(mstp(163),'(A)') '<!--'
54  WRITE(mstp(163),'(A,I1,A1,I3)') 'File generated with PYTHIA ',
55  &mstp(181),'.',mstp(182)
56  WRITE(mstp(163),'(A)') '-->'
57 
58 C...Read first line of initialization info and get number of processes.
59  READ(mstp(161),'(A)',end=400,err=400) string
60  READ(string,*,err=400) idbmup(1),idbmup(2),ebmup(1),
61  &ebmup(2),pdfgup(1),pdfgup(2),pdfsup(1),pdfsup(2),idwtup,nprup
62 
63 C...Copy initialization lines, omitting trailing blanks.
64 C...Embed in <init> ... </init> block.
65  WRITE(mstp(163),'(A)') '<init>'
66  DO 140 ipr=0,nprup
67  IF(ipr.GT.0) READ(mstp(161),'(A)',end=400,err=400) string
68  len=maxlen+1
69  120 len=len-1
70  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 120
71  WRITE(mstp(163),'(A)',err=400) string(1:len)
72  140 CONTINUE
73  WRITE(mstp(163),'(A)') '</init>'
74 
75 C...Begin event loop. Read first line of event info or already done.
76  READ(mstp(162),'(A)',end=320,err=400) string
77  200 CONTINUE
78 
79 C...Look at first line to know number of particles in event.
80  READ(string,*,err=400) nup,idprup,xwgtup,scalup,aqedup,aqcdup
81 
82 C...Begin an <event> block. Copy event lines, omitting trailing blanks.
83  WRITE(mstp(163),'(A)') '<event>'
84  DO 240 i=0,nup
85  IF(i.GT.0) READ(mstp(162),'(A)',end=400,err=400) string
86  len=maxlen+1
87  220 len=len-1
88  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 220
89  WRITE(mstp(163),'(A)',err=400) string(1:len)
90  240 CONTINUE
91 
92 C...Copy trailing comment lines - with a # in the first column - as is.
93  260 READ(mstp(162),'(A)',end=300,err=400) string
94  IF(string(1:1).EQ.'#') THEN
95  len=maxlen+1
96  280 len=len-1
97  IF(len.GT.1.AND.string(len:len).EQ.' ') goto 280
98  WRITE(mstp(163),'(A)',err=400) string(1:len)
99  goto 260
100  ENDIF
101 
102 C..End the <event> block. Loop back to look for next event.
103  WRITE(mstp(163),'(A)') '</event>'
104  goto 200
105 
106 C...Successfully reached end of event loop: write closing tag
107 C...and remove temporary intermediate files (unless asked not to).
108  300 WRITE(mstp(163),'(A)') '</event>'
109  320 WRITE(mstp(163),'(A)') '</LesHouchesEvents>'
110  IF(mstp(164).EQ.1) RETURN
111  CLOSE(mstp(161),err=400,status='DELETE')
112  CLOSE(mstp(162),err=400,status='DELETE')
113  RETURN
114 
115 C...Error exit.
116  400 WRITE(*,*) ' PYLHEF file joining failed!'
117 
118  RETURN
119  END