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

Annotation of /gpamela/gpspe/gpdspe.F

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.5 - (hide annotations) (download)
Tue Jan 24 13:52:01 2006 UTC (18 years, 10 months ago) by bottai
Branch: MAIN
Changes since 3.4: +7 -1 lines
prepare to store the x and y multiplicity of the hit

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

  ViewVC Help
Powered by ViewVC 1.1.23