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

Annotation of /gpamela/gpspe/gpdspe.F

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3.3 - (hide annotations) (download)
Mon Dec 5 12:15:21 2005 UTC (19 years ago) by pam-ba
Branch: MAIN
Changes since 3.2: +37 -1 lines
new spectrometer geometry and internal magnetic field

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

  ViewVC Help
Powered by ViewVC 1.1.23