subroutine hec_ped_ana1 c c pass 1 pedestal computation over all events analysis routine c implicit none c include'hec_par.inc' !shared parameters include'hec_datacard.inc' !datacard values include'hec_geo.inc' !geometry correspondence tables include'hec_ped.inc' !pedestals include'hec_ped_sys.inc' !pedestal computation c integer ic !adc channel number real adc_var !variance of pedestal c c compute the mean and rms of pedestals c possibilities: 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 do ic = 1, i_adc_used adc_ped_run(ic) = 0. adc_rms_run(ic) = 0. if (i_adc0_1(ic) .gt. 0) then c c make sure all intermediate computations are double precision!!! c adc_ped_run(ic) = real( r_adc1(ic)/dble(i_adc0_1(ic)) ) adc_var = real( + r_adc2(ic)/dble(i_adc0_1(ic)) - dble(adc_ped_run(ic)**2) ) c c if you don't believe the above warning, try these prints! c c print *, 'adc_ped_run(ic)**2, real',adc_ped_run(ic)**2 c print *, 'adc_ped_run(ic)**2, dble',dble(adc_ped_run(ic)**2) c if (adc_var .gt. 0.) then adc_rms_run(ic) = sqrt(adc_var) else adc_rms_run(ic) = 0. print *, ' *** bad channel at pedestal computation pass 1' print *, ' *** channel ', ic, ' ped ', adc_ped_run(ic), + ' var ', adc_var endif endif enddo c c print results c print *, ' *** pass 1 pedestal computation analysis done' if (pr_ped .ne. 0) call hec_ped_summary c end