846 def get_det_data_all(self,frag):
847 frh = frag.get_header()
848 trigger_number = frh.trigger_number
849 wvfm_data = None
850 ana_data = None
851
852 get_ana_data = (self.ana_data_prescale is not None and (trigger_number % self.ana_data_prescale)==0)
853 get_wvfm_data = (self.wvfm_data_prescale is not None and (trigger_number % self.wvfm_data_prescale)==0)
854
855 if not (get_ana_data or get_wvfm_data):
856 return None,None
857
858 n_frames = self.get_n_obj(frag)
859 adcs = self.unpacker.np_array_adc(frag)
860
861 daphne_headers = [ self.frame_obj(frag.get_data(iframe*self.frame_obj.sizeof())).get_header() for iframe in range(n_frames) ]
862 timestamp = self.unpacker.np_array_timestamp(frag)
863
864 if (len(adcs)) == 0:
865 return None, None
866
867 det, crate, slot, stream = self.get_det_crate_slot_stream(frag)
868
869 if get_ana_data:
870 ax = 1
871 adc_mean = np.mean(adcs,axis=ax)
872 adc_rms = np.std(adcs,axis=ax)
873 adc_max = np.max(adcs,axis=ax)
874 adc_min = np.min(adcs,axis=ax)
875 adc_median = np.median(adcs,axis=ax)
876 ts_max = np.argmax(adcs,axis=ax)*self.SAMPLING_PERIOD + timestamp
877 ts_min = np.argmin(adcs,axis=ax)*self.SAMPLING_PERIOD + timestamp
878
879 ana_data = [ DAPHNEAnalysisData(run=frh.run_number,
880 trigger=frh.trigger_number,
881 sequence=frh.sequence_number,
882 src_id=frh.element_id.id,
883 channel=self.channel_map.get_offline_channel_from_det_crate_slot_stream_chan(det, crate, slot, stream, daphne_headers[iframe].channel),
884 daphne_chan=daphne_headers[iframe].channel,
885 timestamp_dts=timestamp[iframe],
886 trigger_sample_value=daphne_headers[iframe].trigger_sample_value,
887 threshold=daphne_headers[iframe].threshold,
888 baseline=daphne_headers[iframe].baseline,
889 adc_mean=adc_mean[iframe],
890 adc_rms=adc_rms[iframe],
891 adc_max=adc_max[iframe],
892 adc_min=adc_min[iframe],
893 adc_median=adc_median[iframe],
894 timestamp_max_dts=ts_max[iframe],
895 timestamp_min_dts=ts_min[iframe]) for iframe in range(n_frames) ]
896
897
898 if get_wvfm_data:
899
900 wvfm_data = [ DAPHNEWaveformData(run=frh.run_number,
901 trigger=frh.trigger_number,
902 sequence=frh.sequence_number,
903 src_id=frh.element_id.id,
904 channel=self.channel_map.get_offline_channel_from_det_crate_slot_stream_chan(det, crate, slot, stream, daphne_headers[iframe].channel),
905 daphne_chan=daphne_headers[iframe].channel,
906 timestamp_dts=timestamp[iframe],
907 timestamps=np.arange(np.size(adcs[iframe,:]))*self.SAMPLING_PERIOD+timestamp[iframe],
908 adcs=adcs[iframe,:]) for iframe in range(n_frames) ]
909
910 return ana_data, wvfm_data
911