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