/[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.3 - (show annotations) (download)
Mon Jan 22 10:46:00 2007 UTC (17 years, 10 months ago) by mocchiut
Branch: MAIN
Changes since 1.2: +5 -4 lines
Selftrigger update

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

  ViewVC Help
Powered by ViewVC 1.1.23