subroutine stdstdsclst ( j, n, maxn, list ) c c The previous version of this routine fails on events generated by c herwig. This version works on all of herwig, pythia and isajet. c c Make a list of all stable descendants of j. c If the particle j is stable, then the list has a length of 0. c c j - input - particle to start at c n - output - number of stable descendants c maxn - input - maximum size of list c list - output - list of stdhep indices of the stable descendants. c c WARNING this code assumes that: c a) both jdahep(1,k) and jmohep(1,k) are correct for all k c b) all daughters of a given particle are continguous in the stdhep list. c Sometimes b) may not be statisfied in stdhep; however it does seem to c hold for all weak and strongs decays of hadrons. c c c The algorithm is recursive and at each level 1 of 3 things can happen. c 1) We have stepped past the last daughter of this mother. c Go up a level on the recursion stack and check the next daughter c of the previous mother. c 2) The particle is stable. c Add this particle to the list and chekc the next daughter of this mother. c 3) The particle is not stable. c Check its daughters. c #include "stdhep.inc" #include "stdlun.inc" c ! Arguments. integer j integer n integer maxn integer list(maxn) c ! Index of mother and daughter at current level of recurrsion. integer im, id c ! Level of recursion. integer level c ! Maximum number of levels of recurssion. integer mxlevel parameter ( mxlevel = 20 ) c ! Saved information from earlier levels. integer im_save(mxlevel) integer id_save(mxlevel) c ! Handle trivial cases. n = 0 if ( j .lt. 1 .or. j .gt. nhep ) return c ! Initialize recursion control. level = 0 im = j id = jdahep(1,j) c ! Finished with this mother. Go up a level. 1 if ( jmohep(1,id) .ne. im ) then if ( level .eq. 0 ) return id = id_save(level) + 1 im = im_save(level) level = level - 1 c ! Particle is stable. c ! Some herwig particles have screwed up isthep. c ! else if ( isthep(id) .eq. 1 ) then else if ( jdahep(1,id) .eq. 0 ) then n = n + 1 if ( n .le. maxn ) list(n) = id id = id + 1 c ! Particle is unstable. Drop down a level. else if ( jdahep(1,id) .ne. 0 ) then if ( level .le. mxlevel-1 ) then level = level + 1 id_save(level) = id im_save(level) = im im = id id = jdahep(1,id) else goto 999 endif endif goto 1 999 write(lnhout,1001) j 1001 format(' Too many stable descendants of stdhep particle ', I4) return end