/[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.10 - (show annotations) (download)
Tue Aug 4 14:01:19 2009 UTC (15 years, 4 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, v10REDr01, HEAD
Changes since 1.9: +2 -1 lines
Error occurred while calculating annotation data.
Changed to work with GCC 4.x (gfortran) + ROOT >= 5.24

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).GE.1000.AND.FMODE(2).GE.1000) 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.)
159 & .AND.FMODE(M).EQ.0) THEN
160 SVAR = VAR
161 SB = B
162 SA = A
163 SNPFIT = NPFIT(M)
164 NPFIT(M) = NPLA
165 FMODE(M) = 1
166 GOTO 10
167 ENDIF
168 C
169 C TRY AGAIN IF STILL BAD AND WE HAVE AT LEAST 10 POINT TO MAKE THE FIT
170 C
171 IF ((ABS(VAR).GT.FLIMIT2.OR.VAR.EQ.0.).AND.FMODE(M).EQ.1
172 & .AND.SNPFIT.GT.5) THEN
173 SSVAR = VAR
174 SSB = B
175 SSA = A
176 SSNPFIT = NPFIT(M)
177 NPFIT(M) = NPLA
178 FMODE(M) = 2
179 GOTO 10
180 ENDIF
181 C
182 C IF WE ARE AT THE THIRD TRY AND THE FIT IS WORST THAN THE SECOND TRY TAKE THE FIRST TRY
183 C
184 IF (FMODE(M).EQ.2) THEN
185 IF (ABS(VAR).GT.ABS(SSVAR).OR.ABS(VAR).EQ.0.
186 & .OR.NPFIT(M).LE.4) THEN
187 FMODE(M) = 1
188 VAR=SSVAR
189 B = SSB
190 A = SSA
191 NPFIT(M) = SSNPFIT
192 ENDIF
193 ENDIF
194 C
195 C IF THE SECOND TRY AND THE FIT IS WORST THAN THE FIRST TRY TAKE THE FIRST TRY
196 C
197 IF (FMODE(M).EQ.1) THEN
198 IF (ABS(VAR).GT.ABS(SVAR).OR.ABS(VAR).EQ.0.) THEN
199 FMODE(M) = 0
200 VAR=SVAR
201 B = SB
202 A = SA
203 NPFIT(M) = SNPFIT
204 ENDIF
205 ENDIF
206 ENDIF
207 C
208 VARFIT(M) = VAR
209 IF (M.EQ.1) CX = B
210 IF (M.EQ.2) CY = B
211 DEVIA(M) = A
212 TG(M) = A
213 C
214 ENDDO
215 C
216
217 c 500 CONTINUE
218 CONTINUE
219 RETURN
220 END

  ViewVC Help
Powered by ViewVC 1.1.23