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