Module EvalWin_mod 
module EvalWin_mod
        ! Uses
    use Precision_mod
    use Namelist_mod
    use Chambers_mod
    use Det_Geom_mod
    use Tdc_mod
    use Unp_mod
    use Hists_mod
    use Pattern_mod
    use Cluster_mod
    use Pattern_Log_mod
    use Xtalk_mod, ONLY: DC_IsXtalk, PC_IsXtalk
    use windowstat_mod
        ! Variables
    logical, private :: splithits
    logical, private :: couldbeadelta
    logical, private :: couldbeanoverlap
    logical, private :: couldbeuncor
    logical, private :: continuity
    logical, private :: couldbeamuon
    integer (kind=i4), private :: upcount
    integer (kind=i4), private :: downcount
    integer (kind=i4), private :: minpc
    integer (kind=i4), private :: maxpc
    integer (kind=i4), private :: mindc
    integer (kind=i4), private :: maxdc
    integer (kind=i4), private :: stopplane
    integer (kind=i4), private :: restrictplanesmin
    integer (kind=i4), private :: restrictplanesmax
    integer (kind=i4), private :: hitcount
    real (kind=r4), private :: rup
    real (kind=r4), private :: rdown
    real (kind=r4), private :: rupavg
    real (kind=r4), private :: rdownavg
    integer (kind=i4), private :: tidx
    real (kind=r4), private :: umu
    real (kind=r4), private :: vmu
    logical, private :: scatter
    integer (kind=i4), private :: imu
    integer (kind=i4), private :: lastdiff
    real (kind=r4), private :: deltat
    logical, private :: foundamuwithoutadecay
    integer (kind=i4), private :: smallestdiff
        ! Subroutines and functions
    private function SumHits4Planes (ipcwin, startplane, endplane)
    private subroutine UpdateAddDecayMuWin (iwin)
    private subroutine look4unmatchedecay (ipcwin, laterdecay, dkipcwin)
    public subroutine EvalWindowType (ipcwin)
    private subroutine EvalTriggerWin (ipcwin)
    private subroutine ETW_MOPOO_FastDkDownOrBeamPositron (ipcwin)
    private subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc (ipcwin)
    private subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron (ipcwin)
    private subroutine ETW_MM_OnBothSides_Calc (ipcwin)
    private subroutine ETW_MM_OnBothSides (ipcwin)
    private subroutine ETW_MM_NotOnBothSides (ipcwin)
    private subroutine EvalNonTriggerWin (ipcwin)
    private subroutine ENTW_couldbeamuon_Calc (ipcwin)
    private subroutine ENTW_couldbeamuon (ipcwin)
    private subroutine ENTW_NCBM_OBS_LooksLikeBeamE (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk5 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6 (ipcwin)
    private subroutine ENTW_NCBM_OBS_NLLBE_NotNonMuWidth (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MoreMuThanDk (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_Calc (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NotNormalDk (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent7 (ipcwin)
    private subroutine ENTW_NCBM_NOBS_NotMoreMuThanDk (ipcwin)
end module EvalWin_mod
 Description of Variables 
splithits
logical, private :: splithits
couldbeadelta
logical, private :: couldbeadelta
couldbeanoverlap
logical, private :: couldbeanoverlap
couldbeuncor
logical, private :: couldbeuncor
continuity
logical, private :: continuity
couldbeamuon
logical, private :: couldbeamuon
upcount
integer (kind=i4), private :: upcount
downcount
integer (kind=i4), private :: downcount
minpc
integer (kind=i4), private :: minpc
maxpc
integer (kind=i4), private :: maxpc
mindc
integer (kind=i4), private :: mindc
maxdc
integer (kind=i4), private :: maxdc
stopplane
integer (kind=i4), private :: stopplane
restrictplanesmin
integer (kind=i4), private :: restrictplanesmin
restrictplanesmax
integer (kind=i4), private :: restrictplanesmax
hitcount
integer (kind=i4), private :: hitcount
rup
real (kind=r4), private :: rup
rdown
real (kind=r4), private :: rdown
rupavg
real (kind=r4), private :: rupavg
rdownavg
real (kind=r4), private :: rdownavg
tidx
integer (kind=i4), private :: tidx
umu
real (kind=r4), private :: umu
vmu
real (kind=r4), private :: vmu
scatter
logical, private :: scatter
imu
integer (kind=i4), private :: imu
lastdiff
integer (kind=i4), private :: lastdiff
deltat
real (kind=r4), private :: deltat
foundamuwithoutadecay
logical, private :: foundamuwithoutadecay
smallestdiff
integer (kind=i4), private :: smallestdiff
 Description of Subroutines and Functions 
SumHits4Planes
private function SumHits4Planes (ipcwin, startplane, endplane)
    integer (kind=i4) :: ipcwin
    integer (kind=i4) :: startplane
    integer (kind=i4) :: endplane
    integer (kind=i4) :: SumHits4Planes
end function SumHits4Planes
UpdateAddDecayMuWin
private subroutine UpdateAddDecayMuWin (iwin)
    integer (kind=i4), intent(in) :: iwin
end subroutine UpdateAddDecayMuWin
 iwin is the index into the window 
 structure for the decay window that
 was just added
look4unmatchedecay
private subroutine look4unmatchedecay (ipcwin, laterdecay, dkipcwin)
    integer (kind=i4), intent(in) :: ipcwin
    logical, intent(out) :: laterdecay
    integer (kind=i4) :: dkipcwin
end subroutine look4unmatchedecay
 SUBROUTINE look4unmatchedecay
------------------------------------------------------------------
 It looks at the windows after ipcwin and checks if there is an extra
 positron that could be a later decay of the current muon window.
EvalWindowType
public subroutine EvalWindowType (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: EvalNonTriggerWin, EvalTriggerWin, UpdateAddDecayMuWin
end subroutine EvalWindowType
 SUBROUTINE EvalWindowType( ipcwin )
------------------------------------------------------------------
 Author: Blair
 Date: Jan. 2003
 Inputs: ipcwin - the track number to decide a type for
 Description:
 This subroutine does the hard work of deciding what kind of track
 this is.  Window types are:
            1     Muon
            2     UpStream Decay
            3     DownStream Decay
            4     Beam Positron
            5     Empty
            6     PC Overlap involved
            7     Upstream Decay (DS delta removed)
            8     Downstream Decay (US delta removed)
            9     Upstream Decay (Scatter back downstream)
           10     Downstream Decay (Scatter back upstream)
           11     Muon and Fast Decay Downstream
           12     Muon and Fast Decay Upstream
           13     Muon and beam positron
           14     Upstream Decay ( DS part of beam e+ removed)
           15     Downstream Decay ( US part of beam e+ removed)
           16     Soft uncorrelated track
           17     Cosmic, noise, or beam gas
           18     Too early
           19     Too late
           20     Don't know
           21     Pion
  
 ====> Reorganisation January 2008
 I reorganised this subroutines and its subsubroutines to make the code
 readable. I splited the code into many subroutines. Their names contains
 information about the call flow.
 Each accronyms stands for the subroutines that called this subroutine or
 the tests that lead to the call
 - Example:
 ENTW_NCBM_OBS_NLLBE_NonMuWidth
 EvalNonTriggerWin (ENTW) called ENTW_NCBM_OBS_NLLBE_NonMuWidth
 NCBM because the boolean couldbeamuon a muon is false (NotCouldBeAMuon)
 OBS because the boolean OnBothSides is true
 NLLBE because the boolean LooksLikeBeamE is false (NotLooksLikeBeamE)
EvalTriggerWin
private subroutine EvalTriggerWin (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ETW_MM_NotOnBothSides, ETW_MM_OnBothSides, ETW_MOPOO_FastDkDownOrBeamPositron, ETW_MOPOO_NotFastDkDownOrBeamPositron
end subroutine EvalTriggerWin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!                                                !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!           EvalTriggerWin Subroutines           !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!                                                !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 Subroutine EvalTriggerWin( ipcwin )
========================================================================
 Handle identification of track(s) in trigger window.  
 
ETW_MOPOO_FastDkDownOrBeamPositron
private subroutine ETW_MOPOO_FastDkDownOrBeamPositron (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: look4unmatchedecay
end subroutine ETW_MOPOO_FastDkDownOrBeamPositron
 Subroutine ETW_MOPOO_FastDkDownOrBeamPositron( ipcwin )
========================================================================
 
ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc
private subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc
 Subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc( ipcwin )
========================================================================
 Looks for stopplane. Checks the gaps in the muon tracks. Looks at later
 decays to help decide on the current track
 
ETW_MOPOO_NotFastDkDownOrBeamPositron
private subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ETW_MOPOO_NotFastDkDownOrBeamPositron_Calc
end subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron
 Subroutine ETW_MOPOO_NotFastDkDownOrBeamPositron( ipcwin )
========================================================================
 From the previous test, this window looks like a muon, eventually with
 overlap.
 
! ETW_MOPOO_NFDDOBP
ETW_MM_OnBothSides_Calc
private subroutine ETW_MM_OnBothSides_Calc (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ETW_MM_OnBothSides_Calc
 Subroutine ETW_MM_OnBothSides_Calc( ipcwin )
========================================================================
 Assignment as a decay window only if there is a muon/decay positron pair.
 Because at beginning there is more muons than decay found.
 
! ETW_MM_OBS
ETW_MM_OnBothSides
private subroutine ETW_MM_OnBothSides (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ETW_MM_OnBothSides_Calc
end subroutine ETW_MM_OnBothSides
 Subroutine ETW_MM_OnBothSides( ipcwin )
========================================================================
 Decide if this is a fast decay,
 or a beam positron?
 Look for a significant change in
 radius, or width.  And see if there
 is more than 1 peak in PC TDC hits
 
! ETW_MM_OBS   +++
ETW_MM_NotOnBothSides
private subroutine ETW_MM_NotOnBothSides (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ETW_MM_NotOnBothSides
 Subroutine ETW_MM_OnBothSides( ipcwin )
========================================================================
 Handle identification of track(s) that arent in the trigger window.  
 
! ETW_MM_NOBS   +++
EvalNonTriggerWin
private subroutine EvalNonTriggerWin (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_NCBM_NOBS_MoreMuThanDk, ENTW_NCBM_NOBS_NotMoreMuThanDk, ENTW_NCBM_OBS_LooksLikeBeamE, ENTW_NCBM_OBS_NLLBE_NonMuWidth, ENTW_NCBM_OBS_NLLBE_NotNonMuWidth, ENTW_couldbeamuon
end subroutine EvalNonTriggerWin
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!                                                !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!           EvalNonTriggerWin Subroutines        !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!                                                !!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 Subroutine EvalNonTriggerWin( ipcwin )
========================================================================
 Handle identification of track(s) that arent in the trigger window.  
 
! ENTW
ENTW_couldbeamuon_Calc
private subroutine ENTW_couldbeamuon_Calc (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_couldbeamuon_Calc
ENTW_couldbeamuon
private subroutine ENTW_couldbeamuon (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_couldbeamuon_Calc
end subroutine ENTW_couldbeamuon
ENTW_NCBM_OBS_LooksLikeBeamE
private subroutine ENTW_NCBM_OBS_LooksLikeBeamE (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: UpdateAddDecayMuWin
end subroutine ENTW_NCBM_OBS_LooksLikeBeamE
 Subroutine ENTW_NCBM_OBS_LooksLikeBeamE( ipcwin )
========================================================================
 Widths or starting plane say this probably isn't a muon.
 Could be a beam positron or fast decay
 Beam positron will have smallish radius, 
 and all narrow distribution of PC tdc hits.
 Need to worry about the case of an upstream
 decay with a delta that goes downstream
 Now if there is an unmatched muon, lets see if this
 could be an overlap
 
!! ENTW_NCBM_OBS_LLBE
ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc
private subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: UpdateAddDecayMuWin
end subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc
 Subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc( ipcwin )
========================================================================
 Updates DecayMuWin. Checks for overlaps and deltas. Calculates rsig and
 ravg up and down.
 
ENTW_NCBM_OBS_NLLBE_NonMuWidth
private subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1, ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2, ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta, ENTW_NCBM_OBS_NLLBE_NonMuWidth_Calc
end subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth
 Subroutine ENTW_NCBM_OBS_NLLBE_NonMuWidth( ipcwin )
========================================================================
 some sort of positron or electron
 compare usig and vsig at first nonzero slide
 to usig and vsig at the last nonzero slide
 
!  ENTW_NCBM_OBS_NLLBE_NMW
ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta1( ipcwin )
========================================================================
 This is case 1) 
 Significant change in radius choose larger radius side
 as the decay... other side is the delta
 upstream end            
 
ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_LooksLikeDelta2( ipcwin )
========================================================================
 This is case 1) 
 Significant change in radius choose larger radius side
 as the decay... other side is the delta
 downstream end            
 
ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3, ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4, ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk5, ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_NotLooksLikeDelta( ipcwin )
========================================================================
 This is case 2, a decay with scattering -- or
 this could also be a decay and beam positron
 overlap.  Beam e+ overlap with decay will have
 one side with few hits per plane.
 Try to decide direction of decay?
 Choose end with fewest planes hit
 
ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk3( ipcwin )
========================================================================
 There's already a muon that stops 
 near the target.  Now we have
 a track with few hits per plane
 that isn't just a decay or just
 a beam positron.  Also on one side of 
 the track there is a fairly
 small radius track and few hits per plane.
 upstream decay with a beam positron
 
ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk4( ipcwin )
========================================================================
 There's already a muon that stops 
 near the target.  Now we have
 a track with few hits per plane that 
 isn't just a decay or just
 a beam positron.  Also on one side of 
 the track there is a fairly
 small radius track and few hits per plane.
 upstream decay with a beam positron
 
ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk5
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk5 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk5
 Subroutine EvalNonTriggerWin( ipcwin )
========================================================================
 downstream decay, restrict DC hits
 to downstream of last pc hit
 
ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6
private subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6
 Subroutine ENTW_NCBM_OBS_NLLBE_NMW_NLLD_NormalDk6( ipcwin )
========================================================================
 upstream decay?
 
ENTW_NCBM_OBS_NLLBE_NotNonMuWidth
private subroutine ENTW_NCBM_OBS_NLLBE_NotNonMuWidth (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: UpdateAddDecayMuWin
end subroutine ENTW_NCBM_OBS_NLLBE_NotNonMuWidth
 Subroutine ENTW_NCBM_OBS_NLLBE_NotNonMuWidth( ipcwin )
========================================================================
 This is case 3 or 4) (
 Its a fast decay 
 (overlap in time between muon and decay)
 lets assume target stop for now?
 
!!  ENTW_NCBM_OBS_NLLBE_NNMW
ENTW_NCBM_NOBS_MoreMuThanDk
private subroutine ENTW_NCBM_NOBS_MoreMuThanDk (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_NCBM_NOBS_MMTD_NotNormalDk, UpdateAddDecayMuWin
end subroutine ENTW_NCBM_NOBS_MoreMuThanDk
 Subroutine ENTW_NCBM_NOBS_MoreMuThanDk( ipcwin )
========================================================================
 Have a free slot for a decay... lets
 assume this is the decay we're lookin
 for.
 
! ENTW_NCBM_NOBS_MMTD
ENTW_NCBM_NOBS_MMTD_NND_Calc
private subroutine ENTW_NCBM_NOBS_MMTD_NND_Calc (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_Calc
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_Calc( ipcwin )
========================================================================
 Some preparation for ENTW_NCBM_NOBS_MMTD_NotNormalDk
 
! ENTW_NCBM_NOBS_MMTD_NND
ENTW_NCBM_NOBS_MMTD_NotNormalDk
private subroutine ENTW_NCBM_NOBS_MMTD_NotNormalDk (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
    ! Calls: ENTW_NCBM_NOBS_MMTD_NND_Calc, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6, ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent7
end subroutine ENTW_NCBM_NOBS_MMTD_NotNormalDk
 Subroutine ENTW_NCBM_NOBS_MMTD_NotNormalDk( ipcwin )
========================================================================
 Hmmm.  Must be scattering or time overlap
 Check for overlap... if not try to
 decide on direction of decay given scattering!
 look at side of stop of earliest hit.
 if it is same plane as stopplane, then
 take side with
 Another thing to check is that there isn't an overlap
 of DC hits from a beam positron before this decay.  To
 check this, see if the previous window was a track that
 passed thru the target section of the detector not too 
 long before this track
 
! ENTW_NCBM_NOBS_MMTD_NND
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent2( ipcwin )
========================================================================
 This is case 1) 
 Significant change in radius choose larger radius side
 as the decay... other side is the delta
 upstream end            
 
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent3( ipcwin )
========================================================================
 This is case 1) 
 Significant change in radius choose larger radius side
 as the decay... other side is the delta
 downstream end            
 
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent4( ipcwin )
========================================================================
 
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent5( ipcwin )
========================================================================
 
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6
 Subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent6( ipcwin )
========================================================================
 
ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent7
private subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent7 (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_MMTD_NND_EmptyEvent7
 Subroutine EvalNonTriggerWin( ipcwin )
========================================================================
 Handle identification of track(s) that arent in the trigger window.  
 
ENTW_NCBM_NOBS_NotMoreMuThanDk
private subroutine ENTW_NCBM_NOBS_NotMoreMuThanDk (ipcwin)
    integer (kind=i4), INTENT(in) :: ipcwin
end subroutine ENTW_NCBM_NOBS_NotMoreMuThanDk
 Subroutine EvalNonTriggerWin( ipcwin )
========================================================================
 Handle identification of track(s) that arent in the trigger window.