subroutine hec_cal_evt c c for each event, fill the calibrated data array with values in nA c implicit none c include'hec_par.inc' !shared parameters include'hec_cal.inc' !calibrated energies include'hec_cal_coef.inc' !calibration coefficients include'hec_datacard.inc' !datacard values include'hec_geo.inc' !geometry correspondence tables include'hec_max.inc' !max adc and time values include'hec_ped.inc' !pedestal values c c local delarations c integer i_eta, i_phi, i_z integer i_mod, i_seg, i_pad integer ic real adc_sub_ped c call vzero(hec_cal_ic, i_adc_dim) c c apply calibration to pedestal subtracted adc value for c each channel (use different polynomial after run period 5) c if (irunpd .le. 5) then do ic = 1, i_adc_used adc_sub_ped = adc_max_ic(ic, 1) hec_cal_ic(ic) = hec_cal_coef(ic, 1) + +hec_cal_coef(ic, 2)*adc_sub_ped + +hec_cal_coef(ic, 3)*(hec_cal_coef(ic, 1) + +hec_cal_coef(ic, 2)*(adc_sub_ped))**2 + +hec_cal_coef(ic, 4)*( + (hec_cal_coef(ic, 1) + hec_cal_coef(ic, 2)*(adc_sub_ped))* + (hec_cal_coef(ic, 1) + hec_cal_coef(ic, 2)*(adc_sub_ped))**2) enddo else do ic = 1, i_adc_used c c adc_max_ic is already pedestal subtracted c adc_sub_ped = adc_max_ic(ic, 1) c c simple polynomial c First coefficient should only be used by calibration expert. So, set c it to zero for energy reconstruction. This implies that there is also c a problem with the formula above... but nobody knows how to fix it. c hec_cal_coef(ic, 1) = 0. hec_cal_ic(ic) = hec_cal_coef(ic, 1) + + hec_cal_coef(ic, 2)*adc_sub_ped + + hec_cal_coef(ic, 3)*adc_sub_ped**2 + + hec_cal_coef(ic, 4)*adc_sub_ped**3 enddo endif c DO IC=1, I_ADC_USED c WRITE(*,*)adc_max_ic(ic, 1),hec_cal_ic(ic) c ENDDO c c fill arrays in database and physics systems c do i_pad = 1, i_pad_used do i_seg = 1, i_seg_used do i_mod = 1, i_mod_used ic = dbtoic(i_mod, i_seg, i_pad) c print *,'ic,imod,iseg,ipad', ic, i_mod, i_seg, i_pad if (ic .gt. 0 .and. ic .le. i_adc_used) then hec_cal_db(i_mod, i_seg, i_pad) = + hec_cal_ic(ic) endif enddo enddo enddo do i_z = 1, i_z_used do i_phi = 1, i_phi_used do i_eta = 1, i_eta_used ic = phtoic(i_eta, i_phi, i_z) if (ic .gt. 0 .and. ic .le. i_adc_used) then hec_cal_ph(i_eta, i_phi, i_z) = + hec_cal_ic(ic) endif enddo enddo enddo c end