1 |
cafagna |
3.1 |
* |
2 |
cafagna |
3.2 |
* $Id: gpdspe.F,v 3.1.1.1 2002/07/11 16:02:13 cafagna Exp $ |
3 |
|
|
* |
4 |
|
|
* $Log: gpdspe.F,v $ |
5 |
|
|
* Revision 3.1.1.1 2002/07/11 16:02:13 cafagna |
6 |
|
|
* First GPAMELA release on CVS |
7 |
cafagna |
3.1 |
* |
8 |
|
|
* |
9 |
|
|
*CMZ : 2.01/00 05/04/2000 14.35.18 by Marialuigia Ambriola |
10 |
|
|
*CMZ : 2.00/00 03/03/2000 15.39.06 by Francesco Cafagna |
11 |
|
|
*CMZ : 1.02/00 19/01/2000 15.50.14 by Francesco Cafagna |
12 |
|
|
*CMZ : 1.01/00 16/05/96 17.38.13 by Francesco Cafagna |
13 |
|
|
*CMZ : 1.00/02 27/03/96 18.35.42 by Francesco Cafagna |
14 |
|
|
*-- Author : Francesco Cafagna 23/02/96 |
15 |
|
|
SUBROUTINE GPDSPE |
16 |
|
|
************************************************************************ |
17 |
|
|
* * |
18 |
|
|
* To perform SPE digitization * |
19 |
|
|
* * |
20 |
|
|
* Called by: GUDIGI * |
21 |
|
|
* Author: Francesco Cafagna, 23/02/96 12.50.38 * |
22 |
|
|
* * |
23 |
|
|
************************************************************************ |
24 |
|
|
#include "gcunit.inc" |
25 |
|
|
#include "gpphit.inc" |
26 |
cafagna |
3.2 |
PARAMETER (NH=NHSPE,NHM=NHMSPE,NVOL=3) |
27 |
cafagna |
3.1 |
#include "gppdigi.inc" |
28 |
|
|
c +SEQ,GPDSPE. |
29 |
|
|
#include "gprhit.inc" |
30 |
|
|
#include "gpspe.inc" |
31 |
|
|
#include "gpsed.inc" |
32 |
|
|
* |
33 |
|
|
INTEGER IS,ID,NV,NVM,GPNHIT,NTHIT,NHFRST |
34 |
|
|
CHARACTER*4 CSET |
35 |
|
|
LOGICAL CONT,HF |
36 |
|
|
* |
37 |
|
|
* Data block for digitalization |
38 |
|
|
* |
39 |
|
|
INTEGER NTRA,IDIG,LTRA,NPLANE,LKDN,NTDIGI,JJ |
40 |
|
|
INTEGER KDIGI(4),NUMBVD(NVOL) |
41 |
|
|
REAL XI,YI,XO,YO,PATH,DE,GPGAUS |
42 |
|
|
* |
43 |
|
|
DATA NTRA,LTRA/1,1/ |
44 |
|
|
* |
45 |
|
|
* |
46 |
|
|
* Vector zeroed |
47 |
|
|
* |
48 |
|
|
CALL VZERO(ITRPB ,NHM) |
49 |
|
|
CALL VZERO(ITRSL ,NHM) |
50 |
|
|
CALL VZERO(ITSPA ,NHM) |
51 |
|
|
CALL VZERO(XTSPA,NHM) |
52 |
|
|
CALL VZERO(YTSPA,NHM) |
53 |
|
|
CALL VZERO(ZTSPA,NHM) |
54 |
|
|
CALL VZERO(XOTSPA,NHM) |
55 |
|
|
CALL VZERO(YOTSPA,NHM) |
56 |
|
|
CALL VZERO(ZOTSPA,NHM) |
57 |
|
|
CALL VZERO(ERTSPA,NHM) |
58 |
|
|
CALL VZERO(PATSPA,NHM) |
59 |
|
|
CALL VZERO(NUMD ,NVOL) |
60 |
|
|
CALL VZERO(NDPLAN,NDMSPE) |
61 |
|
|
CALL VZERO(NDSIL ,NDMSPE) |
62 |
|
|
CALL VZERO(NDISTR,NDMSPE) |
63 |
|
|
CALL VZERO(NDIADC,NDMSPE) |
64 |
|
|
* |
65 |
|
|
CONT = .FALSE. |
66 |
|
|
HF = .TRUE. |
67 |
|
|
NTDIGI = 0 |
68 |
|
|
NDISPE = 0 |
69 |
|
|
NV = NVOL |
70 |
|
|
NVM= NVMAX |
71 |
|
|
IS = ISSPE |
72 |
|
|
ID = IDTSPA |
73 |
|
|
CSET = 'SPE ' |
74 |
|
|
IT = -1 |
75 |
|
|
* |
76 |
|
|
* Get the total number of hits stored for TSPA detector |
77 |
|
|
* |
78 |
|
|
NTHIT = GPNHIT(CSET,CNSED(IS,ID) ) |
79 |
|
|
IF (NTHIT.GT.NHM) CONT=.TRUE. |
80 |
|
|
* |
81 |
|
|
* Check on the volume level |
82 |
|
|
* |
83 |
|
|
IF (NV.GT.NVM) THEN |
84 |
|
|
WRITE(CHMAIL,10000) CSET,CNSED(IS,ID),NVOL,NVMAX, |
85 |
|
|
+ IDRUN,IDEVT |
86 |
|
|
CALL GMAIL(1,0) |
87 |
|
|
GO TO 20 |
88 |
|
|
ENDIF |
89 |
|
|
CALL VZERO(VHITS,NH*NHM) |
90 |
|
|
CALL VZERO(ITRA ,NHM) |
91 |
|
|
CALL VZERO(NUMBV,NVOL*NHM) |
92 |
|
|
NHITS = -1 |
93 |
|
|
NHFRST = 1 |
94 |
|
|
LKDN = 0 |
95 |
|
|
10 CALL GPRHIT(CSET,CNSED(IS,ID),IS,ID,NVOL,NH,NHM,NHFRST, |
96 |
|
|
+ IT,NUMD,ITRA,NUMBV,VHITS,NHITS) |
97 |
|
|
* |
98 |
|
|
* If there was a problem in GPRHIT then exit |
99 |
|
|
* |
100 |
|
|
IF(NHITS.LT.0.AND.(NHITS.NE.-(NHM+1)) ) THEN |
101 |
|
|
WRITE(CHMAIL,10100) CSET,CNSED(IS,ID),NHITS,NHM, |
102 |
|
|
+ IDRUN,IDEVT |
103 |
|
|
CALL GMAIL(1,0) |
104 |
|
|
GO TO 20 |
105 |
|
|
ENDIF |
106 |
|
|
IF( NHITS.EQ. -(NHM+1) ) NHITS = NHM |
107 |
|
|
* |
108 |
|
|
* Fill CWN entuple |
109 |
|
|
* |
110 |
|
|
NTHSPE = NHITS |
111 |
|
|
DO I=1,NHITS |
112 |
|
|
ITRPB(I) = NUMBV(1,I) |
113 |
cafagna |
3.2 |
ITRSL(I) = NUMBV(2,I) |
114 |
|
|
ITSPA(I) = NUMBV(3,I) |
115 |
cafagna |
3.1 |
#if defined(GPAMELA_INTER) |
116 |
|
|
XAVSPE(I) = VHITS(1,I) |
117 |
|
|
YAVSPE(I) = VHITS(2,I) |
118 |
|
|
ZAVSPE(I) = VHITS(3,I) |
119 |
|
|
XOUTSPE(I) = VHITS(4,I) |
120 |
|
|
YOUTSPE(I) = VHITS(5,I) |
121 |
|
|
ZOUTSPE(I) = VHITS(6,I) |
122 |
|
|
XINSPE(I) = 2*XAVSPE(I) - XOUTSPE(I) |
123 |
|
|
YINSPE(I) = 2*YAVSPE(I) - YOUTSPE(I) |
124 |
|
|
ZINSPE(I) = 2*ZAVSPE(I) - ZOUTSPE(I) |
125 |
|
|
#endif |
126 |
|
|
#if !defined(GPAMELA_INTER) |
127 |
|
|
XINSPE(I) = VHITS(1,I) |
128 |
|
|
YINSPE(I) = VHITS(2,I) |
129 |
|
|
ZINSPE(I) = VHITS(3,I) |
130 |
|
|
XOUTSPE(I) = VHITS(4,I) |
131 |
|
|
YOUTSPE(I) = VHITS(5,I) |
132 |
|
|
ZOUTSPE(I) = VHITS(6,I) |
133 |
|
|
XAVSPE(I) = (XINSPE(I)+XOUTSPE(I))/2. |
134 |
|
|
YAVSPE(I) = (YINSPE(I)+YOUTSPE(I))/2. |
135 |
|
|
ZAVSPE(I) = (ZINSPE(I)+ZOUTSPE(I))/2. |
136 |
|
|
#endif |
137 |
|
|
ERELSPE(I) = VHITS(7,I) |
138 |
|
|
PATHSPE(I) = VHITS(8,I) |
139 |
|
|
IPARSPE(I) = VHITS(9,I) |
140 |
|
|
P0SPE (I) = VHITS(10,I) |
141 |
|
|
ENDDO |
142 |
|
|
* |
143 |
|
|
* Loop on the hits retrived to fill the CWN common and the DIGI bank |
144 |
|
|
* |
145 |
|
|
C fc IF (HF) NTHSPE = NHITS |
146 |
|
|
C fc DO I=1,NHITS |
147 |
|
|
C fc * |
148 |
|
|
C fc * Start DIGI action |
149 |
|
|
C fc * |
150 |
|
|
C fc NPLANE=NUMBV(3,I) |
151 |
|
|
C fc XI=VHITS(1,I) |
152 |
|
|
C fc YI=VHITS(2,I) |
153 |
|
|
C fc ZI=VHITS(3,I) |
154 |
|
|
C fc XO=VHITS(4,I) |
155 |
|
|
C fc YO=VHITS(5,I) |
156 |
|
|
C fc ZO=VHITS(6,I) |
157 |
|
|
C fc +SELF,IF=INTER |
158 |
|
|
C fc * interactive case: we need the track edges |
159 |
|
|
C fc XI=2.*XI-XO |
160 |
|
|
C fc YI=2.*YI-YO |
161 |
|
|
C fc ZI=2.*ZI-ZO |
162 |
|
|
C fc +SELF. |
163 |
|
|
C fc PATH=VHITS(8,I) |
164 |
|
|
C fc DE=VHITS(7,I) |
165 |
|
|
C fc IF(DE.GT.0.) THEN |
166 |
|
|
C fc DO J=1,6 |
167 |
|
|
C fc NUMBVD(J)=NUMBV(J,I) |
168 |
|
|
C fc ENDDO |
169 |
|
|
C fc c+SELF,IF=PAOLO |
170 |
|
|
C fc c CALL GPSPEHD(I,NPLANE,XI,YI,ZI,XO,YO,ZO,PATH,DE,LKDN) |
171 |
|
|
C fc c+SELF |
172 |
|
|
C fc c+SELF,IF=-PAOLO |
173 |
|
|
C fc c CALL GPSPEHD(I,NUMBVD,NVSPE,XI,YI,ZI,XO,YO,ZO,PATH,DE,LKDN) |
174 |
|
|
C fc c+SELF. |
175 |
|
|
C fc NTDIGI = LKDN |
176 |
|
|
C fc ENDIF |
177 |
|
|
C fc * |
178 |
|
|
C fc * Fill CWN common |
179 |
|
|
C fc * |
180 |
|
|
C fc IF(HF) THEN |
181 |
|
|
C fc ITRPB(I) = NUMBV((NVSPE-3),I) |
182 |
|
|
C fc ITRSL(I) = NUMBV((NVSPE-1),I) |
183 |
|
|
C fc ITSPA(I) = NUMBV(NVSPE,I) |
184 |
|
|
C fc XTSPA(I) = VHITS(1,I) |
185 |
|
|
C fc YTSPA(I) = VHITS(2,I) |
186 |
|
|
C fc ZTSPA(I) = VHITS(3,I) |
187 |
|
|
C fc XOTSPA(I) = VHITS(4,I) |
188 |
|
|
C fc YOTSPA(I) = VHITS(5,I) |
189 |
|
|
C fc ZOTSPA(I) = VHITS(6,I) |
190 |
|
|
C fc ERTSPA(I) = VHITS(7,I) |
191 |
|
|
C fc PATSPA(I) = VHITS(8,I) |
192 |
|
|
C fc ENDIF |
193 |
|
|
C fc IF(CONT) HF = .FALSE. |
194 |
|
|
C fc ENDDO |
195 |
|
|
C fc IF(CONT) THEN |
196 |
|
|
C fc NHFRST = NHFRST + NHM |
197 |
|
|
C fc IF( (NTHIT-NHFRST).LE.NHM) CONT=.FALSE. |
198 |
|
|
C fc GO TO 10 |
199 |
|
|
C fc ENDIF |
200 |
|
|
C fc * |
201 |
|
|
C fc * fill digits with noise included |
202 |
|
|
C fc * |
203 |
|
|
C fc IF(LKDN.GE.1) THEN |
204 |
|
|
C fc DO II=1,LKDN |
205 |
|
|
C fc * plane=0 if the signal is lesser than 1 ADC |
206 |
|
|
C fc IF(INT(RLKD4(II)*ADCX).LE.0.AND.LKD2(II).GE.1. |
207 |
|
|
C fc + AND.LKD2(II).LE.3) LKD1(II)=0 |
208 |
|
|
C fc IF(INT(RLKD4(II)*ADCY).LE.0.AND.LKD2(II).GE.4. |
209 |
|
|
C fc + AND.LKD2(II).LE.5) LKD1(II)=0 |
210 |
|
|
C fc * |
211 |
|
|
C fc JJ=LKDH(II)+(NHFRST-1) |
212 |
|
|
C fc * KDIGI(1)=LKD1(II) |
213 |
|
|
C fc * KDIGI(2)=LKD2(II) |
214 |
|
|
C fc KDIGI(1)=LKD2(II) |
215 |
|
|
C fc KDIGI(2)=LKD3(II) |
216 |
|
|
C fc * R1=RAN(IR) |
217 |
|
|
C fc * R2=RAN(IR) |
218 |
|
|
C fc * GRNDM0=SIN(2.*3.14159*R1)*SQRT(-2.*LOG(R2)) |
219 |
|
|
C fc GRNDM0 = GPGAUS(0.) |
220 |
|
|
C fc IF(LKD2(II).GE.1.AND.LKD2(II).LE.3) THEN |
221 |
|
|
C fc RLKD4(II)=RLKD4(II)+GRNDM0*ENOISX+PIEDX |
222 |
|
|
C fc KDIGI(3)=INT(RLKD4(II)*ADCX) |
223 |
|
|
C fc ENDIF |
224 |
|
|
C fc IF(LKD2(II).GE.4.AND.LKD2(II).LE.5) THEN |
225 |
|
|
C fc RLKD4(II)=RLKD4(II)+GRNDM0*ENOISY+PIEDY |
226 |
|
|
C fc KDIGI(3)=INT(RLKD4(II)*ADCY) |
227 |
|
|
C fc ENDIF |
228 |
|
|
C fc C+SELF,IF=PAOLO |
229 |
|
|
C fc DO J=1,NVOL |
230 |
|
|
C fc NUMBVD(J)=NUMBV(J,JJ) |
231 |
|
|
C fc ENDDO |
232 |
|
|
C fc C+SELF |
233 |
|
|
C fc LTRA=ITRA(JJ) |
234 |
|
|
C fc IF(KDIGI(3).LT.0) KDIGI(3)=0 |
235 |
|
|
C fc IF(KDIGI(3).GE.1024) KDIGI(3)=1023 |
236 |
|
|
C fc IF(KDIGI(3).GT.0.AND.LKD1(II).GT.0) THEN |
237 |
|
|
C fc CALL GSDIGI(IS,ID,LTRA,NTRA,NUMBVD,KDIGI,IDIG) |
238 |
|
|
C fc IF (IDIG.EQ.0) THEN |
239 |
|
|
C fc WRITE(CHMAIL,10200) CSET,CNSED(IS,ID),NVOL,KDIGI |
240 |
|
|
C fc CALL GMAIL(1,0) |
241 |
|
|
C fc GO TO 20 |
242 |
|
|
C fc ENDIF |
243 |
|
|
C fc ENDIF |
244 |
|
|
C fc * |
245 |
|
|
C fc * Fills CWN |
246 |
|
|
C fc * |
247 |
|
|
C fc IF(HF) THEN |
248 |
|
|
C fc IF(LKD2(II).GE.1.AND.LKD2(II).LE.3) KDIGIT=INT(RLKD4(II)* |
249 |
|
|
C fc + ADCX) |
250 |
|
|
C fc IF(LKD2(II).GE.4.AND.LKD2(II).LE.5) KDIGIT=INT(RLKD4(II)* |
251 |
|
|
C fc + ADCY) |
252 |
|
|
C fc IF(KDIGIT.GT.0.AND.LKD1(II).GT.0) THEN |
253 |
|
|
C fc NDISPE=NDISPE+1 |
254 |
|
|
C fc IF (NDISPE.LE.NDMSPE) THEN |
255 |
|
|
C fc NDPLAN(NDISPE)=LKD1(II) |
256 |
|
|
C fc NDSIL (NDISPE)=LKD2(II) |
257 |
|
|
C fc NDISTR(NDISPE)=LKD3(II) |
258 |
|
|
C fc IF(KDIGIT.LT.1024) THEN |
259 |
|
|
C fc NDIADC(NDISPE)=KDIGIT |
260 |
|
|
C fc ELSE |
261 |
|
|
C fc NDIADC(NDISPE)=1023 |
262 |
|
|
C fc ENDIF |
263 |
|
|
C fc ENDIF |
264 |
|
|
C fc ENDIF |
265 |
|
|
C fc ENDIF |
266 |
|
|
C fc ENDDO |
267 |
|
|
C fc ENDIF |
268 |
|
|
* |
269 |
|
|
10000 FORMAT(' GPDSPE: VOLUME level too big: SET=',A4,', DET=',A4,', |
270 |
|
|
+ NVOL=',I3,', NVMAX=',I3,', RUN=',I5,', EVT=',I8) |
271 |
|
|
10100 FORMAT(' GPDSPE: Error in GPRHIT: SET=',A4, |
272 |
|
|
+ ', DET=',A4,',NHITS=',I5,', NHMAX=',I5, |
273 |
|
|
+ ', RUN=',I5,', EVT=',I8) |
274 |
|
|
10200 FORMAT(' GPDSPE: digitization ERROR: SET=',A4,', DET=',A4,', |
275 |
|
|
+ NVOL=',I3,', KDIGI=',4I4) |
276 |
|
|
20 RETURN |
277 |
|
|
END |