Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyupre.f
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file pyupre.f
1 
2 C*********************************************************************
3 
4 C...PYUPRE
5 C...Rearranges contents of the HEPEUP commonblock so that
6 C...mothers precede daughters and daughters of a decay are
7 C...listed consecutively.
8 
9  SUBROUTINE pyupre
10 
11 C...Double precision and integer declarations.
12  IMPLICIT DOUBLE PRECISION(a-h, o-z)
13  IMPLICIT INTEGER(i-n)
14 
15 C...User process event common block.
16  INTEGER maxnup
17  parameter(maxnup=500)
18  INTEGER nup,idprup,idup,istup,mothup,icolup
19  DOUBLE PRECISION xwgtup,scalup,aqedup,aqcdup,pup,vtimup,spinup
20  common/hepeup/nup,idprup,xwgtup,scalup,aqedup,aqcdup,idup(maxnup),
21  &istup(maxnup),mothup(2,maxnup),icolup(2,maxnup),pup(5,maxnup),
22  &vtimup(maxnup),spinup(maxnup)
23  SAVE /hepeup/
24 
25 C...Local arrays.
26  dimension newpos(0:maxnup),idupt(maxnup),istupt(maxnup),
27  &motupt(2,maxnup),icoupt(2,maxnup),pupt(5,maxnup),
28  &vtiupt(maxnup),spiupt(maxnup)
29 
30 C...Check whether a rearrangement is required.
31  need=0
32  DO 100 iup=1,nup
33  IF(mothup(1,iup).GT.iup) need=need+1
34  100 CONTINUE
35  DO 110 iup=2,nup
36  IF(mothup(1,iup).LT.mothup(1,iup-1)) need=need+1
37  110 CONTINUE
38 
39  IF(need.NE.0) THEN
40 C...Find the new order that particles should have.
41  newpos(0)=0
42  nnew=0
43  inew=-1
44  120 inew=inew+1
45  DO 130 iup=1,nup
46  IF(mothup(1,iup).EQ.newpos(inew)) THEN
47  nnew=nnew+1
48  newpos(nnew)=iup
49  ENDIF
50  130 CONTINUE
51  IF(inew.LT.nnew.AND.inew.LT.nup) goto 120
52  IF(nnew.NE.nup) THEN
53  CALL pyerrm(2,
54  & '(PYUPRE:) failed to make sense of mother pointers in HEPEUP')
55  RETURN
56  ENDIF
57 
58 C...Copy old info into temporary storage.
59  DO 150 i=1,nup
60  idupt(i)=idup(i)
61  istupt(i)=istup(i)
62  motupt(1,i)=mothup(1,i)
63  motupt(2,i)=mothup(2,i)
64  icoupt(1,i)=icolup(1,i)
65  icoupt(2,i)=icolup(2,i)
66  DO 140 j=1,5
67  pupt(j,i)=pup(j,i)
68  140 CONTINUE
69  vtiupt(i)=vtimup(i)
70  spiupt(i)=spinup(i)
71  150 CONTINUE
72 
73 C...Copy info back into HEPEUP in right order.
74  DO 180 i=1,nup
75  iold=newpos(i)
76  idup(i)=idupt(iold)
77  istup(i)=istupt(iold)
78  mothup(1,i)=0
79  mothup(2,i)=0
80  DO 160 imot=1,i-1
81  IF(motupt(1,iold).EQ.newpos(imot)) mothup(1,i)=imot
82  IF(motupt(2,iold).EQ.newpos(imot)) mothup(2,i)=imot
83  160 CONTINUE
84  IF(mothup(2,i).GT.0.AND.mothup(2,i).LT.mothup(1,i)) THEN
85  mothsw=mothup(1,i)
86  mothup(1,i)=mothup(2,i)
87  mothup(2,i)=mothsw
88  ENDIF
89  icolup(1,i)=icoupt(1,iold)
90  icolup(2,i)=icoupt(2,iold)
91  DO 170 j=1,5
92  pup(j,i)=pupt(j,iold)
93  170 CONTINUE
94  vtimup(i)=vtiupt(iold)
95  spinup(i)=spiupt(iold)
96  180 CONTINUE
97  ENDIF
98 
99 c...If incoming particles are massive recalculate to put them massless.
100  IF(pup(5,1).NE.0d0.OR.pup(5,2).NE.0d0) THEN
101  pplus=(pup(4,1)+pup(3,1))+(pup(4,2)+pup(3,2))
102  pminus=(pup(4,1)-pup(3,1))+(pup(4,2)-pup(3,2))
103  pup(4,1)=0.5d0*pplus
104  pup(3,1)=pup(4,1)
105  pup(5,1)=0d0
106  pup(4,2)=0.5d0*pminus
107  pup(3,2)=-pup(4,2)
108  pup(5,2)=0d0
109  ENDIF
110 
111  RETURN
112  END