/[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.5 - (show annotations) (download)
Sat Jan 27 06:22:20 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
CVS Tags: v3r04, v3r05, v3r06, v3r00, v3r03
Changes since 1.4: +6 -5 lines
Added DB reconnection routine called in between detector software

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

  ViewVC Help
Powered by ViewVC 1.1.23