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