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