summaryrefslogtreecommitdiff
path: root/Dragon/src/MCGTMT.f
blob: e8977c54da919850affda6813fada6089075934f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
*DECK MCGTMT
      SUBROUTINE MCGTMT(NMERG,NTRTMT,NSETMT,NSEG,NSEG0,NOM,NOM0,WEIGHT,
     1                  WEIGHT0,H,H0,LFORC,NTPROC)
*
*-----------------------------------------------------------------------
*
*Purpose:
* Track merging.
*
*Copyright:
* Copyright (C) 2002 Ecole Polytechnique de Montreal
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version
*
*Author(s): R. Le Tellier
*
*Parameters: input
* NMERG   number of merged tracks for the track under contruction.
* NTRTMT  total number of finalized tracks.
* NSETMT  total number of segments in finalized tracks.
* NSEG    number of segments in the track to be processed.
* NSEG0   number of segments in the track under construction.
* NOM0    integer tracking elements for the under construction.
* WEIGHT0 weight of the under construction.
* H       real tracking elements for the track to be processed.
* LFORC   flag to force a merged track to be finalized.
*
*Parameters: input/output 
* NOM     integer tracking elements for the finalized track.
* WEIGHT  weight of the finalized track.
* H0      real tracking elements for the finalized track.
*
*Parameters: output 
* NTPROC  number of merged tracks for the finalized track.
*
*-----------------------------------------------------------------------
*
      IMPLICIT NONE
*----
*  SUBROUTINE ARGUMENTS
*----
      INTEGER NMERG,NTRTMT,NSETMT,NSEG,NSEG0,NOM(NSEG),
     1 NOM0(NSEG),NTPROC
      DOUBLE PRECISION WEIGHT,H(NSEG),WEIGHT0,H0(NSEG)
      LOGICAL LFORC
*----
*  LOCAL VARIABLES
*----
      INTEGER II,NTEMP
      DOUBLE PRECISION TEMP
*
      IF (NMERG.GT.0) THEN
         IF ((LFORC).OR.(NSEG.NE.NSEG0)) GOTO 20
         DO II=1,NSEG
            IF (NOM(II).NE.NOM0(II)) GOTO 20
         ENDDO
*        merge this track with the previous one
         DO II=1,NSEG
            H0(II)=H0(II)+WEIGHT*H(II)
         ENDDO
         WEIGHT0=WEIGHT0+WEIGHT
      ELSE
*     start
         DO II=1,NSEG
            H0(II)=WEIGHT*H(II)
            NOM0(II)=NOM(II)
         ENDDO
         WEIGHT0=WEIGHT
      ENDIF
      NMERG=NMERG+1
      NSEG0=NSEG
      NTPROC=0
      RETURN
 20   CONTINUE 
*     finalize this "merged" track and start a new one
      NTRTMT=NTRTMT+1
      NSETMT=NSETMT+NSEG0
      DO II=1,MAX(NSEG0,NSEG)
         TEMP=H(II)
         H(II)=H0(II)/WEIGHT0
         H0(II)=WEIGHT*TEMP
         NTEMP=NOM(II)
         NOM(II)=NOM0(II)
         NOM0(II)=NTEMP
      ENDDO
      NTPROC=NMERG
      NMERG=1
      TEMP=WEIGHT
      WEIGHT=WEIGHT0
      WEIGHT0=TEMP
      NTEMP=NSEG
      NSEG=NSEG0
      NSEG0=NTEMP
      RETURN
      END