SUBROUTINE dplot IMPLICIT NONE #include #include #include #include #include #include logical $ first ! first entry in the routine integer $ hstat ! status of HBOOK I/O oper integer $ is, il, ie, ih, ! sector, layer, end, hit $ nh ! real first hit index real $ start, ! start time of the hit $ amp, ! amplitude of the hit $ amp1, amp2, ! amplitude of the other end $ bs, ! beam strobe $ ds ! detector strobe data first /.true./ save first real $ tmin,tmax tmin=00000. tmax=65000. if (first) then first = .false. call hropen(66,'RSTDC','tcal.hbk','N',1024,hstat) call hbookn(id_tuple, 'RS TDC t0 calibration', ltuple, $ 'RSTDC', 30000, tags_tuple) call hcdir('//RSTDC',' ') call vzero ( nm, mlen) call vzero ( tm, mlen) call vzero (etm, mlen) current_run = nrun end if if (nrun .ne. current_run) then c call user_output() c call vzero ( nm, mlen) c call vzero ( tm, mlen) c call vzero (etm, mlen) current_run = nrun endif call adcunp('RD','PED' ) call adcunp('RD','CAL') CALL tdcunp('RD','RAW',tmin,tmax) CALL tdcunp('TS','RAW',tmin,tmax) bs = tsttdc(1,1) ! beam strobe ds = tsttdc(2,1) ! detector strobe do is = 1,msec ! for each sector do il = 1,mlay ! for each layer do ie = 1,2 ! for each end nh = rdthit(ie,il,is) ! real first hit start = rdttdc(ie,il,is,nh) ! start time of first hit amp = rdped(ie,il,is) ! amplitude amp1 = rdcal (1,il,is) ! 1-st end amplitude amp2 = rdcal (2,il,is) ! 2-nd end amplitude if ( ! quality cuts $ start.gt.21000.and.start.lt.21200 $ .and.amp.gt.0.and.amp.lt.2000. $ .and.abs(amp1/amp2-1).lt.0.1) then c write(*,*), ie,is,il,amp,amp1,amp2,87.5/(7.36+amp) c start = (ds - start)*0.5 ! start time start = (ds - start)*0.5 - 87.5/(7.36+amp) + 1.04 ! start time nm (ie,il,is) = nm (ie,il,is) + 1 tm (ie,il,is) = tm (ie,il,is) + start etm(ie,il,is) = etm(ie,il,is) + start*start endif ! quality cuts enddo ! for each end enddo ! for each layer enddo ! for each sector RETURN END c------------------------------------------------------------------------ subroutine define implicit none #include integer*4 nwpawc parameter (nwpawc=1000000) integer iquest common /quest/ iquest(100) real*4 hmemor common /pawc/ hmemor(nwpawc) call hlimit(nwpawc) return end c------------------------------------------------------------------------ subroutine exec_on_exit implicit none #include #include #include integer $ icycle ! PAW cycle call user_output c ----- now save the ntuple ----- call hcdir('//RSTDC',' ') ! go to ntuple directory call hrout(id_tuple, icycle, 'NT') ! write ntuple out call hrend('RSTDC') ! close directory close(66) ! close file return end subroutine user_output() implicit none #include #include #include integer $ is, il, ie ! sector, layer, end do is = 1,msec ! for each sector do il = 1,mlay ! for each layer do ie = 1,2 ! for each end if (nm(ie,il,is).gt.0) then ! if there are entries tm (ie,il,is) = tm (ie,il,is) / nm(ie,il,is) etm(ie,il,is) = etm(ie,il,is) / nm(ie,il,is) etm(ie,il,is) = sqrt(etm(ie,il,is)-tm(ie,il,is)**2) call vzero(tuple, ltuple) ! clear array first tuple( 1) = current_run ! event number tuple( 2) = ie ! end number tuple( 3) = il ! layer number tuple( 4) = is ! sector number tuple( 5) = nm (ie,il,is) ! number of entries tuple( 6) = tm (ie,il,is) ! avr time tuple( 7) = etm (ie,il,is) ! avr time*amplitude call HFN(id_tuple, tuple) ! fill Ntuple endif ! if there are entries enddo ! for each end enddo ! for each layer enddo ! for each sector open (67, file='rd_tof', status='new') write (67, '(a,1x,i8)') $ '# Calibration constants for run ', nrun write (67, '(i2,2x,i2)') 2, 2 ! write format of the table do is = 1,msec ! for each sector do il = 1,21 ! for each layer if (il.gt.mlay) then write (67,'(i2,2x,i2,4x,f8.2,2x,f8.2)') $ is, il, 0.0, 0.0 else write (67,'(i2,2x,i2,4x,f8.2,2x,f8.2)') $ is, il, $ tm(1,il,is) - 42.96, $ tm(2,il,is) - 42.96 endif enddo ! for each layer enddo ! for each sector close (67) return end