19 |
|
|
20 |
INCLUDE 'INTEST.TXT' |
INCLUDE 'INTEST.TXT' |
21 |
|
|
22 |
|
REAL FLIMIT, FLIMIT2 |
23 |
INTEGER NVAR,NPAR |
INTEGER NVAR,NPAR |
24 |
PARAMETER (NVAR=1,NPAR=2) |
PARAMETER (NVAR=1,NPAR=2) |
25 |
|
c PARAMETER (FLIMIT=10000) |
26 |
REAL X(NPLA),Y(NPLA),W(NPLA) |
c PARAMETER (FLIMIT2=2000) |
27 |
|
c PARAMETER (FLIMIT=500) |
28 |
|
PARAMETER (FLIMIT=2000) |
29 |
|
PARAMETER (FLIMIT2=500) |
30 |
|
REAL X(NPLAV),Y(NPLAV),W(NPLAV) |
31 |
REAL DEVIA(2),TG(2) |
REAL DEVIA(2),TG(2) |
32 |
REAL BAR(2,NPLA) |
REAL BAR(2,NPLAV) |
33 |
REAL A, B, VAR |
REAL A, B, VAR |
34 |
REAL PIANO(22) |
REAL SA, SB, SVAR |
35 |
|
REAL SSA, SSB, SSVAR |
36 |
|
REAL PIANO(NPLAV) |
37 |
REAL VARFIT(2) |
REAL VARFIT(2) |
38 |
|
|
39 |
INTEGER ICONT, M, I |
INTEGER ICONT, M, I, SNPFIT,SSNPFIT |
40 |
INTEGER NPFIT(2) |
INTEGER NPFIT(2), CHTRACK,IWPL(2) |
41 |
|
|
42 |
INTEGER IBAR(2,NPLA) |
INTEGER IBAR(2,NPLAV) |
43 |
COMMON/ANGOLO/BAR,IBAR |
COMMON/ANGOLO/BAR,IBAR |
44 |
SAVE /ANGOLO/ |
SAVE /ANGOLO/ |
45 |
|
|
47 |
COMMON/WHERE/CX,CY,PIANO |
COMMON/WHERE/CX,CY,PIANO |
48 |
SAVE /WHERE/ |
SAVE /WHERE/ |
49 |
|
|
50 |
COMMON/CALOFIT/VARFIT,NPFIT |
COMMON/CALOFIT/VARFIT,NPFIT,IWPL,CHTRACK |
51 |
SAVE/CALOFIT/ |
SAVE/CALOFIT/ |
52 |
C |
C |
53 |
ICONT = 0 |
ICONT = 0 |
66 |
C HIGHEST DETECTED ENERGY IS USED . |
C HIGHEST DETECTED ENERGY IS USED . |
67 |
C |
C |
68 |
DO M = 1,2 |
DO M = 1,2 |
69 |
|
SA = 0 |
70 |
|
SB = 0 |
71 |
|
SVAR = 0 |
72 |
|
FMODE(M) = 0 |
73 |
|
10 CONTINUE |
74 |
ICONT = 0 |
ICONT = 0 |
75 |
CALL VZERO(X,NPLA) |
CALL VZERO(X,NPLAV) |
76 |
CALL VZERO(Y,NPLA) |
CALL VZERO(Y,NPLAV) |
77 |
CALL VZERO(W,NPLA) |
CALL VZERO(W,NPLAV) |
78 |
DO I = 1,NPLA |
DO I = 1,NPLA |
79 |
C |
C |
80 |
IF (MOD(M,2).EQ.0) THEN |
IF (MOD(M,2).EQ.0) THEN |
82 |
ELSE |
ELSE |
83 |
X(I) = PIANO(I) |
X(I) = PIANO(I) |
84 |
ENDIF |
ENDIF |
|
C X(I) = -(I-1) * PIANO |
|
85 |
Y(I) = 0. |
Y(I) = 0. |
86 |
IF (NCL(M,I).GE.1) THEN |
C |
87 |
ICONT = ICONT + 1 |
C |
88 |
Y(I) = CLUS(M,I,1) |
C |
89 |
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
IF (FMODE(M).EQ.0) THEN |
90 |
IF (W(I).GT.2000.) W(I) = 2000. |
IF (NCL(M,I).GE.1) THEN |
91 |
|
ICONT = ICONT + 1 |
92 |
|
Y(I) = CLUS(M,I,1) |
93 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
94 |
|
IF (W(I).GT.2000.) THEN |
95 |
|
W(I) = 2000. |
96 |
|
C Y(I) = 0. |
97 |
|
C ICONT = ICONT -1 |
98 |
|
ENDIF |
99 |
|
ENDIF |
100 |
|
ENDIF |
101 |
|
C |
102 |
|
C No weigth and less cluster per plane |
103 |
|
C |
104 |
|
IF(FMODE(M).EQ.1) THEN |
105 |
|
IF (NCL(M,I).GE.1.AND.NCL(M,I).LE.2) THEN |
106 |
|
ICONT = ICONT + 1 |
107 |
|
Y(I) = CLUS(M,I,1) |
108 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.29))**2. |
109 |
|
c W(I) = 1. |
110 |
|
ENDIF |
111 |
|
c IF (W(I).GT.2000.) THEN |
112 |
|
cx W(I) = 2000. |
113 |
|
cc Y(I) = 0. |
114 |
|
cc ICONT = ICONT -1 |
115 |
|
c ENDIF |
116 |
|
ENDIF |
117 |
|
c |
118 |
|
c One cluster per plane |
119 |
|
c |
120 |
|
IF(FMODE(M).EQ.2) THEN |
121 |
|
IF (NCL(M,I).EQ.1) THEN |
122 |
|
ICONT = ICONT + 1 |
123 |
|
Y(I) = CLUS(M,I,1) |
124 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
125 |
|
c W(I) = 1. |
126 |
|
ENDIF |
127 |
ENDIF |
ENDIF |
128 |
if (Y(I).eq.0.or.W(I).eq.2000.) NPFIT(M) = NPFIT(M) - 1 |
c if (Y(I).eq.0.or.W(I).eq.2000.) NPFIT(M) = NPFIT(M) - 1 |
129 |
|
if (Y(I).eq.0.) NPFIT(M) = NPFIT(M) - 1 |
130 |
ENDDO |
ENDDO |
131 |
C |
C |
132 |
|
|
133 |
A = 0. |
A = 0. |
134 |
B = 0. |
B = 0. |
135 |
IF (ICONT.GE.2) CALL LFITW(X,Y,W,NPLA,0,A,B,VAR) |
VAR = 0. |
136 |
|
c print *,' icont = ',icont |
137 |
|
IF (ICONT.GE.2) THEN |
138 |
|
CALL LFITW(X,Y,W,NPLA,0,A,B,VAR) |
139 |
|
ELSE |
140 |
|
NPFIT(M) = 0 |
141 |
|
ENDIF |
142 |
|
C |
143 |
|
C TRY A BETTER FIT IF VAR IS BIG ON THE FIRST TRY |
144 |
|
C |
145 |
|
IF ((ABS(VAR).GT.FLIMIT.OR.VAR.EQ.0.).AND.FMODE(M).EQ.0) THEN |
146 |
|
SVAR = VAR |
147 |
|
SB = B |
148 |
|
SA = A |
149 |
|
SNPFIT = NPFIT(M) |
150 |
|
NPFIT(M) = NPLA |
151 |
|
FMODE(M) = 1 |
152 |
|
GOTO 10 |
153 |
|
ENDIF |
154 |
|
C |
155 |
|
C TRY AGAIN IF STILL BAD AND WE HAVE AT LEAST 10 POINT TO MAKE THE FIT |
156 |
|
C |
157 |
|
IF ((ABS(VAR).GT.FLIMIT2.OR.VAR.EQ.0.).AND.FMODE(M).EQ.1 |
158 |
|
& .AND.SNPFIT.GT.5) THEN |
159 |
|
SSVAR = VAR |
160 |
|
SSB = B |
161 |
|
SSA = A |
162 |
|
SSNPFIT = NPFIT(M) |
163 |
|
NPFIT(M) = NPLA |
164 |
|
FMODE(M) = 2 |
165 |
|
GOTO 10 |
166 |
|
ENDIF |
167 |
|
C |
168 |
|
C IF WE ARE AT THE THIRD TRY AND THE FIT IS WORST THAN THE SECOND TRY TAKE THE FIRST TRY |
169 |
|
C |
170 |
|
IF (FMODE(M).EQ.2) THEN |
171 |
|
IF (ABS(VAR).GT.ABS(SSVAR).OR.ABS(VAR).EQ.0. |
172 |
|
& .OR.NPFIT(M).LE.4) THEN |
173 |
|
FMODE(M) = 1 |
174 |
|
VAR=SSVAR |
175 |
|
B = SSB |
176 |
|
A = SSA |
177 |
|
NPFIT(M) = SSNPFIT |
178 |
|
ENDIF |
179 |
|
ENDIF |
180 |
|
C |
181 |
|
C IF THE SECOND TRY AND THE FIT IS WORST THAN THE FIRST TRY TAKE THE FIRST TRY |
182 |
|
C |
183 |
|
IF (FMODE(M).EQ.1) THEN |
184 |
|
IF (ABS(VAR).GT.ABS(SVAR).OR.ABS(VAR).EQ.0.) THEN |
185 |
|
FMODE(M) = 0 |
186 |
|
VAR=SVAR |
187 |
|
B = SB |
188 |
|
A = SA |
189 |
|
NPFIT(M) = SNPFIT |
190 |
|
ENDIF |
191 |
|
ENDIF |
192 |
|
C |
193 |
VARFIT(M) = VAR |
VARFIT(M) = VAR |
194 |
IF (M.EQ.1) CX = B |
IF (M.EQ.1) CX = B |
195 |
IF (M.EQ.2) CY = B |
IF (M.EQ.2) CY = B |
|
C |
|
196 |
DEVIA(M) = A |
DEVIA(M) = A |
197 |
TG(M) = A |
TG(M) = A |
198 |
|
C |
199 |
ENDDO |
ENDDO |
200 |
C |
C |
201 |
|
|