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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.9 - (hide annotations) (download)
Mon Jul 27 13:58:40 2009 UTC (15 years, 4 months ago) by mocchiut
Branch: MAIN
Changes since 1.8: +3 -2 lines
Fit mode forcing tool added

1 mocchiut 1.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 mocchiut 1.3 REAL FLIMIT, FLIMIT2
23 mocchiut 1.1 INTEGER NVAR,NPAR
24     PARAMETER (NVAR=1,NPAR=2)
25 mocchiut 1.4 c PARAMETER (FLIMIT=10000)
26     c PARAMETER (FLIMIT2=2000)
27 mocchiut 1.5 c PARAMETER (FLIMIT=500)
28     PARAMETER (FLIMIT=2000)
29 mocchiut 1.4 PARAMETER (FLIMIT2=500)
30 mocchiut 1.6 REAL X(NPLAV),Y(NPLAV),W(NPLAV)
31 mocchiut 1.1 REAL DEVIA(2),TG(2)
32 mocchiut 1.6 REAL BAR(2,NPLAV)
33 mocchiut 1.1 REAL A, B, VAR
34 mocchiut 1.2 REAL SA, SB, SVAR
35     REAL SSA, SSB, SSVAR
36 mocchiut 1.6 REAL PIANO(NPLAV)
37 mocchiut 1.1 REAL VARFIT(2)
38    
39 mocchiut 1.2 INTEGER ICONT, M, I, SNPFIT,SSNPFIT
40     INTEGER NPFIT(2), CHTRACK,IWPL(2)
41 mocchiut 1.8 INTEGER FORCEMODE
42 mocchiut 1.1
43 mocchiut 1.6 INTEGER IBAR(2,NPLAV)
44 mocchiut 1.1 COMMON/ANGOLO/BAR,IBAR
45     SAVE /ANGOLO/
46    
47     REAL CX, CY
48     COMMON/WHERE/CX,CY,PIANO
49     SAVE /WHERE/
50    
51 mocchiut 1.2 COMMON/CALOFIT/VARFIT,NPFIT,IWPL,CHTRACK
52 mocchiut 1.1 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 mocchiut 1.8 FORCEMODE = -1
66 mocchiut 1.9 IF (FMODE(1).GE.1000.AND.FMODE(2).GE.1000) THEN
67 mocchiut 1.8 FORCEMODE = FMODE(1)-1000
68     ENDIF
69     C
70 mocchiut 1.1 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 mocchiut 1.2 SA = 0
76     SB = 0
77     SVAR = 0
78     FMODE(M) = 0
79     10 CONTINUE
80 mocchiut 1.1 ICONT = 0
81 mocchiut 1.6 CALL VZERO(X,NPLAV)
82     CALL VZERO(Y,NPLAV)
83     CALL VZERO(W,NPLAV)
84 mocchiut 1.1 DO I = 1,NPLA
85     C
86     IF (MOD(M,2).EQ.0) THEN
87 mocchiut 1.7 X(I) = PIANO(I)
88     C X(I) = PIANO(I) - 5.81
89     ELSE
90 mocchiut 1.1 X(I) = PIANO(I) - 5.81
91 mocchiut 1.7 C X(I) = PIANO(I)
92 mocchiut 1.1 ENDIF
93     Y(I) = 0.
94 mocchiut 1.2 C
95     C
96     C
97 mocchiut 1.8 IF ((FMODE(M).EQ.0.AND.FORCEMODE.EQ.-1)
98     + .OR.FORCEMODE.EQ.0) THEN
99 mocchiut 1.2 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 mocchiut 1.4 C No weigth and less cluster per plane
112 mocchiut 1.2 C
113 mocchiut 1.8 IF((FMODE(M).EQ.1.AND.FORCEMODE.EQ.-1).OR.
114     + FORCEMODE.EQ.1) THEN
115 mocchiut 1.2 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 mocchiut 1.5 W(I) = ((CLUS(M,I,1+NCHA/2)**0.29))**2.
119     c W(I) = 1.
120 mocchiut 1.2 ENDIF
121 mocchiut 1.4 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 mocchiut 1.2 ENDIF
127     c
128     c One cluster per plane
129     c
130 mocchiut 1.8 IF((FMODE(M).EQ.2.AND.FORCEMODE.EQ.-1).OR.
131     + FORCEMODE.EQ.2) THEN
132 mocchiut 1.2 IF (NCL(M,I).EQ.1) THEN
133     ICONT = ICONT + 1
134     Y(I) = CLUS(M,I,1)
135 mocchiut 1.5 W(I) = ((CLUS(M,I,1+NCHA/2)**0.79))**2.
136     c W(I) = 1.
137 mocchiut 1.2 ENDIF
138 mocchiut 1.1 ENDIF
139 mocchiut 1.2 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 mocchiut 1.1 ENDDO
142     C
143    
144     A = 0.
145     B = 0.
146 mocchiut 1.2 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 mocchiut 1.8 IF (FORCEMODE.EQ.-1) THEN
155     C
156     C TRY A BETTER FIT IF VAR IS BIG ON THE FIRST TRY
157     C
158 mocchiut 1.9 IF ((ABS(VAR).GT.FLIMIT.OR.VAR.EQ.0.)
159     & .AND.FMODE(M).EQ.0) THEN
160 mocchiut 1.8 SVAR = VAR
161     SB = B
162     SA = A
163     SNPFIT = NPFIT(M)
164     NPFIT(M) = NPLA
165 mocchiut 1.2 FMODE(M) = 1
166 mocchiut 1.8 GOTO 10
167 mocchiut 1.2 ENDIF
168 mocchiut 1.8 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 mocchiut 1.2 ENDIF
206     ENDIF
207     C
208 mocchiut 1.1 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 mocchiut 1.2 C
214 mocchiut 1.1 ENDDO
215     C
216    
217     500 CONTINUE
218     RETURN
219     END

  ViewVC Help
Powered by ViewVC 1.1.23