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 |
|
INTEGER FORCEMODE |
42 |
|
|
43 |
INTEGER IBAR(2,NPLA) |
INTEGER IBAR(2,NPLAV) |
44 |
COMMON/ANGOLO/BAR,IBAR |
COMMON/ANGOLO/BAR,IBAR |
45 |
SAVE /ANGOLO/ |
SAVE /ANGOLO/ |
46 |
|
|
48 |
COMMON/WHERE/CX,CY,PIANO |
COMMON/WHERE/CX,CY,PIANO |
49 |
SAVE /WHERE/ |
SAVE /WHERE/ |
50 |
|
|
51 |
COMMON/CALOFIT/VARFIT,NPFIT |
COMMON/CALOFIT/VARFIT,NPFIT,IWPL,CHTRACK |
52 |
SAVE/CALOFIT/ |
SAVE/CALOFIT/ |
53 |
C |
C |
54 |
ICONT = 0 |
ICONT = 0 |
62 |
VARFIT(1) = 0. |
VARFIT(1) = 0. |
63 |
VARFIT(2) = 0. |
VARFIT(2) = 0. |
64 |
C |
C |
65 |
|
FORCEMODE = -1 |
66 |
|
IF (FMODE(1).GT.100.AND.FMODE(2).GT.100) THEN |
67 |
|
FORCEMODE = FMODE(1)-1000 |
68 |
|
ENDIF |
69 |
|
C |
70 |
C THE FIT IS PERFORMED WHEN THERE ARE AT LEAST TWO |
C THE FIT IS PERFORMED WHEN THERE ARE AT LEAST TWO |
71 |
C LAYERS WITH SIGNAL . FOR THE FIT THE CLUSTER WITH THE |
C LAYERS WITH SIGNAL . FOR THE FIT THE CLUSTER WITH THE |
72 |
C HIGHEST DETECTED ENERGY IS USED . |
C HIGHEST DETECTED ENERGY IS USED . |
73 |
C |
C |
74 |
DO M = 1,2 |
DO M = 1,2 |
75 |
|
SA = 0 |
76 |
|
SB = 0 |
77 |
|
SVAR = 0 |
78 |
|
FMODE(M) = 0 |
79 |
|
10 CONTINUE |
80 |
ICONT = 0 |
ICONT = 0 |
81 |
CALL VZERO(X,NPLA) |
CALL VZERO(X,NPLAV) |
82 |
CALL VZERO(Y,NPLA) |
CALL VZERO(Y,NPLAV) |
83 |
CALL VZERO(W,NPLA) |
CALL VZERO(W,NPLAV) |
84 |
DO I = 1,NPLA |
DO I = 1,NPLA |
85 |
C |
C |
86 |
IF (MOD(M,2).EQ.0) THEN |
IF (MOD(M,2).EQ.0) THEN |
87 |
X(I) = PIANO(I) - 5.81 |
X(I) = PIANO(I) |
88 |
|
C X(I) = PIANO(I) - 5.81 |
89 |
ELSE |
ELSE |
90 |
X(I) = PIANO(I) |
X(I) = PIANO(I) - 5.81 |
91 |
|
C X(I) = PIANO(I) |
92 |
ENDIF |
ENDIF |
|
C X(I) = -(I-1) * PIANO |
|
93 |
Y(I) = 0. |
Y(I) = 0. |
94 |
IF (NCL(M,I).GE.1) THEN |
C |
95 |
ICONT = ICONT + 1 |
C |
96 |
Y(I) = CLUS(M,I,1) |
C |
97 |
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
IF ((FMODE(M).EQ.0.AND.FORCEMODE.EQ.-1) |
98 |
IF (W(I).GT.2000.) W(I) = 2000. |
+ .OR.FORCEMODE.EQ.0) THEN |
99 |
|
IF (NCL(M,I).GE.1) THEN |
100 |
|
ICONT = ICONT + 1 |
101 |
|
Y(I) = CLUS(M,I,1) |
102 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
103 |
|
IF (W(I).GT.2000.) THEN |
104 |
|
W(I) = 2000. |
105 |
|
C Y(I) = 0. |
106 |
|
C ICONT = ICONT -1 |
107 |
|
ENDIF |
108 |
|
ENDIF |
109 |
ENDIF |
ENDIF |
110 |
if (Y(I).eq.0.or.W(I).eq.2000.) NPFIT(M) = NPFIT(M) - 1 |
C |
111 |
|
C No weigth and less cluster per plane |
112 |
|
C |
113 |
|
IF((FMODE(M).EQ.1.AND.FORCEMODE.EQ.-1).OR. |
114 |
|
+ FORCEMODE.EQ.1) THEN |
115 |
|
IF (NCL(M,I).GE.1.AND.NCL(M,I).LE.2) THEN |
116 |
|
ICONT = ICONT + 1 |
117 |
|
Y(I) = CLUS(M,I,1) |
118 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.29))**2. |
119 |
|
c W(I) = 1. |
120 |
|
ENDIF |
121 |
|
c IF (W(I).GT.2000.) THEN |
122 |
|
cx W(I) = 2000. |
123 |
|
cc Y(I) = 0. |
124 |
|
cc ICONT = ICONT -1 |
125 |
|
c ENDIF |
126 |
|
ENDIF |
127 |
|
c |
128 |
|
c One cluster per plane |
129 |
|
c |
130 |
|
IF((FMODE(M).EQ.2.AND.FORCEMODE.EQ.-1).OR. |
131 |
|
+ FORCEMODE.EQ.2) THEN |
132 |
|
IF (NCL(M,I).EQ.1) THEN |
133 |
|
ICONT = ICONT + 1 |
134 |
|
Y(I) = CLUS(M,I,1) |
135 |
|
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
136 |
|
c W(I) = 1. |
137 |
|
ENDIF |
138 |
|
ENDIF |
139 |
|
c if (Y(I).eq.0.or.W(I).eq.2000.) NPFIT(M) = NPFIT(M) - 1 |
140 |
|
if (Y(I).eq.0.) NPFIT(M) = NPFIT(M) - 1 |
141 |
ENDDO |
ENDDO |
142 |
C |
C |
143 |
|
|
144 |
A = 0. |
A = 0. |
145 |
B = 0. |
B = 0. |
146 |
IF (ICONT.GE.2) CALL LFITW(X,Y,W,NPLA,0,A,B,VAR) |
VAR = 0. |
147 |
|
c print *,' icont = ',icont |
148 |
|
IF (ICONT.GE.2) THEN |
149 |
|
CALL LFITW(X,Y,W,NPLA,0,A,B,VAR) |
150 |
|
ELSE |
151 |
|
NPFIT(M) = 0 |
152 |
|
ENDIF |
153 |
|
C |
154 |
|
IF (FORCEMODE.EQ.-1) THEN |
155 |
|
C |
156 |
|
C TRY A BETTER FIT IF VAR IS BIG ON THE FIRST TRY |
157 |
|
C |
158 |
|
IF ((ABS(VAR).GT.FLIMIT.OR.VAR.EQ.0.).AND.FMODE(M).EQ.0) THEN |
159 |
|
SVAR = VAR |
160 |
|
SB = B |
161 |
|
SA = A |
162 |
|
SNPFIT = NPFIT(M) |
163 |
|
NPFIT(M) = NPLA |
164 |
|
FMODE(M) = 1 |
165 |
|
GOTO 10 |
166 |
|
ENDIF |
167 |
|
C |
168 |
|
C TRY AGAIN IF STILL BAD AND WE HAVE AT LEAST 10 POINT TO MAKE THE FIT |
169 |
|
C |
170 |
|
IF ((ABS(VAR).GT.FLIMIT2.OR.VAR.EQ.0.).AND.FMODE(M).EQ.1 |
171 |
|
& .AND.SNPFIT.GT.5) THEN |
172 |
|
SSVAR = VAR |
173 |
|
SSB = B |
174 |
|
SSA = A |
175 |
|
SSNPFIT = NPFIT(M) |
176 |
|
NPFIT(M) = NPLA |
177 |
|
FMODE(M) = 2 |
178 |
|
GOTO 10 |
179 |
|
ENDIF |
180 |
|
C |
181 |
|
C IF WE ARE AT THE THIRD TRY AND THE FIT IS WORST THAN THE SECOND TRY TAKE THE FIRST TRY |
182 |
|
C |
183 |
|
IF (FMODE(M).EQ.2) THEN |
184 |
|
IF (ABS(VAR).GT.ABS(SSVAR).OR.ABS(VAR).EQ.0. |
185 |
|
& .OR.NPFIT(M).LE.4) THEN |
186 |
|
FMODE(M) = 1 |
187 |
|
VAR=SSVAR |
188 |
|
B = SSB |
189 |
|
A = SSA |
190 |
|
NPFIT(M) = SSNPFIT |
191 |
|
ENDIF |
192 |
|
ENDIF |
193 |
|
C |
194 |
|
C IF THE SECOND TRY AND THE FIT IS WORST THAN THE FIRST TRY TAKE THE FIRST TRY |
195 |
|
C |
196 |
|
IF (FMODE(M).EQ.1) THEN |
197 |
|
IF (ABS(VAR).GT.ABS(SVAR).OR.ABS(VAR).EQ.0.) THEN |
198 |
|
FMODE(M) = 0 |
199 |
|
VAR=SVAR |
200 |
|
B = SB |
201 |
|
A = SA |
202 |
|
NPFIT(M) = SNPFIT |
203 |
|
ENDIF |
204 |
|
ENDIF |
205 |
|
ENDIF |
206 |
|
C |
207 |
VARFIT(M) = VAR |
VARFIT(M) = VAR |
208 |
IF (M.EQ.1) CX = B |
IF (M.EQ.1) CX = B |
209 |
IF (M.EQ.2) CY = B |
IF (M.EQ.2) CY = B |
|
C |
|
210 |
DEVIA(M) = A |
DEVIA(M) = A |
211 |
TG(M) = A |
TG(M) = A |
212 |
|
C |
213 |
ENDDO |
ENDDO |
214 |
C |
C |
215 |
|
|