/[PAMELA software]/gpamela/gpspe/gpdspe.F
ViewVC logotype

Contents of /gpamela/gpspe/gpdspe.F

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.7 - (show annotations) (download)
Tue Feb 7 11:38:52 2006 UTC (18 years, 9 months ago) by bottai
Branch: MAIN
Changes since 3.6: +12 -9 lines
 test of mail delivery

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

  ViewVC Help
Powered by ViewVC 1.1.23