!-----------------------------------------------------------------------
! riter_getmore: returns likelihood probabilities for NH hypothesies (NH>6):
! no_ring, e, mu, pi, K, p, 2e, 3e, ...
! and few other things. Call this routine after the RITER.
! It uses already calculated probabilities from RITER, which have been kept in
! /RIC_TRA/. Probabilities for 2e, 3e, ... are approximations: only the Poissonian 
! part of the likelihood is recalculated.
! Number of photons in the peak = PHOT-PHEB
!
! M. Staric, avg-2000, changes: nov-2000
!
!------------------------------------------------------------------------



      SUBROUTINE RITER_GETMORE(IROW,NH,PROB,PHES,PHEB,PHOT,ID,IFLG)

      IMPLICIT NONE
! input:
      INTEGER IROW              ! RTRA row number of track (input)
      INTEGER NH                ! number of hypothesis (input), min 6
! output:
      REAL PROB(0:NH-1)         ! likelihood probabilities for oth,e,mu,pi,K,p,2e,3e,...
      REAL PHES(0:NH-1)         ! expected number of cerenkov photons for oth,e,mu,...
      REAL PHEB                 ! expected number of background photons
      REAL PHOT                 ! number of photons used for likelihood calculations
      INTEGER ID                ! most probable hypothesis, number from 0 to NH-1
      INTEGER IFLG              ! reconstruction flag, same as RTRA.flr

#include "riter/RIC_TRA.fi"

      INTEGER I
      REAL STFE, PPP, POIS_LOG
      INTEGER ITRA /1/
      SAVE ITRA


      IFLG=0
      ITRA=MAX(MIN(ITRA,NTRA),1)
      DO I=1,NTRA
         IF(IROW.EQ.RTRA_ROW(ITRA)) GOTO 1 
         ITRA=ITRA+1
         IF(ITRA.GT.NTRA) ITRA=1
      ENDDO
      RETURN
      
 1    CONTINUE
      IFLG=RECO_FLAG(ITRA)
      IF(IFLG.EQ.0) RETURN

      PHOT=SFOT(ITRA)
      PHEB=STFB(ITRA)
      DO I=0,MIN(NHYP,NH)-1
         PHES(I)=STFS(I,ITRA)
         PROB(I)=PLKH(I,ITRA)
      ENDDO
      STFE=STFS(1,ITRA)+STFB(ITRA)
      PPP=PLKH(1,ITRA)-POIS_LOG(STFE,PHOT)
      DO I=NHYP,NH-1
         PHES(I)=STFS(1,ITRA)*(I-4)
         STFE=PHES(I)+PHEB
         PROB(I)=PPP+POIS_LOG(STFE,PHOT) ! only approximation for multi e!!!
      ENDDO
      CALL NORMALIZE_LKH(PROB,NH,NH,ID)                           
      DO I=0,NH-1
         PROB(I)=EXP(PROB(I))
      ENDDO

      RETURN
      END







