1 |
mocchiut |
1.1 |
SUBROUTINE DIRECTION(DEVIA) |
2 |
|
|
C----------------------------------------------------- |
3 |
|
|
C- |
4 |
|
|
C- Purpose and Methods : PROGRAM THAT DETERMINES THE |
5 |
|
|
C- TRACK PROJECTIONS ON THE PLANE XZ AND YZ USING |
6 |
|
|
C- ONLY CALORIMETER INFORMATION . |
7 |
|
|
C- |
8 |
|
|
C- Inputs : |
9 |
|
|
C- Outputs : |
10 |
|
|
C- Controls: |
11 |
|
|
C- |
12 |
|
|
C- Created 9-FEB-1994 MIRKO BOEZIO |
13 |
|
|
C- Modified 21-FEB-2003 MIRKO BOEZIO . ADAPTED TO |
14 |
|
|
C- BE USED FOR PAMELA CALORIMETER . |
15 |
|
|
C- |
16 |
|
|
C------------------------------------------------------ |
17 |
|
|
|
18 |
|
|
IMPLICIT NONE |
19 |
|
|
|
20 |
|
|
INCLUDE 'INTEST.TXT' |
21 |
|
|
|
22 |
mocchiut |
1.3 |
REAL FLIMIT, FLIMIT2 |
23 |
mocchiut |
1.1 |
INTEGER NVAR,NPAR |
24 |
|
|
PARAMETER (NVAR=1,NPAR=2) |
25 |
mocchiut |
1.4 |
c PARAMETER (FLIMIT=10000) |
26 |
|
|
c PARAMETER (FLIMIT2=2000) |
27 |
mocchiut |
1.5 |
c PARAMETER (FLIMIT=500) |
28 |
|
|
PARAMETER (FLIMIT=2000) |
29 |
mocchiut |
1.4 |
PARAMETER (FLIMIT2=500) |
30 |
mocchiut |
1.6 |
REAL X(NPLAV),Y(NPLAV),W(NPLAV) |
31 |
mocchiut |
1.1 |
REAL DEVIA(2),TG(2) |
32 |
mocchiut |
1.6 |
REAL BAR(2,NPLAV) |
33 |
mocchiut |
1.1 |
REAL A, B, VAR |
34 |
mocchiut |
1.2 |
REAL SA, SB, SVAR |
35 |
|
|
REAL SSA, SSB, SSVAR |
36 |
mocchiut |
1.6 |
REAL PIANO(NPLAV) |
37 |
mocchiut |
1.1 |
REAL VARFIT(2) |
38 |
|
|
|
39 |
mocchiut |
1.2 |
INTEGER ICONT, M, I, SNPFIT,SSNPFIT |
40 |
|
|
INTEGER NPFIT(2), CHTRACK,IWPL(2) |
41 |
mocchiut |
1.8 |
INTEGER FORCEMODE |
42 |
mocchiut |
1.1 |
|
43 |
mocchiut |
1.6 |
INTEGER IBAR(2,NPLAV) |
44 |
mocchiut |
1.1 |
COMMON/ANGOLO/BAR,IBAR |
45 |
|
|
SAVE /ANGOLO/ |
46 |
|
|
|
47 |
|
|
REAL CX, CY |
48 |
|
|
COMMON/WHERE/CX,CY,PIANO |
49 |
|
|
SAVE /WHERE/ |
50 |
|
|
|
51 |
mocchiut |
1.2 |
COMMON/CALOFIT/VARFIT,NPFIT,IWPL,CHTRACK |
52 |
mocchiut |
1.1 |
SAVE/CALOFIT/ |
53 |
|
|
C |
54 |
|
|
ICONT = 0 |
55 |
|
|
DEVIA(1) = 0. |
56 |
|
|
DEVIA(2) = 0. |
57 |
|
|
CX = 0. |
58 |
|
|
CY = 0. |
59 |
|
|
C |
60 |
|
|
NPFIT(1) = NPLA |
61 |
|
|
NPFIT(2) = NPLA |
62 |
|
|
VARFIT(1) = 0. |
63 |
|
|
VARFIT(2) = 0. |
64 |
|
|
C |
65 |
mocchiut |
1.8 |
FORCEMODE = -1 |
66 |
|
|
IF (FMODE(1).GT.100.AND.FMODE(2).GT.100) THEN |
67 |
|
|
FORCEMODE = FMODE(1)-1000 |
68 |
|
|
ENDIF |
69 |
|
|
C |
70 |
mocchiut |
1.1 |
C THE FIT IS PERFORMED WHEN THERE ARE AT LEAST TWO |
71 |
|
|
C LAYERS WITH SIGNAL . FOR THE FIT THE CLUSTER WITH THE |
72 |
|
|
C HIGHEST DETECTED ENERGY IS USED . |
73 |
|
|
C |
74 |
|
|
DO M = 1,2 |
75 |
mocchiut |
1.2 |
SA = 0 |
76 |
|
|
SB = 0 |
77 |
|
|
SVAR = 0 |
78 |
|
|
FMODE(M) = 0 |
79 |
|
|
10 CONTINUE |
80 |
mocchiut |
1.1 |
ICONT = 0 |
81 |
mocchiut |
1.6 |
CALL VZERO(X,NPLAV) |
82 |
|
|
CALL VZERO(Y,NPLAV) |
83 |
|
|
CALL VZERO(W,NPLAV) |
84 |
mocchiut |
1.1 |
DO I = 1,NPLA |
85 |
|
|
C |
86 |
|
|
IF (MOD(M,2).EQ.0) THEN |
87 |
mocchiut |
1.7 |
X(I) = PIANO(I) |
88 |
|
|
C X(I) = PIANO(I) - 5.81 |
89 |
|
|
ELSE |
90 |
mocchiut |
1.1 |
X(I) = PIANO(I) - 5.81 |
91 |
mocchiut |
1.7 |
C X(I) = PIANO(I) |
92 |
mocchiut |
1.1 |
ENDIF |
93 |
|
|
Y(I) = 0. |
94 |
mocchiut |
1.2 |
C |
95 |
|
|
C |
96 |
|
|
C |
97 |
mocchiut |
1.8 |
IF ((FMODE(M).EQ.0.AND.FORCEMODE.EQ.-1) |
98 |
|
|
+ .OR.FORCEMODE.EQ.0) THEN |
99 |
mocchiut |
1.2 |
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 |
110 |
|
|
C |
111 |
mocchiut |
1.4 |
C No weigth and less cluster per plane |
112 |
mocchiut |
1.2 |
C |
113 |
mocchiut |
1.8 |
IF((FMODE(M).EQ.1.AND.FORCEMODE.EQ.-1).OR. |
114 |
|
|
+ FORCEMODE.EQ.1) THEN |
115 |
mocchiut |
1.2 |
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 |
mocchiut |
1.5 |
W(I) = ((CLUS(M,I,1+NCHA/2)**0.29))**2. |
119 |
|
|
c W(I) = 1. |
120 |
mocchiut |
1.2 |
ENDIF |
121 |
mocchiut |
1.4 |
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 |
mocchiut |
1.2 |
ENDIF |
127 |
|
|
c |
128 |
|
|
c One cluster per plane |
129 |
|
|
c |
130 |
mocchiut |
1.8 |
IF((FMODE(M).EQ.2.AND.FORCEMODE.EQ.-1).OR. |
131 |
|
|
+ FORCEMODE.EQ.2) THEN |
132 |
mocchiut |
1.2 |
IF (NCL(M,I).EQ.1) THEN |
133 |
|
|
ICONT = ICONT + 1 |
134 |
|
|
Y(I) = CLUS(M,I,1) |
135 |
mocchiut |
1.5 |
W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2. |
136 |
|
|
c W(I) = 1. |
137 |
mocchiut |
1.2 |
ENDIF |
138 |
mocchiut |
1.1 |
ENDIF |
139 |
mocchiut |
1.2 |
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 |
mocchiut |
1.1 |
ENDDO |
142 |
|
|
C |
143 |
|
|
|
144 |
|
|
A = 0. |
145 |
|
|
B = 0. |
146 |
mocchiut |
1.2 |
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 |
mocchiut |
1.8 |
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 |
mocchiut |
1.2 |
FMODE(M) = 1 |
165 |
mocchiut |
1.8 |
GOTO 10 |
166 |
mocchiut |
1.2 |
ENDIF |
167 |
mocchiut |
1.8 |
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 |
mocchiut |
1.2 |
ENDIF |
205 |
|
|
ENDIF |
206 |
|
|
C |
207 |
mocchiut |
1.1 |
VARFIT(M) = VAR |
208 |
|
|
IF (M.EQ.1) CX = B |
209 |
|
|
IF (M.EQ.2) CY = B |
210 |
|
|
DEVIA(M) = A |
211 |
|
|
TG(M) = A |
212 |
mocchiut |
1.2 |
C |
213 |
mocchiut |
1.1 |
ENDDO |
214 |
|
|
C |
215 |
|
|
|
216 |
|
|
500 CONTINUE |
217 |
|
|
RETURN |
218 |
|
|
END |