--- DarthVader/CalorimeterLevel2/src/direction.for 2007/11/22 13:53:28 1.7 +++ DarthVader/CalorimeterLevel2/src/direction.for 2009/08/04 14:01:19 1.10 @@ -38,6 +38,7 @@ INTEGER ICONT, M, I, SNPFIT,SSNPFIT INTEGER NPFIT(2), CHTRACK,IWPL(2) + INTEGER FORCEMODE INTEGER IBAR(2,NPLAV) COMMON/ANGOLO/BAR,IBAR @@ -61,6 +62,11 @@ VARFIT(1) = 0. VARFIT(2) = 0. C + FORCEMODE = -1 + IF (FMODE(1).GE.1000.AND.FMODE(2).GE.1000) THEN + FORCEMODE = FMODE(1)-1000 + ENDIF +C C THE FIT IS PERFORMED WHEN THERE ARE AT LEAST TWO C LAYERS WITH SIGNAL . FOR THE FIT THE CLUSTER WITH THE C HIGHEST DETECTED ENERGY IS USED . @@ -88,7 +94,8 @@ C C C - IF (FMODE(M).EQ.0) THEN + IF ((FMODE(M).EQ.0.AND.FORCEMODE.EQ.-1) + + .OR.FORCEMODE.EQ.0) THEN IF (NCL(M,I).GE.1) THEN ICONT = ICONT + 1 Y(I) = CLUS(M,I,1) @@ -103,7 +110,8 @@ C C No weigth and less cluster per plane C - IF(FMODE(M).EQ.1) THEN + IF((FMODE(M).EQ.1.AND.FORCEMODE.EQ.-1).OR. + + FORCEMODE.EQ.1) THEN IF (NCL(M,I).GE.1.AND.NCL(M,I).LE.2) THEN ICONT = ICONT + 1 Y(I) = CLUS(M,I,1) @@ -119,7 +127,8 @@ c c One cluster per plane c - IF(FMODE(M).EQ.2) THEN + IF((FMODE(M).EQ.2.AND.FORCEMODE.EQ.-1).OR. + + FORCEMODE.EQ.2) THEN IF (NCL(M,I).EQ.1) THEN ICONT = ICONT + 1 Y(I) = CLUS(M,I,1) @@ -142,53 +151,57 @@ NPFIT(M) = 0 ENDIF C -C TRY A BETTER FIT IF VAR IS BIG ON THE FIRST TRY -C - IF ((ABS(VAR).GT.FLIMIT.OR.VAR.EQ.0.).AND.FMODE(M).EQ.0) THEN - SVAR = VAR - SB = B - SA = A - SNPFIT = NPFIT(M) - NPFIT(M) = NPLA - FMODE(M) = 1 - GOTO 10 - ENDIF -C -C TRY AGAIN IF STILL BAD AND WE HAVE AT LEAST 10 POINT TO MAKE THE FIT -C - IF ((ABS(VAR).GT.FLIMIT2.OR.VAR.EQ.0.).AND.FMODE(M).EQ.1 - & .AND.SNPFIT.GT.5) THEN - SSVAR = VAR - SSB = B - SSA = A - SSNPFIT = NPFIT(M) - NPFIT(M) = NPLA - FMODE(M) = 2 - GOTO 10 - ENDIF -C -C IF WE ARE AT THE THIRD TRY AND THE FIT IS WORST THAN THE SECOND TRY TAKE THE FIRST TRY -C - IF (FMODE(M).EQ.2) THEN - IF (ABS(VAR).GT.ABS(SSVAR).OR.ABS(VAR).EQ.0. - & .OR.NPFIT(M).LE.4) THEN + IF (FORCEMODE.EQ.-1) THEN +C +C TRY A BETTER FIT IF VAR IS BIG ON THE FIRST TRY +C + IF ((ABS(VAR).GT.FLIMIT.OR.VAR.EQ.0.) + & .AND.FMODE(M).EQ.0) THEN + SVAR = VAR + SB = B + SA = A + SNPFIT = NPFIT(M) + NPFIT(M) = NPLA FMODE(M) = 1 - VAR=SSVAR - B = SSB - A = SSA - NPFIT(M) = SSNPFIT + GOTO 10 ENDIF - ENDIF -C -C IF THE SECOND TRY AND THE FIT IS WORST THAN THE FIRST TRY TAKE THE FIRST TRY -C - IF (FMODE(M).EQ.1) THEN - IF (ABS(VAR).GT.ABS(SVAR).OR.ABS(VAR).EQ.0.) THEN - FMODE(M) = 0 - VAR=SVAR - B = SB - A = SA - NPFIT(M) = SNPFIT +C +C TRY AGAIN IF STILL BAD AND WE HAVE AT LEAST 10 POINT TO MAKE THE FIT +C + IF ((ABS(VAR).GT.FLIMIT2.OR.VAR.EQ.0.).AND.FMODE(M).EQ.1 + & .AND.SNPFIT.GT.5) THEN + SSVAR = VAR + SSB = B + SSA = A + SSNPFIT = NPFIT(M) + NPFIT(M) = NPLA + FMODE(M) = 2 + GOTO 10 + ENDIF +C +C IF WE ARE AT THE THIRD TRY AND THE FIT IS WORST THAN THE SECOND TRY TAKE THE FIRST TRY +C + IF (FMODE(M).EQ.2) THEN + IF (ABS(VAR).GT.ABS(SSVAR).OR.ABS(VAR).EQ.0. + & .OR.NPFIT(M).LE.4) THEN + FMODE(M) = 1 + VAR=SSVAR + B = SSB + A = SSA + NPFIT(M) = SSNPFIT + ENDIF + ENDIF +C +C IF THE SECOND TRY AND THE FIT IS WORST THAN THE FIRST TRY TAKE THE FIRST TRY +C + IF (FMODE(M).EQ.1) THEN + IF (ABS(VAR).GT.ABS(SVAR).OR.ABS(VAR).EQ.0.) THEN + FMODE(M) = 0 + VAR=SVAR + B = SB + A = SA + NPFIT(M) = SNPFIT + ENDIF ENDIF ENDIF C @@ -201,6 +214,7 @@ ENDDO C - 500 CONTINUE +c 500 CONTINUE + CONTINUE RETURN END