/[PAMELA software]/DarthVader/CalorimeterLevel2/src/direction.for
ViewVC logotype

Contents of /DarthVader/CalorimeterLevel2/src/direction.for

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Thu Nov 22 13:53:28 2007 UTC (17 years ago) by mocchiut
Branch: MAIN
CVS Tags: v5r00, v6r01, v6r00
Changes since 1.6: +4 -2 lines
Alignment bug in CBAR fixed

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

  ViewVC Help
Powered by ViewVC 1.1.23