subroutine hec_ped_evt c c produce pedestals for the event c implicit none c include'hec_par.inc' !shared parameters include'hec_adc.inc' !adc values include'hec_datacard.inc' !datacard values include'hec_geo.inc' !geometry correspondence tables include'hec_ped.inc' !pedestal values include'hec_ped_sys.inc' !pedestal computation common c integer ic !adc channel number integer i_t, i_t1, i_t2, nt real adc1, adc2, var c c set the time sampling limits c if (irunpd .ge. 4) then i_t1 = max(nt_ped(1), 1) i_t2 = min(nt_ped(2), i_tim_used) if (i_t1 .gt. i_t2) then print *, + ' *** bad time sampling limits... first time sampling used' i_t1 = 1 i_t2 = 1 endif else print *, + ' *** no time sampling in this run period', irunpd stop endif c c do over channels c nt = i_t2 - i_t1 + 1 do ic = 1, i_adc_used c c do over time samplings c gather moments c adc1 = 0. adc2 = 0. do i_t = i_t1, i_t2 adc1 = adc1 + real(i_adc_ic_t(ic, i_t)) adc2 = adc2 + real(i_adc_ic_t(ic, i_t)**2) enddo c c calculate event by event pedestal and rms c adc_ped_evt(ic) = adc1/real(nt) var = adc2/real(nt) - adc_ped_evt(ic)**2 adc_rms_evt(ic) = 0. if (var .ge. 0.) adc_rms_evt(ic) = sqrt(var) enddo end