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