/[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.8 - (show annotations) (download)
Mon Jul 27 13:47:43 2009 UTC (15 years, 4 months ago) by mocchiut
Branch: MAIN
Changes since 1.7: +60 -48 lines
Fit mode forcing tool added

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 INTEGER FORCEMODE
42
43 INTEGER IBAR(2,NPLAV)
44 COMMON/ANGOLO/BAR,IBAR
45 SAVE /ANGOLO/
46
47 REAL CX, CY
48 COMMON/WHERE/CX,CY,PIANO
49 SAVE /WHERE/
50
51 COMMON/CALOFIT/VARFIT,NPFIT,IWPL,CHTRACK
52 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 FORCEMODE = -1
66 IF (FMODE(1).GT.100.AND.FMODE(2).GT.100) THEN
67 FORCEMODE = FMODE(1)-1000
68 ENDIF
69 C
70 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 SA = 0
76 SB = 0
77 SVAR = 0
78 FMODE(M) = 0
79 10 CONTINUE
80 ICONT = 0
81 CALL VZERO(X,NPLAV)
82 CALL VZERO(Y,NPLAV)
83 CALL VZERO(W,NPLAV)
84 DO I = 1,NPLA
85 C
86 IF (MOD(M,2).EQ.0) THEN
87 X(I) = PIANO(I)
88 C X(I) = PIANO(I) - 5.81
89 ELSE
90 X(I) = PIANO(I) - 5.81
91 C X(I) = PIANO(I)
92 ENDIF
93 Y(I) = 0.
94 C
95 C
96 C
97 IF ((FMODE(M).EQ.0.AND.FORCEMODE.EQ.-1)
98 + .OR.FORCEMODE.EQ.0) THEN
99 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 C No weigth and less cluster per plane
112 C
113 IF((FMODE(M).EQ.1.AND.FORCEMODE.EQ.-1).OR.
114 + FORCEMODE.EQ.1) THEN
115 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 W(I) = ((CLUS(M,I,1+NCHA/2)**0.29))**2.
119 c W(I) = 1.
120 ENDIF
121 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 ENDIF
127 c
128 c One cluster per plane
129 c
130 IF((FMODE(M).EQ.2.AND.FORCEMODE.EQ.-1).OR.
131 + FORCEMODE.EQ.2) THEN
132 IF (NCL(M,I).EQ.1) THEN
133 ICONT = ICONT + 1
134 Y(I) = CLUS(M,I,1)
135 W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2.
136 c W(I) = 1.
137 ENDIF
138 ENDIF
139 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 ENDDO
142 C
143
144 A = 0.
145 B = 0.
146 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 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 FMODE(M) = 1
165 GOTO 10
166 ENDIF
167 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 ENDIF
205 ENDIF
206 C
207 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 C
213 ENDDO
214 C
215
216 500 CONTINUE
217 RETURN
218 END

  ViewVC Help
Powered by ViewVC 1.1.23