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