subroutine hec_ped_evt2 c c pass 2 user event routine c implicit none c include'hec_par.inc' !shared parameters include'hec_adc.inc' !adc values include'hec_datacard.inc' !datacard values include'hec_evth.inc' !event header include'hec_geo.inc' !geometry correspondence tables include'hec_ped.inc' !pedestal values include'hec_ped_sys.inc' !pedestal computation include'hec_trig.inc' !event trigger c integer ic !adc channel number c c before the first event, reset the channel arrays c if (i_event .le. 1) then i_ped_evt2 = 0 do ic = 1, i_adc_used i_adc0_2(ic) = 0 r_adc1(ic) = 0.d0 r_adc2(ic) = 0.d0 enddo endif c c possibilities after pass 1: c 1- ped>0 and rms>0 all ok c 2- ped>0 and var<=0 set rms=0. c 3- ped=0 and rms=0 no data for channel c c before run period 4 (Feb 97) the data had no time samplings c in this case only select random trigger events. c if (irunpd .lt. 4 .and. trig_random) then i_ped_evt2 = i_ped_evt2 + 1 c c gather adc sums c apply sigma cut only for case 1 c leave cases 2 and 3 as bad peds c do ic = 1, i_adc_used if (abs(real(i_adc_ic(ic)) - adc_ped_run(ic)) .le. + sc_ped*adc_rms_run(ic)) then i_adc0_2(ic) = i_adc0_2(ic) + 1 r_adc1(ic) = r_adc1(ic) + dble(i_adc_ic(ic)) r_adc2(ic) = r_adc2(ic) + dble(i_adc_ic(ic)**2) endif enddo c c for run period 4 and up, use datacard tr_ped value to choose trigger c elseif (irunpd .ge. 4 .and. + ((tr_ped .le. 0) .or. + (tr_ped .eq. 1 .and. trig_random) .or. + (tr_ped .eq. 2 .and. trig_pretrigger))) then i_ped_evt2 = i_ped_evt2 + 1 c c compute pedestals for the event c call hec_ped_evt c c gather adc sums c apply sigma cut only for case 1 c leave cases 2 and 3 as bad peds c do ic = 1, i_adc_used if (abs(adc_ped_evt(ic) - adc_ped_run(ic)) .le. + sc_ped*adc_rms_run(ic)) then i_adc0_2(ic) = i_adc0_2(ic) + 1 r_adc1(ic) = r_adc1(ic) + dble(adc_ped_evt(ic)) r_adc2(ic) = r_adc2(ic) + dble(adc_ped_evt(ic)**2) endif enddo endif c end